compat_defs.h revision 1.1 1 /* $NetBSD: compat_defs.h,v 1.1 2002/01/22 20:42:59 thorpej Exp $ */
2
3 #ifndef __NETBSD_COMPAT_DEFS_H__
4 #define __NETBSD_COMPAT_DEFS_H__
5
6 /* System headers needed for (re)definitions below. */
7
8 #include <sys/types.h>
9 #include <errno.h>
10 #include <fcntl.h>
11 #include <limits.h>
12 #include <paths.h>
13 #include <stdio.h>
14 #include <string.h>
15
16 #if HAVE_INTTYPES_H
17 #include <inttypes.h>
18 #endif
19 #if HAVE_STDDEF_H
20 #include <stddef.h>
21 #endif
22 #if !HAVE_VIS_H
23 #include "compat_vis.h"
24 #endif
25
26 #if !defined(__attribute__) && !defined(__GNUC__)
27 #define __attribute__(x)
28 #endif
29
30 /* Type substitutes. */
31
32 #if !HAVE_ID_T
33 typedef unsigned long id_t;
34 #endif
35
36 /* Prototypes for replacement functions. */
37
38 #if !HAVE_BASENAME
39 char *basename(char *);
40 #endif
41
42 #if !HAVE_DIRNAME
43 char *dirname(char *);
44 #endif
45
46 #if !HAVE_ERR_H
47 void err(int, const char *, ...) __attribute__((noreturn));
48 void errx(int, const char *, ...) __attribute__((noreturn));
49 void warn(const char *, ...);
50 void warnx(const char *, ...);
51 #endif
52
53 #if !HAVE_FGETLN
54 char *fgetln(FILE *, size_t *);
55 #endif
56
57 #if !HAVE_FLOCK
58 # define LOCK_SH 0x01
59 # define LOCK_EX 0x02
60 # define LOCK_NB 0x04
61 # define LOCK_UN 0x08
62 int flock(int, int);
63 #endif
64
65 #if !HAVE_FPARSELN
66 # define FPARSELN_UNESCESC 0x01
67 # define FPARSELN_UNESCCONT 0x02
68 # define FPARSELN_UNESCCOMM 0x04
69 # define FPARSELN_UNESCREST 0x08
70 # define FPARSELN_UNESCALL 0x0f
71 char *fparseln(FILE *, size_t *, size_t *, const char [3], int);
72 #endif
73
74 #if !HAVE_SETPROGNAME
75 const char *getprogname(void);
76 void setprogname(const char *);
77 #endif
78
79 #if !HAVE_STRLCAT
80 size_t strlcat(char *, const char *, size_t);
81 #endif
82
83 #if !HAVE_STRLCPY
84 size_t strlcpy(char *, const char *, size_t);
85 #endif
86
87 #if !HAVE_PREAD
88 ssize_t pread(int, void *, size_t, off_t);
89 #endif
90
91 #if !HAVE_PWRITE
92 ssize_t pwrite(int, const void *, size_t, off_t);
93 #endif
94
95 /*
96 * getmode() and setmode() are always defined, as these function names
97 * exist but with very different meanings on other OS's. The compat
98 * versions here simply accept an octal mode number; the "u+x,g-w" type
99 * of syntax is not accepted.
100 */
101
102 #define getmode __nbcompat_getmode
103 #define setmode __nbcompat_setmode
104
105 mode_t getmode(const void *, mode_t);
106 void *setmode(const char *);
107
108 /* Eliminate RCS Id strings, assertions embedded in binaries. */
109
110 #undef _DIAGASSERT
111 #define _DIAGASSERT(x) /**/
112 #define lint
113
114 /* Assume an ANSI compiler for the host. */
115
116 #undef __P
117 #define __P(x) x
118
119 #undef BIG_ENDIAN
120 #undef LITTLE_ENDIAN
121 #define BIG_ENDIAN 4321
122 #define LITTLE_ENDIAN 1234
123
124 #undef BYTE_ORDER
125 #if WORDS_BIGENDIAN
126 #define BYTE_ORDER BIG_ENDIAN
127 #else
128 #define BYTE_ORDER LITTLE_ENDIAN
129 #endif
130
131 #undef MIN
132 #undef MAX
133 #define MIN(a,b) ((a) < (b) ? (a) : (b))
134 #define MAX(a,b) ((a) > (b) ? (a) : (b))
135
136 /* Some definitions not available on all systems. */
137
138 #ifndef _PATH_DEFPATH
139 #define _PATH_DEFPATH "/usr/bin:/bin:/usr/local/bin"
140 #endif
141 #ifndef _PATH_DEV
142 #define _PATH_DEV "/dev/"
143 #endif
144 #ifndef _PATH_DEVNULL
145 #define _PATH_DEVNULL _PATH_DEV "null"
146 #endif
147 #ifndef _PATH_TMP
148 #define _PATH_TMP "/tmp/"
149 #endif
150
151 #ifndef EFTYPE
152 #define EFTYPE EIO
153 #endif
154
155 #ifndef MAXBSIZE
156 #define MAXBSIZE (64 * 1024)
157 #endif
158
159 #ifndef O_EXLOCK
160 #define O_EXLOCK 0
161 #endif
162 #ifndef O_SHLOCK
163 #define O_SHLOCK 0
164 #endif
165
166 #endif /* !__NETBSD_COMPAT_DEFS_H__ */
167