remove OSF1 support
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / btree_berkeley / compat.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: compat.h /main/8 1996/07/18 16:32:14 drk $ */
24 /*-
25  * Copyright (c) 1991, 1993
26  *      The Regents of the University of California.  All rights reserved.
27  *
28  * Redistribution and use in source and binary forms, with or without
29  * modification, are permitted provided that the following conditions
30  * are met:
31  * 1. Redistributions of source code must retain the above copyright
32  *    notice, this list of conditions and the following disclaimer.
33  * 2. Redistributions in binary form must reproduce the above copyright
34  *    notice, this list of conditions and the following disclaimer in the
35  *    documentation and/or other materials provided with the distribution.
36  * 3. All advertising materials mentioning features or use of this software
37  *    must display the following acknowledgement:
38  *      This product includes software developed by the University of
39  *      California, Berkeley and its contributors.
40  * 4. Neither the name of the University nor the names of its contributors
41  *    may be used to endorse or promote products derived from this software
42  *    without specific prior written permission.
43  *
44  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
45  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
48  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54  * SUCH DAMAGE.
55  *
56  *      @(#)compat.h    8.3 (Berkeley) 9/6/93
57  */
58
59 #ifndef _COMPAT_H_
60 #define _COMPAT_H_
61
62 #include <sys/types.h>
63 #include "utility/config.h"
64
65 /*
66  * If your system doesn't typedef u_long, u_short, or u_char, change
67  * the 0 to a 1.
68  */
69 #if 0
70 typedef unsigned long   u_long;
71 typedef unsigned short  u_short;
72 typedef unsigned char   u_char;
73 #endif
74
75 /* If your system doesn't typedef size_t, change the 0 to a 1. */
76 #if 0
77 typedef unsigned int    size_t;
78 #endif
79
80 /*
81  * If your system doesn't have the POSIX type for a signal mask,
82  * change the 0 to a 1.
83  */
84 #if 0
85 typedef unsigned int    sigset_t;
86 #endif
87
88 /*
89  * If your system's vsnprintf returns a char *, not an int,
90  * change the 0 to a 1.
91  */
92 #if !defined(_AIX) && !defined(linux) && !defined(CSRG_BASED) && !defined(sun)
93 #define VSPRINTF_CHARSTAR
94 #endif
95
96 /*
97  * If you don't have POSIX 1003.1 signals, the signal code surrounding the 
98  * temporary file creation is intended to block all of the possible signals
99  * long enough to create the file and unlink it.  All of this stuff is
100  * intended to use old-style BSD calls to fake POSIX 1003.1 calls.
101  */
102 #ifdef  NO_POSIX_SIGNALS
103 #define sigemptyset(set)        (*(set) = 0)
104 #define sigfillset(set)         (*(set) = ~(sigset_t)0, 0)
105 #define sigaddset(set,signo)    (*(set) |= sigmask(signo), 0)
106 #define sigdelset(set,signo)    (*(set) &= ~sigmask(signo), 0)
107 #define sigismember(set,signo)  ((*(set) & sigmask(signo)) != 0)
108
109 #define SIG_BLOCK       1
110 #define SIG_UNBLOCK     2
111 #define SIG_SETMASK     3
112
113 static int __sigtemp;           /* For the use of sigprocmask */
114
115 /* Repeated test of oset != NULL is to avoid "*0". */
116 #define sigprocmask(how, set, oset)                                     \
117         ((__sigtemp =                                                   \
118         (((how) == SIG_BLOCK) ?                                         \
119                 sigblock(0) | *(set) :                                  \
120         (((how) == SIG_UNBLOCK) ?                                       \
121                 sigblock(0) & ~(*(set)) :                               \
122         ((how) == SIG_SETMASK ?                                         \
123                 *(set) : sigblock(0))))),                               \
124         ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) :      \
125                 sigsetmask(__sigtemp)), 0)
126 #endif
127
128 /*
129  * If realloc(3) of a NULL pointer on your system isn't the same as
130  * a malloc(3) call, change the 0 to a 1, and add realloc.o to the
131  * MISC line in your Makefile.
132  */
133 /*
134 #if 1
135 #define realloc __fix_realloc
136 #endif
137 */
138 void * __fix_realloc __P((void*, size_t));
139
140
141 /*
142  * If your system doesn't have an include file with the appropriate
143  * byte order set, make sure you specify the correct one.
144  */
145 #ifndef BYTE_ORDER
146
147 #define LITTLE_ENDIAN   1234            /* LSB first: i386, vax */
148 #define BIG_ENDIAN      4321            /* MSB first: 68000, ibm, net */
149
150 #ifdef MMDB_LITTLE_ENDIAN
151 #define BYTE_ORDER      LITTLE_ENDIAN   /* Set for your system. */
152 #endif
153
154 #ifdef MMDB_BIG_ENDIAN
155 #define BYTE_ORDER      BIG_ENDIAN      /* Set for your system. */
156 #endif
157
158
159 #endif
160
161 #if defined(SYSV) || defined(SYSTEM5) || defined(SVR4)
162 /* #define      index(a, b)             strchr(a, b) */
163 #ifndef rindex
164 #define rindex(a, b)            strrchr(a, b)
165 #endif
166 #define bzero(a, b)             memset(a, 0, b)
167 #define bcmp(a, b, n)           memcmp(a, b, n)
168 #define bcopy(a, b, n)          memmove(b, a, n)
169 #endif
170
171 #if defined(BSD) || defined(BSD4_3)
172 #define strchr(a, b)            index(a, b)
173 #define strrchr(a, b)           rindex(a, b)
174 #define memcmp(a, b, n)         bcmp(a, b, n)
175 #define memmove(a, b, n)        bcopy(b, a, n)
176 #endif
177
178 /*
179  * 32-bit machine.  The db routines are theoretically independent of
180  * the size of u_shorts and u_longs, but I don't know that anyone has
181  * ever actually tried it.  At a minimum, change the following #define's
182  * if you are trying to compile on a different type of system.
183  */
184 #ifndef USHRT_MAX
185 #define USHRT_MAX               0xFFFF
186 #define ULONG_MAX               0xFFFFFFFF
187 #endif
188
189 /* POSIX 1003.1 access mode mask. */
190 #ifndef O_ACCMODE
191 #define O_ACCMODE       (O_RDONLY|O_WRONLY|O_RDWR)
192 #endif
193
194 /* POSIX 1003.2 RE limit. */
195 #ifndef _POSIX2_RE_DUP_MAX
196 #define _POSIX2_RE_DUP_MAX      255
197 #endif
198
199 /*
200  * If you can't provide lock values in the open(2) call.  Note, this
201  * allows races to happen.
202  */
203 #ifndef O_EXLOCK
204 #define O_EXLOCK        0
205 #endif
206
207 #ifndef O_SHLOCK
208 #define O_SHLOCK        0
209 #endif
210
211 #ifndef EFTYPE
212 #define EFTYPE          EINVAL          /* POSIX 1003.1 format errno. */
213 #endif
214
215 #ifndef WCOREDUMP                       /* 4.4BSD extension */
216 #define WCOREDUMP(a)    0
217 #endif
218
219 #ifndef STDERR_FILENO
220 #define STDIN_FILENO    0               /* ANSI C #defines */
221 #define STDOUT_FILENO   1
222 #define STDERR_FILENO   2
223 #endif
224
225 #ifndef SEEK_END
226 #define SEEK_SET        0               /* POSIX 1003.1 seek values */
227 #define SEEK_CUR        1
228 #define SEEK_END        2
229 #endif
230
231 #ifndef S_ISLNK                         /* BSD POSIX 1003.1 extensions */
232 #define S_ISLNK(m)      ((m & 0170000) == 0120000)
233 #define S_ISSOCK(m)     ((m & 0170000) == 0140000)
234 #endif
235
236 #ifndef TCSASOFT
237 #define TCSASOFT        0
238 #endif
239
240 #ifndef _POSIX2_RE_DUP_MAX
241 #define _POSIX2_RE_DUP_MAX      255
242 #endif
243
244 #ifndef NULL                            /* ANSI C #defines NULL everywhere. */
245 #define NULL            0
246 #endif
247
248 #undef MAX
249 #define MAX(a,b)        ((a)<(b)?(b):(a))
250
251 #undef MIN
252 #define MIN(a,b)        ((a)<(b)?(a):(b))
253
254 #ifndef DEFFILEMODE                     /* Default file permissions. */
255 #define DEFFILEMODE     (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
256 #endif
257
258 #ifndef _BSD_VA_LIST_
259 #define _BSD_VA_LIST_   char *
260 #endif
261
262 #endif /* !_COMPAT_H_ */