diff options
Diffstat (limited to 'tcl/unix/tclUnixPort.h')
-rw-r--r-- | tcl/unix/tclUnixPort.h | 177 |
1 files changed, 99 insertions, 78 deletions
diff --git a/tcl/unix/tclUnixPort.h b/tcl/unix/tclUnixPort.h index fb9152f3e13..b84ef03f2a2 100644 --- a/tcl/unix/tclUnixPort.h +++ b/tcl/unix/tclUnixPort.h @@ -14,7 +14,7 @@ * by Karl Lehenbauer, Mark Diekhans and Peter da Silva. * * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. + * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -28,6 +28,14 @@ #ifndef _TCLINT # include "tclInt.h" #endif + +/* + *--------------------------------------------------------------------------- + * The following sets of #includes and #ifdefs are required to get Tcl to + * compile under the various flavors of unix. + *--------------------------------------------------------------------------- + */ + #include <errno.h> #include <fcntl.h> #ifdef HAVE_NET_ERRNO_H @@ -35,16 +43,18 @@ #endif #include <pwd.h> #include <signal.h> -#include <sys/param.h> +#ifdef HAVE_SYS_PARAM_H +# include <sys/param.h> +#endif #include <sys/types.h> #ifdef USE_DIRENT2_H # include "../compat/dirent2.h" #else -# ifdef NO_DIRENT_H -# include "../compat/dirent.h" -# else -# include <dirent.h> -# endif +#ifdef NO_DIRENT_H +# include "../compat/dirent.h" +#else +# include <dirent.h> +#endif #endif #include <sys/file.h> #ifdef HAVE_SYS_SELECT_H @@ -55,11 +65,11 @@ # include <sys/time.h> # include <time.h> #else -# if HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# include <time.h> -# endif +#if HAVE_SYS_TIME_H +# include <sys/time.h> +#else +# include <time.h> +#endif #endif #ifndef NO_SYS_WAIT_H # include <sys/wait.h> @@ -70,7 +80,6 @@ # include "../compat/unistd.h" #endif #ifdef USE_FIONBIO - /* * Not using the Posix fcntl(...,O_NONBLOCK,...) interface, instead * we are using ioctl(..,FIONBIO,..). @@ -84,6 +93,7 @@ # include <sys/ioctl.h> /* For FIONBIO. */ # endif #endif /* USE_FIONBIO */ +#include <utime.h> /* * Socket support stuff: This likely needs more work to parameterize for @@ -105,11 +115,11 @@ */ #ifndef NO_FLOAT_H -#include <float.h> +# include <float.h> #else -# ifndef NO_VALUES_H -# include <values.h> -# endif +#ifndef NO_VALUES_H +# include <values.h> +#endif #endif #ifndef FLT_MAX @@ -148,30 +158,6 @@ #endif /* - * The following defines denote malloc and free as the system calls - * used to allocate new memory. These defines are only used in the - * file tclCkalloc.c. - */ - -#define TclpAlloc(size) malloc(size) -#define TclpFree(ptr) free(ptr) -#define TclpRealloc(ptr, size) realloc(ptr, size) - -/* - * The default platform eol translation on Unix is TCL_TRANSLATE_LF: - */ - -#define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_LF - -/* - * Not all systems declare the errno variable in errno.h. so this - * file does it explicitly. The list of system error messages also - * isn't generally declared in a header file anywhere. - */ - -extern int errno; - -/* * The type of the status returned by wait varies from UNIX system * to UNIX system. The macro below defines it: */ @@ -235,21 +221,18 @@ extern int errno; #ifndef SEEK_SET # define SEEK_SET 0 #endif - #ifndef SEEK_CUR # define SEEK_CUR 1 #endif - #ifndef SEEK_END # define SEEK_END 2 #endif /* - * The stuff below is needed by the "time" command. If this - * system has no gettimeofday call, then must use times and the - * CLK_TCK #define (from sys/param.h) to compute elapsed time. - * Unfortunately, some systems only have HZ and no CLK_TCK, and - * some might not even have HZ. + * The stuff below is needed by the "time" command. If this system has no + * gettimeofday call, then must use times and the CLK_TCK #define (from + * sys/param.h) to compute elapsed time. Unfortunately, some systems only + * have HZ and no CLK_TCK, and some might not even have HZ. */ #ifdef NO_GETTOD @@ -300,21 +283,12 @@ EXTERN int gettimeofday _ANSI_ARGS_((struct timeval *tp, #endif /* - * On UNIX, there's no platform specific implementation of "TclpStat(...)" - * or "TclpAccess(...)". Simply call "stat(...)' and "access(...)" - * respectively. - */ - -#define TclpStat stat -#define TclpAccess access - -/* * On systems without symbolic links (i.e. S_IFLNK isn't defined) * define "lstat" to use "stat" instead. */ #ifndef S_IFLNK -# define lstat stat +# define lstat stat #endif /* @@ -438,22 +412,19 @@ EXTERN int gettimeofday _ANSI_ARGS_((struct timeval *tp, #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS) /* - * The following implements the Unix method for exiting the process. - */ -#define TclPlatformExit(status) exit(status) - -/* - * The following functions always succeeds under Unix. + * Not all systems declare the errno variable in errno.h. so this + * file does it explicitly. The list of system error messages also + * isn't generally declared in a header file anywhere. */ -#define TclHasSockets(interp) (TCL_OK) +extern int errno; /* * Variables provided by the C library: */ -#if defined(_sgi) || defined(__sgi) -#define environ _environ +#if defined(_sgi) || defined(__sgi) || (defined(__APPLE__) && defined(__DYNAMIC__)) +# define environ _environ #endif extern char **environ; @@ -468,27 +439,77 @@ extern char **environ; extern double strtod(); /* - * The following macros define time related functions in terms of - * standard Unix routines. + *--------------------------------------------------------------------------- + * The following macros and declarations represent the interface between + * generic and unix-specific parts of Tcl. Some of the macros may override + * functions declared in tclInt.h. + *--------------------------------------------------------------------------- */ -#define TclpGetDate(t,u) ((u) ? gmtime((t)) : localtime((t))) -#define TclStrftime(s,m,f,t) (strftime((s),(m),(f),(t))) -#define TclpGetPid(pid) ((unsigned long) (pid)) +/* + * The default platform eol translation on Unix is TCL_TRANSLATE_LF. + */ -#define TclpReleaseFile(file) +#define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_LF + +/* + * The following macros have trivial definitions, allowing generic code to + * address platform-specific issues. + */ + +#define TclpAsyncMark(async) +#define TclpGetPid(pid) ((unsigned long) (pid)) +#define TclpReleaseFile(file) /* Nothing. */ + +/* + * The following defines wrap the system memory allocation routines for + * use by tclAlloc.c. By default off unused on Unix. + */ + +#if USE_TCLALLOC +# define TclpSysAlloc(size, isBin) malloc((size_t)size) +# define TclpSysFree(ptr) free((char*)ptr) +# define TclpSysRealloc(ptr, size) realloc((char*)ptr, (size_t)size) +#endif /* - * TclpFinalize is a noop on Unix systems. + * The following macros and declaration wrap the C runtime library + * functions. */ -#define TclpFinalize() +#define TclpExit exit + +#ifdef TclpStat +#undef TclpStat +#endif + +EXTERN int TclpLstat _ANSI_ARGS_((CONST char *path, + struct stat *buf)); +EXTERN int TclpStat _ANSI_ARGS_((CONST char *path, + struct stat *buf)); /* - * The following routine is only exported for testing purposes. + * Platform specific mutex definition used by memory allocators. + * These mutexes are statically allocated and explicitly initialized. + * Most modules do not use this, but instead use Tcl_Mutex types and + * Tcl_MutexLock and Tcl_MutexUnlock that are self-initializing. */ -EXTERN int TclUnixWaitForFile _ANSI_ARGS_((int fd, int mask, - int timeout)); +#ifdef TCL_THREADS +#include <pthread.h> +typedef pthread_mutex_t TclpMutex; +EXTERN void TclpMutexInit _ANSI_ARGS_((TclpMutex *mPtr)); +EXTERN void TclpMutexLock _ANSI_ARGS_((TclpMutex *mPtr)); +EXTERN void TclpMutexUnlock _ANSI_ARGS_((TclpMutex *mPtr)); +#else +typedef int TclpMutex; +#define TclpMutexInit(a) +#define TclpMutexLock(a) +#define TclpMutexUnlock(a) +#endif /* TCL_THREADS */ + +#include "tclPlatDecls.h" +#include "tclIntPlatDecls.h" #endif /* _TCLUNIXPORT */ + |