From 1fd838affc9b1e15924743ed98ea94121cf9bfcf Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 7 Aug 1996 20:25:10 +0000 Subject: [PATCH] More functions unavailable on some systems. * configure.in (AC_CHECK_FUNCS): Add ctermid, setpgid, setsid, tcgetpgrp, tcsetpgrp, and waitpid to the list of functions to check for. * configure, scmconfig.h.in: Updated, using autoconf and autoheader. * posix.c (scm_sys_ctermid, scm_sys_setpgid, scm_sys_setsid, scm_sys_tcgetpgrp, scm_sys_tcsetpgrp, scm_sys_waitpid): Put the bodies of these functions in "#ifdef HAVE_MUMBLE" clauses, with a stub that signals an error as the #else. --- libguile/configure | 2 +- libguile/configure.in | 2 +- libguile/posix.c | 36 ++++++++++++++++++++++++++++++++++++ libguile/scmconfig.h.in | 18 ++++++++++++++++++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/libguile/configure b/libguile/configure index 862c1825a..899d9707e 100755 --- a/libguile/configure +++ b/libguile/configure @@ -1419,7 +1419,7 @@ EOF fi -for ac_func in ftime times geteuid seteuid setegid select uname mkdir rmdir getcwd rename putenv setlocale strftime strptime mknod nice lstat readlink symlink sync +for ac_func in ctermid ftime getcwd geteuid lstat mkdir mknod nice putenv readlink rename rmdir select setegid seteuid setlocale setpgid setsid strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then diff --git a/libguile/configure.in b/libguile/configure.in index 92fa3f2d4..ed30f64be 100644 --- a/libguile/configure.in +++ b/libguile/configure.in @@ -26,7 +26,7 @@ AC_TYPE_GETGROUPS AC_TYPE_SIGNAL AC_TYPE_MODE_T -AC_CHECK_FUNCS(ftime times geteuid seteuid setegid select uname mkdir rmdir getcwd rename putenv setlocale strftime strptime mknod nice lstat readlink symlink sync) +AC_CHECK_FUNCS(ctermid ftime getcwd geteuid lstat mkdir mknod nice putenv readlink rename rmdir select setegid seteuid setlocale setpgid setsid strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid) AC_REPLACE_FUNCS(inet_aton) diff --git a/libguile/posix.c b/libguile/posix.c index 08b2ac527..beb9494a6 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -397,6 +397,7 @@ scm_sys_waitpid (pid, options) SCM options; #endif { +#ifdef HAVE_WAITPID int i; int status; int ioptions; @@ -413,6 +414,11 @@ scm_sys_waitpid (pid, options) if (i == -1) SCM_SYSERROR (s_sys_waitpid); return scm_cons (SCM_MAKINUM (0L + i), SCM_MAKINUM (0L + status)); +#else + SCM_SYSMISSING (s_sys_waitpid); + /* not reached. */ + return SCM_BOOL_F; +#endif } @@ -587,22 +593,34 @@ SCM scm_setpgid (pid, pgid) SCM pid, pgid; { +#ifdef HAVE_SETPGID SCM_ASSERT (SCM_INUMP (pid), pid, SCM_ARG1, s_setpgid); SCM_ASSERT (SCM_INUMP (pgid), pgid, SCM_ARG2, s_setpgid); /* FIXME(?): may be known as setpgrp. */ if (setpgid (SCM_INUM (pid), SCM_INUM (pgid)) != 0) SCM_SYSERROR (s_setpgid); return SCM_UNSPECIFIED; +#else + SCM_SYSMISSING (s_sys_setpgid); + /* not reached. */ + return SCM_BOOL_F; +#endif } SCM_PROC (s_setsid, "setsid", 0, 0, 0, scm_setsid); SCM scm_setsid () { +#ifdef HAVE_SETSID pid_t sid = setsid (); if (sid == -1) SCM_SYSERROR (s_setsid); return SCM_UNSPECIFIED; +#else + SCM_SYSMISSING (s_sys_setsid); + /* not reached. */ + return SCM_BOOL_F; +#endif } SCM_PROC (s_ttyname, "ttyname", 1, 0, 0, scm_ttyname); @@ -635,10 +653,16 @@ SCM_PROC (s_ctermid, "ctermid", 0, 0, 0, scm_ctermid); SCM scm_ctermid () { +#ifdef HAVE_CTERMID char *result = ctermid (NULL); if (*result == '\0') SCM_SYSERROR (s_ctermid); return scm_makfrom0str (result); +#else + SCM_SYSMISSING (s_sys_ctermid); + /* not reached. */ + return SCM_BOOL_F; +#endif } SCM_PROC (s_tcgetpgrp, "tcgetpgrp", 1, 0, 0, scm_tcgetpgrp); @@ -646,6 +670,7 @@ SCM scm_tcgetpgrp (port) SCM port; { +#ifdef HAVE_TCGETPGRP int fd; pid_t pgid; SCM_ASSERT (SCM_NIMP (port) && SCM_OPFPORTP (port), port, SCM_ARG1, s_tcgetpgrp); @@ -653,6 +678,11 @@ scm_tcgetpgrp (port) if (fd == -1 || (pgid = tcgetpgrp (fd)) == -1) SCM_SYSERROR (s_tcgetpgrp); return SCM_MAKINUM (pgid); +#else + SCM_SYSMISSING (s_sys_tcgetpgrp); + /* not reached. */ + return SCM_BOOL_F; +#endif } SCM_PROC (s_tcsetpgrp, "tcsetpgrp", 2, 0, 0, scm_tcsetpgrp); @@ -660,6 +690,7 @@ SCM scm_tcsetpgrp (port, pgid) SCM port, pgid; { +#ifdef HAVE_TCSETPGRP int fd; SCM_ASSERT (SCM_NIMP (port) && SCM_OPFPORTP (port), port, SCM_ARG1, s_tcsetpgrp); SCM_ASSERT (SCM_INUMP (pgid), pgid, SCM_ARG2, s_tcsetpgrp); @@ -667,6 +698,11 @@ scm_tcsetpgrp (port, pgid) if (fd == -1 || tcsetpgrp (fd, SCM_INUM (pgid)) == -1) SCM_SYSERROR (s_tcsetpgrp); return SCM_UNSPECIFIED; +#else + SCM_SYSMISSING (s_sys_tcsetpgrp); + /* not reached. */ + return SCM_BOOL_F; +#endif } /* Copy exec args from an SCM vector into a new C array. */ diff --git a/libguile/scmconfig.h.in b/libguile/scmconfig.h.in index 07703d591..9d828e001 100644 --- a/libguile/scmconfig.h.in +++ b/libguile/scmconfig.h.in @@ -71,6 +71,9 @@ caller's stack frame. On most machines, this is not the case. */ #undef SCM_STACK_GROWS_UP +/* Define if you have the ctermid function. */ +#undef HAVE_CTERMID + /* Define if you have the ftime function. */ #undef HAVE_FTIME @@ -116,6 +119,12 @@ /* Define if you have the setlocale function. */ #undef HAVE_SETLOCALE +/* Define if you have the setpgid function. */ +#undef HAVE_SETPGID + +/* Define if you have the setsid function. */ +#undef HAVE_SETSID + /* Define if you have the strftime function. */ #undef HAVE_STRFTIME @@ -128,12 +137,21 @@ /* Define if you have the sync function. */ #undef HAVE_SYNC +/* Define if you have the tcgetpgrp function. */ +#undef HAVE_TCGETPGRP + +/* Define if you have the tcsetpgrp function. */ +#undef HAVE_TCSETPGRP + /* Define if you have the times function. */ #undef HAVE_TIMES /* Define if you have the uname function. */ #undef HAVE_UNAME +/* Define if you have the waitpid function. */ +#undef HAVE_WAITPID + /* Define if you have the header file. */ #undef HAVE_DIRENT_H