]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/system.h
Fix Irix6 EH failures, was broken by mips16 patch.
[thirdparty/gcc.git] / gcc / system.h
CommitLineData
aca69483
KG
1/* system.h - Get common system includes and various definitions and
2 declarations based on autoconf macros.
3 Copyright (C) 1998 Free Software Foundation, Inc.
4
5 */
6
7#ifndef __GCC_SYSTEM_H__
8#define __GCC_SYSTEM_H__
9
10#include <stdio.h>
11#include <ctype.h>
12
13/* Jim Meyering writes:
14
15 "... Some ctype macros are valid only for character codes that
16 isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
17 using /bin/cc or gcc but without giving an ansi option). So, all
18 ctype uses should be through macros like ISPRINT... If
19 STDC_HEADERS is defined, then autoconf has verified that the ctype
20 macros don't need to be guarded with references to isascii. ...
21 Defining isascii to 1 should let any compiler worth its salt
22 eliminate the && through constant folding."
23
24 Bruno Haible adds:
25
26 "... Furthermore, isupper(c) etc. have an undefined result if c is
27 outside the range -1 <= c <= 255. One is tempted to write isupper(c)
28 with c being of type `char', but this is wrong if c is an 8-bit
29 character >= 128 which gets sign-extended to a negative value.
30 The macro ISUPPER protects against this as well." */
31
32#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
33# define IN_CTYPE_DOMAIN(c) 1
34#else
35# define IN_CTYPE_DOMAIN(c) isascii(c)
36#endif
37
38#ifdef isblank
39# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
40#else
41# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
42#endif
43#ifdef isgraph
44# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c))
45#else
46# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c))
47#endif
48
49#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
50#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
51#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
52#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
53#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
54#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
55#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
56#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
57#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
58#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
59
60/* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
61 - Its arg may be any int or unsigned int; it need not be an unsigned char.
62 - It's guaranteed to evaluate its argument exactly once.
63 - It's typically faster.
64 Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
65 only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless
66 it's important to use the locale's definition of `digit' even when the
67 host does not conform to Posix. */
68#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
69
70
71#include <sys/types.h>
72#include <sys/stat.h>
73#include <errno.h>
74
75#ifndef errno
76extern int errno;
77#endif
78
79#ifdef HAVE_STRING_H
80# include <string.h>
81#else
82# ifdef HAVE_STRINGS_H
83# include <strings.h>
84# endif
85#endif
86
87#ifdef HAVE_STDLIB_H
88# include <stdlib.h>
89#endif
90
91#ifdef HAVE_UNISTD_H
92# include <unistd.h>
93#endif
94
95#ifdef HAVE_SYS_PARAM_H
96# include <sys/param.h>
97#endif
98
99#if HAVE_LIMITS_H
100# include <limits.h>
101#endif
102
103#ifdef TIME_WITH_SYS_TIME
104# include <sys/time.h>
105# include <time.h>
106#else
107# if HAVE_SYS_TIME_H
108# include <sys/time.h>
109# else
110# include <time.h>
111#endif
112#endif
113
114#ifdef HAVE_FCNTL_H
115# include <fcntl.h>
116#else
117# include <sys/file.h>
118#endif
119
120#ifndef SEEK_SET
121# define SEEK_SET 0
122# define SEEK_CUR 1
123# define SEEK_END 2
124#endif
125#ifndef F_OK
126# define F_OK 0
127# define X_OK 1
128# define W_OK 2
129# define R_OK 4
130#endif
131
132
133
134#ifndef bcopy
135# ifdef HAVE_BCOPY
136# ifdef NEED_DECLARATION_BCOPY
137void bcopy ();
138# endif
139# else /* ! HAVE_BCOPY */
140# define bcopy(src,dst,len) memcpy ((dst),(src),(len))
141# endif
142#endif
143
144#ifndef bcmp
145# ifdef HAVE_BCMP
146# ifdef NEED_DECLARATION_BCMP
147void bcmp ();
148# endif
149# else /* ! HAVE_BCMP */
150# define bcmp(left,right,len) memcmp ((left),(right),(len))
151# endif
152#endif
153
154#ifndef bzero
155# ifdef HAVE_BZERO
156# ifdef NEED_DECLARATION_BZERO
157void bzero ();
158# endif
159# else /* ! HAVE_BZERO */
160# define bzero(dst,len) memset ((dst),0,(len))
161# endif
162#endif
163
164#ifndef index
165# ifdef HAVE_INDEX
166# ifdef NEED_DECLARATION_INDEX
167extern char *index ();
168# endif
169# else /* ! HAVE_INDEX */
170# define index strchr
171# endif
172#endif
173
174#ifndef rindex
175# ifdef HAVE_RINDEX
176# ifdef NEED_DECLARATION_RINDEX
177extern char *rindex ();
178# endif
179# else /* ! HAVE_RINDEX */
180# define rindex strrchr
181# endif
182#endif
183
184#ifdef NEED_DECLARATION_FREE
185extern void free ();
186#endif
187
188#endif /* __GCC_SYSTEM_H__ */