home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / e / emxdev8f.zip / EMX.H < prev    next >
C/C++ Source or Header  |  1992-11-19  |  9KB  |  332 lines

  1. /* sys/emx.h (emx+gcc) */
  2.  
  3. /* Must be included before any other head files */
  4.  
  5. #if defined (__cplusplus)
  6. extern "C" {
  7. #endif
  8.  
  9. #define FALSE 0
  10. #define TRUE  1
  11.  
  12. extern __const__ int _nfiles;
  13. extern char ** _org_environ;
  14.  
  15. #define _SIZE_T
  16. typedef unsigned long size_t;
  17.  
  18. struct stat;
  19. struct timeval;
  20. struct timeb;
  21. struct _fd_set;
  22. struct _FILE;
  23.  
  24. #define _TM
  25. struct tm
  26. {
  27.   int tm_sec;     /* 0..59 */
  28.   int tm_min;     /* 0..59 */
  29.   int tm_hour;    /* 0..23 */
  30.   int tm_mday;    /* 1..31 */
  31.   int tm_mon;     /* 0..11 */
  32.   int tm_year;    /* 0(:=1900).. */
  33.   int tm_wday;    /* 0..6 */
  34.   int tm_yday;    /* 0..365 */
  35.   int tm_isdst;   /* 0 */
  36. };
  37.  
  38. struct _new_proc
  39. {
  40.   unsigned long  arg_off;
  41.   unsigned long  env_off;
  42.   unsigned long  fname_off;
  43.   unsigned short arg_sel;
  44.   unsigned short env_sel;
  45.   unsigned short fname_sel;
  46.   unsigned short arg_count;
  47.   unsigned short arg_size;
  48.   unsigned short env_count;
  49.   unsigned short env_size;
  50.   unsigned short mode;
  51. };
  52.  
  53. struct _ftd
  54. {
  55.   unsigned int sec   : 5;
  56.   unsigned int min   : 6;
  57.   unsigned int hour  : 5;
  58.   unsigned int day   : 5;
  59.   unsigned int month : 4;
  60.   unsigned int year  : 7;
  61. };
  62.  
  63. struct _dtd
  64. {
  65.   unsigned char  hsec;
  66.   unsigned char  sec;
  67.   unsigned char  min;
  68.   unsigned char  hour;
  69.   unsigned char  day;
  70.   unsigned char  month;
  71.   unsigned short year;
  72. };
  73.  
  74. struct _find
  75. {
  76.   char           reserved[21];
  77.   unsigned char  attr;
  78.   unsigned short time;
  79.   unsigned short date;
  80.   unsigned short size_lo;         /* split due to alignment problems */
  81.   unsigned short size_hi;
  82.   char name[257];                 /* Big buffer for OS/2             */
  83. };
  84.  
  85. struct _select
  86. {
  87.   int              nfds;
  88.   struct _fd_set * readfds;
  89.   struct _fd_set * writefds;
  90.   struct _fd_set * exceptfds;
  91.   struct timeval * timeout;
  92. };
  93.  
  94.  
  95. #if defined (_EMXLIBC)
  96. #define _NFILES 256
  97. #else
  98. #define _NFILES 40
  99. #endif
  100.  
  101. /* Low-level i/o */
  102.  
  103. /*      O_ACCMODE   0x00000003 */
  104. /*      O_NDELAY    0x00000004 */
  105. /*      O_APPEND    0x00000008 */
  106. /*      O_TEXT      0x00000010 */
  107. #define F_EOF       0x00000020
  108. #define F_TERMIO    0x00000040
  109. #define F_DEV       0x00000080
  110. /*      O_BINARY    0x00000100 */
  111. /*      O_CREAT     0x00000200 */
  112. /*      O_TRUNC     0x00000400 */
  113. /*      O_EXCL      0x00000800 */
  114. #define F_NPIPE     0x00001000
  115.  
  116. /* stdio */
  117.  
  118. /*      _IOREAD     0x00000001 */
  119. /*      _IOWRT      0x00000002 */
  120. /*      _IORW       0x00000004 */
  121. /*      _IOEOF      0x00000008 */
  122. /*      _IOERR      0x00000010 */
  123. /*      _IOLBF      0x00000020 */
  124. /*      _IONBF      0x00000040 */
  125. #define _IOOPEN     0x00000080
  126. #define _IOBUFMASK  0x00000700
  127. #define _IOBUFNONE  0x00000000
  128. #define _IOBUFUSER  0x00000100
  129. #define _IOBUFCHAR  0x00000200
  130. #define _IOBUFLIB   0x00000300
  131. #define _IOBUFTMP   0x00000400
  132. #define _IOTMP      0x00000800
  133. #define _IOSTRING   0x00001000
  134. #define _IOREREAD   0x00002000
  135.  
  136. /* argv[i][-1] contains some flag bits: */
  137.  
  138. #define _ARG_DQUOTE   0x01          /* Argument quoted (")                  */
  139. #define _ARG_RESPONSE 0x02          /* Argument read from response file     */
  140. #define _ARG_WILDCARD 0x04          /* Argument expanded from wildcard      */
  141. #define _ARG_NONZERO  0x80          /* Always set, to avoid end of string   */
  142.  
  143. /* _uflags constants */
  144.  
  145. #define _UF_SIG_BENIGN 0x0001       /* Benign signal handlers               */
  146.  
  147. #if !defined (__IODATA)
  148. extern int _files[];
  149. extern int _lookahead[];
  150. #endif
  151.  
  152. #if !defined (_EXIT_C)
  153. extern void (*_atexit_v[32])(void);
  154. extern int _atexit_n;
  155. #endif
  156.  
  157. #if !defined (_TZSET_C)
  158. extern int _tzset_flag;
  159. #endif
  160.  
  161. #if !defined (_NLS_INIT_C)
  162. extern int _nls_init_flag;
  163. #endif
  164.  
  165. #define END_OF_HEAP 0xfffffffe      /* even! */
  166.  
  167. #define rover _malloc_rover
  168. #define bottom _malloc_bottom
  169. #define top _malloc_top
  170.  
  171. #if !defined (_MALLOC_C)
  172. extern size_t *rover, *bottom, *top;
  173. #endif
  174.  
  175. #define alloca __builtin_alloca
  176.  
  177. unsigned __alarm (unsigned sec);
  178. void *__brk (void *addr);
  179. void __cgets (char *buffer);
  180. int __chdir (__const__ char *name);
  181. int __chmod (__const__ char *name, int flag, int attr);
  182. int __chdrive (char drive);
  183. int __chsize (int handle, long length);
  184. long long __clock (void);
  185. int __close (int handle);
  186. int __core (int handle);
  187. int __dup (int handle);
  188. int __dup2 (int handle1, int handle2);
  189. int __endthread (int tid);
  190. void __volatile__ __exit (int ret);
  191. int __fcntl (int handle, int request, int arg);
  192. int __filesys (__const__ char *drive, char *name, size_t size);
  193. int __filetime (int handle, int flag, struct _ftd *date_time);
  194. int __findfirst (__const__ char *name, int attr, struct _find *fp);
  195. int __findnext (struct _find *fp);
  196. int __fork (void);
  197. int __fstat (int handle, struct stat *buffer);
  198. int __fsync (int handle);
  199. void __ftime (struct timeb *ptr);
  200. int __ftruncate (int handle, long length);
  201. int __getcwd (char *buffer, char drive);
  202. char __getdrive (void);
  203. int __getpid (void);
  204. int __getppid (void);
  205. int __ioctl1 (int handle, int code);
  206. int __ioctl2 (int handle, int request, int arg);
  207. int __kill (int pid, int sig);
  208. int __lseek (int handle, long offset, int origin);
  209. void *__memaccess (unsigned first, unsigned last, int flag);
  210. int __memavail (void);
  211. int __mkdir (__const__ char *name);
  212. int __newthread (int tid);
  213. void __nls_memupr (unsigned char *buf, size_t size);
  214. int __open (__const__ char *name, int flags);
  215. int __pipe (int *two_handles, int pipe_size);
  216. int __portaccess (unsigned first, unsigned last);
  217. int __ptrace (int request, int pid, int addr, int data);
  218. int __raise (int sig);
  219. int __read (int handle, void *buf, size_t nbyte);
  220. int __read_kbd (int echo, int wait, int sig);
  221. int __remove (__const__ char *name);
  222. int __rename (__const__ char *old_name, __const__ char *new_name);
  223. int __rmdir (__const__ char *name);
  224. void *__sbrk (int incr);
  225. void __scrsize (int *dst);
  226. int __select (struct _select *args);
  227. void (*__signal (int sig, void (*handler)()))(int sig);
  228. unsigned __sleep (unsigned sec);
  229. unsigned __sleep2 (unsigned millisec);
  230. int __spawnve (struct _new_proc *np);
  231. int __stat (__const__ char *name, struct stat *buffer);
  232. int __swchar (int flag, int new);
  233. int __syserrno (void);
  234. void __timezone (int distance);
  235. int __uflags (int mask, int new);
  236. long __ulimit (int cmd, long new_limit);
  237. int __umask (int pmode);
  238. void __unwind2 (void *xcpt_reg_ptr);
  239. int __utimes (__const__ char *name, __const__ struct timeval *tvp);
  240. int __wait (int *status);
  241. int __waitpid (int pid, int *status, int options);
  242. int __write (int handle, __const__ void *buf, size_t nbyte);
  243.  
  244. void _cleanup (void);
  245. int _day (int year, int month, int day);
  246. void _endbuf (struct _FILE *stream);
  247. void _fbuf (struct _FILE *stream);
  248. struct _FILE *_fopen (struct _FILE *dst, __const__ char *fname,
  249.     __const__ char *mode, int shmode);
  250. void *_expand2 (void *mem, size_t size);
  251. int _flushstream (struct _FILE *stream, int c);
  252. int _fxam (double x);
  253. int _input (struct _FILE *stream, __const__ char *format, char *arg_ptr);
  254. void *_malloc2 (size_t size);
  255. int _mktime (struct tm *t);
  256. struct _FILE *_newstream (void);
  257. int _output (struct _FILE *stream, __const__ char *format, char *arg_ptr);
  258. int _sopen (__const__ char *name, int oflag, int shflag, char *va);
  259. void _tmpbuf (struct _FILE *stream);
  260. int _strtoul (__const__ char *string, char **end_ptr, int radix,
  261.     unsigned long *dst);
  262.  
  263. #define nbuf(s) (((s)->flags & _IOBUFMASK) == _IOBUFNONE)
  264. #define cbuf(s) (((s)->flags & _IOBUFMASK) == _IOBUFCHAR)
  265. #define ubuf(s) (((s)->flags & _IOBUFMASK) == _IOBUFUSER)
  266. #define lbuf(s) (((s)->flags & _IOBUFMASK) == _IOBUFLIB)
  267. #define tbuf(s) (((s)->flags & _IOBUFMASK) == _IOBUFTMP)
  268.  
  269. #define bbuf(s) (ubuf (s) || lbuf (s) || tbuf (s))
  270.  
  271. /* Replace some bits in an lvalue */
  272.  
  273. #define SETBITS(dst,mask,new) ((dst) = ((dst) & ~(mask)) | ((new) & (mask)))
  274.  
  275. #define FX_P_NAN       1
  276. #define FX_N_NAN       3
  277. #define FX_P_NORMAL    4
  278. #define FX_P_INFINITY  5
  279. #define FX_N_NORMAL    6
  280. #define FX_N_INFINITY  7
  281. #define FX_P_ZERO      8
  282. #define FX_P_EMPTY     9
  283. #define FX_N_ZERO     10
  284. #define FX_N_EMPTY    11
  285. #define FX_P_DENORMAL 12
  286. #define FX_N_DENORMAL 14
  287.  
  288. #define _A_NORMAL 0x00  /* No attributes */
  289. #define _A_RDONLY 0x01  /* Read-only     */
  290. #define _A_HIDDEN 0x02  /* Hidden        */
  291. #define _A_SYSTEM 0x04  /* System        */
  292. #define _A_VOLID  0x08  /* Volume label  */
  293. #define _A_SUBDIR 0x10  /* Directory     */
  294. #define _A_ARCH   0x20  /* Archive       */
  295.  
  296. #define _S2UL_OK        0
  297. #define _S2UL_ERROR     1
  298. #define _S2UL_OVERFLOW  2
  299.  
  300. #if defined (__MT__)
  301.  
  302. struct _thread
  303. {
  304.   int             _th_errno;                /* comes first, cf. errnofun.s */
  305.   void          * _th_arg;
  306.   void          (*_th_start)(void *arg);
  307.   unsigned char * _th_strtok_ptr;
  308.   char            _th_asctime_buf[26+2];    /* 2 chars for padding */
  309.   char            _th_tmpnam_buf[16];       /* cf. stdio.h */
  310.   struct tm       _th_gmtime_buf;
  311.   int             _th_reserved[1000];
  312. };
  313.  
  314. struct _thread *_thread (void);
  315. int _tid (void);
  316. void _heap_lock (void);
  317. void _heap_unlock (void);
  318.  
  319. #define HEAP_LOCK   _heap_lock()
  320. #define HEAP_UNLOCK _heap_unlock()
  321.  
  322. #else
  323.  
  324. #define HEAP_LOCK
  325. #define HEAP_UNLOCK
  326.  
  327. #endif /* defined (__MT__) */
  328.  
  329. #if defined (__cplusplus)
  330. }
  331. #endif
  332.