Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
f77wrappers.c
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001, Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2.1 of the GNU Lesser General Public License 
00007   as published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU Lesser General Public 
00021   License along with this program; if not, write the Free Software 
00022   Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 
00023   USA.
00024 
00025   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00026   Mountain View, CA 94043, or:
00027 
00028   http://www.sgi.com
00029 
00030   For further information regarding this notice, see:
00031 
00032   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00033 
00034 */
00035 
00036 
00037 
00038 #pragma ident "@(#) libf/fio/f77wrappers.c      92.3    11/16/99 15:43:33"
00039 
00040  
00041 #if     !defined(_LITTLE_ENDIAN)
00042 /*
00043  * This file contains the necessary interfaces to either the Cray or old F77 
00044  * routines which need such new interfaces
00045  *
00046  */
00047 #include <stdio.h>
00048 #include <foreign.h>
00049 #include <errno.h>
00050 #include <liberrno.h>
00051 #include <sys/types.h>
00052 #include <sys/stat.h>
00053 #include <stdlib.h>
00054 #include "fio.h"
00055 
00056 
00057 /* Return 1 if open by F90, 0 otherwise */
00058 static int f90_or_f77 (int *u)
00059 {
00060    unit *cup;
00061    cup  = _fort_unit[UHASH(*u)].ulist;
00062    if (cup != NULL) {
00063       if (cup->private || cup->uid != *u)
00064          cup    = _search_unit_list(cup, *u);
00065    }
00066    return (cup != NULL);
00067 }
00068 
00069 #define SELECT(unit, funcname, args) \
00070 if (f90_or_f77(unit)) return __##funcname##_f90##args; else  return __##funcname##_f77##args
00071 
00072 
00073 /* all the external routines */
00074 
00075 extern int __fgetc_f90 (int *u, char *c, int clen);
00076 extern int __fgetc_f77 (int *u, char *c, int clen);
00077 extern int __fputc_f90 (int *u, char *c, int clen);
00078 extern int __fputc_f77 (int *u, char *c, int clen);
00079 extern int __fseek_f90 (int *u, int *off, int *from);
00080 extern int __fseek_f77 (int *u, int *off, int *from);
00081 extern int __fseek64_f90 (int *u, long long *off, int *from);
00082 extern int __fseek64_f77 (int *u, long long *off, int *from);
00083 extern int __fstat_f90 (int *u, int *stbuf);
00084 extern int __fstat_f77 (int *u, int *stbuf);
00085 extern int __fstat64_f90 (int *u, long long *stbuf);
00086 extern int __fstat64_f77 (int *u, long long *stbuf);
00087 extern int __isatty_f90 (int *u);
00088 extern int __isatty_f77 (int *u);
00089 extern long long __ftell64_f90 (int *u);
00090 extern long long __ftell64_f77 (int *u);
00091 extern void __ttynam_f90 (char *name, int strlen, int *u);
00092 extern void __ttynam_f77 (char *name, int strlen, int *u);
00093 extern int __usdumplock_f90 (void *l, int *u, char *str, int len);
00094 extern int __usdumplock_f77 (void *l, int *u, char *str, int len);
00095 extern int __usdumpsema_f90 (void *s, int *u, char *str, int len);
00096 extern int __usdumpsema_f77 (void *s, int *u, char *str, int len);
00097 extern void __flush_f90 (int *u, int *istat);
00098 extern int __flush_f77 (int *u);
00099 
00100 
00101 /* Here are the wrappers */
00102                                          
00103 extern int
00104 fgetc_(int *u, char *c, int clen)
00105 {
00106    SELECT(u,fgetc,(u,c,clen));
00107 }
00108 
00109 extern int 
00110 fputc_(int *u, char *c, int clen)
00111 {
00112    SELECT(u,fputc,(u,c,clen));
00113 }
00114 
00115 extern int
00116 fseek_(int *u, int *off, int *from)
00117 {
00118    SELECT(u,fseek,(u,off,from));
00119 }
00120 
00121 extern int
00122 fseek64_(int *u, long long *off, int *from)
00123 {
00124    SELECT(u,fseek64,(u,off,from));
00125 }
00126 
00127 extern int 
00128 fstat_(int *u, int *stbuf)
00129 {
00130    SELECT(u,fstat,(u,stbuf));
00131 }
00132 
00133 extern int 
00134 fstat64_(int *u, long long *stbuf)
00135 {
00136    SELECT(u,fstat64,(u,stbuf));
00137 }
00138 
00139 
00140 extern int 
00141 isatty_ (int *u)
00142 {
00143    SELECT(u,isatty,(u));
00144 }
00145 
00146 extern long long
00147 ftell64_(int *u)
00148 {
00149    SELECT(u,ftell64,(u));
00150 }
00151 
00152 extern int ftell_ (int *u)
00153 {
00154    int r;
00155    r = ftell64_(u);
00156    return (r);
00157 }
00158 
00159 extern void 
00160 ttynam_ (char *name, int strlen, int *u)
00161 {
00162    if (f90_or_f77(u)) __ttynam_f90(name,strlen,u);
00163    else __ttynam_f77(name,strlen,u);
00164 }
00165 
00166 
00167 extern int
00168 usdumplock_(void *l, int *u, char *str, int len)
00169 {
00170    SELECT(u,usdumplock,(l,u,str,len));
00171 }
00172 
00173 extern int
00174 usdumpsema_(void *s, int *u, char *str, int len) {
00175    SELECT(u,usdumpsema,(s,u,str,len));
00176 }
00177 
00178 extern int
00179 flush_ (int *u)
00180 {
00181    int istat;
00182    if (f90_or_f77(u)) {
00183       __flush_f90(u,&istat);
00184       return (istat);
00185    } else {
00186       return (__flush_f77(u));
00187    }
00188 }
00189 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines