Thu May 21 13:14:25 1998 John Metzler <jmetzler@cygnus.com>
[deliverable/binutils-gdb.git] / gdb / rdi-share / host.h
1 /*
2 * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved.
3 *
4 * This software may be freely used, copied, modified, and distributed
5 * provided that the above copyright notice is preserved in all copies of the
6 * software.
7 */
8
9
10 #ifndef _host_LOADED
11 #define _host_LOADED 1
12
13 #include <stdio.h>
14 #include <stddef.h>
15 #include <stdlib.h>
16
17 #ifndef SEEK_SET
18 # define SEEK_SET 0
19 #endif
20 #ifndef SEEK_CUR
21 # define SEEK_CUR 1
22 #endif
23 #ifndef SEEK_END
24 # define SEEK_END 2
25 #endif
26
27 /* The following for the benefit of compiling on SunOS */
28 #ifndef offsetof
29 # define offsetof(T, member) ((char *)&(((T *)0)->member) - (char *)0)
30 #endif
31
32 #ifdef unix /* A temporary sop to older compilers */
33 # ifndef __unix /* (good for long-term portability?) */
34 # define __unix 1
35 # endif
36 #endif
37
38 #ifdef __unix
39 /* Generic unix -- hopefully a split into other variants will not be */
40 /* needed. However, beware the 'bsd' test above and safe_toupper etc. */
41 /* which cope with backwards (pre-posix/X/open) unix compatility. */
42 # define COMPILING_ON_UNIX 1
43 #endif
44 #if defined(_WIN32)
45 # define COMPILING_ON_WIN32 1
46 # if !defined(__CYGWIN32__)
47 # define COMPILING_ON_WINDOWS 1
48 # endif
49 #endif
50 #if defined(_CONSOLE)
51 # define COMPILING_ON_WINDOWS_CONSOLE 1
52 # define COMPILING_ON_WINDOWS 1
53 #endif
54 #ifdef _MSC_VER
55 # define COMPILING_ON_MSDOS 1
56 # define COMPILING_ON_WINDOWS 1
57 # if defined(__cplusplus)
58 # define IMPLEMENT_BOOL_AS_INT 1 /* VC++ doesn't have 'bool' (yet) */
59 # endif
60 #endif
61 /* The '(defined(__sparc) && defined(P_tmpdir) */
62 /* && !defined(__svr4__))' is to detect gcc on SunOS. */
63 /* C++ compilers don't have to define __STDC__ */
64 #if (defined(__sparc) && defined(P_tmpdir))
65 # if defined(__svr4__)
66 # define COMPILING_ON_SOLARIS
67 # else
68 # define COMPILING_ON_SUNOS
69 # endif
70 #endif
71 #ifdef __hppa
72 # define COMPILING_ON_HPUX
73 #endif
74
75 /*
76 * The following typedefs may need alteration for obscure host machines.
77 */
78 #if defined(__alpha) && defined(__osf__) /* =========================== */
79 /* Under OSF the alpha has 64-bit pointers and 64-bit longs. */
80 typedef int int32;
81 typedef unsigned int unsigned32;
82 /* IPtr and UPtr are 'ints of same size as pointer'. Do not use in */
83 /* new code. Currently only used within 'ncc'. */
84 typedef long int IPtr;
85 typedef unsigned long int UPtr;
86
87 #else /* all hosts except alpha under OSF ============================= */
88
89 typedef long int int32;
90 typedef unsigned long int unsigned32;
91 /* IPtr and UPtr are 'ints of same size as pointer'. Do not use in */
92 /* new code. Currently only used within 'ncc'. */
93 #define IPtr int32
94 #define UPtr unsigned32
95 #endif /* ============================================================= */
96
97 typedef short int int16;
98 typedef unsigned short int unsigned16;
99 typedef signed char int8;
100 typedef unsigned char unsigned8;
101
102 /* The following code defines the 'bool' type to be 'int' under C */
103 /* and real 'bool' under C++. It also avoids warnings such as */
104 /* C++ keyword 'bool' used as identifier. It can be overridden by */
105 /* defining IMPLEMENT_BOOL_AS_ENUM or IMPLEMENT_BOOL_AS_INT. */
106 #undef _bool
107
108 #ifdef IMPLEMENT_BOOL_AS_ENUM
109 enum _bool { _false, _true };
110 # define _bool enum _bool
111 #elif defined(IMPLEMENT_BOOL_AS_INT) || !defined(__cplusplus)
112 # define _bool int
113 # define _false 0
114 # define _true 1
115 #endif
116
117 #ifdef _bool
118 # if defined(_MFC_VER) || defined(__CC_NORCROFT) /* When using MS Visual C/C++ v4.2 */
119 # define bool _bool /* avoids "'bool' is reserved word" warning */
120 # else
121 typedef _bool bool;
122 # endif
123 # define true _true
124 # define false _false
125 #endif
126
127 #define YES true
128 #define NO false
129 #undef TRUE /* some OSF headers define as 1 */
130 #define TRUE true
131 #undef FALSE /* some OSF headers define as 1 */
132 #define FALSE false
133
134 /* 'uint' conflicts with some Unixen sys/types.h, so we now don't define it */
135 typedef unsigned8 uint8;
136 typedef unsigned16 uint16;
137 typedef unsigned32 uint32;
138
139 typedef unsigned Uint;
140 typedef unsigned8 Uint8;
141 typedef unsigned16 Uint16;
142 typedef unsigned32 Uint32;
143
144 #ifdef ALPHA_TASO_SHORT_ON_OSF /* was __alpha && __osf. */
145 /* The following sets ArgvType for 64-bit pointers so that */
146 /* DEC Unix (OSF) cc can be used with the -xtaso_short compiler option */
147 /* to force pointers to be 32-bit. Not currently used since most/all */
148 /* ARM tools accept 32 or 64 bit pointers transparently. See IPtr. */
149 #pragma pointer_size (save)
150 #pragma pointer_size (long)
151 typedef char *ArgvType;
152 #pragma pointer_size (restore)
153 #else
154 typedef char *ArgvType;
155 #endif
156
157 /*
158 * Rotate macros
159 */
160 #define ROL_32(val, n) \
161 ((((unsigned32)(val) << (n)) | ((unsigned32)(val) >> (32-(n)))) & 0xFFFFFFFFL)
162 #define ROR_32(val, n) \
163 ((((unsigned32)(val) >> (n)) | ((unsigned32)(val) << (32-(n)))) & 0xFFFFFFFFL)
164
165 #ifdef COMPILING_ON_UNIX
166 # define FOPEN_WB "w"
167 # define FOPEN_RB "r"
168 # define FOPEN_RWB "r+"
169 # ifndef __STDC__ /* caveat RISCiX... */
170 # define remove(file) unlink(file) /* a horrid hack, but probably best? */
171 # endif
172 #else
173 # define FOPEN_WB "wb"
174 # define FOPEN_RB "rb"
175 # define FOPEN_RWB "rb+"
176 #endif
177
178 #ifndef FILENAME_MAX
179 # define FILENAME_MAX 256
180 #endif
181
182 #if (!defined(__STDC__) && !defined(__cplusplus) && !defined(_MSC_VER)) || \
183 defined(COMPILING_ON_SUNOS)
184 /* Use bcopy rather than memmove, as memmove is not available. */
185 /* There does not seem to be a header for bcopy. */
186 void bcopy(const char *src, char *dst, int length);
187 # define memmove(d,s,l) bcopy(s,d,l)
188
189 /* BSD/SUN don't have strtoul(), but then strtol() doesn't barf on */
190 /* overflow as required by ANSI... This bodge is horrid. */
191 # define strtoul(s, ptr, base) strtol(s, ptr, base)
192
193 /* strtod is present in the C-library but is not in stdlib.h */
194 extern double strtod(const char *str, char **ptr);
195 #endif
196
197 /* For systems that do not define EXIT_SUCCESS and EXIT_FAILURE */
198 #ifndef EXIT_SUCCESS
199 # define EXIT_SUCCESS 0
200 #endif
201 #ifndef EXIT_FAILURE
202 # define EXIT_FAILURE 1
203 #endif
204
205 #ifndef IGNORE
206 #define IGNORE(x) (x = x) /* Silence compiler warnings for unused arguments */
207 #endif
208
209 /* Define endian-ness of host */
210
211 #if defined(__acorn) || defined(__mvs) || defined(_WIN32) || \
212 (defined(__alpha) && defined(__osf__))
213 # define HOST_ENDIAN_LITTLE
214 #elif defined(__sparc) || defined(macintosh)
215 # define HOST_ENDIAN_BIG
216 #else
217 # define HOST_ENDIAN_UNKNOWN
218 #endif
219
220 #endif
221
222 /* end of host.h */
This page took 0.032807 seconds and 4 git commands to generate.