1 | /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h,v 3.53 2003/10/28 18:36:37 tsi Exp $ */
|
---|
2 | /*
|
---|
3 | * Copyright 1997-2003 by The XFree86 Project, Inc
|
---|
4 | *
|
---|
5 | * Permission to use, copy, modify, distribute, and sell this software and its
|
---|
6 | * documentation for any purpose is hereby granted without fee, provided that
|
---|
7 | * the above copyright notice appear in all copies and that both that
|
---|
8 | * copyright notice and this permission notice appear in supporting
|
---|
9 | * documentation, and that the names of the above listed copyright holders
|
---|
10 | * not be used in advertising or publicity pertaining to distribution of
|
---|
11 | * the software without specific, written prior permission. The above listed
|
---|
12 | * copyright holders make no representations about the suitability of this
|
---|
13 | * software for any purpose. It is provided "as is" without express or
|
---|
14 | * implied warranty.
|
---|
15 | *
|
---|
16 | * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
|
---|
17 | * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
18 | * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE
|
---|
19 | * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
---|
20 | * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
---|
21 | * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
---|
22 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
---|
23 | *
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef _XF86_ANSIC_H
|
---|
27 | #define _XF86_ANSIC_H
|
---|
28 |
|
---|
29 | /* Handle <stdarg.h> */
|
---|
30 |
|
---|
31 | #ifndef IN_MODULE
|
---|
32 | # include <stdarg.h>
|
---|
33 | #else /* !IN_MODULE */
|
---|
34 | # ifndef __OS2ELF__
|
---|
35 | # include <stdarg.h>
|
---|
36 | # else /* __OS2ELF__ */
|
---|
37 | /* EMX/gcc_elf under OS/2 does not have native header files */
|
---|
38 | # if !defined (_VA_LIST)
|
---|
39 | # define _VA_LIST
|
---|
40 | typedef char *va_list;
|
---|
41 | # endif
|
---|
42 | # define _VA_ROUND(t) ((sizeof (t) + 3) & -4)
|
---|
43 | # if !defined (va_start)
|
---|
44 | # define va_start(ap,v) ap = (va_list)&v + ((sizeof (v) + 3) & -4)
|
---|
45 | # define va_end(ap) (ap = 0, (void)0)
|
---|
46 | # define va_arg(ap,t) (ap += _VA_ROUND (t), *(t *)(ap - _VA_ROUND (t)))
|
---|
47 | # endif
|
---|
48 | # endif /* __OS2ELF__ */
|
---|
49 | #endif /* IN_MODULE */
|
---|
50 |
|
---|
51 | /*
|
---|
52 | * The first set of definitions are required both for modules and
|
---|
53 | * libc_wrapper.c.
|
---|
54 | */
|
---|
55 |
|
---|
56 | #if defined(XFree86LOADER) || defined(NEED_XF86_TYPES)
|
---|
57 |
|
---|
58 | #if !defined(SYSV) && !defined(SVR4) && !defined(Lynx) || \
|
---|
59 | defined(__SCO__) || defined(__UNIXWARE__)
|
---|
60 | #define HAVE_VSSCANF
|
---|
61 | #define HAVE_VFSCANF
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #ifndef NULL
|
---|
65 | #if (defined(SVR4) || defined(SYSV)) && !defined(__GNUC__)
|
---|
66 | #define NULL 0
|
---|
67 | #else
|
---|
68 | #define NULL ((void *)0)
|
---|
69 | #endif
|
---|
70 | #endif
|
---|
71 | #ifndef EOF
|
---|
72 | #define EOF (-1)
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | #ifndef PATH_MAX
|
---|
76 | #define PATH_MAX 1024
|
---|
77 | #endif
|
---|
78 |
|
---|
79 | /* <limits.h> stuff */
|
---|
80 | #define x_BITSPERBYTE 8
|
---|
81 | #define x_BITS(type) (x_BITSPERBYTE * (int)sizeof(type))
|
---|
82 | #define x_SHORTBITS x_BITS(short)
|
---|
83 | #define x_INTBITS x_BITS(int)
|
---|
84 | #define x_LONGBITS x_BITS(long)
|
---|
85 | #ifndef SHRT_MIN
|
---|
86 | #define SHRT_MIN ((short)(1 << (x_SHORTBITS - 1)))
|
---|
87 | #endif
|
---|
88 |
|
---|
89 | #ifndef FONTMODULE
|
---|
90 | #include "misc.h"
|
---|
91 | #endif
|
---|
92 | #include "xf86_libc.h"
|
---|
93 | #ifndef SHRT_MAX
|
---|
94 | #define SHRT_MAX ((short)~SHRT_MIN)
|
---|
95 | #endif
|
---|
96 | #ifndef USHRT_MAX
|
---|
97 | #define USHRT_MAX ((unsigned short)~0)
|
---|
98 | #endif
|
---|
99 | #ifndef MINSHORT
|
---|
100 | #define MINSHORT SHRT_MIN
|
---|
101 | #endif
|
---|
102 | #ifndef MAXSHORT
|
---|
103 | #define MAXSHORT SHRT_MAX
|
---|
104 | #endif
|
---|
105 | #ifndef INT_MIN
|
---|
106 | #define INT_MIN (1 << (x_INTBITS - 1))
|
---|
107 | #endif
|
---|
108 | #ifndef INT_MAX
|
---|
109 | #define INT_MAX (~INT_MIN)
|
---|
110 | #endif
|
---|
111 | #ifndef UINT_MAX
|
---|
112 | #define UINT_MAX (~0)
|
---|
113 | #endif
|
---|
114 | #ifndef MININT
|
---|
115 | #define MININT INT_MIN
|
---|
116 | #endif
|
---|
117 | #ifndef MAXINT
|
---|
118 | #define MAXINT INT_MAX
|
---|
119 | #endif
|
---|
120 | #ifndef LONG_MIN
|
---|
121 | #define LONG_MIN ((long)(1 << (x_LONGBITS - 1)))
|
---|
122 | #endif
|
---|
123 | #ifndef LONG_MAX
|
---|
124 | #define LONG_MAX ((long)~LONG_MIN)
|
---|
125 | #endif
|
---|
126 | #ifndef ULONG_MAX
|
---|
127 | #define ULONG_MAX ((unsigned long)~0UL)
|
---|
128 | #endif
|
---|
129 | #ifndef MINLONG
|
---|
130 | #define MINLONG LONG_MIN
|
---|
131 | #endif
|
---|
132 | #ifndef MAXLONG
|
---|
133 | #define MAXLONG LONG_MAX
|
---|
134 | #endif
|
---|
135 |
|
---|
136 | #endif /* XFree86LOADER || NEED_XF86_TYPES */
|
---|
137 |
|
---|
138 | #if defined(XFree86LOADER) || defined(NEED_XF86_PROTOTYPES)
|
---|
139 | /*
|
---|
140 | * ANSI C compilers only.
|
---|
141 | */
|
---|
142 |
|
---|
143 | /* ANSI C emulation library */
|
---|
144 |
|
---|
145 | extern void xf86abort(void);
|
---|
146 | extern int xf86abs(int);
|
---|
147 | extern double xf86acos(double);
|
---|
148 | extern double xf86asin(double);
|
---|
149 | extern double xf86atan(double);
|
---|
150 | extern double xf86atan2(double,double);
|
---|
151 | extern double xf86atof(const char*);
|
---|
152 | extern int xf86atoi(const char*);
|
---|
153 | extern long xf86atol(const char*);
|
---|
154 | extern void *xf86bsearch(const void *, const void *, xf86size_t, xf86size_t,
|
---|
155 | int (*)(const void *, const void *));
|
---|
156 | extern double xf86ceil(double);
|
---|
157 | extern void* xf86calloc(xf86size_t,xf86size_t);
|
---|
158 | extern void xf86clearerr(XF86FILE*);
|
---|
159 | extern double xf86cos(double);
|
---|
160 | extern void xf86exit(int);
|
---|
161 | extern double xf86exp(double);
|
---|
162 | extern double xf86fabs(double);
|
---|
163 | extern int xf86fclose(XF86FILE*);
|
---|
164 | extern int xf86feof(XF86FILE*);
|
---|
165 | extern int xf86ferror(XF86FILE*);
|
---|
166 | extern int xf86fflush(XF86FILE*);
|
---|
167 | extern int xf86fgetc(XF86FILE*);
|
---|
168 | extern int xf86getc(XF86FILE*);
|
---|
169 | extern int xf86fgetpos(XF86FILE*,XF86fpos_t*);
|
---|
170 | extern char* xf86fgets(char*,INT32,XF86FILE*);
|
---|
171 | extern int xf86finite(double);
|
---|
172 | extern double xf86floor(double);
|
---|
173 | extern double xf86fmod(double,double);
|
---|
174 | extern XF86FILE* xf86fopen(const char*,const char*);
|
---|
175 | extern double xf86frexp(double, int*);
|
---|
176 | extern int xf86printf(const char*,...);
|
---|
177 | extern int xf86fprintf(XF86FILE*,const char*,...);
|
---|
178 | extern int xf86fputc(int,XF86FILE*);
|
---|
179 | extern int xf86fputs(const char*,XF86FILE*);
|
---|
180 | extern xf86size_t xf86fread(void*,xf86size_t,xf86size_t,XF86FILE*);
|
---|
181 | extern void xf86free(void*);
|
---|
182 | extern XF86FILE* xf86freopen(const char*,const char*,XF86FILE*);
|
---|
183 | #if defined(HAVE_VFSCANF) || !defined(NEED_XF86_PROTOTYPES)
|
---|
184 | extern int xf86fscanf(XF86FILE*,const char*,...);
|
---|
185 | #else
|
---|
186 | extern int xf86fscanf(/*XF86FILE*,const char*,char *,char *,char *,char *,
|
---|
187 | char *,char *,char *,char *,char *,char * */);
|
---|
188 | #endif
|
---|
189 | extern int xf86fseek(XF86FILE*,long,int);
|
---|
190 | extern int xf86fsetpos(XF86FILE*,const XF86fpos_t*);
|
---|
191 | extern long xf86ftell(XF86FILE*);
|
---|
192 | extern xf86size_t xf86fwrite(const void*,xf86size_t,xf86size_t,XF86FILE*);
|
---|
193 | extern char* xf86getenv(const char*);
|
---|
194 | extern int xf86isalnum(int);
|
---|
195 | extern int xf86isalpha(int);
|
---|
196 | extern int xf86iscntrl(int);
|
---|
197 | extern int xf86isdigit(int);
|
---|
198 | extern int xf86isgraph(int);
|
---|
199 | extern int xf86islower(int);
|
---|
200 | extern int xf86isprint(int);
|
---|
201 | extern int xf86ispunct(int);
|
---|
202 | extern int xf86isspace(int);
|
---|
203 | extern int xf86isupper(int);
|
---|
204 | extern int xf86isxdigit(int);
|
---|
205 | extern long xf86labs(long);
|
---|
206 | extern double xf86ldexp(double,int);
|
---|
207 | extern double xf86log(double);
|
---|
208 | extern double xf86log10(double);
|
---|
209 | extern void* xf86malloc(xf86size_t);
|
---|
210 | extern void* xf86memchr(const void*,int,xf86size_t);
|
---|
211 | extern int xf86memcmp(const void*,const void*,xf86size_t);
|
---|
212 | extern void* xf86memcpy(void*,const void*,xf86size_t);
|
---|
213 | extern void* xf86memmove(void*,const void*,xf86size_t);
|
---|
214 | extern void* xf86memset(void*,int,xf86size_t);
|
---|
215 | extern double xf86modf(double,double*);
|
---|
216 | extern void xf86perror(const char*);
|
---|
217 | extern double xf86pow(double,double);
|
---|
218 | extern void xf86qsort(void*, xf86size_t, xf86size_t,
|
---|
219 | int(*)(const void*, const void*));
|
---|
220 | extern void* xf86realloc(void*,xf86size_t);
|
---|
221 | extern long xf86random(void);
|
---|
222 | extern int xf86remove(const char*);
|
---|
223 | extern int xf86rename(const char*,const char*);
|
---|
224 | extern void xf86rewind(XF86FILE*);
|
---|
225 | extern int xf86setbuf(XF86FILE*,char*);
|
---|
226 | extern int xf86setvbuf(XF86FILE*,char*,int,xf86size_t);
|
---|
227 | extern double xf86sin(double);
|
---|
228 | extern int xf86sprintf(char*,const char*,...);
|
---|
229 | extern int xf86snprintf(char*,xf86size_t,const char*,...);
|
---|
230 | extern double xf86sqrt(double);
|
---|
231 | #if defined(HAVE_VSSCANF) || !defined(NEED_XF86_PROTOTYPES)
|
---|
232 | extern int xf86sscanf(char*,const char*,...);
|
---|
233 | #else
|
---|
234 | extern int xf86sscanf(/*char*,const char*,char *,char *,char *,char *,
|
---|
235 | char *,char *,char *,char *,char *,char * */);
|
---|
236 | #endif
|
---|
237 | extern char* xf86strcat(char*,const char*);
|
---|
238 | extern char* xf86strchr(const char*, int c);
|
---|
239 | extern int xf86strcmp(const char*,const char*);
|
---|
240 | extern int xf86strcasecmp(const char*,const char*);
|
---|
241 | extern char* xf86strcpy(char*,const char*);
|
---|
242 | extern xf86size_t xf86strcspn(const char*,const char*);
|
---|
243 | extern char* xf86strerror(int);
|
---|
244 | extern xf86size_t xf86strlcat(char*,const char*,xf86size_t);
|
---|
245 | extern xf86size_t xf86strlcpy(char*,const char*,xf86size_t);
|
---|
246 | extern xf86size_t xf86strlen(const char*);
|
---|
247 | extern char* xf86strncat(char *, const char *, xf86size_t);
|
---|
248 | extern int xf86strncmp(const char*,const char*,xf86size_t);
|
---|
249 | extern int xf86strncasecmp(const char*,const char*,xf86size_t);
|
---|
250 | extern char* xf86strncpy(char*,const char*,xf86size_t);
|
---|
251 | extern char* xf86strpbrk(const char*,const char*);
|
---|
252 | extern char* xf86strrchr(const char*,int);
|
---|
253 | extern xf86size_t xf86strspn(const char*,const char*);
|
---|
254 | extern char* xf86strstr(const char*,const char*);
|
---|
255 | extern double xf86strtod(const char*,char**);
|
---|
256 | extern char* xf86strtok(char*,const char*);
|
---|
257 | extern long xf86strtol(const char*,char**,int);
|
---|
258 | extern unsigned long xf86strtoul(const char*,char**,int);
|
---|
259 | extern double xf86tan(double);
|
---|
260 | extern XF86FILE* xf86tmpfile(void);
|
---|
261 | extern char* xf86tmpnam(char*);
|
---|
262 | extern int xf86tolower(int);
|
---|
263 | extern int xf86toupper(int);
|
---|
264 | extern int xf86ungetc(int,XF86FILE*);
|
---|
265 | extern int xf86vfprintf(XF86FILE*,const char*,va_list);
|
---|
266 | extern int xf86vsprintf(char*,const char*,va_list);
|
---|
267 | extern int xf86vsnprintf(char*,xf86size_t,const char*,va_list);
|
---|
268 |
|
---|
269 | extern int xf86open(const char*, int,...);
|
---|
270 | extern int xf86close(int);
|
---|
271 | extern long xf86lseek(int, long, int);
|
---|
272 | extern int xf86ioctl(int, unsigned long, pointer);
|
---|
273 | extern xf86ssize_t xf86read(int, void *, xf86size_t);
|
---|
274 | extern xf86ssize_t xf86write(int, const void *, xf86size_t);
|
---|
275 | extern void* xf86mmap(void*, xf86size_t, int, int, int, xf86size_t /* off_t */);
|
---|
276 | extern int xf86munmap(void*, xf86size_t);
|
---|
277 | extern int xf86stat(const char *, struct xf86stat *);
|
---|
278 | extern int xf86fstat(int, struct xf86stat *);
|
---|
279 | extern int xf86access(const char *, int);
|
---|
280 | extern int xf86errno;
|
---|
281 | extern int xf86GetErrno(void);
|
---|
282 |
|
---|
283 | extern double xf86HUGE_VAL;
|
---|
284 |
|
---|
285 | extern double xf86hypot(double,double);
|
---|
286 |
|
---|
287 | /* non-ANSI C functions */
|
---|
288 | extern XF86DIR* xf86opendir(const char*);
|
---|
289 | extern int xf86closedir(XF86DIR*);
|
---|
290 | extern XF86DIRENT* xf86readdir(XF86DIR*);
|
---|
291 | extern void xf86rewinddir(XF86DIR*);
|
---|
292 | extern void xf86bcopy(const void*,void*,xf86size_t);
|
---|
293 | extern int xf86ffs(int);
|
---|
294 | extern char* xf86strdup(const char*);
|
---|
295 | extern void xf86bzero(void*,unsigned int);
|
---|
296 | extern int xf86execl(const char *, const char *, ...);
|
---|
297 | extern long xf86fpossize(void);
|
---|
298 | extern int xf86chmod(const char *, xf86mode_t);
|
---|
299 | extern int xf86chown(const char *, xf86uid_t, xf86gid_t);
|
---|
300 | extern xf86uid_t xf86geteuid(void);
|
---|
301 | extern xf86gid_t xf86getegid(void);
|
---|
302 | extern int xf86getpid(void);
|
---|
303 | extern int xf86mknod(const char *, xf86mode_t, xf86dev_t);
|
---|
304 | extern int xf86mkdir(const char *, xf86mode_t);
|
---|
305 | unsigned int xf86sleep(unsigned int seconds);
|
---|
306 | /* sysv IPC */
|
---|
307 | extern int xf86shmget(xf86key_t key, int size, int xf86shmflg);
|
---|
308 | extern char * xf86shmat(int id, char *addr, int xf86shmflg);
|
---|
309 | extern int xf86shmdt(char *addr);
|
---|
310 | extern int xf86shmctl(int id, int xf86cmd, pointer buf);
|
---|
311 |
|
---|
312 | extern int xf86setjmp(xf86jmp_buf env);
|
---|
313 | extern int xf86setjmp0(xf86jmp_buf env);
|
---|
314 | extern int xf86setjmp1(xf86jmp_buf env, int);
|
---|
315 | extern int xf86setjmp1_arg2(void);
|
---|
316 | extern int xf86setjmperror(xf86jmp_buf env);
|
---|
317 | extern int xf86getjmptype(void);
|
---|
318 | extern void xf86longjmp(xf86jmp_buf env, int val);
|
---|
319 | #define xf86setjmp_macro(env) \
|
---|
320 | (xf86getjmptype() == 0 ? xf86setjmp0((env)) : \
|
---|
321 | (xf86getjmptype() == 1 ? xf86setjmp1((env), xf86setjmp1_arg2()) : \
|
---|
322 | xf86setjmperror((env))))
|
---|
323 |
|
---|
324 | #else /* XFree86LOADER || NEED_XF86_PROTOTYPES */
|
---|
325 | #include <unistd.h>
|
---|
326 | #include <stdio.h>
|
---|
327 | #include <sys/ioctl.h>
|
---|
328 | #include <errno.h>
|
---|
329 | #include <fcntl.h>
|
---|
330 | #include <ctype.h>
|
---|
331 | #ifdef HAVE_SYSV_IPC
|
---|
332 | #include <sys/ipc.h>
|
---|
333 | #include <sys/shm.h>
|
---|
334 | #endif
|
---|
335 | #include <sys/stat.h>
|
---|
336 | #define stat_t struct stat
|
---|
337 | #endif /* XFree86LOADER || NEED_XF86_PROTOTYPES */
|
---|
338 |
|
---|
339 | /*
|
---|
340 | * These things are always required by drivers (but not by libc_wrapper.c),
|
---|
341 | * even for a static server because some OSs don't provide them.
|
---|
342 | */
|
---|
343 |
|
---|
344 | extern int xf86getpagesize(void);
|
---|
345 | extern void xf86usleep(unsigned long);
|
---|
346 | extern void xf86getsecs(long *, long *);
|
---|
347 | #ifndef DONT_DEFINE_WRAPPERS
|
---|
348 | #undef getpagesize
|
---|
349 | #define getpagesize() xf86getpagesize()
|
---|
350 | #undef usleep
|
---|
351 | #define usleep(ul) xf86usleep(ul)
|
---|
352 | #undef getsecs
|
---|
353 | #define getsecs(a, b) xf86getsecs(a, b)
|
---|
354 | #endif
|
---|
355 | #endif /* _XF86_ANSIC_H */
|
---|