1 /* Copyright (C) 1989, 1992, 1993, 1994, 1997, 1998, 1999 artofcode LLC. All rights reserved. 2 3 This program is free software; you can redistribute it and/or modify it 4 under the terms of the GNU General Public License as published by the 5 Free Software Foundation; either version 2 of the License, or (at your 6 option) any later version. 7 8 This program is distributed in the hope that it will be useful, but 9 WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along 14 with this program; if not, write to the Free Software Foundation, Inc., 15 59 Temple Place, Suite 330, Boston, MA, 02111-1307. 16 17 */ 18 19 /*$Id: memory_.h,v 1.2.6.1.2.1 2003/01/17 00:49:05 giles Exp $ */ 20 /* Generic substitute for Unix memory.h */ 21 22 #ifndef memory__INCLUDED 23 # define memory__INCLUDED 24 25 /* We must include std.h before any file that includes sys/types.h. */ 26 #include "std.h" 27 28 /****** 29 ****** Note: the System V bcmp routine only returns zero or non-zero, 30 ****** unlike memcmp which returns -1, 0, or 1. 31 ******/ 32 33 #ifdef __TURBOC__ 34 /* Define inline functions */ 35 # ifdef __WIN32__ 36 # define memcmp_inline(b1,b2,len) memcmp(b1,b2,len) 37 # else 38 # define memcmp_inline(b1,b2,len) __memcmp__(b1,b2,len) 39 # endif 40 # include <mem.h> 41 #else 42 /* Not Turbo C, no inline functions */ 43 # define memcmp_inline(b1,b2,len) memcmp(b1,b2,len) 44 /* 45 * Apparently the newer VMS compilers include prototypes 46 * for the mem... routines in <string.h>. Unfortunately, 47 * gcc lies on Sun systems: it defines __STDC__ even if 48 * the header files in /usr/include are broken. 49 * However, Solaris systems, which define __svr4__, do have 50 * correct header files. 51 */ 52 /* 53 * The exceptions vastly outnumber the BSD4_2 "rule": 54 * these tests should be the other way around.... 55 */ 56 # 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) 57 # include <string.h> 58 # else 59 # if defined(BSD4_2) || defined(UTEK) 60 extern bcopy(), bcmp(), bzero(); 61 62 # define memcpy(dest,src,len) bcopy(src,dest,len) 63 # define memcmp(b1,b2,len) bcmp(b1,b2,len) 64 /* Define our own versions of missing routines (in gsmisc.c). */ 65 # define MEMORY__NEED_MEMMOVE 66 # include <sys/types.h> /* for size_t */ 67 # define MEMORY__NEED_MEMSET 68 # if defined(UTEK) 69 # define MEMORY__NEED_MEMCHR 70 # endif /* UTEK */ 71 # else 72 # include <memory.h> 73 # if defined(__SVR3) || defined(sun) /* Not sure this is right.... */ 74 # define MEMORY__NEED_MEMMOVE 75 # include <sys/types.h> /* for size_t */ 76 # endif /* __SVR3 or sun */ 77 # endif /* BSD4_2 or UTEK */ 78 # endif /* VMS, POSIX, ... */ 79 #endif /* !__TURBOC__ */ 80 81 /* 82 * If we are profiling, substitute our own versions of memset, memcpy, 83 * and memmove, in case profiling libraries aren't available. 84 */ 85 #ifdef PROFILE 86 # define MEMORY__NEED_MEMCPY 87 # define MEMORY__NEED_MEMMOVE 88 # define MEMORY__NEED_MEMSET 89 #endif 90 91 /* Declare substitutes for library procedures we supply. */ 92 #ifdef MEMORY__NEED_MEMMOVE 93 # define memmove(dest,src,len) gs_memmove(dest,src,len) 94 void *gs_memmove(P3(void *, const void *, size_t)); 95 #endif 96 #ifdef MEMORY__NEED_MEMCPY 97 # define memcpy(dest,src,len) gs_memcpy(dest,src,len) 98 void *gs_memcpy(P3(void *, const void *, size_t)); 99 #endif 100 #ifdef MEMORY__NEED_MEMSET 101 # define memset(dest,ch,len) gs_memset(dest,ch,len) 102 void *gs_memset(P3(void *, int, size_t)); 103 #endif 104 #ifdef MEMORY__NEED_MEMCHR 105 # define memchr(ptr,ch,len) gs_memchr(ptr,ch,len) 106 void *gs_memchr(P3(const void *, int, size_t)); 107 #endif 108 109 110 111 #endif /* memory__INCLUDED */ 112