persistentstorage/sqlite3api/TEST/TCL/tcldistribution/unix/tclUnixPort.h
changeset 0 08ec8eefde2f
child 23 26645d81f48d
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 /*
       
     2  * tclUnixPort.h --
       
     3  *
       
     4  *	This header file handles porting issues that occur because
       
     5  *	of differences between systems.  It reads in UNIX-related
       
     6  *	header files and sets up UNIX-related macros for Tcl's UNIX
       
     7  *	core.  It should be the only file that contains #ifdefs to
       
     8  *	handle different flavors of UNIX.  This file sets up the
       
     9  *	union of all UNIX-related things needed by any of the Tcl
       
    10  *	core files.  This file depends on configuration #defines such
       
    11  *	as NO_DIRENT_H that are set up by the "configure" script.
       
    12  *
       
    13  *	Much of the material in this file was originally contributed
       
    14  *	by Karl Lehenbauer, Mark Diekhans and Peter da Silva.
       
    15  *
       
    16  * Copyright (c) 1991-1994 The Regents of the University of California.
       
    17  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
       
    18  * Portions Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiaries. All rights reserved.    
       
    19  *
       
    20  * See the file "license.terms" for information on usage and redistribution
       
    21  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
       
    22  *
       
    23  * RCS: @(#) $Id: tclUnixPort.h,v 1.27.2.18 2007/04/21 22:42:49 kennykb Exp $
       
    24  */
       
    25 
       
    26 #ifndef _TCLUNIXPORT
       
    27 #define _TCLUNIXPORT
       
    28 
       
    29 #ifndef _TCLINT
       
    30 #   include "tclInt.h"
       
    31 #endif
       
    32 
       
    33 #if defined(__SYMBIAN32__)
       
    34 #include <sys/select.h>
       
    35 
       
    36 #define TCL_LOCAL_MAIN_HOOK ChildProcessInit
       
    37 #endif
       
    38 
       
    39 /*
       
    40  *---------------------------------------------------------------------------
       
    41  * The following sets of #includes and #ifdefs are required to get Tcl to
       
    42  * compile under the various flavors of unix.
       
    43  *---------------------------------------------------------------------------
       
    44  */
       
    45 
       
    46 #include <errno.h>
       
    47 #include <fcntl.h>
       
    48 #ifdef HAVE_NET_ERRNO_H
       
    49 #   include <net/errno.h>
       
    50 #endif
       
    51 #include <pwd.h>
       
    52 #ifndef __SYMBIAN32__  // added to prevent link errors on armv5
       
    53 #include <signal.h>
       
    54 #endif
       
    55 #ifdef HAVE_SYS_PARAM_H
       
    56 #   include <sys/param.h>
       
    57 #endif
       
    58 #include <sys/types.h>
       
    59 #ifdef USE_DIRENT2_H
       
    60 #   include "../compat/dirent2.h"
       
    61 #else
       
    62 #ifdef NO_DIRENT_H
       
    63 #   include "../compat/dirent.h"
       
    64 #else
       
    65 #   include <dirent.h>
       
    66 #endif
       
    67 #endif
       
    68 
       
    69 #ifdef HAVE_STRUCT_DIRENT64
       
    70 typedef struct dirent64	Tcl_DirEntry;
       
    71 #   define TclOSreaddir		readdir64
       
    72 #else
       
    73 typedef struct dirent	Tcl_DirEntry;
       
    74 #   define TclOSreaddir		readdir
       
    75 #endif
       
    76 
       
    77 #ifdef HAVE_TYPE_OFF64_T
       
    78 typedef off64_t		Tcl_SeekOffset;
       
    79 #   define TclOSseek		lseek64
       
    80 #   define TclOSopen		open64
       
    81 #else
       
    82 typedef off_t		Tcl_SeekOffset;
       
    83 #   define TclOSseek		lseek
       
    84 #   define TclOSopen		open
       
    85 #endif
       
    86 
       
    87 #ifdef HAVE_STRUCT_STAT64
       
    88 #   define TclOSstat		stat64
       
    89 #   define TclOSlstat		lstat64
       
    90 #else
       
    91 #   define TclOSstat		stat
       
    92 #   define TclOSlstat		lstat
       
    93 #endif
       
    94 
       
    95 #if !HAVE_STRTOLL && defined(TCL_WIDE_INT_TYPE) && !TCL_WIDE_INT_IS_LONG
       
    96 EXTERN Tcl_WideInt	strtoll _ANSI_ARGS_((CONST char *string,
       
    97 					     char **endPtr, int base));
       
    98 EXTERN Tcl_WideUInt	strtoull _ANSI_ARGS_((CONST char *string,
       
    99 					      char **endPtr, int base));
       
   100 #endif
       
   101 
       
   102 #ifdef __SYMBIAN32__  
       
   103 // conforming to PIPS file standards
       
   104 #include <sys/filio.h>
       
   105 #else
       
   106 #include <sys/file.h>
       
   107 #endif
       
   108 #ifdef HAVE_SYS_SELECT_H
       
   109 #   include <sys/select.h>
       
   110 #endif
       
   111 #include <sys/stat.h>
       
   112 
       
   113 #ifdef __CYGWIN__
       
   114 #   define timezone _timezone
       
   115     typedef long TIMEZONE_t;
       
   116 #else	/* !__CYGWIN__ */
       
   117     typedef int TIMEZONE_t;
       
   118 #endif	/* !__CYGWIN__ */
       
   119 
       
   120 #if TIME_WITH_SYS_TIME
       
   121 #   include <sys/time.h>
       
   122 #   include <time.h>
       
   123 #else
       
   124 #if HAVE_SYS_TIME_H
       
   125 #   include <sys/time.h>
       
   126 #else
       
   127 #   include <time.h>
       
   128 #endif
       
   129 #endif
       
   130 #ifndef NO_SYS_WAIT_H
       
   131 #   include <sys/wait.h>
       
   132 #endif
       
   133 #ifdef HAVE_UNISTD_H
       
   134 #   include <unistd.h>
       
   135 #else
       
   136 #   include "../compat/unistd.h"
       
   137 #endif
       
   138 #ifdef	USE_FIONBIO
       
   139     /*
       
   140      * Not using the Posix fcntl(...,O_NONBLOCK,...) interface, instead
       
   141      * we are using ioctl(..,FIONBIO,..).
       
   142      */
       
   143 
       
   144 #   ifdef HAVE_SYS_FILIO_H
       
   145 #	include	<sys/filio.h>	/* For FIONBIO. */
       
   146 #   endif
       
   147 
       
   148 #   ifdef HAVE_SYS_IOCTL_H
       
   149 #	include	<sys/ioctl.h>	/* For FIONBIO. */
       
   150 #   endif
       
   151 #endif	/* USE_FIONBIO */
       
   152 #include <utime.h>
       
   153 
       
   154 /*
       
   155  * Socket support stuff: This likely needs more work to parameterize for
       
   156  * each system.
       
   157  */
       
   158 
       
   159 #include <sys/socket.h>		/* struct sockaddr, SOCK_STREAM, ... */
       
   160 #ifndef NO_UNAME
       
   161 #   include <sys/utsname.h>	/* uname system call. */
       
   162 #endif
       
   163 #include <netinet/in.h>		/* struct in_addr, struct sockaddr_in */
       
   164 #include <arpa/inet.h>		/* inet_ntoa() */
       
   165 #include <netdb.h>		/* gethostbyname() */
       
   166 
       
   167 /*
       
   168  * Some platforms (e.g. SunOS) don't define FLT_MAX and FLT_MIN, so we
       
   169  * look for an alternative definition.  If no other alternative is available
       
   170  * we use a reasonable guess.
       
   171  */
       
   172 
       
   173 #ifndef NO_FLOAT_H
       
   174 #   include <float.h>
       
   175 #else
       
   176 #ifndef NO_VALUES_H
       
   177 #   include <values.h>
       
   178 #endif
       
   179 #endif
       
   180 
       
   181 #ifndef FLT_MAX
       
   182 #   ifdef MAXFLOAT
       
   183 #	define FLT_MAX MAXFLOAT
       
   184 #   else
       
   185 #	define FLT_MAX 3.402823466E+38F
       
   186 #   endif
       
   187 #endif
       
   188 #ifndef FLT_MIN
       
   189 #   ifdef MINFLOAT
       
   190 #	define FLT_MIN MINFLOAT
       
   191 #   else
       
   192 #	define FLT_MIN 1.175494351E-38F
       
   193 #   endif
       
   194 #endif
       
   195 
       
   196 /*
       
   197  * NeXT doesn't define O_NONBLOCK, so #define it here if necessary.
       
   198  */
       
   199 
       
   200 #ifndef O_NONBLOCK
       
   201 #   define O_NONBLOCK 0x80
       
   202 #endif
       
   203 
       
   204 /*
       
   205  * HPUX needs the flag O_NONBLOCK to get the right non-blocking I/O
       
   206  * semantics, while most other systems need O_NDELAY.  Define the
       
   207  * constant NBIO_FLAG to be one of these
       
   208  */
       
   209 
       
   210 #ifdef HPUX
       
   211 #  define NBIO_FLAG O_NONBLOCK
       
   212 #else
       
   213 #  define NBIO_FLAG O_NDELAY
       
   214 #endif
       
   215 
       
   216 /*
       
   217  * The type of the status returned by wait varies from UNIX system
       
   218  * to UNIX system.  The macro below defines it:
       
   219  */
       
   220 
       
   221 #ifdef _AIX
       
   222 #   define WAIT_STATUS_TYPE pid_t
       
   223 #else
       
   224 #ifndef NO_UNION_WAIT
       
   225 #   define WAIT_STATUS_TYPE union wait
       
   226 #else
       
   227 #   define WAIT_STATUS_TYPE int
       
   228 #endif
       
   229 #endif
       
   230 
       
   231 /*
       
   232  * Supply definitions for macros to query wait status, if not already
       
   233  * defined in header files above.
       
   234  */
       
   235 
       
   236 #ifndef WIFEXITED
       
   237 #   define WIFEXITED(stat)  (((*((int *) &(stat))) & 0xff) == 0)
       
   238 #endif
       
   239 
       
   240 #ifndef WEXITSTATUS
       
   241 #   define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff)
       
   242 #endif
       
   243 
       
   244 #ifndef WIFSIGNALED
       
   245 #   define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff)))
       
   246 #endif
       
   247 
       
   248 #ifndef WTERMSIG
       
   249 #   define WTERMSIG(stat)    ((*((int *) &(stat))) & 0x7f)
       
   250 #endif
       
   251 
       
   252 #ifndef WIFSTOPPED
       
   253 #   define WIFSTOPPED(stat)  (((*((int *) &(stat))) & 0xff) == 0177)
       
   254 #endif
       
   255 
       
   256 #ifndef WSTOPSIG
       
   257 #   define WSTOPSIG(stat)    (((*((int *) &(stat))) >> 8) & 0xff)
       
   258 #endif
       
   259 
       
   260 /*
       
   261  * Define constants for waitpid() system call if they aren't defined
       
   262  * by a system header file.
       
   263  */
       
   264 
       
   265 #ifndef WNOHANG
       
   266 #   define WNOHANG 1
       
   267 #endif
       
   268 #ifndef WUNTRACED
       
   269 #   define WUNTRACED 2
       
   270 #endif
       
   271 
       
   272 /*
       
   273  * Supply macros for seek offsets, if they're not already provided by
       
   274  * an include file.
       
   275  */
       
   276 
       
   277 #ifndef SEEK_SET
       
   278 #   define SEEK_SET 0
       
   279 #endif
       
   280 #ifndef SEEK_CUR
       
   281 #   define SEEK_CUR 1
       
   282 #endif
       
   283 #ifndef SEEK_END
       
   284 #   define SEEK_END 2
       
   285 #endif
       
   286 
       
   287 /*
       
   288  * The stuff below is needed by the "time" command.  If this system has no
       
   289  * gettimeofday call, then must use times and the CLK_TCK #define (from
       
   290  * sys/param.h) to compute elapsed time.  Unfortunately, some systems only
       
   291  * have HZ and no CLK_TCK, and some might not even have HZ.
       
   292  */
       
   293 
       
   294 #ifdef NO_GETTOD
       
   295 #   include <sys/times.h>
       
   296 #   include <sys/param.h>
       
   297 #   ifndef CLK_TCK
       
   298 #       ifdef HZ
       
   299 #           define CLK_TCK HZ
       
   300 #       else
       
   301 #           define CLK_TCK 60
       
   302 #       endif
       
   303 #   endif
       
   304 #else
       
   305 #   ifdef HAVE_BSDGETTIMEOFDAY
       
   306 #	define gettimeofday BSDgettimeofday
       
   307 #   endif
       
   308 #endif
       
   309 
       
   310 #ifdef GETTOD_NOT_DECLARED
       
   311 EXTERN int		gettimeofday _ANSI_ARGS_((struct timeval *tp,
       
   312 			    struct timezone *tzp));
       
   313 #endif
       
   314 
       
   315 /*
       
   316  * Define access mode constants if they aren't already defined.
       
   317  */
       
   318 
       
   319 #ifndef F_OK
       
   320 #    define F_OK 00
       
   321 #endif
       
   322 #ifndef X_OK
       
   323 #    define X_OK 01
       
   324 #endif
       
   325 #ifndef W_OK
       
   326 #    define W_OK 02
       
   327 #endif
       
   328 #ifndef R_OK
       
   329 #    define R_OK 04
       
   330 #endif
       
   331 
       
   332 /*
       
   333  * Define FD_CLOEEXEC (the close-on-exec flag bit) if it isn't
       
   334  * already defined.
       
   335  */
       
   336 
       
   337 #ifndef FD_CLOEXEC
       
   338 #   define FD_CLOEXEC 1
       
   339 #endif
       
   340 
       
   341 /*
       
   342  * On systems without symbolic links (i.e. S_IFLNK isn't defined)
       
   343  * define "lstat" to use "stat" instead.
       
   344  */
       
   345 
       
   346 #ifndef S_IFLNK
       
   347 #   undef TclOSlstat
       
   348 #   define lstat	stat
       
   349 #   define lstat64	stat64
       
   350 #   define TclOSlstat	TclOSstat
       
   351 #endif
       
   352 
       
   353 /*
       
   354  * Define macros to query file type bits, if they're not already
       
   355  * defined.
       
   356  */
       
   357 
       
   358 #ifndef S_ISREG
       
   359 #   ifdef S_IFREG
       
   360 #       define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
       
   361 #   else
       
   362 #       define S_ISREG(m) 0
       
   363 #   endif
       
   364 #endif /* !S_ISREG */
       
   365 #ifndef S_ISDIR
       
   366 #   ifdef S_IFDIR
       
   367 #       define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
       
   368 #   else
       
   369 #       define S_ISDIR(m) 0
       
   370 #   endif
       
   371 #endif /* !S_ISDIR */
       
   372 #ifndef S_ISCHR
       
   373 #   ifdef S_IFCHR
       
   374 #       define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
       
   375 #   else
       
   376 #       define S_ISCHR(m) 0
       
   377 #   endif
       
   378 #endif /* !S_ISCHR */
       
   379 #ifndef S_ISBLK
       
   380 #   ifdef S_IFBLK
       
   381 #       define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
       
   382 #   else
       
   383 #       define S_ISBLK(m) 0
       
   384 #   endif
       
   385 #endif /* !S_ISBLK */
       
   386 #ifndef S_ISFIFO
       
   387 #   ifdef S_IFIFO
       
   388 #       define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
       
   389 #   else
       
   390 #       define S_ISFIFO(m) 0
       
   391 #   endif
       
   392 #endif /* !S_ISFIFO */
       
   393 #ifndef S_ISLNK
       
   394 #   ifdef S_IFLNK
       
   395 #       define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
       
   396 #   else
       
   397 #       define S_ISLNK(m) 0
       
   398 #   endif
       
   399 #endif /* !S_ISLNK */
       
   400 #ifndef S_ISSOCK
       
   401 #   ifdef S_IFSOCK
       
   402 #       define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
       
   403 #   else
       
   404 #       define S_ISSOCK(m) 0
       
   405 #   endif
       
   406 #endif /* !S_ISSOCK */
       
   407 
       
   408 /*
       
   409  * Make sure that MAXPATHLEN and MAXNAMLEN are defined.
       
   410  */
       
   411 
       
   412 #ifndef MAXPATHLEN
       
   413 #   ifdef PATH_MAX
       
   414 #       define MAXPATHLEN PATH_MAX
       
   415 #   else
       
   416 #       define MAXPATHLEN 2048
       
   417 #   endif
       
   418 #endif
       
   419 
       
   420 #ifndef MAXNAMLEN
       
   421 #   ifdef NAME_MAX
       
   422 #	define MAXNAMLEN NAME_MAX
       
   423 #   else
       
   424 #	define MAXNAMLEN 255
       
   425 #   endif
       
   426 #endif
       
   427 
       
   428 /*
       
   429  * Make sure that L_tmpnam is defined.
       
   430  */
       
   431 
       
   432 #ifndef L_tmpnam
       
   433 #   define L_tmpnam 100
       
   434 #endif
       
   435 
       
   436 /*
       
   437  * The following macro defines the type of the mask arguments to
       
   438  * select:
       
   439  */
       
   440 
       
   441 #ifndef NO_FD_SET
       
   442 #   define SELECT_MASK fd_set
       
   443 #else /* NO_FD_SET */
       
   444 #   ifndef _AIX
       
   445 	typedef long fd_mask;
       
   446 #   endif /* !AIX */
       
   447 #   if defined(_IBMR2)
       
   448 #	define SELECT_MASK void
       
   449 #   else /* !defined(_IBMR2) */
       
   450 #	define SELECT_MASK int
       
   451 #   endif /* defined(_IBMR2) */
       
   452 #endif /* !NO_FD_SET */
       
   453 
       
   454 /*
       
   455  * Define "NBBY" (number of bits per byte) if it's not already defined.
       
   456  */
       
   457 
       
   458 #ifndef NBBY
       
   459 #   define NBBY 8
       
   460 #endif
       
   461 
       
   462 /*
       
   463  * The following macro defines the number of fd_masks in an fd_set:
       
   464  */
       
   465 
       
   466 #ifndef FD_SETSIZE
       
   467 #   ifdef OPEN_MAX
       
   468 #	define FD_SETSIZE OPEN_MAX
       
   469 #   else
       
   470 #	define FD_SETSIZE 256
       
   471 #   endif
       
   472 #endif /* FD_SETSIZE */
       
   473 #if !defined(howmany)
       
   474 #   define howmany(x, y) (((x)+((y)-1))/(y))
       
   475 #endif /* !defined(howmany) */
       
   476 #ifndef NFDBITS
       
   477 #   define NFDBITS NBBY*sizeof(fd_mask)
       
   478 #endif /* NFDBITS */
       
   479 #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
       
   480 
       
   481 /*
       
   482  * Not all systems declare the errno variable in errno.h. so this
       
   483  * file does it explicitly.  The list of system error messages also
       
   484  * isn't generally declared in a header file anywhere.
       
   485  */
       
   486 
       
   487 #ifdef NO_ERRNO
       
   488 extern int errno;
       
   489 #endif
       
   490 
       
   491 /*
       
   492  * Not all systems declare all the errors that Tcl uses!  Provide some
       
   493  * work-arounds...
       
   494  */
       
   495 
       
   496 #ifndef EOVERFLOW
       
   497 #   ifdef EFBIG
       
   498 #	define EOVERFLOW EFBIG
       
   499 #   else /* !EFBIG */
       
   500 #	define EOVERFLOW EINVAL
       
   501 #   endif /* EFBIG */
       
   502 #endif /* EOVERFLOW */
       
   503 
       
   504 /*
       
   505  * Variables provided by the C library:
       
   506  */
       
   507 
       
   508 #if defined(_sgi) || defined(__sgi) || (defined(__APPLE__) && defined(__DYNAMIC__))
       
   509 #   define environ _environ
       
   510 #endif
       
   511 extern char **environ;
       
   512 
       
   513 /*
       
   514  * At present (12/91) not all stdlib.h implementations declare strtod.
       
   515  * The declaration below is here to ensure that it's declared, so that
       
   516  * the compiler won't take the default approach of assuming it returns
       
   517  * an int.  There's no ANSI prototype for it because there would end
       
   518  * up being too many conflicts with slightly-different prototypes.
       
   519  */
       
   520 
       
   521 extern double strtod();
       
   522 
       
   523 /*
       
   524  * There is no platform-specific panic routine for Unix in the Tcl internals.
       
   525  */
       
   526 
       
   527 #define TclpPanic ((Tcl_PanicProc *) NULL)
       
   528 
       
   529 /*
       
   530  * Darwin specifc configure overrides.
       
   531  */
       
   532 
       
   533 #ifdef __APPLE__
       
   534 /*
       
   535  * Support for fat compiles: configure runs only once for multiple architectures
       
   536  */
       
   537 #   if defined(__LP64__) && defined (NO_COREFOUNDATION_64)
       
   538 #       undef HAVE_COREFOUNDATION
       
   539 #    endif /* __LP64__ && NO_COREFOUNDATION_64 */
       
   540 #   include <sys/cdefs.h>
       
   541 #   ifdef __DARWIN_UNIX03
       
   542 #       if __DARWIN_UNIX03
       
   543 #           undef HAVE_PUTENV_THAT_COPIES
       
   544 #       else
       
   545 #           define HAVE_PUTENV_THAT_COPIES 1
       
   546 #       endif
       
   547 #   endif /* __DARWIN_UNIX03 */
       
   548 /*
       
   549  * The termios configure test program relies on the configure script being run
       
   550  * from a terminal, which is not the case e.g. when configuring from Xcode.
       
   551  * Since termios is known to be present on all Mac OS X releases since 10.0,
       
   552  * override the configure defines for serial API here. [Bug 497147]
       
   553  */
       
   554 #   define USE_TERMIOS 1
       
   555 #   undef  USE_TERMIO
       
   556 #   undef  USE_SGTTY
       
   557 /*
       
   558  * Include AvailabilityMacros.h here (when available) to ensure any symbolic
       
   559  * MAC_OS_X_VERSION_* constants passed on the command line are translated.
       
   560  */
       
   561 #   ifdef HAVE_AVAILABILITYMACROS_H
       
   562 #       include <AvailabilityMacros.h>
       
   563 #   endif
       
   564 /*
       
   565  * Support for weak import.
       
   566  */
       
   567 #   ifdef HAVE_WEAK_IMPORT
       
   568 #       if !defined(HAVE_AVAILABILITYMACROS_H) || !defined(MAC_OS_X_VERSION_MIN_REQUIRED)
       
   569 #           undef HAVE_WEAK_IMPORT
       
   570 #       else
       
   571 #           ifndef WEAK_IMPORT_ATTRIBUTE
       
   572 #               define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import))
       
   573 #           endif
       
   574 #       endif
       
   575 #   endif /* HAVE_WEAK_IMPORT */
       
   576 /*
       
   577  * Support for MAC_OS_X_VERSION_MAX_ALLOWED define from AvailabilityMacros.h:
       
   578  * only use API available in the indicated OS version or earlier.
       
   579  */
       
   580 #   ifdef MAC_OS_X_VERSION_MAX_ALLOWED
       
   581 #       if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 && defined(__LP64__)
       
   582 #           undef HAVE_COREFOUNDATION
       
   583 #       endif
       
   584 #       if MAC_OS_X_VERSION_MAX_ALLOWED < 1040
       
   585 #           undef HAVE_OSSPINLOCKLOCK
       
   586 #           undef HAVE_PTHREAD_ATFORK
       
   587 #           undef HAVE_COPYFILE
       
   588 #       endif
       
   589 #       if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
       
   590 #           ifdef TCL_THREADS
       
   591 		/* prior to 10.3, realpath is not threadsafe, c.f. bug 711232 */
       
   592 #               define NO_REALPATH 1
       
   593 #           endif
       
   594 #           undef HAVE_LANGINFO
       
   595 #       endif
       
   596 #   endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
       
   597 #   if defined(HAVE_COREFOUNDATION) && defined(__LP64__) && \
       
   598 	    defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1050
       
   599 #       warning "Weak import of 64-bit CoreFoundation is not supported, will not run on Mac OS X < 10.5."
       
   600 #   endif
       
   601 /*
       
   602  * At present, using vfork() instead of fork() causes execve() to fail
       
   603  * intermittently on Darwin x86_64. rdar://4685553
       
   604  */
       
   605 #   if defined(__x86_64__) && !defined(FIXED_RDAR_4685553)
       
   606 #       undef USE_VFORK
       
   607 #   endif /* __x86_64__ */
       
   608 #endif /* __APPLE__ */
       
   609 
       
   610 /*
       
   611  * Darwin 8 copyfile API.
       
   612  */
       
   613 
       
   614 #ifdef HAVE_COPYFILE
       
   615 #ifdef HAVE_COPYFILE_H
       
   616 #include <copyfile.h>
       
   617 #if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1040
       
   618 /* Support for weakly importing copyfile. */
       
   619 #define WEAK_IMPORT_COPYFILE
       
   620 extern int copyfile(const char *from, const char *to, copyfile_state_t state,
       
   621 		    copyfile_flags_t flags) WEAK_IMPORT_ATTRIBUTE;
       
   622 #endif /* HAVE_WEAK_IMPORT */
       
   623 #else /* HAVE_COPYFILE_H */
       
   624 int copyfile(const char *from, const char *to, void *state, uint32_t flags);
       
   625 #define COPYFILE_ACL            (1<<0)
       
   626 #define COPYFILE_XATTR          (1<<2)
       
   627 #define COPYFILE_NOFOLLOW_SRC   (1<<18)
       
   628 #if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1040
       
   629 /* Support for weakly importing copyfile. */
       
   630 #define WEAK_IMPORT_COPYFILE
       
   631 extern int copyfile(const char *from, const char *to, void *state,
       
   632                     uint32_t flags) WEAK_IMPORT_ATTRIBUTE;
       
   633 #endif /* HAVE_WEAK_IMPORT */
       
   634 #endif /* HAVE_COPYFILE_H */
       
   635 #endif /* HAVE_COPYFILE */
       
   636 
       
   637 /*
       
   638  *---------------------------------------------------------------------------
       
   639  * The following macros and declarations represent the interface between 
       
   640  * generic and unix-specific parts of Tcl.  Some of the macros may override 
       
   641  * functions declared in tclInt.h.
       
   642  *---------------------------------------------------------------------------
       
   643  */
       
   644 
       
   645 /*
       
   646  * The default platform eol translation on Unix is TCL_TRANSLATE_LF.
       
   647  */
       
   648 
       
   649 #ifdef DJGPP
       
   650 #define	TCL_PLATFORM_TRANSLATION	TCL_TRANSLATE_CRLF
       
   651 #else
       
   652 #define	TCL_PLATFORM_TRANSLATION	TCL_TRANSLATE_LF
       
   653 #endif
       
   654 
       
   655 /*
       
   656  * The following macros have trivial definitions, allowing generic code to 
       
   657  * address platform-specific issues.
       
   658  */
       
   659 
       
   660 #define TclpGetPid(pid)		((unsigned long) (pid))
       
   661 #define TclpReleaseFile(file)	/* Nothing. */
       
   662 
       
   663 /*
       
   664  * The following defines wrap the system memory allocation routines for
       
   665  * use by tclAlloc.c.  By default off unused on Unix.
       
   666  */
       
   667 
       
   668 #if USE_TCLALLOC
       
   669 #   define TclpSysAlloc(size, isBin)	malloc((size_t)size)
       
   670 #   define TclpSysFree(ptr)		free((char*)ptr)
       
   671 #   define TclpSysRealloc(ptr, size)	realloc((char*)ptr, (size_t)size)
       
   672 #endif
       
   673 
       
   674 /*
       
   675  * The following macros and declaration wrap the C runtime library
       
   676  * functions.
       
   677  */
       
   678 #if !defined(__SYMBIAN32__) || !defined(__WINSCW__)
       
   679 #define TclpExit		exit
       
   680 #endif
       
   681 /*
       
   682  * Platform specific mutex definition used by memory allocators.
       
   683  * These mutexes are statically allocated and explicitly initialized.
       
   684  * Most modules do not use this, but instead use Tcl_Mutex types and
       
   685  * Tcl_MutexLock and Tcl_MutexUnlock that are self-initializing.
       
   686  */
       
   687 
       
   688 #ifdef TCL_THREADS
       
   689 #include <pthread.h>
       
   690 typedef pthread_mutex_t TclpMutex;
       
   691 EXTERN void	TclpMutexInit _ANSI_ARGS_((TclpMutex *mPtr));
       
   692 EXTERN void	TclpMutexLock _ANSI_ARGS_((TclpMutex *mPtr));
       
   693 EXTERN void	TclpMutexUnlock _ANSI_ARGS_((TclpMutex *mPtr));
       
   694 EXTERN Tcl_DirEntry * 	TclpReaddir(DIR *);
       
   695 #ifndef TclpLocaltime
       
   696 EXTERN struct tm *     	TclpLocaltime(TclpTime_t_CONST);
       
   697 #endif
       
   698 #ifndef TclpGmtime
       
   699 EXTERN struct tm *     	TclpGmtime(TclpTime_t_CONST);
       
   700 #endif
       
   701 EXTERN char *          	TclpInetNtoa(struct in_addr);
       
   702 #define inet_ntoa(x)	TclpInetNtoa(x)
       
   703 #else
       
   704 typedef int TclpMutex;
       
   705 #define	TclpMutexInit(a)
       
   706 #define	TclpMutexLock(a)
       
   707 #define	TclpMutexUnlock(a)
       
   708 #endif /* TCL_THREADS */
       
   709 
       
   710 
       
   711 /*
       
   712  * Set of MT-safe implementations of some
       
   713  * known-to-be-MT-unsafe library calls.
       
   714  * Instead of returning pointers to the
       
   715  * static storage, those return pointers
       
   716  * to the TSD data. 
       
   717  */
       
   718 
       
   719 #include <pwd.h>
       
   720 #include <grp.h>
       
   721 
       
   722 EXTERN struct passwd*  TclpGetPwNam(const char *name);
       
   723 EXTERN struct group*   TclpGetGrNam(const char *name);
       
   724 EXTERN struct passwd*  TclpGetPwUid(uid_t uid);
       
   725 EXTERN struct group*   TclpGetGrGid(gid_t gid);
       
   726 EXTERN struct hostent* TclpGetHostByName(const char *name);
       
   727 EXTERN struct hostent* TclpGetHostByAddr(const char *addr, int length, int type);
       
   728 
       
   729 #include "tclPlatDecls.h"
       
   730 #include "tclIntPlatDecls.h"
       
   731 
       
   732 #endif /* _TCLUNIXPORT */