2 |
- |
1 |
/* Copyright (C) 1989, 1992, 1993, 1994, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
|
|
|
3 |
This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
implied.
|
|
|
5 |
|
|
|
6 |
This software is distributed under license and may not be copied,
|
|
|
7 |
modified or distributed except as expressly authorized under the terms
|
|
|
8 |
of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
|
|
|
10 |
For more information about licensing, please refer to
|
|
|
11 |
http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/* $Id: memory_.h,v 1.6 2002/06/16 05:03:12 lpd Exp $ */
|
|
|
18 |
/* Generic substitute for Unix memory.h */
|
|
|
19 |
|
|
|
20 |
#ifndef memory__INCLUDED
|
|
|
21 |
# define memory__INCLUDED
|
|
|
22 |
|
|
|
23 |
/* We must include std.h before any file that includes sys/types.h. */
|
|
|
24 |
#include "std.h"
|
|
|
25 |
|
|
|
26 |
/******
|
|
|
27 |
****** Note: the System V bcmp routine only returns zero or non-zero,
|
|
|
28 |
****** unlike memcmp which returns -1, 0, or 1.
|
|
|
29 |
******/
|
|
|
30 |
|
|
|
31 |
#ifdef __TURBOC__
|
|
|
32 |
/* Define inline functions */
|
|
|
33 |
# ifdef __WIN32__
|
|
|
34 |
# define memcmp_inline(b1,b2,len) memcmp(b1,b2,len)
|
|
|
35 |
# else
|
|
|
36 |
# define memcmp_inline(b1,b2,len) __memcmp__(b1,b2,len)
|
|
|
37 |
# endif
|
|
|
38 |
# include <mem.h>
|
|
|
39 |
#else
|
|
|
40 |
/* Not Turbo C, no inline functions */
|
|
|
41 |
# define memcmp_inline(b1,b2,len) memcmp(b1,b2,len)
|
|
|
42 |
/*
|
|
|
43 |
* Apparently the newer VMS compilers include prototypes
|
|
|
44 |
* for the mem... routines in <string.h>. Unfortunately,
|
|
|
45 |
* gcc lies on Sun systems: it defines __STDC__ even if
|
|
|
46 |
* the header files in /usr/include are broken.
|
|
|
47 |
* However, Solaris systems, which define __svr4__, do have
|
|
|
48 |
* correct header files.
|
|
|
49 |
*/
|
|
|
50 |
/*
|
|
|
51 |
* The exceptions vastly outnumber the BSD4_2 "rule":
|
|
|
52 |
* these tests should be the other way around....
|
|
|
53 |
*/
|
|
|
54 |
# 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)
|
|
|
55 |
# include <string.h>
|
|
|
56 |
# else
|
|
|
57 |
# if defined(BSD4_2) || defined(UTEK)
|
|
|
58 |
extern bcopy(), bcmp(), bzero();
|
|
|
59 |
|
|
|
60 |
# define memcpy(dest,src,len) bcopy(src,dest,len)
|
|
|
61 |
# define memcmp(b1,b2,len) bcmp(b1,b2,len)
|
|
|
62 |
/* Define our own versions of missing routines (in gsmisc.c). */
|
|
|
63 |
# define MEMORY__NEED_MEMMOVE
|
|
|
64 |
# include <sys/types.h> /* for size_t */
|
|
|
65 |
# define MEMORY__NEED_MEMSET
|
|
|
66 |
# if defined(UTEK)
|
|
|
67 |
# define MEMORY__NEED_MEMCHR
|
|
|
68 |
# endif /* UTEK */
|
|
|
69 |
# else
|
|
|
70 |
# include <memory.h>
|
|
|
71 |
# if defined(__SVR3) || defined(sun) /* Not sure this is right.... */
|
|
|
72 |
# define MEMORY__NEED_MEMMOVE
|
|
|
73 |
# include <sys/types.h> /* for size_t */
|
|
|
74 |
# endif /* __SVR3 or sun */
|
|
|
75 |
# endif /* BSD4_2 or UTEK */
|
|
|
76 |
# endif /* VMS, POSIX, ... */
|
|
|
77 |
#endif /* !__TURBOC__ */
|
|
|
78 |
|
|
|
79 |
/*
|
|
|
80 |
* If we are profiling, substitute our own versions of memset, memcpy,
|
|
|
81 |
* and memmove, in case profiling libraries aren't available.
|
|
|
82 |
*/
|
|
|
83 |
#ifdef PROFILE
|
|
|
84 |
# define MEMORY__NEED_MEMCPY
|
|
|
85 |
# define MEMORY__NEED_MEMMOVE
|
|
|
86 |
# define MEMORY__NEED_MEMSET
|
|
|
87 |
#endif
|
|
|
88 |
|
|
|
89 |
/*
|
|
|
90 |
* Declare substitutes for library procedures we supply. We undef them
|
|
|
91 |
* first, just in case we are substituting for an existing library facility
|
|
|
92 |
* that happens to be implemented as a macro.
|
|
|
93 |
*/
|
|
|
94 |
#ifdef MEMORY__NEED_MEMMOVE
|
|
|
95 |
# undef memmove
|
|
|
96 |
# define memmove(dest,src,len) gs_memmove(dest,src,len)
|
|
|
97 |
void *gs_memmove(void *, const void *, size_t);
|
|
|
98 |
#endif
|
|
|
99 |
#ifdef MEMORY__NEED_MEMCPY
|
|
|
100 |
# undef memcpy
|
|
|
101 |
# define memcpy(dest,src,len) gs_memcpy(dest,src,len)
|
|
|
102 |
void *gs_memcpy(void *, const void *, size_t);
|
|
|
103 |
#endif
|
|
|
104 |
#ifdef MEMORY__NEED_MEMSET
|
|
|
105 |
# undef memset
|
|
|
106 |
# define memset(dest,ch,len) gs_memset(dest,ch,len)
|
|
|
107 |
void *gs_memset(void *, int, size_t);
|
|
|
108 |
#endif
|
|
|
109 |
#ifdef MEMORY__NEED_MEMCHR
|
|
|
110 |
# undef memchr
|
|
|
111 |
# define memchr(ptr,ch,len) gs_memchr(ptr,ch,len)
|
|
|
112 |
void *gs_memchr(const void *, int, size_t);
|
|
|
113 |
#endif
|
|
|
114 |
|
|
|
115 |
#endif /* memory__INCLUDED */
|