home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / GNU / FGRE11AS.ZIP / STD.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-22  |  4.5 KB  |  166 lines

  1. /* std.h - automagically adapt to old and new compilers.
  2.    In the Public Domain; written by Mike Haertel. */
  3.  
  4. /* MS-DOS port (c) 1990 by Thorsten Ohl, ohl@gnu.ai.mit.edu
  5.    This port is also distributed under the terms of the
  6.    GNU General Public License as published by the
  7.    Free Software Foundation.
  8.  
  9.    Please note that this file is not identical to the
  10.    original GNU release, you should have received this
  11.    code as patch to the official release.
  12.  
  13.    $Header: e:/gnu/fgrep/RCS/std.h 1.1.0.3 90/09/24 00:38:01 tho Exp $
  14.  */
  15.  
  16. #if __STDC__
  17.  
  18. #include <stddef.h>
  19. #include <limits.h>
  20.  
  21. typedef void *PTR;
  22. typedef const void *PTRCONST;
  23.  
  24. #define AND ,
  25. #define DEFUN(F, L, P) F(P)
  26. #define EXFUN(F, P) F P
  27.  
  28. #else
  29.  
  30. #define const
  31. #define volatile
  32.  
  33. /* The following approximations of <stddef.h> and <limits.h> are appropriate
  34.    for most machines. */
  35. typedef int ptrdiff_t;
  36. typedef unsigned int size_t;
  37. #define NULL 0
  38. #define offsetof(T, M) ((size_t)&((T *) 0)->(M))
  39.  
  40. #define CHAR_BIT 8
  41. #define SCHAR_MIN -128
  42. #define SCHAR_MAX 127
  43. #define UCHAR_MAX 255
  44. #define CHAR_MIN ((char) UCHAR_MAX < 0 ? SCHAR_MIN : 0)
  45. #define CHAR_MAX ((char) UCHAR_MAX < 0 ? SCHAR_MAX : UCHAR_MAX)
  46. #define SHRT_MIN -32768
  47. #define SHRT_MAX 32767
  48. #define USHRT_MAX 65535
  49. #define INT_MIN (sizeof (int) == 2 ? -32768 : -2147483648)
  50. #define INT_MAX (sizeof (int) == 2 ? 32767 : 2147483647)
  51. #define UINT_MAX (sizeof (int) == 2 ? 65535 : 4294967295)
  52. #define LONG_MIN -2147483648L
  53. #define LONG_MAX 2147483647L
  54. #define ULONG_MAX 4294967295
  55.  
  56. typedef char *PTR;
  57. typedef const char *PTRCONST;
  58.  
  59. #define AND ;
  60. #define DEFUN(F, L, P) F L P ;
  61. #define EXFUN(F, P) F()
  62.  
  63. #endif
  64.  
  65. /* Deal with <ctype.h> lossage. */
  66. #include <ctype.h>
  67.  
  68. #ifndef isascii
  69.  
  70. #define ISALNUM(C) isalnum(C)
  71. #define ISALPHA(C) isalpha(C)
  72. #define ISCNTRL(C) iscntrl(C)
  73. #define ISDIGIT(C) isdigit(C)
  74. #define ISGRAPH(C) isgraph(C)
  75. #define ISLOWER(C) islower(C)
  76. #define ISPRINT(C) isprint(C)
  77. #define ISPUNCT(C) ispunct(C)
  78. #define ISSPACE(C) isspace(C)
  79. #define ISUPPER(C) isupper(C)
  80. #define ISXDIGIT(C) isxdigit(C)
  81. #define TOLOWER(C) tolower(C)
  82. #define TOUPPER(C) toupper(C)
  83.  
  84. #else
  85.  
  86. #define ISALNUM(C) (isascii(C) && isalnum(C))
  87. #define ISALPHA(C) (isascii(C) && isalpha(C))
  88. #define ISCNTRL(C) (isascii(C) && iscntrl(C))
  89. #define ISDIGIT(C) (isascii(C) && isdigit(C))
  90. #define ISGRAPH(C) (isascii(C) && isgraph(C))
  91. #define ISLOWER(C) (isascii(C) && islower(C))
  92. #define ISPRINT(C) (isascii(C) && isprint(C))
  93. #define ISPUNCT(C) (isascii(C) && ispunct(C))
  94. #define ISSPACE(C) (isascii(C) && isspace(C))
  95. #define ISUPPER(C) (isascii(C) && isupper(C))
  96. #define ISXDIGIT(C) (isascii(C) && isxdigit(C))
  97. #define TOLOWER(C) (ISUPPER(C) ? tolower(C) : (C))
  98. #define TOUPPER(C) (ISLOWER(C) ? toupper(C) : (C))
  99.  
  100. #endif
  101.  
  102. /* Declaring this here should be safe.  Some losing <errno.h>'s don't. */
  103. #ifndef MSDOS
  104. extern int errno;
  105. #endif
  106.  
  107. /* Adapt variable arguments to new implementations (with <stdarg.h>)
  108.    or old (which are assumed to have <varargs.h>). */
  109.  
  110. #if __STDC__
  111.  
  112. #include <stdarg.h>
  113.  
  114. #define VA_ALIST ...
  115. #define VA_DCL ...
  116. #define VA_LIST va_list
  117. #define VA_START(AP, LASTARG) va_start(AP, LASTARG)
  118. #define VA_ARG(AP, TYPE) va_arg(AP, TYPE)
  119. #define VA_END(AP) va_end(AP)
  120.  
  121. #define VA_DEFUN(F, L, P) F(P)
  122.  
  123. #else
  124.  
  125. #include <varargs.h>
  126.  
  127. #define VA_ALIST va_alist
  128. #define VA_DCL va_dcl
  129. #define VA_LIST va_list
  130. #define VA_START(AP, LASTARG) va_start(AP)
  131. #define VA_ARG(AP, TYPE) va_arg(AP, TYPE)
  132. #define VA_END(AP) va_end(AP)
  133.  
  134. #define VA_DEFUN(F, L, P) F L P
  135.  
  136. #endif
  137.  
  138. /* Declarations of traditional library routines. */
  139. #ifdef MSDOS
  140. #include <stdlib.h>
  141. extern void *xmalloc (size_t size);
  142. extern void *xrealloc (void *ptr, size_t size);
  143. #else /* not MSDOS */
  144. extern double EXFUN(atof, (const char *));
  145. extern int EXFUN(atoi, (const char *));
  146. extern long int EXFUN(atol, (const char *));
  147. extern int EXFUN(rand, (void));
  148. extern void EXFUN(srand, (int));
  149. extern PTR EXFUN(calloc, (size_t, size_t));
  150. extern void EXFUN(free, (PTR));
  151. extern PTR EXFUN(malloc, (size_t));
  152. extern PTR EXFUN(realloc, (PTR, size_t));
  153. extern void EXFUN(abort, (void));
  154. extern void EXFUN(exit, (int));
  155. extern char *EXFUN(getenv, (const char *));
  156. extern int EXFUN(system, (const char *));
  157. extern void EXFUN(qsort, (PTR, size_t, size_t,
  158.               int EXFUN((*), (PTRCONST, PTRCONST))));
  159. extern int EXFUN(abs, (int));
  160. extern long int EXFUN(labs, (long int));
  161.  
  162. #ifdef X_strerror
  163. extern char *EXFUN(strerror, (int));
  164. #endif
  165. #endif /* not MSDOS */
  166.