home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume25 / tcsh-6.01 / part05 / tc.os.h < prev    next >
C/C++ Source or Header  |  1991-12-19  |  12KB  |  491 lines

  1. /* $Header: /home/hyperion/mu/christos/src/sys/tcsh-6.01/RCS/tc.os.h,v 3.22 1991/11/26 04:28:26 christos Exp $ */
  2. /*
  3.  * tc.os.h: Shell os dependent defines
  4.  */
  5. /*-
  6.  * Copyright (c) 1980, 1991 The Regents of the University of California.
  7.  * All rights reserved.
  8.  *
  9.  * Redistribution and use in source and binary forms, with or without
  10.  * modification, are permitted provided that the following conditions
  11.  * are met:
  12.  * 1. Redistributions of source code must retain the above copyright
  13.  *    notice, this list of conditions and the following disclaimer.
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in the
  16.  *    documentation and/or other materials provided with the distribution.
  17.  * 3. All advertising materials mentioning features or use of this software
  18.  *    must display the following acknowledgement:
  19.  *    This product includes software developed by the University of
  20.  *    California, Berkeley and its contributors.
  21.  * 4. Neither the name of the University nor the names of its contributors
  22.  *    may be used to endorse or promote products derived from this software
  23.  *    without specific prior written permission.
  24.  *
  25.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  26.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  29.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  31.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  32.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  33.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  34.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  35.  * SUCH DAMAGE.
  36.  */
  37. #ifndef _h_tc_os
  38. #define _h_tc_os
  39.  
  40. #define NEEDstrerror        /* Too hard to find which systems have it */
  41.  
  42. #if SVID > 3
  43. /*
  44.  * for SVR4 we fork pipelines backwards. 
  45.  * more info in sh.sem.c
  46.  */
  47. # define BACKPIPE
  48. #endif /* SVID > 3 */
  49.  
  50. #ifdef OREO
  51. # include <sys/time.h>
  52. # include <sys/resource.h>
  53. # ifdef POSIX
  54. #  ifdef T_BREAK
  55. #   undef T_BREAK
  56. #  endif /* T_BREAK */
  57. #  include <sys/tty.h>
  58. #  include <termios.h>
  59. # endif /* POSIX */
  60. #endif /* OREO */
  61.  
  62. #ifndef NCARGS
  63. # ifdef ARG_MAX
  64. #  define NCARGS ARG_MAX
  65. # else
  66. #  ifdef _MINIX
  67. #   define NCARGS 80
  68. #  else /* !_MINIX */
  69. #   define NCARGS 1024
  70. #  endif /* _MINIX */
  71. # endif /* ARG_MAX */
  72. #endif /* NCARGS */
  73.  
  74. #ifdef titan
  75. extern int end;
  76. #endif /* titan */
  77.  
  78. #ifdef hpux
  79. # ifdef lint
  80. /*
  81.  * Hpux defines struct ucred, in <sys/user.h>, but if I include that
  82.  * then I need to include the *world*
  83.  * [all this to pass lint cleanly!!!]
  84.  * so I define struct ucred here...
  85.  */
  86. struct ucred {
  87.     int     foo;
  88. };
  89. # endif /* lint */
  90.  
  91. /*
  92.  * hpux 7.0 does not define it
  93.  */
  94. # ifndef CSUSP
  95. #  define CSUSP 032
  96. # endif    /* CSUSP */
  97.  
  98. # ifndef hp9000s500
  99. #  include <sys/bsdtty.h>
  100. # endif
  101.  
  102. # ifndef POSIX
  103. #  ifdef BSDJOBS
  104. #   define getpgrp(a) getpgrp2(a)
  105. #   define setpgrp(a, b) setpgrp2(a, b)
  106. #  endif /* BSDJOBS */
  107. # endif    /* POSIX */
  108. #endif /* hpux */
  109.  
  110. /*
  111.  * ISC does not define CSUSP
  112.  */
  113. #ifdef ISC
  114. # ifndef CSUSP
  115. #  define CSUSP 032
  116. # endif    /* CSUSP */
  117. #endif /* ISC */
  118.  
  119. #ifdef ISC202
  120. # undef TIOCGWINSZ
  121. #endif /* ISC202 */
  122.  
  123. /*
  124.  * XXX: This will be changed soon to 
  125.  * #if (SVID > 0) && defined(TIOCGWINSZ)
  126.  * If that breaks on your machine, let me know.
  127.  */
  128. #if defined(INTEL) || defined(u3b2) || defined (u3b5) || \
  129.     defined(ub15) || defined(u3b20d) || defined(ISC) || defined(SCO) 
  130. #ifdef TIOCGWINSZ
  131. /*
  132.  * for struct winsiz
  133.  */
  134. # include <sys/stream.h>
  135. # include <sys/ptem.h>
  136. #endif /* TIOCGWINSZ */
  137. # ifndef ODT
  138. #  define NEEDgethostname
  139. # endif /* ODT */
  140. #endif /* INTEL || att || isc || sco */
  141.  
  142. #ifdef UNIXPC
  143. # define NEEDgethostname
  144. #endif /* UNIXPC */
  145.  
  146. #ifdef IRIS4D
  147. # include <sys/time.h>
  148. # include <sys/resource.h>
  149. /*
  150.  * BSDsetpgrp() and BSDgetpgrp() are BSD versions of setpgrp, etc.
  151.  */
  152. # define setpgrp BSDsetpgrp
  153. # define getpgrp BSDgetpgrp
  154. #endif /* IRIS4D */
  155.  
  156. /*
  157.  * Stat
  158.  */
  159. #ifdef ISC
  160. /* these are not defined for _POSIX_SOURCE under ISC 2.2 */
  161. # ifndef S_IFMT
  162. #  define S_IFMT  0170000        /* type of file */
  163. #  define S_IFDIR 0040000        /* directory */
  164. #  define S_IFCHR 0020000        /* character special */
  165. #  define S_IFBLK 0060000        /* block special */
  166. #  define S_IFREG 0100000        /* regular */
  167. #  define S_IFIFO 0010000        /* fifo */
  168. #  define S_IFNAM 0050000        /* special named file */
  169. # endif /* S_IFMT */
  170. #endif /* ISC */
  171.  
  172. #ifdef uts
  173. /*
  174.  * The uts 2.1.2 macros (Amdahl) are busted!
  175.  * You should fix <sys/stat.h>, cause other programs will break too!
  176.  *
  177.  * From: creiman@ncsa.uiuc.edu (Charlie Reiman)
  178.  */
  179. # undef S_ISDIR
  180. # undef S_ISCHR
  181. # undef S_ISBLK
  182. # undef S_ISREG
  183. # undef S_ISFIFO
  184. # undef S_ISNAM
  185. # undef S_ISLNK
  186. # undef S_ISSOCK
  187. #endif /* uts */
  188.  
  189. #ifdef S_IFMT
  190. # if !defined(S_ISDIR) && defined(S_IFDIR)
  191. #  define S_ISDIR(a)    (((a) & S_IFMT) == S_IFDIR)
  192. # endif    /* ! S_ISDIR && S_IFDIR */
  193. # if !defined(S_ISCHR) && defined(S_IFCHR)
  194. #  define S_ISCHR(a)    (((a) & S_IFMT) == S_IFCHR)
  195. # endif /* ! S_ISCHR && S_IFCHR */
  196. # if !defined(S_ISBLK) && defined(S_IFBLK)
  197. #  define S_ISBLK(a)    (((a) & S_IFMT) == S_IFBLK)
  198. # endif    /* ! S_ISBLK && S_IFBLK */
  199. # if !defined(S_ISREG) && defined(S_IFREG)
  200. #  define S_ISREG(a)    (((a) & S_IFMT) == S_IFREG)
  201. # endif    /* ! S_ISREG && S_IFREG */
  202. # if !defined(S_ISFIFO) && defined(S_IFIFO)
  203. #  define S_ISFIFO(a)    (((a) & S_IFMT) == S_IFIFO)
  204. # endif    /* ! S_ISFIFO && S_IFIFO */
  205. # if !defined(S_ISNAM) && defined(S_IFNAM)
  206. #  define S_ISNAM(a)    (((a) & S_IFMT) == S_IFNAM)
  207. # endif    /* ! S_ISNAM && S_IFNAM */
  208. # if !defined(S_ISLNK) && defined(S_IFLNK)
  209. #  define S_ISLNK(a)    (((a) & S_IFMT) == S_IFLNK)
  210. # endif    /* ! S_ISLNK && S_IFLNK */
  211. # if !defined(S_ISSOCK) && defined(S_IFSOCK)
  212. #  define S_ISSOCK(a)    (((a) & S_IFMT) == S_IFSOCK)
  213. # endif    /* ! S_ISSOCK && S_IFSOCK */
  214. #endif /* S_IFMT */
  215.  
  216. #ifndef S_IEXEC
  217. # define S_IEXEC 0000100
  218. #endif /* S_IEXEC */
  219. #ifndef S_IXOTH
  220. # define S_IXOTH (S_IEXEC >> 6)
  221. #endif /* S_IXOTH */
  222. #ifndef S_IXGRP
  223. # define S_IXGRP (S_IEXEC >> 3)
  224. #endif /* S_IXGRP */
  225. #ifndef S_IXUSR
  226. # define S_IXUSR S_IEXEC
  227. #endif /* S_IXUSR */
  228.  
  229. /*
  230.  * Access()
  231.  */
  232. #ifndef F_OK
  233. # define F_OK 0
  234. #endif /* F_OK */
  235. #ifndef X_OK
  236. # define X_OK 1
  237. #endif /* X_OK */
  238. #ifndef W_OK
  239. # define W_OK 2
  240. #endif /* W_OK */
  241. #ifndef R_OK
  242. # define R_OK 4
  243. #endif /* R_OK */
  244.  
  245. /*
  246.  * Open()
  247.  */
  248. #ifndef O_RDONLY
  249. # define O_RDONLY    0
  250. #endif /* O_RDONLY */
  251. #ifndef O_WRONLY
  252. # define O_WRONLY    1
  253. #endif /* O_WRONLY */
  254. #ifndef O_RDWR
  255. # define O_RDWR        2
  256. #endif /* O_RDWR */
  257.  
  258. /*
  259.  * Lseek()
  260.  */
  261. #ifndef L_SET
  262. # ifdef SEEK_SET
  263. #  define L_SET        SEEK_SET
  264. # else
  265. #  define L_SET        0
  266. # endif    /* SEEK_SET */
  267. #endif /* L_SET */
  268. #ifndef L_INCR
  269. # ifdef SEEK_CUR
  270. #  define L_INCR    SEEK_CUR
  271. # else
  272. #  define L_INCR    1
  273. # endif    /* SEEK_CUR */
  274. #endif /* L_INCR */
  275. #ifndef L_XTND
  276. # ifdef SEEK_END
  277. #  define L_XTND    SEEK_END
  278. # else
  279. #  define L_XTND    2
  280. # endif /* SEEK_END */
  281. #endif /* L_XTND */
  282.  
  283. #ifdef _SEQUENT_
  284. # define NEEDgethostname
  285. #endif /* _SEQUENT_ */
  286.  
  287. #if defined(BSD) && defined(POSIXJOBS) 
  288. # define setpgid(pid, pgrp)    setpgrp(pid, pgrp)
  289. #endif /* BSD && POSIXJOBS */
  290.  
  291. #if defined(BSDJOBS) && !(defined(POSIX) && defined(POSIXJOBS))
  292. # if !defined(_AIX370) && !defined(_AIXPS2)
  293. #  define setpgid(pid, pgrp)    setpgrp(pid, pgrp)
  294. # endif /* !_AIX370 && !_AIXPS2 */
  295. # define NEEDtcgetpgrp
  296. #endif /* BSDJOBS && !(POSIX && POSIXJOBS) */
  297.  
  298. #ifdef RENO 
  299. /*
  300.  * RENO has this broken. It is fixed on 4.4BSD
  301.  */
  302. # define NEEDtcgetpgrp
  303. #endif /* RENO */
  304.  
  305. #ifdef DGUX
  306. # define setpgrp(a, b) setpgrp2(a, b)
  307. # define getpgrp(a) getpgrp2(a)
  308. #endif /* DGUX */
  309.  
  310. #ifdef SXA
  311. # ifndef _BSDX_
  312. /*
  313.  * Only needed in the system V environment.
  314.  */
  315. #  define setrlimit     bsd_setrlimit
  316. #  define getrlimit    bsd_getrlimit
  317. # endif    /* _BSDX_ */
  318. # ifndef NOFILE
  319. #  define    NOFILE    64
  320. # endif    /* NOFILE */
  321. #endif /* SXA */
  322.  
  323. #ifdef _MINIX
  324. # ifndef NOFILE
  325. #  define NOFILE 64
  326. # endif /* NOFILE */
  327. /*
  328.  * Minix does not have these, so...
  329.  */
  330. # define nice(a)        /**/
  331. # define ulimit(a, b)        (0x003fffff)
  332. # define getpgrp()        getpid()
  333. # define gethostname(a, b)    (strncpy((a), "minix") == NULL)
  334. #endif /* _MINIX */
  335.  
  336. #ifndef POSIX
  337. # define mygetpgrp()    getpgrp(0)
  338. #else /* POSIX */
  339. # if defined(BSD) || defined(sun)
  340. #  define mygetpgrp()    getpgrp(0)
  341. # else /* BSD || sun */
  342. #  define mygetpgrp()    getpgrp()
  343. # endif    /* BSD || sun */
  344. #endif /* POSIX */
  345.  
  346.  
  347. #if SVID > 0 && !defined(OREO) && !defined(sgi)
  348. # define NEEDgetwd
  349. #endif /* SVID > 0 && !OREO && !sgi */
  350.  
  351. #ifndef S_IFLNK
  352. # define lstat stat
  353. #endif /* S_IFLNK */
  354.  
  355.  
  356. #if defined(BSDTIMES) && !defined(_SEQUENT_)
  357. typedef struct timeval timeval_t;
  358. #endif /* BSDTIMES && ! _SEQUENT_ */
  359.  
  360. #ifdef NeXT
  361. /*
  362.  * From Tony_Mason@transarc.com, override NeXT's malloc stuff.
  363.  */
  364. # define malloc tcsh_malloc
  365. # define calloc tcsh_calloc
  366. # define realloc tcsh_realloc
  367. # define free tcsh_free
  368. #endif /* NeXT */
  369.  
  370.  
  371. #if !defined(POSIX) || defined(sun)
  372. extern time_t time();
  373. extern char *getenv();
  374. extern int atoi();
  375. extern char *ttyname();
  376.  
  377. # ifndef hpux
  378. extern int abort();
  379. # ifndef fps500
  380. extern int qsort();
  381. # endif /* fps500 */
  382. # else
  383. extern void abort();
  384. extern void qsort();
  385. # endif
  386. extern void perror();
  387.  
  388. #ifndef NEEDgethostname
  389. extern int gethostname();
  390. #endif
  391.  
  392. # ifdef BSDSIGS
  393. #  if defined(_AIX370) || defined(MACH) || defined(NeXT) || defined(_AIXPS2)
  394. extern int sigvec();
  395. extern int sigpause();
  396. #  else    /* _AIX370 || MACH || NeXT || _AIXPS2 */
  397. #   if !defined(apollo) || !defined(__STDC__)
  398. # ifndef fps500
  399. extern sigret_t sigvec();
  400. extern void sigpause();
  401. # endif /* fps500 */
  402. #   endif /* !apollo || !__STDC__ */
  403. #  endif /* _AIX370 || MACH || NeXT || _AIXPS2 */
  404. extern sigmask_t sigblock();
  405. extern sigmask_t sigsetmask();
  406. # endif    /* BSDSIGS */
  407.  
  408. # ifndef killpg
  409. extern int killpg();
  410. # endif    /* killpg */
  411.  
  412. # ifndef lstat
  413. extern int lstat();
  414. # endif    /* lstat */
  415.  
  416. #ifdef BSD
  417. extern uid_t getuid(), geteuid();
  418. extern gid_t getgid(), getegid();
  419. #endif /* BSD */
  420.  
  421. # ifdef SYSMALLOC
  422. extern memalign_t malloc();
  423. extern memalign_t realloc();
  424. extern memalign_t calloc();
  425. extern void free();
  426. # endif    /* SYSMALLOC */
  427.  
  428. # ifdef BSDTIMES
  429. extern int getrlimit();
  430. extern int setrlimit();
  431. extern int getrusage();
  432. extern int gettimeofday();
  433. # endif    /* BSDTIMES */
  434.  
  435. # if defined(NLS) && !defined(NOSTRCOLL) && !defined(NeXT)
  436. extern int strcoll();
  437. # endif
  438.  
  439. # ifdef BSDJOBS
  440. #  ifdef BSDTIMES
  441. extern int wait3();
  442. #  else    /* ! BSDTIMES */
  443. #   if !defined(POSIXJOBS) && !defined(_SEQUENT_)
  444. extern int wait3();
  445. #   else /* POSIXJOBS || _SEQUENT_ */
  446. extern int waitpid();
  447. #   endif /* POSIXJOBS || _SEQUENT_ */
  448. #  endif /* ! BSDTIMES */
  449. # else /* !BSDJOBS */
  450. #  if SVID < 3
  451. extern int ourwait();
  452. #  else    /* SVID >= 3 */
  453. extern int wait();
  454. #  endif /* SVID >= 3 */
  455. # endif    /* ! BSDJOBS */
  456.  
  457. # ifdef BSDNICE
  458. extern int setpriority();
  459. # else /* !BSDNICE */
  460. extern int nice();
  461. # endif    /* !BSDNICE */
  462.  
  463. # ifndef fps500
  464. extern void setpwent();
  465. extern void endpwent();
  466. # endif /* fps500 */
  467.  
  468. #ifndef __STDC__
  469. extern struct passwd *getpwuid(), *getpwnam(), *getpwent();
  470. #ifdef PW_SHADOW
  471. extern struct spwd *getspnam(), *getspent();
  472. #endif /* PW_SHADOW */
  473. #endif /* __STDC__ */
  474.  
  475. # ifndef getwd
  476. extern char *getwd();
  477. # endif    /* getwd */
  478. #else /* POSIX */
  479.  
  480. # if (defined(sun) && !defined(__GNUC__)) || defined(_IBMR2) || defined(_IBMESA)
  481. extern char *getwd();
  482. # endif    /* (sun && ! __GNUC__) || _IBMR2 || _IBMESA */
  483.  
  484. # ifdef SCO
  485. extern char *ttyname();   
  486. # endif /* SCO */
  487.  
  488. #endif /* POSIX */
  489.  
  490. #endif /* _h_tc_os */
  491.