tclUnixPort.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. /*
  2. * tclUnixPort.h --
  3. *
  4. * This header file handles porting issues that occur because of
  5. * differences between systems. It reads in UNIX-related header files and
  6. * sets up UNIX-related macros for Tcl's UNIX core. It should be the only
  7. * file that contains #ifdefs to handle different flavors of UNIX. This
  8. * file sets up the union of all UNIX-related things needed by any of the
  9. * Tcl core files. This file depends on configuration #defines such as
  10. * NO_DIRENT_H that are set up by the "configure" script.
  11. *
  12. * Much of the material in this file was originally contributed by Karl
  13. * Lehenbauer, Mark Diekhans and Peter da Silva.
  14. *
  15. * Copyright (c) 1991-1994 The Regents of the University of California.
  16. * Copyright (c) 1994-1997 Sun Microsystems, Inc.
  17. *
  18. * See the file "license.terms" for information on usage and redistribution of
  19. * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  20. */
  21. #ifndef _TCLUNIXPORT
  22. #define _TCLUNIXPORT
  23. /*
  24. *---------------------------------------------------------------------------
  25. * The following sets of #includes and #ifdefs are required to get Tcl to
  26. * compile under the various flavors of unix.
  27. *---------------------------------------------------------------------------
  28. */
  29. #include <errno.h>
  30. #include <fcntl.h>
  31. #ifdef HAVE_NET_ERRNO_H
  32. # include <net/errno.h>
  33. #endif
  34. #include <pwd.h>
  35. #include <signal.h>
  36. #ifdef HAVE_SYS_PARAM_H
  37. # include <sys/param.h>
  38. #endif
  39. #include <sys/types.h>
  40. #ifdef USE_DIRENT2_H
  41. # include "../compat/dirent2.h"
  42. #else
  43. #ifdef NO_DIRENT_H
  44. # include "../compat/dirent.h"
  45. #else
  46. # include <dirent.h>
  47. #endif
  48. #endif
  49. /*
  50. *---------------------------------------------------------------------------
  51. * Parameterize for 64-bit filesystem support.
  52. *---------------------------------------------------------------------------
  53. */
  54. #ifdef HAVE_STRUCT_DIRENT64
  55. typedef struct dirent64 Tcl_DirEntry;
  56. # define TclOSreaddir readdir64
  57. #else
  58. typedef struct dirent Tcl_DirEntry;
  59. # define TclOSreaddir readdir
  60. #endif
  61. #ifdef HAVE_DIR64
  62. typedef DIR64 TclDIR;
  63. # define TclOSopendir opendir64
  64. # define TclOSrewinddir rewinddir64
  65. # define TclOSclosedir closedir64
  66. #else
  67. typedef DIR TclDIR;
  68. # define TclOSopendir opendir
  69. # define TclOSrewinddir rewinddir
  70. # define TclOSclosedir closedir
  71. #endif
  72. #ifdef HAVE_TYPE_OFF64_T
  73. typedef off64_t Tcl_SeekOffset;
  74. # define TclOSseek lseek64
  75. # define TclOSopen open64
  76. #else
  77. typedef off_t Tcl_SeekOffset;
  78. # define TclOSseek lseek
  79. # define TclOSopen open
  80. #endif
  81. #ifdef __CYGWIN__
  82. #ifdef __cplusplus
  83. extern "C" {
  84. #endif
  85. /* Make some symbols available without including <windows.h> */
  86. # define DWORD unsigned int
  87. # define CP_UTF8 65001
  88. # define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004
  89. # define HANDLE void *
  90. # define HINSTANCE void *
  91. # define SOCKET unsigned int
  92. # define WSAEWOULDBLOCK 10035
  93. typedef unsigned short WCHAR;
  94. #ifdef __clang__
  95. #pragma clang diagnostic push
  96. #pragma clang diagnostic ignored "-Wignored-attributes"
  97. #endif
  98. __declspec(dllimport) extern __stdcall int GetModuleHandleExW(unsigned int, const void *, void *);
  99. __declspec(dllimport) extern __stdcall int GetModuleFileNameW(void *, const void *, int);
  100. __declspec(dllimport) extern __stdcall int WideCharToMultiByte(int, int, const void *, int,
  101. char *, int, const char *, void *);
  102. __declspec(dllimport) extern __stdcall int MultiByteToWideChar(int, int, const char *, int,
  103. WCHAR *, int);
  104. __declspec(dllimport) extern __stdcall void OutputDebugStringW(const WCHAR *);
  105. __declspec(dllimport) extern __stdcall int IsDebuggerPresent(void);
  106. __declspec(dllimport) extern __stdcall int GetLastError(void);
  107. __declspec(dllimport) extern __stdcall int GetFileAttributesW(const WCHAR *);
  108. __declspec(dllimport) extern __stdcall int SetFileAttributesW(const WCHAR *, int);
  109. __declspec(dllimport) extern int cygwin_conv_path(int, const void *, void *, int);
  110. #ifdef __clang__
  111. #pragma clang diagnostic pop
  112. #endif
  113. # define timezone _timezone
  114. extern int TclOSstat(const char *name, void *statBuf);
  115. extern int TclOSlstat(const char *name, void *statBuf);
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119. #elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__)
  120. # define TclOSstat(name, buf) stat64(name, (struct stat64 *)buf)
  121. # define TclOSlstat(name,buf) lstat64(name, (struct stat64 *)buf)
  122. #else
  123. # define TclOSstat(name, buf) stat(name, (struct stat *)buf)
  124. # define TclOSlstat(name, buf) lstat(name, (struct stat *)buf)
  125. #endif
  126. /*
  127. *---------------------------------------------------------------------------
  128. * Miscellaneous includes that might be missing.
  129. *---------------------------------------------------------------------------
  130. */
  131. #include <sys/file.h>
  132. #ifdef HAVE_SYS_SELECT_H
  133. # include <sys/select.h>
  134. #endif
  135. #include <sys/stat.h>
  136. #ifdef TIME_WITH_SYS_TIME
  137. # include <sys/time.h>
  138. # include <time.h>
  139. #else
  140. #ifdef HAVE_SYS_TIME_H
  141. # include <sys/time.h>
  142. #else
  143. # include <time.h>
  144. #endif
  145. #endif
  146. #ifndef NO_SYS_WAIT_H
  147. # include <sys/wait.h>
  148. #endif
  149. #ifdef HAVE_INTTYPES_H
  150. # include <inttypes.h>
  151. #endif
  152. #include <limits.h>
  153. #ifdef HAVE_STDINT_H
  154. # include <stdint.h>
  155. #endif
  156. #ifdef HAVE_UNISTD_H
  157. # include <unistd.h>
  158. #else
  159. # include "../compat/unistd.h"
  160. #endif
  161. extern int TclUnixSetBlockingMode(int fd, int mode);
  162. #include <utime.h>
  163. /*
  164. *---------------------------------------------------------------------------
  165. * Socket support stuff: This likely needs more work to parameterize for each
  166. * system.
  167. *---------------------------------------------------------------------------
  168. */
  169. #include <sys/socket.h> /* struct sockaddr, SOCK_STREAM, ... */
  170. #ifndef NO_UNAME
  171. # include <sys/utsname.h> /* uname system call. */
  172. #endif
  173. #include <netinet/in.h> /* struct in_addr, struct sockaddr_in */
  174. #include <arpa/inet.h> /* inet_ntoa() */
  175. #include <netdb.h> /* getaddrinfo() */
  176. #ifdef NEED_FAKE_RFC2553
  177. # include "../compat/fake-rfc2553.h"
  178. #endif
  179. /*
  180. *---------------------------------------------------------------------------
  181. * Some platforms (e.g. SunOS) don't define FLT_MAX and FLT_MIN, so we look
  182. * for an alternative definition. If no other alternative is available we use
  183. * a reasonable guess.
  184. *---------------------------------------------------------------------------
  185. */
  186. #ifndef NO_FLOAT_H
  187. # include <float.h>
  188. #else
  189. #ifndef NO_VALUES_H
  190. # include <values.h>
  191. #endif
  192. #endif
  193. #ifndef FLT_MAX
  194. # ifdef MAXFLOAT
  195. # define FLT_MAX MAXFLOAT
  196. # else
  197. # define FLT_MAX 3.402823466E+38F
  198. # endif
  199. #endif
  200. #ifndef FLT_MIN
  201. # ifdef MINFLOAT
  202. # define FLT_MIN MINFLOAT
  203. # else
  204. # define FLT_MIN 1.175494351E-38F
  205. # endif
  206. #endif
  207. /*
  208. *---------------------------------------------------------------------------
  209. * NeXT doesn't define O_NONBLOCK, so #define it here if necessary.
  210. *---------------------------------------------------------------------------
  211. */
  212. #ifndef O_NONBLOCK
  213. # define O_NONBLOCK 0x80
  214. #endif
  215. /*
  216. *---------------------------------------------------------------------------
  217. * The type of the status returned by wait varies from UNIX system to UNIX
  218. * 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 defined
  233. * in header files above.
  234. *---------------------------------------------------------------------------
  235. */
  236. #ifndef WIFEXITED
  237. # define WIFEXITED(stat) (((*((int *) &(stat))) & 0xFF) == 0)
  238. #endif
  239. #ifndef WEXITSTATUS
  240. # define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xFF)
  241. #endif
  242. #ifndef WIFSIGNALED
  243. # define WIFSIGNALED(stat) \
  244. (((*((int *) &(stat)))) && ((*((int *) &(stat))) \
  245. == ((*((int *) &(stat))) & 0x00FF)))
  246. #endif
  247. #ifndef WTERMSIG
  248. # define WTERMSIG(stat) ((*((int *) &(stat))) & 0x7F)
  249. #endif
  250. #ifndef WIFSTOPPED
  251. # define WIFSTOPPED(stat) (((*((int *) &(stat))) & 0xFF) == 0177)
  252. #endif
  253. #ifndef WSTOPSIG
  254. # define WSTOPSIG(stat) (((*((int *) &(stat))) >> 8) & 0xFF)
  255. #endif
  256. /*
  257. *---------------------------------------------------------------------------
  258. * Define constants for waitpid() system call if they aren't defined by a
  259. * system header file.
  260. *---------------------------------------------------------------------------
  261. */
  262. #ifndef WNOHANG
  263. # define WNOHANG 1
  264. #endif
  265. #ifndef WUNTRACED
  266. # define WUNTRACED 2
  267. #endif
  268. /*
  269. *---------------------------------------------------------------------------
  270. * Supply macros for seek offsets, if they're not already provided by an
  271. * include file.
  272. *---------------------------------------------------------------------------
  273. */
  274. #ifndef SEEK_SET
  275. # define SEEK_SET 0
  276. #endif
  277. #ifndef SEEK_CUR
  278. # define SEEK_CUR 1
  279. #endif
  280. #ifndef SEEK_END
  281. # define SEEK_END 2
  282. #endif
  283. /*
  284. *---------------------------------------------------------------------------
  285. * The stuff below is needed by the "time" command. If this system has no
  286. * gettimeofday call, then must use times() instead.
  287. *---------------------------------------------------------------------------
  288. */
  289. #ifdef NO_GETTOD
  290. # include <sys/times.h>
  291. #else
  292. # ifdef HAVE_BSDGETTIMEOFDAY
  293. # define gettimeofday BSDgettimeofday
  294. # endif
  295. #endif
  296. #ifdef GETTOD_NOT_DECLARED
  297. extern int gettimeofday(struct timeval *tp,
  298. struct timezone *tzp);
  299. #endif
  300. /*
  301. *---------------------------------------------------------------------------
  302. * Define access mode constants if they aren't already defined.
  303. *---------------------------------------------------------------------------
  304. */
  305. #ifndef F_OK
  306. # define F_OK 00
  307. #endif
  308. #ifndef X_OK
  309. # define X_OK 01
  310. #endif
  311. #ifndef W_OK
  312. # define W_OK 02
  313. #endif
  314. #ifndef R_OK
  315. # define R_OK 04
  316. #endif
  317. /*
  318. *---------------------------------------------------------------------------
  319. * Define FD_CLOEEXEC (the close-on-exec flag bit) if it isn't already
  320. * defined.
  321. *---------------------------------------------------------------------------
  322. */
  323. #ifndef FD_CLOEXEC
  324. # define FD_CLOEXEC 1
  325. #endif
  326. /*
  327. *---------------------------------------------------------------------------
  328. * On systems without symbolic links (i.e. S_IFLNK isn't defined) define
  329. * "lstat" to use "stat" instead.
  330. *---------------------------------------------------------------------------
  331. */
  332. #ifndef S_IFLNK
  333. # undef TclOSlstat
  334. # define lstat stat
  335. # define lstat64 stat64
  336. # define TclOSlstat TclOSstat
  337. #endif
  338. /*
  339. *---------------------------------------------------------------------------
  340. * Define macros to query file type bits, if they're not already defined.
  341. *---------------------------------------------------------------------------
  342. */
  343. #ifndef S_ISREG
  344. # ifdef S_IFREG
  345. # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  346. # else
  347. # define S_ISREG(m) 0
  348. # endif
  349. #endif /* !S_ISREG */
  350. #ifndef S_ISDIR
  351. # ifdef S_IFDIR
  352. # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  353. # else
  354. # define S_ISDIR(m) 0
  355. # endif
  356. #endif /* !S_ISDIR */
  357. #ifndef S_ISCHR
  358. # ifdef S_IFCHR
  359. # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  360. # else
  361. # define S_ISCHR(m) 0
  362. # endif
  363. #endif /* !S_ISCHR */
  364. #ifndef S_ISBLK
  365. # ifdef S_IFBLK
  366. # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  367. # else
  368. # define S_ISBLK(m) 0
  369. # endif
  370. #endif /* !S_ISBLK */
  371. #ifndef S_ISFIFO
  372. # ifdef S_IFIFO
  373. # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  374. # else
  375. # define S_ISFIFO(m) 0
  376. # endif
  377. #endif /* !S_ISFIFO */
  378. #ifndef S_ISLNK
  379. # ifdef S_IFLNK
  380. # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  381. # else
  382. # define S_ISLNK(m) 0
  383. # endif
  384. #endif /* !S_ISLNK */
  385. #ifndef S_ISSOCK
  386. # ifdef S_IFSOCK
  387. # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  388. # else
  389. # define S_ISSOCK(m) 0
  390. # endif
  391. #endif /* !S_ISSOCK */
  392. /*
  393. *---------------------------------------------------------------------------
  394. * Make sure that MAXPATHLEN and MAXNAMLEN are defined.
  395. *---------------------------------------------------------------------------
  396. */
  397. #ifndef MAXPATHLEN
  398. # ifdef PATH_MAX
  399. # define MAXPATHLEN PATH_MAX
  400. # else
  401. # define MAXPATHLEN 2048
  402. # endif
  403. #endif
  404. #ifndef MAXNAMLEN
  405. # ifdef NAME_MAX
  406. # define MAXNAMLEN NAME_MAX
  407. # else
  408. # define MAXNAMLEN 255
  409. # endif
  410. #endif
  411. /*
  412. *---------------------------------------------------------------------------
  413. * The following macro defines the type of the mask arguments to select:
  414. *---------------------------------------------------------------------------
  415. */
  416. #ifndef NO_FD_SET
  417. # define SELECT_MASK fd_set
  418. #else /* NO_FD_SET */
  419. # ifndef _AIX
  420. typedef long fd_mask;
  421. # endif /* !AIX */
  422. # if defined(_IBMR2)
  423. # define SELECT_MASK void
  424. # else /* !defined(_IBMR2) */
  425. # define SELECT_MASK int
  426. # endif /* defined(_IBMR2) */
  427. #endif /* !NO_FD_SET */
  428. /*
  429. *---------------------------------------------------------------------------
  430. * Define "NBBY" (number of bits per byte) if it's not already defined.
  431. *---------------------------------------------------------------------------
  432. */
  433. #ifndef NBBY
  434. # define NBBY 8
  435. #endif
  436. /*
  437. *---------------------------------------------------------------------------
  438. * The following macro defines the number of fd_masks in an fd_set:
  439. *---------------------------------------------------------------------------
  440. */
  441. #ifndef FD_SETSIZE
  442. # ifdef OPEN_MAX
  443. # define FD_SETSIZE OPEN_MAX
  444. # else
  445. # define FD_SETSIZE 256
  446. # endif
  447. #endif /* FD_SETSIZE */
  448. #ifndef howmany
  449. # define howmany(x, y) (((x)+((y)-1))/(y))
  450. #endif /* !defined(howmany) */
  451. #ifndef NFDBITS
  452. # define NFDBITS NBBY*sizeof(fd_mask)
  453. #endif /* NFDBITS */
  454. #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
  455. /*
  456. *---------------------------------------------------------------------------
  457. * Not all systems declare the errno variable in errno.h. so this file does it
  458. * explicitly. The list of system error messages also isn't generally declared
  459. * in a header file anywhere.
  460. *---------------------------------------------------------------------------
  461. */
  462. #ifdef NO_ERRNO
  463. extern int errno;
  464. #endif /* NO_ERRNO */
  465. /*
  466. *---------------------------------------------------------------------------
  467. * Not all systems declare all the errors that Tcl uses! Provide some
  468. * work-arounds...
  469. *---------------------------------------------------------------------------
  470. */
  471. #ifndef EOVERFLOW
  472. # ifdef EFBIG
  473. # define EOVERFLOW EFBIG
  474. # else /* !EFBIG */
  475. # define EOVERFLOW EINVAL
  476. # endif /* EFBIG */
  477. #endif /* EOVERFLOW */
  478. /*
  479. *---------------------------------------------------------------------------
  480. * Variables provided by the C library:
  481. *---------------------------------------------------------------------------
  482. */
  483. #if defined(__APPLE__) && defined(__DYNAMIC__)
  484. # include <crt_externs.h>
  485. # define environ (*_NSGetEnviron())
  486. # define USE_PUTENV 1
  487. #else
  488. # if defined(_sgi) || defined(__sgi)
  489. # define environ _environ
  490. # endif
  491. extern char ** environ;
  492. #endif
  493. /*
  494. *---------------------------------------------------------------------------
  495. * Darwin specifc configure overrides.
  496. *---------------------------------------------------------------------------
  497. */
  498. #ifdef __APPLE__
  499. /*
  500. *---------------------------------------------------------------------------
  501. * Support for fat compiles: configure runs only once for multiple architectures
  502. *---------------------------------------------------------------------------
  503. */
  504. # if defined(__LP64__) && defined (NO_COREFOUNDATION_64)
  505. # undef HAVE_COREFOUNDATION
  506. # endif /* __LP64__ && NO_COREFOUNDATION_64 */
  507. # include <sys/cdefs.h>
  508. # ifdef __DARWIN_UNIX03
  509. # if __DARWIN_UNIX03
  510. # undef HAVE_PUTENV_THAT_COPIES
  511. # else
  512. # define HAVE_PUTENV_THAT_COPIES 1
  513. # endif
  514. # endif /* __DARWIN_UNIX03 */
  515. /*
  516. *---------------------------------------------------------------------------
  517. * Include AvailabilityMacros.h here (when available) to ensure any symbolic
  518. * MAC_OS_X_VERSION_* constants passed on the command line are translated.
  519. *---------------------------------------------------------------------------
  520. */
  521. # ifdef HAVE_AVAILABILITYMACROS_H
  522. # include <AvailabilityMacros.h>
  523. # endif
  524. /*
  525. *---------------------------------------------------------------------------
  526. * Support for weak import.
  527. *---------------------------------------------------------------------------
  528. */
  529. # ifdef HAVE_WEAK_IMPORT
  530. # if !defined(HAVE_AVAILABILITYMACROS_H) || !defined(MAC_OS_X_VERSION_MIN_REQUIRED)
  531. # undef HAVE_WEAK_IMPORT
  532. # else
  533. # ifndef WEAK_IMPORT_ATTRIBUTE
  534. # define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import))
  535. # endif
  536. # endif
  537. # endif /* HAVE_WEAK_IMPORT */
  538. /*
  539. *---------------------------------------------------------------------------
  540. * Support for MAC_OS_X_VERSION_MAX_ALLOWED define from AvailabilityMacros.h:
  541. * only use API available in the indicated OS version or earlier.
  542. *---------------------------------------------------------------------------
  543. */
  544. # ifdef MAC_OS_X_VERSION_MAX_ALLOWED
  545. # if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 && defined(__LP64__)
  546. # undef HAVE_COREFOUNDATION
  547. # endif
  548. # if MAC_OS_X_VERSION_MAX_ALLOWED < 1040
  549. # undef HAVE_OSSPINLOCKLOCK
  550. # undef HAVE_PTHREAD_ATFORK
  551. # undef HAVE_COPYFILE
  552. # endif
  553. # if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
  554. # ifdef TCL_THREADS
  555. /* prior to 10.3, realpath is not threadsafe, c.f. bug 711232 */
  556. # define NO_REALPATH 1
  557. # endif
  558. # undef HAVE_LANGINFO
  559. # endif
  560. # endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
  561. # if defined(HAVE_COREFOUNDATION) && defined(__LP64__) && \
  562. defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1050
  563. # warning "Weak import of 64-bit CoreFoundation is not supported, will not run on Mac OS X < 10.5."
  564. # endif
  565. /*
  566. *---------------------------------------------------------------------------
  567. * At present, using vfork() instead of fork() causes execve() to fail
  568. * intermittently on Darwin x86_64. rdar://4685553
  569. *---------------------------------------------------------------------------
  570. */
  571. # if defined(__x86_64__) && !defined(FIXED_RDAR_4685553)
  572. # undef USE_VFORK
  573. # endif /* __x86_64__ */
  574. /* Workaround problems with vfork() when building with llvm-gcc-4.2 */
  575. # if defined (__llvm__) && \
  576. (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 2 || \
  577. (__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ > 0))))
  578. # undef USE_VFORK
  579. # endif /* __llvm__ */
  580. #endif /* __APPLE__ */
  581. /*
  582. *---------------------------------------------------------------------------
  583. * The following macros and declarations represent the interface between
  584. * generic and unix-specific parts of Tcl. Some of the macros may override
  585. * functions declared in tclInt.h.
  586. *---------------------------------------------------------------------------
  587. */
  588. /*
  589. * The default platform eol translation on Unix is TCL_TRANSLATE_LF.
  590. */
  591. #ifdef DJGPP
  592. #define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_CRLF
  593. typedef int socklen_t;
  594. #else
  595. #define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_LF
  596. #endif
  597. /*
  598. *---------------------------------------------------------------------------
  599. * The following macros have trivial definitions, allowing generic code to
  600. * address platform-specific issues.
  601. *---------------------------------------------------------------------------
  602. */
  603. #define TclpReleaseFile(file) /* Nothing. */
  604. /*
  605. *---------------------------------------------------------------------------
  606. * The following defines wrap the system memory allocation routines.
  607. *---------------------------------------------------------------------------
  608. */
  609. #define TclpSysAlloc(size, isBin) malloc((size_t)(size))
  610. #define TclpSysFree(ptr) free((char *)(ptr))
  611. #define TclpSysRealloc(ptr, size) realloc((char *)(ptr), (size_t)(size))
  612. /*
  613. *---------------------------------------------------------------------------
  614. * The following macros and declaration wrap the C runtime library functions.
  615. *---------------------------------------------------------------------------
  616. */
  617. #define TclpExit exit
  618. #ifdef TCL_THREADS
  619. # include <pthread.h>
  620. #endif /* TCL_THREADS */
  621. /* FIXME - Hyper-enormous platform assumption! */
  622. #ifndef AF_INET6
  623. # define AF_INET6 10
  624. #endif
  625. /*
  626. *---------------------------------------------------------------------------
  627. * Set of MT-safe implementations of some known-to-be-MT-unsafe library calls.
  628. * Instead of returning pointers to the static storage, those return pointers
  629. * to the TSD data.
  630. *---------------------------------------------------------------------------
  631. */
  632. #include <pwd.h>
  633. #include <grp.h>
  634. extern struct passwd * TclpGetPwNam(const char *name);
  635. extern struct group * TclpGetGrNam(const char *name);
  636. extern struct passwd * TclpGetPwUid(uid_t uid);
  637. extern struct group * TclpGetGrGid(gid_t gid);
  638. extern struct hostent * TclpGetHostByName(const char *name);
  639. extern struct hostent * TclpGetHostByAddr(const char *addr,
  640. int length, int type);
  641. extern void *TclpMakeTcpClientChannelMode(
  642. void *tcpSocket, int mode);
  643. #endif /* _TCLUNIXPORT */
  644. /*
  645. * Local Variables:
  646. * mode: c
  647. * c-basic-offset: 4
  648. * fill-column: 78
  649. * End:
  650. */