Initial revision
[LeanCalc.git] / calc / calc / alloc.h
1 /*
2  * alloc - storage allocation and storage debug macros
3  *
4  * Copyright (C) 1999  David I. Bell
5  *
6  * Calc is open software; you can redistribute it and/or modify it under
7  * the terms of the version 2.1 of the GNU Lesser General Public License
8  * as published by the Free Software Foundation.
9  *
10  * Calc is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
13  * Public License for more details.
14  *
15  * A copy of version 2.1 of the GNU Lesser General Public License is
16  * distributed with calc under the filename COPYING-LGPL.  You should have
17  * received a copy with calc; if not, write to Free Software Foundation, Inc.
18  * 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * @(#) $Revision$
21  * @(#) $Id$
22  * @(#) $Source$
23  *
24  * Under source code control:   1990/02/15 01:48:29
25  * File existed as early as:    before 1990
26  *
27  * Share and enjoy!  :-)        http://www.isthe.com/chongo/tech/comp/calc/
28  */
29
30
31 #if !defined(__ALLOC_H__)
32 #define __ALLOC_H__
33
34
35 #if defined(CALC_SRC)   /* if we are building from the calc source tree */
36 # include "calc/have_malloc.h"
37 # include "calc/have_newstr.h"
38 # include "calc/have_string.h"
39 # include "calc/have_memmv.h"
40 #else
41 # include <calc/have_malloc.h>
42 # include <calc/have_newstr.h>
43 # include <calc/have_string.h>
44 # include <calc/have_memmv.h>
45 #endif
46
47 #ifdef HAVE_MALLOC_H
48 # include <malloc.h>
49 #else
50 #if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
51    extern void *malloc();
52    extern void *realloc();
53    extern void free();
54 # else
55    extern char *malloc();
56    extern char *realloc();
57    extern void free();
58 # endif
59 #endif
60
61 #ifdef HAVE_STRING_H
62 # include <string.h>
63
64 #else
65
66 # if defined(HAVE_NEWSTR)
67 extern void *memcpy();
68 extern void *memset();
69 #if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
70 extern size_t strlen();
71 #  else
72 extern long strlen();
73 #  endif
74 # else /* HAVE_NEWSTR */
75 extern void bcopy();
76 extern void bfill();
77 extern char *index();
78 # endif /* HAVE_NEWSTR */
79 extern char *strchr();
80 extern char *strcpy();
81 extern char *strncpy();
82 extern char *strcat();
83 extern int strcmp();
84
85 #endif
86
87 #if !defined(HAVE_NEWSTR)
88 #undef memcpy
89 #define memcpy(s1, s2, n) bcopy(s2, s1, n)
90 #undef memset
91 #define memset(s, c, n) bfill(s, n, c)
92 #undef strchr
93 #define strchr(s, c) index(s, c)
94 #endif /* HAVE_NEWSTR */
95
96 #if !defined(HAVE_MEMMOVE)
97 # undef CALC_SIZE_T
98 #if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
99 #  define CALC_SIZE_T size_t
100 # else
101 #  define CALC_SIZE_T long
102 # endif
103 extern void *memmove(void *s1, const void *s2, CALC_SIZE_T n);
104 #endif
105
106 #endif /* !__ALLOC_H__ */