home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / ux.h < prev    next >
C/C++ Source or Header  |  2000-12-05  |  19KB  |  849 lines

  1. /* -*-C-*-
  2.  
  3. $Id: ux.h,v 1.74 2000/12/05 21:23:48 cph Exp $
  4.  
  5. Copyright (c) 1988-2000 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. /* Unix system include file */
  23.  
  24. #ifndef SCM_UX_H
  25. #define SCM_UX_H
  26.  
  27. #define SYSTEM_NAME "unix"
  28.  
  29. #ifdef __386BSD__
  30. #  define SYSTEM_VARIANT "386BSD"
  31. #endif
  32.  
  33. #ifdef _AIX
  34. #  define SYSTEM_VARIANT "AIX"
  35. #endif
  36.  
  37. #ifdef apollo
  38. #  define SYSTEM_VARIANT "Domain"
  39. #endif
  40.  
  41. #ifdef __bsdi__            /* works on bsdi 3.0 */
  42. #  define SYSTEM_VARIANT "BSDI BSD/OS"
  43. #endif
  44.  
  45. #ifdef __FreeBSD__
  46. #  define SYSTEM_VARIANT "FreeBSD"
  47. #endif
  48.  
  49. #if defined(__hpux) || defined(hpux)
  50. #  define SYSTEM_VARIANT "HP/UX"
  51. #endif
  52.  
  53. #if defined(_IRIX) || defined(_IRIX4) || defined(_IRIX6)
  54. #  define SYSTEM_VARIANT "Irix"
  55. #endif
  56.  
  57. #ifdef __linux__
  58. #  define SYSTEM_VARIANT "GNU/Linux"
  59. #endif
  60.  
  61. #ifdef _NEXTOS
  62. #  define SYSTEM_VARIANT "NeXT"
  63. #endif
  64.  
  65. #ifdef __osf__
  66. #  define SYSTEM_VARIANT "OSF"
  67. #endif
  68.  
  69. #ifdef _PIXEL
  70. #  define SYSTEM_VARIANT "Pixel"
  71. #endif
  72.  
  73. #if defined(_SUNOS) || defined(_SUNOS3) || defined(_SUNOS4)
  74. #  define SYSTEM_VARIANT "SunOS"
  75. #endif
  76.  
  77. #ifdef _ULTRIX
  78. #  define SYSTEM_VARIANT "Ultrix"
  79. #endif
  80.  
  81. #ifndef SYSTEM_VARIANT
  82. #  define SYSTEM_VARIANT "unknown"
  83. #endif
  84.  
  85. #include "config.h"
  86.  
  87. #include <errno.h>
  88. #include <grp.h>
  89. #include <pwd.h>
  90. #include <signal.h>
  91. #include <stdio.h>
  92. #include <sys/param.h>
  93. #include <sys/stat.h>
  94. #include <sys/times.h>
  95. #include <sys/types.h>
  96.  
  97. #ifdef HAVE_UNISTD_H
  98. #  include <unistd.h>
  99. #endif
  100.  
  101. /* GNU C library defines environ if __USE_GNU is defined.  */
  102. #ifndef __USE_GNU
  103.   extern char ** environ;
  104. #endif
  105.  
  106. #ifdef STDC_HEADERS
  107. #  include <stdlib.h>
  108. #  include <string.h>
  109. #else
  110. #  ifndef HAVE_STRCHR
  111. #    define strchr index
  112. #    define strrchr rindex
  113. #  endif
  114.    extern char * strchr ();
  115.    extern char * strrchr ();
  116. #  ifndef HAVE_MEMCPY
  117. #    define memcpy(d, s, n) bcopy ((s), (d), (n))
  118. #    define memmove(d, s, n) bcopy ((s), (d), (n))
  119. #  endif
  120. #endif
  121.  
  122. #ifdef HAVE_SYS_FILE_H
  123. #  include <sys/file.h>
  124. #endif
  125.  
  126. #ifdef HAVE_SYS_IOCTL_H
  127. #  include <sys/ioctl.h>
  128. #else
  129.    extern int EXFUN (ioctl, (int, unsigned long, ...));
  130. #endif
  131.  
  132. #ifdef HAVE_FCNTL_H
  133. #  include <fcntl.h>
  134. #else
  135.    extern int EXFUN (open, (CONST char *, int, ...));
  136. #endif
  137.  
  138. #ifdef HAVE_LIMITS_H
  139. #  include <limits.h>
  140. #endif
  141.  
  142. #ifdef HAVE_SYS_WAIT_H
  143. #  include <sys/wait.h>
  144. #else
  145. #  ifndef WIFEXITED
  146. #    define WIFEXITED(_X) (((_X) & 0x00FF) == 0)
  147. #  endif
  148. #  ifndef WIFSTOPPED
  149. #    define WIFSTOPPED(_X) (((_X) & 0x00FF) == 0x007F)
  150. #  endif
  151. #  ifndef WIFSIGNALED
  152. #    define WIFSIGNALED(_X)                        \
  153.        ((((_X) & 0x00FF) != 0) && (((_X) & 0x00FF) != 0x007F))
  154. #  endif
  155. #  ifndef WEXITSTATUS
  156. #    define WEXITSTATUS(_X) (((_X) & 0xFF00) >> 8)
  157. #  endif
  158. #  ifndef WTERMSIG
  159. #    define WTERMSIG(_X) ((_X) & 0x007F)
  160. #  endif
  161. #  ifndef WSTOPSIG
  162. #    define WSTOPSIG(_X) (((_X) & 0xFF00) >> 8)
  163. #  endif
  164.    extern pid_t EXFUN (wait, (int *));
  165. #  ifdef HAVE_WAITPID
  166.      extern pid_t EXFUN (waitpid, (pid_t, int *, int));
  167. #  endif
  168. #  ifdef HAVE_WAIT3
  169.      extern pid_t EXFUN (wait3, (int *, int, struct rusage *));
  170. #  endif
  171. #endif
  172.  
  173. #ifndef WUNTRACED
  174. #  define WUNTRACED 0
  175. #endif
  176.  
  177. #ifdef HAVE_DIRENT_H
  178. #  include <dirent.h>
  179. #  define NAMLEN(_D) (strlen ((_D) -> d_name))
  180. #else
  181. #  define dirent direct
  182. #  define NAMLEN(_D) (strlen ((_D) -> d_namlen))
  183. #  ifdef HAVE_SYS_NDIR_H
  184. #    include <sys/ndir.h>
  185. #  endif
  186. #  ifdef HAVE_SYS_DIR_H
  187. #    include <sys/dir.h>
  188. #  endif
  189. #  ifdef HAVE_NDIR_H
  190. #    include <ndir.h>
  191. #  endif
  192. #endif
  193.  
  194. #ifdef TIME_WITH_SYS_TIME
  195. #  include <sys/time.h>
  196. #  include <time.h>
  197. #else
  198. #  ifdef HAVE_SYS_TIME_H
  199. #    include <sys/time.h>
  200. #  else
  201. #    include <time.h>
  202. #  endif
  203. #endif
  204.  
  205. #ifdef HAVE_UTIME_H
  206. #  include <utime.h>
  207. #else
  208.    /* It's really there. */
  209.    struct utimbuf
  210.    {
  211.      time_t actime;
  212.      time_t modtime;
  213.    };
  214.    extern int EXFUN (utime, (CONST char *, struct utimbuf *)); 
  215. #endif
  216.  
  217. #ifdef HAVE_TERMIOS_H
  218. #  include <termios.h>
  219. #else
  220. #  ifdef HAVE_TERMIO_H
  221. #    include <termio.h>
  222. #  else
  223. #    ifdef HAVE_SGTTY_H
  224. #      include <sgtty.h>
  225. #    endif
  226. #  endif
  227. #endif
  228.  
  229. #ifdef HAVE_SYS_POLL_H
  230. #  include <sys/poll.h>
  231. #endif
  232.  
  233. #if defined(HAVE_SOCKET) && defined(HAVE_GETHOSTBYNAME) && defined(HAVE_GETHOSTNAME)
  234. #  define HAVE_SOCKETS
  235. #  include <sys/socket.h>
  236. #  include <netinet/in.h>
  237. #  include <netdb.h>
  238. #  ifdef HAVE_SYS_UN_H
  239. #    include <sys/un.h>
  240. #    ifdef AF_UNIX
  241. #      define HAVE_UNIX_SOCKETS
  242. #    endif
  243. #  endif
  244. #endif
  245.  
  246. #ifdef HAVE_SYS_PTYIO_H
  247. #include <sys/ptyio.h>
  248. #endif
  249.  
  250. #ifdef HAVE_BSDTTY_H
  251. #include <bsdtty.h>
  252. #endif
  253.  
  254. #ifdef HAVE_STROPTS_H
  255. #include <stropts.h>
  256. #endif
  257.  
  258. #include "intext.h"
  259. #include "dstack.h"
  260. #include "osscheme.h"
  261. #include "syscall.h"
  262.  
  263. typedef RETSIGTYPE Tsignal_handler_result;
  264. typedef RETSIGTYPE (*Tsignal_handler) ();
  265.  
  266. #ifdef VOID_SIGNAL_HANDLERS
  267. #  define SIGNAL_HANDLER_RETURN() return
  268. #else
  269. #  define SIGNAL_HANDLER_RETURN() return (0)
  270. #endif
  271.  
  272. /* Crufty, but it will work here. */
  273. #ifndef ENOSYS
  274. #  define ENOSYS 0
  275. #endif
  276.  
  277. #ifndef SIG_ERR
  278. #  define SIG_ERR ((Tsignal_handler) (-1))
  279. #endif
  280.  
  281. #if !defined(SIGCHLD) && defined(SIGCLD)
  282. #  define SIGCHLD SIGCLD
  283. #endif
  284. #if !defined(SIGABRT) && defined(SIGIOT)
  285. #  define SIGABRT SIGIOT
  286. #endif
  287.  
  288. /* Provide null defaults for all the signals we're likely to use so we
  289.    aren't continually testing to see if they're defined. */
  290.  
  291. #ifndef SIGLOST
  292. #  define SIGLOST 0
  293. #endif
  294. #ifndef SIGWINCH
  295. #  define SIGWINCH 0
  296. #endif
  297. #ifndef SIGWINDOW
  298. #  define SIGWINDOW 0
  299. #endif
  300. #ifndef SIGXCPU
  301. #  define SIGXCPU 0
  302. #endif
  303. #ifndef SIGXFSZ
  304. #  define SIGXFSZ 0
  305. #endif
  306. #ifndef SIGURG
  307. #  define SIGURG 0
  308. #endif
  309. #ifndef SIGIO
  310. #  define SIGIO 0
  311. #endif
  312. #ifndef SIGUSR1
  313. #  define SIGUSR1 0
  314. #endif
  315. #ifndef SIGUSR2
  316. #  define SIGUSR2 0
  317. #endif
  318. #ifndef SIGVTALRM
  319. #  define SIGVTALRM 0
  320. #endif
  321. #ifndef SIGABRT
  322. #  define SIGABRT 0
  323. #endif
  324. #ifndef SIGPWR
  325. #  define SIGPWR 0
  326. #endif
  327. #ifndef SIGPROF
  328. #  define SIGPROF 0
  329. #endif
  330. #ifndef SIGSTOP
  331. #  define SIGSTOP 0
  332. #endif
  333. #ifndef SIGTSTP
  334. #  define SIGTSTP 0
  335. #endif
  336. #ifndef SIGCONT
  337. #  define SIGCONT 0
  338. #endif
  339. #ifndef SIGCHLD
  340. #  define SIGCHLD 0
  341. #endif
  342. #ifndef SIGTTIN
  343. #  define SIGTTIN 0
  344. #endif
  345. #ifndef SIGTTOU
  346. #  define SIGTTOU 0
  347. #endif
  348. #ifndef SIGBUS
  349. #  define SIGBUS 0
  350. #endif
  351. #ifndef SIGEMT
  352. #  define SIGEMT 0
  353. #endif
  354. #ifndef SIGSYS
  355. #  define SIGSYS 0
  356. #endif
  357.  
  358. /* constants for access() */
  359. #ifndef R_OK
  360. #  define R_OK 4
  361. #  define W_OK 2
  362. #  define X_OK 1
  363. #  define F_OK 0
  364. #endif
  365.  
  366. #ifndef MAXPATHLEN
  367. #  define MAXPATHLEN 1024
  368. #endif
  369.  
  370. #ifdef HAVE_STDC
  371. #  define ALERT_CHAR '\a'
  372. #  define ALERT_STRING "\a"
  373. #else
  374. #  define ALERT_CHAR '\007'
  375. #  define ALERT_STRING "\007"
  376. #endif
  377.  
  378. #ifndef STDIN_FILENO
  379. #  define STDIN_FILENO 0
  380. #  define STDOUT_FILENO 1
  381. #  define STDERR_FILENO 2
  382. #endif
  383.  
  384. /* constants for open() and fcntl() */
  385. #ifndef O_RDONLY
  386. #  define O_RDONLY 0
  387. #  define O_WRONLY 1
  388. #  define O_RDWR 2
  389. #endif
  390.  
  391. /* mode bit definitions for open(), creat(), and chmod() */
  392. #ifndef S_IRWXU
  393. #  define S_IRWXU 0700
  394. #  define S_IRWXG 0070
  395. #  define S_IRWXO 0007
  396. #endif
  397.  
  398. #ifndef S_IRUSR
  399. #  define S_IRUSR 0400
  400. #  define S_IWUSR 0200
  401. #  define S_IXUSR 0100
  402. #  define S_IRGRP 0040
  403. #  define S_IWGRP 0020
  404. #  define S_IXGRP 0010
  405. #  define S_IROTH 0004
  406. #  define S_IWOTH 0002
  407. #  define S_IXOTH 0001
  408. #endif
  409.  
  410. #define MODE_REG (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
  411. #define MODE_DIR (MODE_REG | S_IXUSR | S_IXGRP | S_IXOTH)
  412.  
  413. /* constants for lseek() */
  414. #ifndef SEEK_SET
  415. #  define SEEK_SET 0
  416. #  define SEEK_CUR 1
  417. #  define SEEK_END 2
  418. #endif
  419.  
  420. #ifdef HAVE_GETLOGIN
  421. #  ifndef HAVE_UNISTD_H
  422.      extern char * EXFUN (getlogin, (void));
  423. #  endif
  424. #endif
  425.  
  426. #ifndef STDC_HEADERS
  427. #  ifndef HAVE_MALLOC_H
  428.      extern PTR EXFUN (malloc, (size_t));
  429.      extern PTR EXFUN (realloc, (PTR, size_t));
  430. #  endif
  431.    extern char * EXFUN (getenv, (CONST char *));
  432. #endif
  433.  
  434. #define UX_abort abort
  435. #define UX_accept accept
  436. #define UX_access access
  437. #define UX_alarm alarm
  438. #define UX_bind bind
  439. #define UX_chdir chdir
  440. #define UX_chmod chmod
  441. #define UX_close close
  442. #define UX_connect connect
  443. #define UX_ctime ctime
  444. #define UX_dup dup
  445. #define UX_fcntl fcntl
  446. #define UX_free free
  447. #define UX_fstat fstat
  448. #define UX_fstatfs fstatfs
  449. #define UX_ftruncate ftruncate
  450. #define UX_getegid getegid
  451. #define UX_getenv getenv
  452. #define UX_geteuid geteuid
  453. #define UX_getgid getgid
  454. #define UX_getgrgid getgrgid
  455. #define UX_gethostbyname gethostbyname
  456. #define UX_gethostname gethostname
  457. #define UX_getlogin getlogin
  458. #define UX_getpid getpid
  459. #define UX_getpwnam getpwnam
  460. #define UX_getpwuid getpwuid
  461. #define UX_getservbyname getservbyname
  462. #define UX_gettimeofday gettimeofday
  463. #define UX_getuid getuid
  464. #define UX_gmtime gmtime
  465. #define UX_ioctl ioctl
  466. #define UX_link link
  467. #define UX_listen listen
  468. #define UX_localtime localtime
  469. #define UX_lseek lseek
  470. #define UX_malloc malloc
  471. #define UX_mknod mknod
  472. #define UX_mktime mktime
  473. #define UX_open open
  474. #define UX_pause pause
  475. #define UX_pipe pipe
  476. #define UX_read read
  477. #define UX_readlink readlink
  478. #define UX_realloc realloc
  479. #define UX_rmdir rmdir
  480. #define UX_select select
  481. #define UX_setitimer setitimer
  482. #define UX_signal signal
  483. #define UX_sleep sleep
  484. #define UX_socket socket
  485. #define UX_stat stat
  486. #define UX_statfs statfs
  487. #define UX_symlink symlink
  488. #define UX_system system
  489. #define UX_time time
  490. #define UX_times times
  491. #define UX_truncate truncate
  492. #define UX_unlink unlink
  493. #define UX_utime utime
  494. #define UX_vfork vfork
  495. #define UX_wait wait
  496. #define UX_write write
  497.  
  498. #ifdef HAVE_SYMLINK
  499. #define UX_lstat lstat
  500. #else
  501. #define UX_lstat stat
  502. #endif
  503.  
  504. #ifdef HAVE_DUP2
  505. #  define UX_dup2 dup2
  506. #else
  507. #  ifdef HAVE_FCNTL
  508.    extern int EXFUN (UX_dup2, (int, int));
  509. #  define EMULATE_DUP2
  510. #  define HAVE_DUP2
  511. #  endif
  512. #endif
  513.  
  514. #ifdef HAVE_GETCWD
  515. #  define UX_getcwd getcwd
  516. #else
  517.    extern char * EXFUN (UX_getcwd, (char *, size_t));
  518. #  define EMULATE_GETCWD
  519. #  define HAVE_GETCWD
  520. #endif
  521.  
  522. #ifdef HAVE_MKDIR
  523. #  define UX_mkdir mkdir
  524. #else
  525.    extern int EXFUN (UX_mkdir, (CONST char *, mode_t));
  526. #  define EMULATE_MKDIR
  527. #  define HAVE_MKDIR
  528. #endif
  529.  
  530. #ifdef HAVE_RENAME
  531. #  define UX_rename rename
  532. #else
  533.    extern int EXFUN (UX_rename, (CONST char *, CONST char *));
  534. #  define EMULATE_RENAME
  535. #  define HAVE_RENAME
  536. #endif
  537.  
  538. #ifdef HAVE_WAITPID
  539. #  define UX_waitpid waitpid
  540. #else
  541. #  ifdef HAVE_WAIT3
  542.    extern int EXFUN (UX_waitpid, (pid_t, int *, int));
  543. #  define EMULATE_WAITPID
  544. #  define HAVE_WAITPID
  545. #  endif
  546. #endif
  547.  
  548. #ifdef HAVE_CTERMID
  549. #  define UX_ctermid ctermid
  550. #else
  551.    extern char * EXFUN (UX_ctermid, (char * s));
  552. #  define EMULATE_CTERMID
  553. #endif
  554.  
  555. #ifdef HAVE_KILL
  556. #  define UX_kill kill
  557. #else
  558.    extern int EXFUN (UX_kill, (pid_t pid, int sig));
  559. #  define EMULATE_KILL
  560. #endif
  561.  
  562. #ifdef HAVE_POLL
  563. #  ifndef INFTIM
  564. #    define INFTIM (-1)
  565. #  endif
  566. #else
  567. #  ifdef FD_SET
  568. #    define SELECT_TYPE fd_set
  569. #  else
  570. #    define SELECT_TYPE int
  571. #    define FD_SETSIZE ((sizeof (int)) * CHAR_BIT)
  572. #    define FD_SET(n, p) ((*(p)) |= (1 << (n)))
  573. #    define FD_CLR(n, p) ((*(p)) &= ~(1 << (n)))
  574. #    define FD_ISSET(n, p) (((*(p)) & (1 << (n))) != 0)
  575. #    define FD_ZERO(p) ((*(p)) = 0)
  576. #  endif
  577. #endif
  578.  
  579. #ifdef _POSIX_VERSION
  580. #  define ERRNO_NONBLOCK EAGAIN
  581. #  define FCNTL_NONBLOCK O_NONBLOCK
  582. #else
  583. #  ifdef EWOULDBLOCK
  584. #    define ERRNO_NONBLOCK EWOULDBLOCK
  585. #    define FCNTL_NONBLOCK FNDELAY
  586. #  else
  587. #    define AMBIGUOUS_NONBLOCK
  588. #    ifdef EAGAIN
  589. #      define ERRNO_NONBLOCK EAGAIN
  590. #    endif
  591. #    define FCNTL_NONBLOCK O_NDELAY
  592. #  endif
  593. #endif
  594.  
  595. #if defined(HAVE_GRANTPT) && defined(HAVE_STROPTS_H) && !defined(__osf__) && !defined(__linux__)
  596.    /* Must push various STREAMS modules onto the slave side of a PTY
  597.       when it is opened.  */
  598. #  define SLAVE_PTY_P(filename) ((strncmp ((filename), "/dev/pts/", 9)) == 0)
  599.    extern int EXFUN (UX_setup_slave_pty, (int));
  600. #  define SETUP_SLAVE_PTY UX_setup_slave_pty
  601. #endif
  602.  
  603. #ifndef TIOCSIGSEND
  604. #  ifdef TIOCSIGNAL
  605. #    define TIOCSIGSEND TIOCSIGNAL
  606. #  else
  607. #    ifdef TIOCSIG
  608. #      define TIOCSIGSEND TIOCSIG
  609. #    endif
  610. #  endif
  611. #endif
  612.  
  613. #ifdef HAVE_TERMIOS_H
  614.  
  615. typedef struct
  616. {
  617.   struct termios tio;
  618. #ifdef HAVE_STRUCT_LTCHARS
  619.   struct ltchars ltc;
  620. #endif
  621. } Ttty_state;
  622.  
  623. #define UX_tcflush tcflush
  624. #define UX_tcdrain tcdrain
  625. #define UX_tcgetattr tcgetattr
  626. #define UX_tcsetattr tcsetattr
  627.  
  628. #else /* not HAVE_TERMIOS_H */
  629.  
  630. extern int EXFUN (UX_tcdrain, (int));
  631. extern int EXFUN (UX_tcflush, (int, int));
  632. /* These values chosen to match the ioctl TCFLSH argument for termio. */
  633. #define TCIFLUSH 0
  634. #define TCOFLUSH 1
  635. #define TCIOFLUSH 2
  636.  
  637. #ifdef HAVE_TERMIO_H
  638.  
  639. typedef struct
  640. {
  641.   struct termio tio;
  642. #ifdef HAVE_STRUCT_LTCHARS
  643.   struct ltchars ltc;
  644. #endif
  645. } Ttty_state;
  646.  
  647. #else /* not HAVE_TERMIO_H */
  648. #ifdef HAVE_SGTTY_H
  649.  
  650. typedef struct
  651. {
  652.   struct sgttyb sg;
  653.   struct tchars tc;
  654. #ifdef HAVE_STRUCT_LTCHARS
  655.   struct ltchars ltc;
  656. #endif
  657.   int lmode;
  658. } Ttty_state;
  659.  
  660. #endif /* not HAVE_SGTTY_H */
  661. #endif /* not HAVE_TERMIO_H */
  662. #endif /* not HAVE_TERMIOS_H */
  663.  
  664. extern int EXFUN (UX_terminal_get_state, (int, Ttty_state *));
  665. extern int EXFUN (UX_terminal_set_state, (int, Ttty_state *));
  666.  
  667. #ifdef _POSIX_VERSION
  668. #  define UX_getpgrp getpgrp
  669. #  define UX_setsid setsid
  670. #  define UX_setpgid setpgid
  671. #  define UX_tcgetpgrp tcgetpgrp
  672. #  define UX_tcsetpgrp tcsetpgrp
  673. #else
  674. #  if defined(HAVE_GETPGRP) && defined(HAVE_SETPGRP)
  675. #    ifdef GETPGRP_VOID
  676. #      define UX_getpgrp getpgrp
  677. #    else
  678.        extern pid_t EXFUN (UX_getpgrp, (void));
  679. #      define EMULATE_GETPGRP
  680. #    endif
  681. #    ifdef SETPGRP_VOID
  682. #      define UX_setsid setpgrp
  683. #    else
  684.          extern pid_t EXFUN (UX_setsid, (void));
  685. #        define EMULATE_SETSID
  686. #    endif
  687. #    ifdef HAVE_SETPGRP2
  688. #      define UX_setpgid setpgrp2
  689. #    else
  690. #      ifdef SETPGRP_VOID
  691.          extern int UX_setpgid (pid_t, pid_t);
  692. #        define EMULATE_SETPGID
  693. #      else
  694. #        define UX_setpgid setpgrp
  695. #      endif
  696. #    endif
  697. #  endif
  698.    extern pid_t EXFUN (UX_tcgetpgrp, (int));
  699. #  define EMULATE_TCGETPGRP
  700.    extern int EXFUN (UX_tcsetpgrp, (int, pid_t));
  701. #  define EMULATE_TCSETPGRP
  702. #endif
  703.  
  704. #ifdef HAVE_SIGACTION
  705.  
  706. #define UX_sigemptyset sigemptyset
  707. #define UX_sigfillset sigfillset
  708. #define UX_sigaddset sigaddset
  709. #define UX_sigdelset sigdelset
  710. #define UX_sigismember sigismember
  711. #define UX_sigaction sigaction
  712. #define UX_sigsuspend sigsuspend
  713. #define UX_sigprocmask sigprocmask
  714. #define HAVE_POSIX_SIGNALS
  715.  
  716. #else /* not HAVE_SIGACTION */
  717.  
  718. typedef long sigset_t;
  719. extern int EXFUN (UX_sigemptyset, (sigset_t *));
  720. extern int EXFUN (UX_sigfillset, (sigset_t *));
  721. extern int EXFUN (UX_sigaddset, (sigset_t *, int));
  722. extern int EXFUN (UX_sigdelset, (sigset_t *, int));
  723. extern int EXFUN (UX_sigismember, (CONST sigset_t *, int));
  724.  
  725. #ifdef HAVE_SIGVEC
  726. #  define UX_sigvec sigvec
  727. #else
  728. #  ifdef HAVE_SIGVECTOR
  729. #    define UX_sigvec sigvector
  730. #    define HAVE_SIGVEC
  731. #  endif
  732. #endif
  733.  
  734. #ifdef HAVE_SIGVEC
  735.  
  736. struct sigaction
  737. {
  738.   Tsignal_handler sa_handler;
  739.   sigset_t sa_mask;
  740.   int sa_flags;
  741. };
  742.  
  743. extern int EXFUN
  744.   (UX_sigaction, (int, CONST struct sigaction *, struct sigaction *));
  745. extern int EXFUN (UX_sigprocmask, (int, CONST sigset_t *, sigset_t *));
  746. extern int EXFUN (UX_sigsuspend, (CONST sigset_t *));
  747. #define SIG_BLOCK 0
  748. #define SIG_UNBLOCK 1
  749. #define SIG_SETMASK 2
  750.  
  751. #define HAVE_POSIX_SIGNALS
  752.  
  753. #else /* not HAVE_SIGVEC */
  754. #ifdef HAVE_SIGHOLD
  755.  
  756. #define UX_sigset sigset
  757. #define UX_sighold sighold
  758. #define UX_sigrelse sigrelse
  759.  
  760. #endif /* HAVE_SIGHOLD */
  761. #endif /* HAVE_SIGVEC */
  762. #endif /* HAVE_SIGACTION */
  763.  
  764. #ifdef _POSIX_VERSION
  765.  
  766. #  ifndef HAVE_FPATHCONF
  767.      extern long EXFUN (fpathconf, (int, int));
  768. #    define EMULATE_FPATHCONF
  769. #  endif
  770.  
  771. #  ifndef HAVE_SYSCONF
  772.      extern long EXFUN (sysconf, (int));
  773. #    define EMULATE_SYSCONF
  774. #  endif
  775.  
  776.    extern cc_t EXFUN (UX_PC_VDISABLE, (int fildes));
  777.    extern clock_t EXFUN (UX_SC_CLK_TCK, (void));
  778. #  define UX_SC_OPEN_MAX() ((size_t) (sysconf (_SC_OPEN_MAX)))
  779. #  define UX_SC_CHILD_MAX() ((size_t) (sysconf (_SC_CHILD_MAX)))
  780.  
  781. #  ifdef _POSIX_JOB_CONTROL
  782. #    define UX_SC_JOB_CONTROL() 1
  783. #  else
  784. #    define UX_SC_JOB_CONTROL() ((sysconf (_SC_JOB_CONTROL)) >= 0)
  785. #  endif
  786.  
  787. #else /* not _POSIX_VERSION */
  788.  
  789. #  define UX_PC_VDISABLE(fildes) '\377'
  790.  
  791. #  ifdef OPEN_MAX
  792. #    define UX_SC_OPEN_MAX() OPEN_MAX
  793. #  else
  794. #    ifdef _NFILE
  795. #      define UX_SC_OPEN_MAX() _NFILE
  796. #    else
  797. #      define UX_SC_OPEN_MAX() 16
  798. #    endif
  799. #  endif
  800.  
  801. #  ifdef CHILD_MAX
  802. #    define UX_SC_CHILD_MAX() CHILD_MAX
  803. #  else
  804. #    define UX_SC_CHILD_MAX() 6
  805. #  endif
  806.  
  807. #  ifdef CLK_TCK
  808. #    define UX_SC_CLK_TCK() CLK_TCK
  809. #  else
  810. #    ifdef HZ
  811. #      define UX_SC_CLK_TCK() HZ
  812. #    else
  813. #      define UX_SC_CLK_TCK() 60
  814. #    endif
  815. #  endif
  816.  
  817. #  ifdef TIOCGPGRP
  818. #    define UX_SC_JOB_CONTROL() 1
  819. #  else
  820. #    define UX_SC_JOB_CONTROL() 0
  821. #  endif
  822.  
  823. #endif /* not _POSIX_VERSION */
  824.  
  825. extern void EXFUN (UX_prim_check_errno, (enum syscall_names name));
  826.  
  827. #define STD_VOID_SYSTEM_CALL(name, expression)                \
  828. {                                    \
  829.   while ((expression) < 0)                        \
  830.     if (errno != EINTR)                            \
  831.       error_system_call (errno, (name));                \
  832. }
  833.  
  834. #define STD_UINT_SYSTEM_CALL(name, result, expression)            \
  835. {                                    \
  836.   while (((result) = (expression)) < 0)                    \
  837.     if (errno != EINTR)                            \
  838.       error_system_call (errno, (name));                \
  839. }
  840.  
  841. #define STD_PTR_SYSTEM_CALL(name, result, expression)            \
  842. {                                    \
  843.   while (((result) = (expression)) == 0)                \
  844.     if (errno != EINTR)                            \
  845.       error_system_call (errno, (name));                \
  846. }
  847.  
  848. #endif /* SCM_UX_H */
  849.