Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-05-18 08:30:22

0001 /*
0002  * tclUnixPort.h --
0003  *
0004  *  This header file handles porting issues that occur because of
0005  *  differences between systems. It reads in UNIX-related header files and
0006  *  sets up UNIX-related macros for Tcl's UNIX core. It should be the only
0007  *  file that contains #ifdefs to handle different flavors of UNIX. This
0008  *  file sets up the union of all UNIX-related things needed by any of the
0009  *  Tcl core files. This file depends on configuration #defines such as
0010  *  NO_DIRENT_H that are set up by the "configure" script.
0011  *
0012  *  Much of the material in this file was originally contributed by Karl
0013  *  Lehenbauer, Mark Diekhans and Peter da Silva.
0014  *
0015  * Copyright (c) 1991-1994 The Regents of the University of California.
0016  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
0017  *
0018  * See the file "license.terms" for information on usage and redistribution of
0019  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
0020  */
0021 
0022 #ifndef _TCLUNIXPORT
0023 #define _TCLUNIXPORT
0024 
0025 /*
0026  *---------------------------------------------------------------------------
0027  * The following sets of #includes and #ifdefs are required to get Tcl to
0028  * compile under the various flavors of unix.
0029  *---------------------------------------------------------------------------
0030  */
0031 
0032 #include <errno.h>
0033 #include <fcntl.h>
0034 #ifdef HAVE_NET_ERRNO_H
0035 #   include <net/errno.h>
0036 #endif
0037 #include <pwd.h>
0038 #include <signal.h>
0039 #ifdef HAVE_SYS_PARAM_H
0040 #   include <sys/param.h>
0041 #endif
0042 #include <sys/types.h>
0043 #ifdef USE_DIRENT2_H
0044 #   include "../compat/dirent2.h"
0045 #else
0046 #ifdef NO_DIRENT_H
0047 #   include "../compat/dirent.h"
0048 #else
0049 #   include <dirent.h>
0050 #endif
0051 #endif
0052 
0053 /*
0054  *---------------------------------------------------------------------------
0055  * Parameterize for 64-bit filesystem support.
0056  *---------------------------------------------------------------------------
0057  */
0058 
0059 #ifdef HAVE_STRUCT_DIRENT64
0060 typedef struct dirent64     Tcl_DirEntry;
0061 #   define TclOSreaddir     readdir64
0062 #else
0063 typedef struct dirent       Tcl_DirEntry;
0064 #   define TclOSreaddir     readdir
0065 #endif
0066 #ifdef HAVE_DIR64
0067 typedef DIR64           TclDIR;
0068 #   define TclOSopendir     opendir64
0069 #   define TclOSrewinddir   rewinddir64
0070 #   define TclOSclosedir    closedir64
0071 #else
0072 typedef DIR         TclDIR;
0073 #   define TclOSopendir     opendir
0074 #   define TclOSrewinddir   rewinddir
0075 #   define TclOSclosedir    closedir
0076 #endif
0077 
0078 #ifdef HAVE_TYPE_OFF64_T
0079 typedef off64_t     Tcl_SeekOffset;
0080 #   define TclOSseek        lseek64
0081 #   define TclOSopen        open64
0082 #else
0083 typedef off_t       Tcl_SeekOffset;
0084 #   define TclOSseek        lseek
0085 #   define TclOSopen        open
0086 #endif
0087 
0088 #ifdef __CYGWIN__
0089 #ifdef __cplusplus
0090 extern "C" {
0091 #endif
0092     /* Make some symbols available without including <windows.h> */
0093 #   define DWORD unsigned int
0094 #   define CP_UTF8 65001
0095 #   define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004
0096 #   define HANDLE void *
0097 #   define HINSTANCE void *
0098 #   define SOCKET unsigned int
0099 #   define WSAEWOULDBLOCK 10035
0100     typedef unsigned short WCHAR;
0101 #ifdef __clang__
0102 #pragma clang diagnostic push
0103 #pragma clang diagnostic ignored "-Wignored-attributes"
0104 #endif
0105     __declspec(dllimport) extern __stdcall int GetModuleHandleExW(unsigned int, const void *, void *);
0106     __declspec(dllimport) extern __stdcall int GetModuleFileNameW(void *, const void *, int);
0107     __declspec(dllimport) extern __stdcall int WideCharToMultiByte(int, int, const void *, int,
0108         char *, int, const char *, void *);
0109     __declspec(dllimport) extern __stdcall int MultiByteToWideChar(int, int, const char *, int,
0110         WCHAR *, int);
0111     __declspec(dllimport) extern __stdcall void OutputDebugStringW(const WCHAR *);
0112     __declspec(dllimport) extern __stdcall int IsDebuggerPresent(void);
0113     __declspec(dllimport) extern __stdcall int GetLastError(void);
0114     __declspec(dllimport) extern __stdcall int GetFileAttributesW(const WCHAR *);
0115     __declspec(dllimport) extern __stdcall int SetFileAttributesW(const WCHAR *, int);
0116     __declspec(dllimport) extern int cygwin_conv_path(int, const void *, void *, int);
0117 #ifdef __clang__
0118 #pragma clang diagnostic pop
0119 #endif
0120 #   define timezone _timezone
0121     extern int TclOSstat(const char *name, void *statBuf);
0122     extern int TclOSlstat(const char *name, void *statBuf);
0123 #ifdef __cplusplus
0124 }
0125 #endif
0126 #elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__)
0127 #   define TclOSstat(name, buf) stat64(name, (struct stat64 *)buf)
0128 #   define TclOSlstat(name,buf) lstat64(name, (struct stat64 *)buf)
0129 #else
0130 #   define TclOSstat(name, buf) stat(name, (struct stat *)buf)
0131 #   define TclOSlstat(name, buf) lstat(name, (struct stat *)buf)
0132 #endif
0133 
0134 /*
0135  *---------------------------------------------------------------------------
0136  * Miscellaneous includes that might be missing.
0137  *---------------------------------------------------------------------------
0138  */
0139 
0140 #include <sys/file.h>
0141 #ifdef HAVE_SYS_SELECT_H
0142 #   include <sys/select.h>
0143 #endif
0144 #include <sys/stat.h>
0145 #ifdef TIME_WITH_SYS_TIME
0146 #   include <sys/time.h>
0147 #   include <time.h>
0148 #else
0149 #ifdef HAVE_SYS_TIME_H
0150 #   include <sys/time.h>
0151 #else
0152 #   include <time.h>
0153 #endif
0154 #endif
0155 #ifndef NO_SYS_WAIT_H
0156 #   include <sys/wait.h>
0157 #endif
0158 #ifdef HAVE_INTTYPES_H
0159 #   include <inttypes.h>
0160 #endif
0161 #include <limits.h>
0162 #ifdef HAVE_STDINT_H
0163 #   include <stdint.h>
0164 #endif
0165 #ifdef HAVE_UNISTD_H
0166 #   include <unistd.h>
0167 #else
0168 #   include "../compat/unistd.h"
0169 #endif
0170 
0171 extern int TclUnixSetBlockingMode(int fd, int mode);
0172 
0173 #include <utime.h>
0174 
0175 /*
0176  *---------------------------------------------------------------------------
0177  * Socket support stuff: This likely needs more work to parameterize for each
0178  * system.
0179  *---------------------------------------------------------------------------
0180  */
0181 
0182 #include <sys/socket.h>     /* struct sockaddr, SOCK_STREAM, ... */
0183 #ifndef NO_UNAME
0184 #   include <sys/utsname.h> /* uname system call. */
0185 #endif
0186 #include <netinet/in.h>     /* struct in_addr, struct sockaddr_in */
0187 #include <arpa/inet.h>      /* inet_ntoa() */
0188 #include <netdb.h>      /* getaddrinfo() */
0189 #ifdef NEED_FAKE_RFC2553
0190 # include "../compat/fake-rfc2553.h"
0191 #endif
0192 
0193 /*
0194  *---------------------------------------------------------------------------
0195  * Some platforms (e.g. SunOS) don't define FLT_MAX and FLT_MIN, so we look
0196  * for an alternative definition. If no other alternative is available we use
0197  * a reasonable guess.
0198  *---------------------------------------------------------------------------
0199  */
0200 
0201 #ifndef NO_FLOAT_H
0202 #   include <float.h>
0203 #else
0204 #ifndef NO_VALUES_H
0205 #   include <values.h>
0206 #endif
0207 #endif
0208 
0209 #ifndef FLT_MAX
0210 #   ifdef MAXFLOAT
0211 #   define FLT_MAX  MAXFLOAT
0212 #   else
0213 #   define FLT_MAX  3.402823466E+38F
0214 #   endif
0215 #endif
0216 #ifndef FLT_MIN
0217 #   ifdef MINFLOAT
0218 #   define FLT_MIN  MINFLOAT
0219 #   else
0220 #   define FLT_MIN  1.175494351E-38F
0221 #   endif
0222 #endif
0223 
0224 /*
0225  *---------------------------------------------------------------------------
0226  * NeXT doesn't define O_NONBLOCK, so #define it here if necessary.
0227  *---------------------------------------------------------------------------
0228  */
0229 
0230 #ifndef O_NONBLOCK
0231 #   define O_NONBLOCK 0x80
0232 #endif
0233 
0234 /*
0235  *---------------------------------------------------------------------------
0236  * The type of the status returned by wait varies from UNIX system to UNIX
0237  * system. The macro below defines it:
0238  *---------------------------------------------------------------------------
0239  */
0240 
0241 #ifdef _AIX
0242 #   define WAIT_STATUS_TYPE pid_t
0243 #else
0244 #ifndef NO_UNION_WAIT
0245 #   define WAIT_STATUS_TYPE union wait
0246 #else
0247 #   define WAIT_STATUS_TYPE int
0248 #endif
0249 #endif
0250 
0251 /*
0252  *---------------------------------------------------------------------------
0253  * Supply definitions for macros to query wait status, if not already defined
0254  * in header files above.
0255  *---------------------------------------------------------------------------
0256  */
0257 
0258 #ifndef WIFEXITED
0259 #   define WIFEXITED(stat)  (((*((int *) &(stat))) & 0xFF) == 0)
0260 #endif
0261 
0262 #ifndef WEXITSTATUS
0263 #   define WEXITSTATUS(stat)    (((*((int *) &(stat))) >> 8) & 0xFF)
0264 #endif
0265 
0266 #ifndef WIFSIGNALED
0267 #   define WIFSIGNALED(stat) \
0268     (((*((int *) &(stat)))) && ((*((int *) &(stat))) \
0269         == ((*((int *) &(stat))) & 0x00FF)))
0270 #endif
0271 
0272 #ifndef WTERMSIG
0273 #   define WTERMSIG(stat)   ((*((int *) &(stat))) & 0x7F)
0274 #endif
0275 
0276 #ifndef WIFSTOPPED
0277 #   define WIFSTOPPED(stat) (((*((int *) &(stat))) & 0xFF) == 0177)
0278 #endif
0279 
0280 #ifndef WSTOPSIG
0281 #   define WSTOPSIG(stat)   (((*((int *) &(stat))) >> 8) & 0xFF)
0282 #endif
0283 
0284 /*
0285  *---------------------------------------------------------------------------
0286  * Define constants for waitpid() system call if they aren't defined by a
0287  * system header file.
0288  *---------------------------------------------------------------------------
0289  */
0290 
0291 #ifndef WNOHANG
0292 #   define WNOHANG 1
0293 #endif
0294 #ifndef WUNTRACED
0295 #   define WUNTRACED 2
0296 #endif
0297 
0298 /*
0299  *---------------------------------------------------------------------------
0300  * Supply macros for seek offsets, if they're not already provided by an
0301  * include file.
0302  *---------------------------------------------------------------------------
0303  */
0304 
0305 #ifndef SEEK_SET
0306 #   define SEEK_SET 0
0307 #endif
0308 #ifndef SEEK_CUR
0309 #   define SEEK_CUR 1
0310 #endif
0311 #ifndef SEEK_END
0312 #   define SEEK_END 2
0313 #endif
0314 
0315 /*
0316  *---------------------------------------------------------------------------
0317  * The stuff below is needed by the "time" command. If this system has no
0318  * gettimeofday call, then must use times() instead.
0319  *---------------------------------------------------------------------------
0320  */
0321 
0322 #ifdef NO_GETTOD
0323 #   include <sys/times.h>
0324 #else
0325 #   ifdef HAVE_BSDGETTIMEOFDAY
0326 #   define gettimeofday BSDgettimeofday
0327 #   endif
0328 #endif
0329 
0330 #ifdef GETTOD_NOT_DECLARED
0331 extern int  gettimeofday(struct timeval *tp,
0332                 struct timezone *tzp);
0333 #endif
0334 
0335 /*
0336  *---------------------------------------------------------------------------
0337  * Define access mode constants if they aren't already defined.
0338  *---------------------------------------------------------------------------
0339  */
0340 
0341 #ifndef F_OK
0342 #   define F_OK     00
0343 #endif
0344 #ifndef X_OK
0345 #   define X_OK     01
0346 #endif
0347 #ifndef W_OK
0348 #   define W_OK     02
0349 #endif
0350 #ifndef R_OK
0351 #   define R_OK     04
0352 #endif
0353 
0354 /*
0355  *---------------------------------------------------------------------------
0356  * Define FD_CLOEEXEC (the close-on-exec flag bit) if it isn't already
0357  * defined.
0358  *---------------------------------------------------------------------------
0359  */
0360 
0361 #ifndef FD_CLOEXEC
0362 #   define FD_CLOEXEC   1
0363 #endif
0364 
0365 /*
0366  *---------------------------------------------------------------------------
0367  * On systems without symbolic links (i.e. S_IFLNK isn't defined) define
0368  * "lstat" to use "stat" instead.
0369  *---------------------------------------------------------------------------
0370  */
0371 
0372 #ifndef S_IFLNK
0373 #   undef TclOSlstat
0374 #   define lstat    stat
0375 #   define lstat64  stat64
0376 #   define TclOSlstat   TclOSstat
0377 #endif
0378 
0379 /*
0380  *---------------------------------------------------------------------------
0381  * Define macros to query file type bits, if they're not already defined.
0382  *---------------------------------------------------------------------------
0383  */
0384 
0385 #ifndef S_ISREG
0386 #   ifdef S_IFREG
0387 #   define S_ISREG(m)   (((m) & S_IFMT) == S_IFREG)
0388 #   else
0389 #   define S_ISREG(m)   0
0390 #   endif
0391 #endif /* !S_ISREG */
0392 #ifndef S_ISDIR
0393 #   ifdef S_IFDIR
0394 #   define S_ISDIR(m)   (((m) & S_IFMT) == S_IFDIR)
0395 #   else
0396 #   define S_ISDIR(m)   0
0397 #   endif
0398 #endif /* !S_ISDIR */
0399 #ifndef S_ISCHR
0400 #   ifdef S_IFCHR
0401 #   define S_ISCHR(m)   (((m) & S_IFMT) == S_IFCHR)
0402 #   else
0403 #   define S_ISCHR(m)   0
0404 #   endif
0405 #endif /* !S_ISCHR */
0406 
0407 #ifndef S_ISBLK
0408 #   ifdef S_IFBLK
0409 #   define S_ISBLK(m)   (((m) & S_IFMT) == S_IFBLK)
0410 #   else
0411 #   define S_ISBLK(m)   0
0412 #   endif
0413 #endif /* !S_ISBLK */
0414 
0415 #ifndef S_ISFIFO
0416 #   ifdef S_IFIFO
0417 #   define S_ISFIFO(m)  (((m) & S_IFMT) == S_IFIFO)
0418 #   else
0419 #   define S_ISFIFO(m)  0
0420 #   endif
0421 #endif /* !S_ISFIFO */
0422 
0423 #ifndef S_ISLNK
0424 #   ifdef S_IFLNK
0425 #   define S_ISLNK(m)   (((m) & S_IFMT) == S_IFLNK)
0426 #   else
0427 #   define S_ISLNK(m)   0
0428 #   endif
0429 #endif /* !S_ISLNK */
0430 
0431 #ifndef S_ISSOCK
0432 #   ifdef S_IFSOCK
0433 #   define S_ISSOCK(m)  (((m) & S_IFMT) == S_IFSOCK)
0434 #   else
0435 #   define S_ISSOCK(m)  0
0436 #   endif
0437 #endif /* !S_ISSOCK */
0438 
0439 /*
0440  *---------------------------------------------------------------------------
0441  * Make sure that MAXPATHLEN and MAXNAMLEN are defined.
0442  *---------------------------------------------------------------------------
0443  */
0444 
0445 #ifndef MAXPATHLEN
0446 #   ifdef PATH_MAX
0447 #   define MAXPATHLEN   PATH_MAX
0448 #   else
0449 #   define MAXPATHLEN   2048
0450 #   endif
0451 #endif
0452 
0453 #ifndef MAXNAMLEN
0454 #   ifdef NAME_MAX
0455 #   define MAXNAMLEN    NAME_MAX
0456 #   else
0457 #   define MAXNAMLEN    255
0458 #   endif
0459 #endif
0460 
0461 /*
0462  *---------------------------------------------------------------------------
0463  * The following macro defines the type of the mask arguments to select:
0464  *---------------------------------------------------------------------------
0465  */
0466 
0467 #ifndef NO_FD_SET
0468 #   define SELECT_MASK  fd_set
0469 #else /* NO_FD_SET */
0470 #   ifndef _AIX
0471     typedef long    fd_mask;
0472 #   endif /* !AIX */
0473 #   if defined(_IBMR2)
0474 #   define SELECT_MASK  void
0475 #   else /* !defined(_IBMR2) */
0476 #   define SELECT_MASK  int
0477 #   endif /* defined(_IBMR2) */
0478 #endif /* !NO_FD_SET */
0479 
0480 /*
0481  *---------------------------------------------------------------------------
0482  * Define "NBBY" (number of bits per byte) if it's not already defined.
0483  *---------------------------------------------------------------------------
0484  */
0485 
0486 #ifndef NBBY
0487 #   define NBBY     8
0488 #endif
0489 
0490 /*
0491  *---------------------------------------------------------------------------
0492  * The following macro defines the number of fd_masks in an fd_set:
0493  *---------------------------------------------------------------------------
0494  */
0495 
0496 #ifndef FD_SETSIZE
0497 #   ifdef OPEN_MAX
0498 #   define FD_SETSIZE   OPEN_MAX
0499 #   else
0500 #   define FD_SETSIZE   256
0501 #   endif
0502 #endif /* FD_SETSIZE */
0503 
0504 #ifndef howmany
0505 #   define howmany(x, y)    (((x)+((y)-1))/(y))
0506 #endif /* !defined(howmany) */
0507 
0508 #ifndef NFDBITS
0509 #   define NFDBITS  NBBY*sizeof(fd_mask)
0510 #endif /* NFDBITS */
0511 
0512 #define MASK_SIZE   howmany(FD_SETSIZE, NFDBITS)
0513 
0514 /*
0515  *---------------------------------------------------------------------------
0516  * Not all systems declare the errno variable in errno.h. so this file does it
0517  * explicitly. The list of system error messages also isn't generally declared
0518  * in a header file anywhere.
0519  *---------------------------------------------------------------------------
0520  */
0521 
0522 #ifdef NO_ERRNO
0523 extern int errno;
0524 #endif /* NO_ERRNO */
0525 
0526 /*
0527  *---------------------------------------------------------------------------
0528  * Not all systems declare all the errors that Tcl uses! Provide some
0529  * work-arounds...
0530  *---------------------------------------------------------------------------
0531  */
0532 
0533 #ifndef EOVERFLOW
0534 #   ifdef EFBIG
0535 #   define EOVERFLOW    EFBIG
0536 #   else /* !EFBIG */
0537 #   define EOVERFLOW    EINVAL
0538 #   endif /* EFBIG */
0539 #endif /* EOVERFLOW */
0540 
0541 /*
0542  *---------------------------------------------------------------------------
0543  * Variables provided by the C library:
0544  *---------------------------------------------------------------------------
0545  */
0546 
0547 #if defined(__APPLE__) && defined(__DYNAMIC__)
0548 #   include <crt_externs.h>
0549 #   define environ  (*_NSGetEnviron())
0550 #   define USE_PUTENV   1
0551 #else
0552 #   if defined(_sgi) || defined(__sgi)
0553 #   define environ  _environ
0554 #   endif
0555 extern char **      environ;
0556 #endif
0557 
0558 /*
0559  *---------------------------------------------------------------------------
0560  * Darwin specifc configure overrides.
0561  *---------------------------------------------------------------------------
0562  */
0563 
0564 #ifdef __APPLE__
0565 
0566 /*
0567  *---------------------------------------------------------------------------
0568  * Support for fat compiles: configure runs only once for multiple architectures
0569  *---------------------------------------------------------------------------
0570  */
0571 
0572 #   if defined(__LP64__) && defined (NO_COREFOUNDATION_64)
0573 #   undef HAVE_COREFOUNDATION
0574 #   endif /* __LP64__ && NO_COREFOUNDATION_64 */
0575 #   include <sys/cdefs.h>
0576 #   ifdef __DARWIN_UNIX03
0577 #   if __DARWIN_UNIX03
0578 #       undef HAVE_PUTENV_THAT_COPIES
0579 #   else
0580 #       define HAVE_PUTENV_THAT_COPIES  1
0581 #   endif
0582 #   endif /* __DARWIN_UNIX03 */
0583 
0584 /*
0585  *---------------------------------------------------------------------------
0586  * Include AvailabilityMacros.h here (when available) to ensure any symbolic
0587  * MAC_OS_X_VERSION_* constants passed on the command line are translated.
0588  *---------------------------------------------------------------------------
0589  */
0590 
0591 #   ifdef HAVE_AVAILABILITYMACROS_H
0592 #   include <AvailabilityMacros.h>
0593 #   endif
0594 
0595 /*
0596  *---------------------------------------------------------------------------
0597  * Support for weak import.
0598  *---------------------------------------------------------------------------
0599  */
0600 
0601 #   ifdef HAVE_WEAK_IMPORT
0602 #   if !defined(HAVE_AVAILABILITYMACROS_H) || !defined(MAC_OS_X_VERSION_MIN_REQUIRED)
0603 #       undef HAVE_WEAK_IMPORT
0604 #   else
0605 #       ifndef WEAK_IMPORT_ATTRIBUTE
0606 #       define WEAK_IMPORT_ATTRIBUTE    __attribute__((weak_import))
0607 #       endif
0608 #   endif
0609 #   endif /* HAVE_WEAK_IMPORT */
0610 
0611 /*
0612  *---------------------------------------------------------------------------
0613  * Support for MAC_OS_X_VERSION_MAX_ALLOWED define from AvailabilityMacros.h:
0614  * only use API available in the indicated OS version or earlier.
0615  *---------------------------------------------------------------------------
0616  */
0617 
0618 #   ifdef MAC_OS_X_VERSION_MAX_ALLOWED
0619 #   if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 && defined(__LP64__)
0620 #       undef HAVE_COREFOUNDATION
0621 #   endif
0622 #   if MAC_OS_X_VERSION_MAX_ALLOWED < 1040
0623 #       undef HAVE_OSSPINLOCKLOCK
0624 #       undef HAVE_PTHREAD_ATFORK
0625 #       undef HAVE_COPYFILE
0626 #   endif
0627 #   if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
0628 #       ifdef TCL_THREADS
0629         /* prior to 10.3, realpath is not threadsafe, c.f. bug 711232 */
0630 #       define NO_REALPATH 1
0631 #       endif
0632 #       undef HAVE_LANGINFO
0633 #   endif
0634 #   endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
0635 #   if defined(HAVE_COREFOUNDATION) && defined(__LP64__) && \
0636         defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1050
0637 #   warning "Weak import of 64-bit CoreFoundation is not supported, will not run on Mac OS X < 10.5."
0638 #   endif
0639 
0640 /*
0641  *---------------------------------------------------------------------------
0642  * At present, using vfork() instead of fork() causes execve() to fail
0643  * intermittently on Darwin x86_64. rdar://4685553
0644  *---------------------------------------------------------------------------
0645  */
0646 
0647 #   if defined(__x86_64__) && !defined(FIXED_RDAR_4685553)
0648 #   undef USE_VFORK
0649 #   endif /* __x86_64__ */
0650 /* Workaround problems with vfork() when building with llvm-gcc-4.2 */
0651 #   if defined (__llvm__) && \
0652         (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 2 || \
0653         (__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ > 0))))
0654 #   undef USE_VFORK
0655 #   endif /* __llvm__ */
0656 #endif /* __APPLE__ */
0657 
0658 /*
0659  *---------------------------------------------------------------------------
0660  * The following macros and declarations represent the interface between
0661  * generic and unix-specific parts of Tcl. Some of the macros may override
0662  * functions declared in tclInt.h.
0663  *---------------------------------------------------------------------------
0664  */
0665 
0666 /*
0667  * The default platform eol translation on Unix is TCL_TRANSLATE_LF.
0668  */
0669 
0670 #ifdef DJGPP
0671 #define TCL_PLATFORM_TRANSLATION    TCL_TRANSLATE_CRLF
0672 typedef int socklen_t;
0673 #else
0674 #define TCL_PLATFORM_TRANSLATION    TCL_TRANSLATE_LF
0675 #endif
0676 
0677 /*
0678  *---------------------------------------------------------------------------
0679  * The following macros have trivial definitions, allowing generic code to
0680  * address platform-specific issues.
0681  *---------------------------------------------------------------------------
0682  */
0683 
0684 #define TclpReleaseFile(file)   /* Nothing. */
0685 
0686 /*
0687  *---------------------------------------------------------------------------
0688  * The following defines wrap the system memory allocation routines.
0689  *---------------------------------------------------------------------------
0690  */
0691 
0692 #define TclpSysAlloc(size, isBin)   malloc((size_t)(size))
0693 #define TclpSysFree(ptr)        free((char *)(ptr))
0694 #define TclpSysRealloc(ptr, size)   realloc((char *)(ptr), (size_t)(size))
0695 
0696 /*
0697  *---------------------------------------------------------------------------
0698  * The following macros and declaration wrap the C runtime library functions.
0699  *---------------------------------------------------------------------------
0700  */
0701 
0702 #define TclpExit    exit
0703 
0704 #ifdef TCL_THREADS
0705 #   include <pthread.h>
0706 #endif /* TCL_THREADS */
0707 
0708 /* FIXME - Hyper-enormous platform assumption! */
0709 #ifndef AF_INET6
0710 #   define AF_INET6 10
0711 #endif
0712 
0713 /*
0714  *---------------------------------------------------------------------------
0715  * Set of MT-safe implementations of some known-to-be-MT-unsafe library calls.
0716  * Instead of returning pointers to the static storage, those return pointers
0717  * to the TSD data.
0718  *---------------------------------------------------------------------------
0719  */
0720 
0721 #include <pwd.h>
0722 #include <grp.h>
0723 
0724 extern struct passwd *  TclpGetPwNam(const char *name);
0725 extern struct group *   TclpGetGrNam(const char *name);
0726 extern struct passwd *  TclpGetPwUid(uid_t uid);
0727 extern struct group *   TclpGetGrGid(gid_t gid);
0728 extern struct hostent * TclpGetHostByName(const char *name);
0729 extern struct hostent * TclpGetHostByAddr(const char *addr,
0730                     int length, int type);
0731 extern void *TclpMakeTcpClientChannelMode(
0732                     void *tcpSocket, int mode);
0733 
0734 #endif /* _TCLUNIXPORT */
0735 
0736 /*
0737  * Local Variables:
0738  * mode: c
0739  * c-basic-offset: 4
0740  * fill-column: 78
0741  * End:
0742  */