diff options
Diffstat (limited to 'libguile/posix.c')
-rw-r--r-- | libguile/posix.c | 141 |
1 files changed, 4 insertions, 137 deletions
diff --git a/libguile/posix.c b/libguile/posix.c index a5c72624c..15b38e79c 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -27,6 +27,10 @@ #include <errno.h> #include <uniconv.h> +#ifdef HAVE_SCHED_H +# include <sched.h> +#endif + #include "libguile/_scm.h" #include "libguile/dynwind.h" #include "libguile/fports.h" @@ -138,7 +142,6 @@ extern char *ttyname(); #endif #include <sys/file.h> /* from Gnulib */ -#include <nproc.h> /* Some Unix systems don't define these. CPP hair is dangerous, but this seems safe enough... */ @@ -1325,54 +1328,6 @@ SCM_DEFINE (scm_tmpnam, "tmpnam", 0, 0, 0, #endif -#ifndef HAVE_MKSTEMP -extern int mkstemp (char *); -#endif - -SCM_DEFINE (scm_mkstemp, "mkstemp!", 1, 0, 0, - (SCM tmpl), - "Create a new unique file in the file system and return a new\n" - "buffered port open for reading and writing to the file.\n" - "\n" - "@var{tmpl} is a string specifying where the file should be\n" - "created: it must end with @samp{XXXXXX} and those @samp{X}s\n" - "will be changed in the string to return the name of the file.\n" - "(@code{port-filename} on the port also gives the name.)\n" - "\n" - "POSIX doesn't specify the permissions mode of the file, on GNU\n" - "and most systems it's @code{#o600}. An application can use\n" - "@code{chmod} to relax that if desired. For example\n" - "@code{#o666} less @code{umask}, which is usual for ordinary\n" - "file creation,\n" - "\n" - "@example\n" - "(let ((port (mkstemp! (string-copy \"/tmp/myfile-XXXXXX\"))))\n" - " (chmod port (logand #o666 (lognot (umask))))\n" - " ...)\n" - "@end example") -#define FUNC_NAME s_scm_mkstemp -{ - char *c_tmpl; - int rv; - - scm_dynwind_begin (0); - - c_tmpl = scm_to_locale_string (tmpl); - scm_dynwind_free (c_tmpl); - - SCM_SYSCALL (rv = mkstemp (c_tmpl)); - if (rv == -1) - SCM_SYSERROR; - - scm_substring_move_x (scm_from_locale_string (c_tmpl), - SCM_INUM0, scm_string_length (tmpl), - tmpl, SCM_INUM0); - - scm_dynwind_end (); - return scm_fdes_to_port (rv, "w+", tmpl); -} -#undef FUNC_NAME - SCM_DEFINE (scm_tmpfile, "tmpfile", 0, 0, 0, (void), "Return an input/output port to a unique temporary file\n" @@ -1485,58 +1440,6 @@ SCM_DEFINE (scm_utime, "utime", 1, 5, 0, } #undef FUNC_NAME -SCM_DEFINE (scm_access, "access?", 2, 0, 0, - (SCM path, SCM how), - "Test accessibility of a file under the real UID and GID of the\n" - "calling process. The return is @code{#t} if @var{path} exists\n" - "and the permissions requested by @var{how} are all allowed, or\n" - "@code{#f} if not.\n" - "\n" - "@var{how} is an integer which is one of the following values,\n" - "or a bitwise-OR (@code{logior}) of multiple values.\n" - "\n" - "@defvar R_OK\n" - "Test for read permission.\n" - "@end defvar\n" - "@defvar W_OK\n" - "Test for write permission.\n" - "@end defvar\n" - "@defvar X_OK\n" - "Test for execute permission.\n" - "@end defvar\n" - "@defvar F_OK\n" - "Test for existence of the file. This is implied by each of the\n" - "other tests, so there's no need to combine it with them.\n" - "@end defvar\n" - "\n" - "It's important to note that @code{access?} does not simply\n" - "indicate what will happen on attempting to read or write a\n" - "file. In normal circumstances it does, but in a set-UID or\n" - "set-GID program it doesn't because @code{access?} tests the\n" - "real ID, whereas an open or execute attempt uses the effective\n" - "ID.\n" - "\n" - "A program which will never run set-UID/GID can ignore the\n" - "difference between real and effective IDs, but for maximum\n" - "generality, especially in library functions, it's best not to\n" - "use @code{access?} to predict the result of an open or execute,\n" - "instead simply attempt that and catch any exception.\n" - "\n" - "The main use for @code{access?} is to let a set-UID/GID program\n" - "determine what the invoking user would have been allowed to do,\n" - "without the greater (or perhaps lesser) privileges afforded by\n" - "the effective ID. For more on this, see ``Testing File\n" - "Access'' in The GNU C Library Reference Manual.") -#define FUNC_NAME s_scm_access -{ - int rv; - - WITH_STRING (path, c_path, - rv = access (c_path, scm_to_int (how))); - return scm_from_bool (!rv); -} -#undef FUNC_NAME - SCM_DEFINE (scm_getpid, "getpid", 0, 0, 0, (), "Return an integer representing the current process ID.") @@ -1991,36 +1894,6 @@ SCM_DEFINE (scm_setaffinity, "setaffinity", 2, 0, 0, #endif /* HAVE_SCHED_SETAFFINITY */ -SCM_DEFINE (scm_total_processor_count, "total-processor-count", 0, 0, 0, - (void), - "Return the total number of processors of the machine, which\n" - "is guaranteed to be at least 1. A ``processor'' here is a\n" - "thread execution unit, which can be either:\n\n" - "@itemize\n" - "@item an execution core in a (possibly multi-core) chip, in a\n" - " (possibly multi- chip) module, in a single computer, or\n" - "@item a thread execution unit inside a core in the case of\n" - " @dfn{hyper-threaded} CPUs.\n" - "@end itemize\n\n" - "Which of the two definitions is used, is unspecified.\n") -#define FUNC_NAME s_scm_total_processor_count -{ - return scm_from_ulong (num_processors (NPROC_ALL)); -} -#undef FUNC_NAME - -SCM_DEFINE (scm_current_processor_count, "current-processor-count", 0, 0, 0, - (void), - "Like @code{total-processor-count}, but return the number of\n" - "processors available to the current process. See\n" - "@code{setaffinity} and @code{getaffinity} for more\n" - "information.\n") -#define FUNC_NAME s_scm_current_processor_count -{ - return scm_from_ulong (num_processors (NPROC_CURRENT)); -} -#undef FUNC_NAME - #if HAVE_GETPASS SCM_DEFINE (scm_getpass, "getpass", 1, 0, 0, @@ -2218,12 +2091,6 @@ scm_init_posix () scm_c_define ("WUNTRACED", scm_from_int (WUNTRACED)); #endif - /* access() symbols. */ - scm_c_define ("R_OK", scm_from_int (R_OK)); - scm_c_define ("W_OK", scm_from_int (W_OK)); - scm_c_define ("X_OK", scm_from_int (X_OK)); - scm_c_define ("F_OK", scm_from_int (F_OK)); - #ifdef LC_COLLATE scm_c_define ("LC_COLLATE", scm_from_int (LC_COLLATE)); #endif |