home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / apps / dtp / ghost / gs301src / atari / std.h < prev   
C/C++ Source or Header  |  1994-09-17  |  8KB  |  206 lines

  1. /* Copyright (C) 1989, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* std.h */
  20. /* Standard definitions for Aladdin Enterprises code */
  21.  
  22. #ifndef std_INCLUDED
  23. #  define std_INCLUDED
  24.  
  25. #include "stdpre.h"
  26.  
  27. /* Include the architecture definitions. */
  28. #include "arch.h"
  29.  
  30. /* Define integer data type sizes in terms of log2s. */
  31. #define arch_sizeof_short (1 << arch_log2_sizeof_short)
  32. #define arch_sizeof_int (1 << arch_log2_sizeof_int)
  33. #define arch_sizeof_long (1 << arch_log2_sizeof_long)
  34. #define arch_ints_are_short (arch_sizeof_int == arch_sizeof_short)
  35.  
  36. /* Define unsigned 16- and 32-bit types.  These are needed in */
  37. /* a surprising number of places that do bit manipulation. */
  38. #if arch_sizeof_short == 2    /* no plausible alternative! */
  39. typedef ushort bits16;
  40. #endif
  41. #if arch_sizeof_int == 4
  42. typedef uint bits32;
  43. #else
  44. # if arch_sizeof_long == 4
  45. typedef ulong bits32;
  46. # endif
  47. #endif
  48.  
  49. /* Minimum and maximum values for the signed types. */
  50. /* Avoid casts, to make them acceptable to strict ANSI compilers. */
  51. #define min_short (-1 << (arch_sizeof_short * 8 - 1))
  52. #define max_short (~min_short)
  53. #define min_int (-1 << (arch_sizeof_int * 8 - 1))
  54. #define max_int (~min_int)
  55. #define min_long (-1L << (arch_sizeof_long * 8 - 1))
  56. #define max_long (~min_long)
  57.  
  58. /*
  59.  * The maximum values for the unsigned types are defined in arch.h,
  60.  * because so many compilers handle unsigned constants wrong.
  61.  * In particular, most of the DEC VMS compilers incorrectly sign-extend
  62.  * short unsigned constants (but not short unsigned variables) when
  63.  * widening them to longs.  We program around this on a case-by-case basis.
  64.  * Some compilers don't truncate constants when they are cast down.
  65.  * The UTek compiler does special weird things of its own.
  66.  * All the rest (including gcc on all platforms) do the right thing.
  67.  */
  68. #define max_uchar arch_max_uchar
  69. #define max_ushort arch_max_ushort
  70. #define max_uint arch_max_uint
  71. #define max_ulong arch_max_ulong
  72.  
  73. /* Minimum and maximum values for pointers. */
  74. #if arch_ptrs_are_signed
  75. #  define min_ptr min_long
  76. #  define max_ptr max_long
  77. #else
  78. #  define min_ptr ((ulong)0)
  79. #  define max_ptr max_ulong
  80. #endif
  81.  
  82. /* Define a reliable arithmetic right shift. */
  83. /* Must use arith_rshift_1 for a shift by a literal 1. */
  84. #define arith_rshift_slow(x,n) ((x) < 0 ? ~(~(x) >> (n)) : (x) >> (n))
  85. #if arch_arith_rshift == 2
  86. #  define arith_rshift(x,n) ((x) >> (n))
  87. #  define arith_rshift_1(x) ((x) >> 1)
  88. #else
  89. #if arch_arith_rshift == 1        /* OK except for n=1 */
  90. #  define arith_rshift(x,n) ((x) >> (n))
  91. #  define arith_rshift_1(x) arith_rshift_slow(x,1)
  92. #else
  93. #  define arith_rshift(x,n) arith_rshift_slow(x,n)
  94. #  define arith_rshift_1(x) arith_rshift_slow(x,1)
  95. #endif
  96. #endif
  97.  
  98. /* Standard error printing macros. */
  99. /* Use dprintf for messages that just go to dstderr, */
  100. /* eprintf for error messages to estderr that include the program name, */
  101. /* lprintf for debugging messages that should include line number info. */
  102. /* Since we intercept fprintf to redirect output under MS Windows, */
  103. /* we have to define dputc and dputs in terms of fprintf also. */
  104.  
  105. /* Intercept fprintf to redirect console I/O to a window on
  106.  * the Atari ST platform.
  107.  */
  108.  
  109. #ifdef atarist
  110. #  include "st_winio.h"
  111. #endif
  112.  
  113. /* dstderr and estderr may be redefined. */
  114. #define dstderr stderr
  115. #define estderr stderr
  116.  
  117. #define dputc(chr) dprintf1("%c", chr)
  118. #define dputs(str) dprintf1("%s", str)
  119. #define dprintf(str)\
  120.   fprintf(dstderr, str)
  121. #define dprintf1(str,arg1)\
  122.   fprintf(dstderr, str, arg1)
  123. #define dprintf2(str,arg1,arg2)\
  124.   fprintf(dstderr, str, arg1, arg2)
  125. #define dprintf3(str,arg1,arg2,arg3)\
  126.   fprintf(dstderr, str, arg1, arg2, arg3)
  127. #define dprintf4(str,arg1,arg2,arg3,arg4)\
  128.   fprintf(dstderr, str, arg1, arg2, arg3, arg4)
  129. #define dprintf5(str,arg1,arg2,arg3,arg4,arg5)\
  130.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5)
  131. #define dprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
  132.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6)
  133. #define dprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
  134.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
  135. #define dprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
  136.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  137. #define dprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
  138.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
  139. #define dprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
  140.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
  141. #define dprintf11(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)\
  142.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11)
  143. #define dprintf12(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)\
  144.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)
  145.  
  146. #ifdef PROGRAM_NAME
  147. extern const char *PROGRAM_NAME;
  148. #  define _epn fprintf(estderr, "%s: ", PROGRAM_NAME),
  149. #else
  150. #  define _epn /* */
  151. #endif
  152.  
  153. #define eprintf(str)\
  154.   (_epn fprintf(estderr, str))
  155. #define eprintf1(str,arg1)\
  156.   (_epn fprintf(estderr, str, arg1))
  157. #define eprintf2(str,arg1,arg2)\
  158.   (_epn fprintf(estderr, str, arg1, arg2))
  159. #define eprintf3(str,arg1,arg2,arg3)\
  160.   (_epn fprintf(estderr, str, arg1, arg2, arg3))
  161. #define eprintf4(str,arg1,arg2,arg3,arg4)\
  162.   (_epn fprintf(estderr, str, arg1, arg2, arg3, arg4))
  163. #define eprintf5(str,arg1,arg2,arg3,arg4,arg5)\
  164.   (_epn fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5))
  165. #define eprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
  166.   (_epn fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6))
  167. #define eprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
  168.   (_epn fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7))
  169. #define eprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
  170.   (_epn fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))
  171. #define eprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
  172.   (_epn fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))
  173. #define eprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
  174.   (_epn fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10))
  175.  
  176. #if __LINE__                /* compiler provides it */
  177. #  define _epl _epn fprintf(estderr, "%s(%d): ", __FILE__, __LINE__),
  178. #else
  179. #  define _epl _epn
  180. #endif
  181.  
  182. #define lprintf(str)\
  183.   (_epl fprintf(estderr, str))
  184. #define lprintf1(str,arg1)\
  185.   (_epl fprintf(estderr, str, arg1))
  186. #define lprintf2(str,arg1,arg2)\
  187.   (_epl fprintf(estderr, str, arg1, arg2))
  188. #define lprintf3(str,arg1,arg2,arg3)\
  189.   (_epl fprintf(estderr, str, arg1, arg2, arg3))
  190. #define lprintf4(str,arg1,arg2,arg3,arg4)\
  191.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4))
  192. #define lprintf5(str,arg1,arg2,arg3,arg4,arg5)\
  193.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5))
  194. #define lprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
  195.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6))
  196. #define lprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
  197.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7))
  198. #define lprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
  199.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))
  200. #define lprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
  201.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))
  202. #define lprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
  203.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10))
  204.  
  205. #endif                    /* std_INCLUDED */
  206.