tclUnixPort.h
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:18k
源码类别:

通讯编程

开发平台:

Visual C++

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