From f65a7138c4a7858f606aeaa17c6f7b6abd42d928 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sat, 31 Jan 1998 17:41:14 -0700 Subject: [PATCH] configure.in (getlogin,getgid,getuid, [...]): Check. * libU77/configure.in (getlogin,getgid,getuid, kill,link,ttyname): Check. * libU77/config.h.in (HAVE_GETLOGIN, HAVE_GETGID, HAVE_GETUID, HAVE_KILL, HAVE_LINK, HAVE_TTYNAME): New defs. * libU77/getlog_.c: Conditionalize for target platform. Set errno to ENOSYS if target libc doesn't have the function. * libU77/getgid_.c: Likewise. * libU77/getuid_.c: Likewise. * libU77/kill_.c: Likewise. * libU77/link_.c: Likewise. * libU77/ttynam_.c: Likewise. From-SVN: r17562 --- gcc/f/runtime/libU77/Makefile.in | 19 ++++--------------- gcc/f/runtime/libU77/config.h.in | 17 +++++++++++++++++ gcc/f/runtime/libU77/configure.in | 2 +- gcc/f/runtime/libU77/getgid_.c | 6 ++++++ gcc/f/runtime/libU77/getlog_.c | 10 +++++++++- gcc/f/runtime/libU77/getuid_.c | 6 ++++++ gcc/f/runtime/libU77/kill_.c | 5 +++++ gcc/f/runtime/libU77/link_.c | 6 ++++++ gcc/f/runtime/libU77/ttynam_.c | 6 ++++++ 9 files changed, 60 insertions(+), 17 deletions(-) diff --git a/gcc/f/runtime/libU77/Makefile.in b/gcc/f/runtime/libU77/Makefile.in index c2160a302bb..bb101710d0c 100644 --- a/gcc/f/runtime/libU77/Makefile.in +++ b/gcc/f/runtime/libU77/Makefile.in @@ -25,30 +25,19 @@ VPATH = @srcdir@ #### Start of system configuration section. #### -# The _FOR_TARGET things are appropriate for a cross-make, passed by the -# superior makefile -GCC_FOR_TARGET = @CC@ -CC = $(GCC_FOR_TARGET) -CFLAGS = @CFLAGS@ $(GCC_FLAGS) CPPFLAGS = @CPPFLAGS@ DEFS = @DEFS@ -CGFLAGS = #-g0 # f2c.h should already be installed in xgcc's include directory but add that # to -I anyhow in case not using xgcc. fio.h is in libI77. We need config.h # from `.'. -ALL_CFLAGS = -I. -I$(srcdir) -I$(srcdir)/../libI77 -I../../../include $(CPPFLAGS) $(DEFS) $(CFLAGS) -AR = @AR@ -AR_FLAGS = rc -RANLIB = @RANLIB@ -RANLIB_TEST = @RANLIB_TEST@ +ALL_CFLAGS = -I. -I$(srcdir) -I$(srcdir)/../libI77 -I.. $(CPPFLAGS) $(DEFS) $(CFLAGS) CROSS = @CROSS@ -G77DIR = ../../../ .SUFFIXES: .SUFFIXES: .c .o .c.o: - $(CC) -c -DSkip_f2c_Undefs $(ALL_CFLAGS) $(CGFLAGS) $< + $(CC) -c -DSkip_f2c_Undefs $(ALL_CFLAGS) $< OBJS = VersionU.o gerror_.o perror_.o ierrno_.o itime_.o time_.o \ unlink_.o fnum_.o getpid_.o getuid_.o getgid_.o kill_.o rand_.o \ @@ -71,7 +60,7 @@ SRCS = Version.c gerror_.c perror_.c ierrno_.c itime_.c time_.c \ umask_.c sys_clock_.c date_.c second_.c flush1_.c mclock_.c \ alarm_.c -F2C_H = ../../../include/f2c.h +F2C_H = ../f2c.h all: $(OBJS) @@ -93,7 +82,7 @@ distclean realclean maintainer-clean: clean $(OBJS): $(F2C_H) config.h check: - -$(G77DIR)g77 --driver=$(G77DIR)/xgcc -B$(G77DIR) -g $(srcdir)/u77-test.f $(lib) && ./a.out + -$(G77DIR)g77 -B$(G77DIR) -g $(srcdir)/u77-test.f $(lib) && ./a.out rm -f a.out access_.o: access_.c diff --git a/gcc/f/runtime/libU77/config.h.in b/gcc/f/runtime/libU77/config.h.in index 4fcffeb2162..c967b25f21d 100644 --- a/gcc/f/runtime/libU77/config.h.in +++ b/gcc/f/runtime/libU77/config.h.in @@ -84,3 +84,20 @@ /* Define if you have the times function. */ #undef HAVE_TIMES +/* Define if you have the getlogin function. */ +#undef HAVE_GETLOGIN + +/* Define if you have the getgid function. */ +#undef HAVE_GETGID + +/* Define if you have the getuid function. */ +#undef HAVE_GETUID + +/* Define if you have the kill function. */ +#undef HAVE_KILL + +/* Define if you have the link function. */ +#undef HAVE_LINK + +/* Define if you have the ttyname function. */ +#undef HAVE_TTYNAME diff --git a/gcc/f/runtime/libU77/configure.in b/gcc/f/runtime/libU77/configure.in index 3cacc9f04c7..6caf4e31a39 100644 --- a/gcc/f/runtime/libU77/configure.in +++ b/gcc/f/runtime/libU77/configure.in @@ -98,7 +98,7 @@ AC_STRUCT_TM dnl Checks for library functions. AC_CHECK_FUNCS(symlink getcwd getwd lstat gethostname strerror clock \ - getrusage times alarm) + getrusage times alarm getlogin getgid getuid kill link ttyname) test $ac_cv_func_symlink = yes && MAYBES="$MAYBES symlnk_.o" test $ac_cv_func_lstat = yes && MAYBES="$MAYBES lstat_.o" test $ac_cv_func_gethostname = yes && MAYBES="$MAYBES hostnm_.o" diff --git a/gcc/f/runtime/libU77/getgid_.c b/gcc/f/runtime/libU77/getgid_.c index 02e8a4e4895..b489bacc6ed 100644 --- a/gcc/f/runtime/libU77/getgid_.c +++ b/gcc/f/runtime/libU77/getgid_.c @@ -23,6 +23,7 @@ Boston, MA 02111-1307, USA. */ #include #endif #include +#include /* for ENOSYS */ #include "f2c.h" #ifdef KR_headers @@ -31,5 +32,10 @@ integer G77_getgid_0 () integer G77_getgid_0 (void) #endif { +#if defined (HAVE_GETGID) return getgid (); +#else + errno = ENOSYS; + return -1; +#endif } diff --git a/gcc/f/runtime/libU77/getlog_.c b/gcc/f/runtime/libU77/getlog_.c index 1c2f7db1ce1..82cb564a67a 100644 --- a/gcc/f/runtime/libU77/getlog_.c +++ b/gcc/f/runtime/libU77/getlog_.c @@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA. */ #else # include #endif +#include /* for ENOSYS */ #include "f2c.h" /* getlogin not in svr1-3 */ @@ -51,7 +52,9 @@ extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); { size_t i; char *p; + int status; +#if defined (HAVE_GETLOGIN) p = getlogin (); if (p != NULL) { i = strlen (p); @@ -59,5 +62,10 @@ extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); } else { s_copy (str, " ", Lstr, 1); } - return 0; + status = 0; +#else + errno = ENOSYS; + status = -1; +#endif + return status; } diff --git a/gcc/f/runtime/libU77/getuid_.c b/gcc/f/runtime/libU77/getuid_.c index 421bb4c9362..408ff0ab600 100644 --- a/gcc/f/runtime/libU77/getuid_.c +++ b/gcc/f/runtime/libU77/getuid_.c @@ -23,6 +23,7 @@ Boston, MA 02111-1307, USA. */ #include #endif #include +#include /* for ENOSYS */ #include "f2c.h" #ifdef KR_headers @@ -31,5 +32,10 @@ integer G77_getuid_0 () integer G77_getuid_0 (void) #endif { +#if defined (HAVE_GETUID) return getuid (); +#else + errno = ENOSYS; + return -1; +#endif } diff --git a/gcc/f/runtime/libU77/kill_.c b/gcc/f/runtime/libU77/kill_.c index 32afddf1e46..99197bd02e7 100644 --- a/gcc/f/runtime/libU77/kill_.c +++ b/gcc/f/runtime/libU77/kill_.c @@ -33,5 +33,10 @@ integer G77_kill_0 (pid, signum) integer G77_kill_0 (const integer *pid, const integer *signum) #endif { +#if defined (HAVE_KILL) return kill ((pid_t) *pid, *signum) ? errno : 0; +#else + errno = ENOSYS; + return -1; +#endif } diff --git a/gcc/f/runtime/libU77/link_.c b/gcc/f/runtime/libU77/link_.c index 7a0b51b0184..003fac8ffe2 100644 --- a/gcc/f/runtime/libU77/link_.c +++ b/gcc/f/runtime/libU77/link_.c @@ -31,6 +31,7 @@ Boston, MA 02111-1307, USA. */ #if HAVE_SYS_PARAM_H # include #endif +#include /* for ENOSYS */ #include "f2c.h" #ifdef KR_headers @@ -44,6 +45,7 @@ void g_char(const char *a, ftnlen alen, char *b); integer G77_link_0 (const char *path1, const char *path2, const ftnlen Lpath1, const ftnlen Lpath2) #endif { +#if defined (HAVE_LINK) char *buff1, *buff2; char *bp, *blast; int i; @@ -57,4 +59,8 @@ integer G77_link_0 (const char *path1, const char *path2, const ftnlen Lpath1, c i = link (buff1, buff2); free (buff1); free (buff2); return i ? errno : 0; +#else /* ! HAVE_LINK */ + errno = ENOSYS; + return -1; +#endif } diff --git a/gcc/f/runtime/libU77/ttynam_.c b/gcc/f/runtime/libU77/ttynam_.c index 12b50191fe3..cb1d1e9a35c 100644 --- a/gcc/f/runtime/libU77/ttynam_.c +++ b/gcc/f/runtime/libU77/ttynam_.c @@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA. */ #else # include #endif +#include /* for ENOSYS */ #include "f2c.h" #ifdef KR_headers @@ -45,6 +46,7 @@ extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); /* Character */ void G77_ttynam_0 (char *ret_val, ftnlen ret_val_len, integer *lunit) #endif { +#if defined (HAVE_TTYNAME) size_t i; char *p; @@ -55,4 +57,8 @@ extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); } else { s_copy (ret_val, " ", ret_val_len, 1); } +#else + errno = ENOSYS; + return -1; +#endif }