memory_.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* Copyright (C) 1989, 1992, 1993, 1994, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: memory_.h,v 1.2 2000/09/19 19:00:47 lpd Exp $ */
  16. /* Generic substitute for Unix memory.h */
  17. #ifndef memory__INCLUDED
  18. # define memory__INCLUDED
  19. /* We must include std.h before any file that includes sys/types.h. */
  20. #include "std.h"
  21. /******
  22. ****** Note: the System V bcmp routine only returns zero or non-zero,
  23. ****** unlike memcmp which returns -1, 0, or 1.
  24. ******/
  25. #ifdef __TURBOC__
  26. /* Define inline functions */
  27. # ifdef __WIN32__
  28. # define memcmp_inline(b1,b2,len) memcmp(b1,b2,len)
  29. # else
  30. # define memcmp_inline(b1,b2,len) __memcmp__(b1,b2,len)
  31. # endif
  32. # include <mem.h>
  33. #else
  34. /* Not Turbo C, no inline functions */
  35. # define memcmp_inline(b1,b2,len) memcmp(b1,b2,len)
  36. /*
  37. * Apparently the newer VMS compilers include prototypes
  38. * for the mem... routines in <string.h>. Unfortunately,
  39. * gcc lies on Sun systems: it defines __STDC__ even if
  40. * the header files in /usr/include are broken.
  41. * However, Solaris systems, which define __svr4__, do have
  42. * correct header files.
  43. */
  44. /*
  45. * The exceptions vastly outnumber the BSD4_2 "rule":
  46. * these tests should be the other way around....
  47. */
  48. # if defined(VMS) || defined(_POSIX_SOURCE) || (defined(__STDC__) && (!defined(sun) || defined(__svr4__))) || defined(_HPUX_SOURCE) || defined(__WATCOMC__) || defined(THINK_C) || defined(bsdi) || defined(__FreeBSD) || (defined(_MSC_VER) && _MSC_VER >= 1000)
  49. # include <string.h>
  50. # else
  51. # if defined(BSD4_2) || defined(UTEK)
  52. extern bcopy(), bcmp(), bzero();
  53. # define memcpy(dest,src,len) bcopy(src,dest,len)
  54. # define memcmp(b1,b2,len) bcmp(b1,b2,len)
  55. /* Define our own versions of missing routines (in gsmisc.c). */
  56. # define MEMORY__NEED_MEMMOVE
  57. # include <sys/types.h> /* for size_t */
  58. # define MEMORY__NEED_MEMSET
  59. # if defined(UTEK)
  60. # define MEMORY__NEED_MEMCHR
  61. # endif /* UTEK */
  62. # else
  63. # include <memory.h>
  64. # if defined(__SVR3) || defined(sun) /* Not sure this is right.... */
  65. # define MEMORY__NEED_MEMMOVE
  66. # include <sys/types.h> /* for size_t */
  67. # endif /* __SVR3 or sun */
  68. # endif /* BSD4_2 or UTEK */
  69. # endif /* VMS, POSIX, ... */
  70. #endif /* !__TURBOC__ */
  71. /*
  72. * If we are profiling, substitute our own versions of memset, memcpy,
  73. * and memmove, in case profiling libraries aren't available.
  74. */
  75. #ifdef PROFILE
  76. # define MEMORY__NEED_MEMCPY
  77. # define MEMORY__NEED_MEMMOVE
  78. # define MEMORY__NEED_MEMSET
  79. #endif
  80. /* Declare substitutes for library procedures we supply. */
  81. #ifdef MEMORY__NEED_MEMMOVE
  82. # define memmove(dest,src,len) gs_memmove(dest,src,len)
  83. void *gs_memmove(P3(void *, const void *, size_t));
  84. #endif
  85. #ifdef MEMORY__NEED_MEMCPY
  86. # define memcpy(dest,src,len) gs_memcpy(dest,src,len)
  87. void *gs_memcpy(P3(void *, const void *, size_t));
  88. #endif
  89. #ifdef MEMORY__NEED_MEMSET
  90. # define memset(dest,ch,len) gs_memset(dest,ch,len)
  91. void *gs_memset(P3(void *, int, size_t));
  92. #endif
  93. #ifdef MEMORY__NEED_MEMCHR
  94. # define memchr(ptr,ch,len) gs_memchr(ptr,ch,len)
  95. void *gs_memchr(P3(const void *, int, size_t));
  96. #endif
  97. #endif /* memory__INCLUDED */