OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [config/] [stdint.m4] - Blame information for rev 280

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
dnl @synopsis GCC_HEADER_STDINT [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])]
2
dnl
3
dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
4
dnl existence of an include file <stdint.h> that defines a set of
5
dnl typedefs, especially uint8_t,int32_t,uintptr_t.
6
dnl Many older installations will not provide this file, but some will
7
dnl have the very same definitions in <inttypes.h>. In other enviroments
8
dnl we can use the inet-types in <sys/types.h> which would define the
9
dnl typedefs int8_t and u_int8_t respectivly.
10
dnl
11
dnl This macros will create a local "_stdint.h" or the headerfile given as
12
dnl an argument. In many cases that file will pick the definition from a
13
dnl "#include <stdint.h>" or "#include <inttypes.h>" statement, while
14
dnl in other environments it will provide the set of basic 'stdint's defined:
15
dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
16
dnl int_least32_t.. int_fast32_t.. intmax_t
17
dnl which may or may not rely on the definitions of other files.
18
dnl
19
dnl Sometimes the stdint.h or inttypes.h headers conflict with sys/types.h,
20
dnl so we test the headers together with sys/types.h and always include it
21
dnl into the generated header (to match the tests with the generated file).
22
dnl Hopefully this is not a big annoyance.
23
dnl
24
dnl If your installed header files require the stdint-types you will want to
25
dnl create an installable file mylib-int.h that all your other installable
26
dnl header may include. So, for a library package named "mylib", just use
27
dnl      GCC_HEADER_STDINT(mylib-int.h)
28
dnl in configure.in and install that header file in Makefile.am along with
29
dnl the other headers (mylib.h).  The mylib-specific headers can simply
30
dnl use "#include <mylib-int.h>" to obtain the stdint-types.
31
dnl
32
dnl Remember, if the system already had a valid <stdint.h>, the generated
33
dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
34
dnl
35
dnl @author  Guido Draheim <guidod@gmx.de>, Paolo Bonzini <bonzini@gnu.org>
36
 
37
AC_DEFUN([GCC_HEADER_STDINT],
38
[m4_define(_GCC_STDINT_H, m4_ifval($1, $1, _stdint.h))
39
 
40
inttype_headers=`echo inttypes.h sys/inttypes.h $2 | sed -e 's/,/ /g'`
41
 
42
acx_cv_header_stdint=stddef.h
43
acx_cv_header_stdint_kind="(already complete)"
44
for i in stdint.h $inttype_headers; do
45
  unset ac_cv_type_uintptr_t
46
  unset ac_cv_type_uintmax_t
47
  unset ac_cv_type_int_least32_t
48
  unset ac_cv_type_int_fast32_t
49
  unset ac_cv_type_uint64_t
50
  _AS_ECHO_N([looking for a compliant stdint.h in $i, ])
51
  AC_CHECK_TYPE(uintmax_t,[acx_cv_header_stdint=$i],continue,[#include <sys/types.h>
52
#include <$i>])
53
  AC_CHECK_TYPE(uintptr_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include <sys/types.h>
54
#include <$i>])
55
  AC_CHECK_TYPE(int_least32_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include <sys/types.h>
56
#include <$i>])
57
  AC_CHECK_TYPE(int_fast32_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include <sys/types.h>
58
#include <$i>])
59
  AC_CHECK_TYPE(uint64_t,,[acx_cv_header_stdint_kind="(lacks uint64_t)"], [#include <sys/types.h>
60
#include <$i>])
61
  break
62
done
63
if test "$acx_cv_header_stdint" = stddef.h; then
64
  acx_cv_header_stdint_kind="(lacks uintmax_t)"
65
  for i in stdint.h $inttype_headers; do
66
    unset ac_cv_type_uintptr_t
67
    unset ac_cv_type_uint32_t
68
    unset ac_cv_type_uint64_t
69
    _AS_ECHO_N([looking for an incomplete stdint.h in $i, ])
70
    AC_CHECK_TYPE(uint32_t,[acx_cv_header_stdint=$i],continue,[#include <sys/types.h>
71
#include <$i>])
72
    AC_CHECK_TYPE(uint64_t,,,[#include <sys/types.h>
73
#include <$i>])
74
    AC_CHECK_TYPE(uintptr_t,,,[#include <sys/types.h>
75
#include <$i>])
76
    break
77
  done
78
fi
79
if test "$acx_cv_header_stdint" = stddef.h; then
80
  acx_cv_header_stdint_kind="(u_intXX_t style)"
81
  for i in sys/types.h $inttype_headers; do
82
    unset ac_cv_type_u_int32_t
83
    unset ac_cv_type_u_int64_t
84
    _AS_ECHO_N([looking for u_intXX_t types in $i, ])
85
    AC_CHECK_TYPE(u_int32_t,[acx_cv_header_stdint=$i],continue,[#include <sys/types.h>
86
#include <$i>])
87
    AC_CHECK_TYPE(u_int64_t,,,[#include <sys/types.h>
88
#include <$i>])
89
    break
90
  done
91
fi
92
if test "$acx_cv_header_stdint" = stddef.h; then
93
  acx_cv_header_stdint_kind="(using manual detection)"
94
fi
95
 
96
test -z "$ac_cv_type_uintptr_t" && ac_cv_type_uintptr_t=no
97
test -z "$ac_cv_type_uint64_t" && ac_cv_type_uint64_t=no
98
test -z "$ac_cv_type_u_int64_t" && ac_cv_type_u_int64_t=no
99
test -z "$ac_cv_type_int_least32_t" && ac_cv_type_int_least32_t=no
100
test -z "$ac_cv_type_int_fast32_t" && ac_cv_type_int_fast32_t=no
101
 
102
# ----------------- Summarize what we found so far
103
 
104
AC_MSG_CHECKING([what to include in _GCC_STDINT_H])
105
 
106
case `AS_BASENAME(_GCC_STDINT_H)` in
107
  stdint.h) AC_MSG_WARN([are you sure you want it there?]) ;;
108
  inttypes.h) AC_MSG_WARN([are you sure you want it there?]) ;;
109
  *) ;;
110
esac
111
 
112
AC_MSG_RESULT($acx_cv_header_stdint $acx_cv_header_stdint_kind)
113
 
114
# ----------------- done included file, check C basic types --------
115
 
116
# Lacking an uintptr_t?  Test size of void *
117
case "$acx_cv_header_stdint:$ac_cv_type_uintptr_t" in
118
  stddef.h:* | *:no) AC_CHECK_SIZEOF(void *) ;;
119
esac
120
 
121
# Lacking an uint64_t?  Test size of long
122
case "$acx_cv_header_stdint:$ac_cv_type_uint64_t:$ac_cv_type_u_int64_t" in
123
  stddef.h:*:* | *:no:no) AC_CHECK_SIZEOF(long) ;;
124
esac
125
 
126
if test $acx_cv_header_stdint = stddef.h; then
127
  # Lacking a good header?  Test size of everything and deduce all types.
128
  AC_CHECK_SIZEOF(int)
129
  AC_CHECK_SIZEOF(short)
130
  AC_CHECK_SIZEOF(char)
131
 
132
  AC_MSG_CHECKING(for type equivalent to int8_t)
133
  case "$ac_cv_sizeof_char" in
134
    1) acx_cv_type_int8_t=char ;;
135
    *) AC_MSG_ERROR(no 8-bit type, please report a bug)
136
  esac
137
  AC_MSG_RESULT($acx_cv_type_int8_t)
138
 
139
  AC_MSG_CHECKING(for type equivalent to int16_t)
140
  case "$ac_cv_sizeof_int:$ac_cv_sizeof_short" in
141
    2:*) acx_cv_type_int16_t=int ;;
142
    *:2) acx_cv_type_int16_t=short ;;
143
    *) AC_MSG_ERROR(no 16-bit type, please report a bug)
144
  esac
145
  AC_MSG_RESULT($acx_cv_type_int16_t)
146
 
147
  AC_MSG_CHECKING(for type equivalent to int32_t)
148
  case "$ac_cv_sizeof_int:$ac_cv_sizeof_long" in
149
    4:*) acx_cv_type_int32_t=int ;;
150
    *:4) acx_cv_type_int32_t=long ;;
151
    *) AC_MSG_ERROR(no 32-bit type, please report a bug)
152
  esac
153
  AC_MSG_RESULT($acx_cv_type_int32_t)
154
fi
155
 
156
# These tests are here to make the output prettier
157
 
158
if test "$ac_cv_type_uint64_t" != yes && test "$ac_cv_type_u_int64_t" != yes; then
159
  case "$ac_cv_sizeof_long" in
160
    8) acx_cv_type_int64_t=long ;;
161
  esac
162
  AC_MSG_CHECKING(for type equivalent to int64_t)
163
  AC_MSG_RESULT(${acx_cv_type_int64_t-'using preprocessor symbols'})
164
fi
165
 
166
# Now we can use the above types
167
 
168
if test "$ac_cv_type_uintptr_t" != yes; then
169
  AC_MSG_CHECKING(for type equivalent to intptr_t)
170
  case $ac_cv_sizeof_void_p in
171
    2) acx_cv_type_intptr_t=int16_t ;;
172
    4) acx_cv_type_intptr_t=int32_t ;;
173
    8) acx_cv_type_intptr_t=int64_t ;;
174
    *) AC_MSG_ERROR(no equivalent for intptr_t, please report a bug)
175
  esac
176
  AC_MSG_RESULT($acx_cv_type_intptr_t)
177
fi
178
 
179
# ----------------- done all checks, emit header -------------
180
AC_CONFIG_COMMANDS(_GCC_STDINT_H, [
181
if test "$GCC" = yes; then
182
  echo "/* generated for " `$CC --version | sed 1q` "*/" > tmp-stdint.h
183
else
184
  echo "/* generated for $CC */" > tmp-stdint.h
185
fi
186
 
187
sed 's/^ *//' >> tmp-stdint.h <<EOF
188
 
189
  #ifndef GCC_GENERATED_STDINT_H
190
  #define GCC_GENERATED_STDINT_H 1
191
 
192
  #include <sys/types.h>
193
EOF
194
 
195
if test "$acx_cv_header_stdint" != stdint.h; then
196
  echo "#include <stddef.h>" >> tmp-stdint.h
197
fi
198
if test "$acx_cv_header_stdint" != stddef.h; then
199
  echo "#include <$acx_cv_header_stdint>" >> tmp-stdint.h
200
fi
201
 
202
sed 's/^ *//' >> tmp-stdint.h <<EOF
203
  /* glibc uses these symbols as guards to prevent redefinitions.  */
204
  #ifdef __int8_t_defined
205
  #define _INT8_T
206
  #define _INT16_T
207
  #define _INT32_T
208
  #endif
209
  #ifdef __uint32_t_defined
210
  #define _UINT32_T
211
  #endif
212
 
213
EOF
214
 
215
# ----------------- done header, emit basic int types -------------
216
if test "$acx_cv_header_stdint" = stddef.h; then
217
  sed 's/^ *//' >> tmp-stdint.h <<EOF
218
 
219
    #ifndef _UINT8_T
220
    #define _UINT8_T
221
    #ifndef __uint8_t_defined
222
    #define __uint8_t_defined
223
    typedef unsigned $acx_cv_type_int8_t uint8_t;
224
    #endif
225
    #endif
226
 
227
    #ifndef _UINT16_T
228
    #define _UINT16_T
229
    #ifndef __uint16_t_defined
230
    #define __uint16_t_defined
231
    typedef unsigned $acx_cv_type_int16_t uint16_t;
232
    #endif
233
    #endif
234
 
235
    #ifndef _UINT32_T
236
    #define _UINT32_T
237
    #ifndef __uint32_t_defined
238
    #define __uint32_t_defined
239
    typedef unsigned $acx_cv_type_int32_t uint32_t;
240
    #endif
241
    #endif
242
 
243
    #ifndef _INT8_T
244
    #define _INT8_T
245
    #ifndef __int8_t_defined
246
    #define __int8_t_defined
247
    typedef $acx_cv_type_int8_t int8_t;
248
    #endif
249
    #endif
250
 
251
    #ifndef _INT16_T
252
    #define _INT16_T
253
    #ifndef __int16_t_defined
254
    #define __int16_t_defined
255
    typedef $acx_cv_type_int16_t int16_t;
256
    #endif
257
    #endif
258
 
259
    #ifndef _INT32_T
260
    #define _INT32_T
261
    #ifndef __int32_t_defined
262
    #define __int32_t_defined
263
    typedef $acx_cv_type_int32_t int32_t;
264
    #endif
265
    #endif
266
EOF
267
elif test "$ac_cv_type_u_int32_t" = yes; then
268
  sed 's/^ *//' >> tmp-stdint.h <<EOF
269
 
270
    /* int8_t int16_t int32_t defined by inet code, we do the u_intXX types */
271
    #ifndef _INT8_T
272
    #define _INT8_T
273
    #endif
274
    #ifndef _INT16_T
275
    #define _INT16_T
276
    #endif
277
    #ifndef _INT32_T
278
    #define _INT32_T
279
    #endif
280
 
281
    #ifndef _UINT8_T
282
    #define _UINT8_T
283
    #ifndef __uint8_t_defined
284
    #define __uint8_t_defined
285
    typedef u_int8_t uint8_t;
286
    #endif
287
    #endif
288
 
289
    #ifndef _UINT16_T
290
    #define _UINT16_T
291
    #ifndef __uint16_t_defined
292
    #define __uint16_t_defined
293
    typedef u_int16_t uint16_t;
294
    #endif
295
    #endif
296
 
297
    #ifndef _UINT32_T
298
    #define _UINT32_T
299
    #ifndef __uint32_t_defined
300
    #define __uint32_t_defined
301
    typedef u_int32_t uint32_t;
302
    #endif
303
    #endif
304
EOF
305
else
306
  sed 's/^ *//' >> tmp-stdint.h <<EOF
307
 
308
    /* Some systems have guard macros to prevent redefinitions, define them.  */
309
    #ifndef _INT8_T
310
    #define _INT8_T
311
    #endif
312
    #ifndef _INT16_T
313
    #define _INT16_T
314
    #endif
315
    #ifndef _INT32_T
316
    #define _INT32_T
317
    #endif
318
    #ifndef _UINT8_T
319
    #define _UINT8_T
320
    #endif
321
    #ifndef _UINT16_T
322
    #define _UINT16_T
323
    #endif
324
    #ifndef _UINT32_T
325
    #define _UINT32_T
326
    #endif
327
EOF
328
fi
329
 
330
# ------------- done basic int types, emit int64_t types ------------
331
if test "$ac_cv_type_uint64_t" = yes; then
332
  sed 's/^ *//' >> tmp-stdint.h <<EOF
333
 
334
    /* system headers have good uint64_t and int64_t */
335
    #ifndef _INT64_T
336
    #define _INT64_T
337
    #endif
338
    #ifndef _UINT64_T
339
    #define _UINT64_T
340
    #endif
341
EOF
342
elif test "$ac_cv_type_u_int64_t" = yes; then
343
  sed 's/^ *//' >> tmp-stdint.h <<EOF
344
 
345
    /* system headers have an u_int64_t (and int64_t) */
346
    #ifndef _INT64_T
347
    #define _INT64_T
348
    #endif
349
    #ifndef _UINT64_T
350
    #define _UINT64_T
351
    #ifndef __uint64_t_defined
352
    #define __uint64_t_defined
353
    typedef u_int64_t uint64_t;
354
    #endif
355
    #endif
356
EOF
357
elif test -n "$acx_cv_type_int64_t"; then
358
  sed 's/^ *//' >> tmp-stdint.h <<EOF
359
 
360
    /* architecture has a 64-bit type, $acx_cv_type_int64_t */
361
    #ifndef _INT64_T
362
    #define _INT64_T
363
    typedef $acx_cv_type_int64_t int64_t;
364
    #endif
365
    #ifndef _UINT64_T
366
    #define _UINT64_T
367
    #ifndef __uint64_t_defined
368
    #define __uint64_t_defined
369
    typedef unsigned $acx_cv_type_int64_t uint64_t;
370
    #endif
371
    #endif
372
EOF
373
else
374
  sed 's/^ *//' >> tmp-stdint.h <<EOF
375
 
376
    /* some common heuristics for int64_t, using compiler-specific tests */
377
    #if defined __STDC_VERSION__ && (__STDC_VERSION__-0) >= 199901L
378
    #ifndef _INT64_T
379
    #define _INT64_T
380
    #ifndef __int64_t_defined
381
    typedef long long int64_t;
382
    #endif
383
    #endif
384
    #ifndef _UINT64_T
385
    #define _UINT64_T
386
    typedef unsigned long long uint64_t;
387
    #endif
388
 
389
    #elif defined __GNUC__ && defined (__STDC__) && __STDC__-0
390
    /* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
391
       does not implement __extension__.  But that compiler doesn't define
392
       __GNUC_MINOR__.  */
393
    # if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
394
    # define __extension__
395
    # endif
396
 
397
    # ifndef _INT64_T
398
    # define _INT64_T
399
    __extension__ typedef long long int64_t;
400
    # endif
401
    # ifndef _UINT64_T
402
    # define _UINT64_T
403
    __extension__ typedef unsigned long long uint64_t;
404
    # endif
405
 
406
    #elif !defined __STRICT_ANSI__
407
    # if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
408
 
409
    #  ifndef _INT64_T
410
    #  define _INT64_T
411
    typedef __int64 int64_t;
412
    #  endif
413
    #  ifndef _UINT64_T
414
    #  define _UINT64_T
415
    typedef unsigned __int64 uint64_t;
416
    #  endif
417
    # endif /* compiler */
418
 
419
    #endif /* ANSI version */
420
EOF
421
fi
422
 
423
# ------------- done int64_t types, emit intptr types ------------
424
if test "$ac_cv_type_uintptr_t" != yes; then
425
  sed 's/^ *//' >> tmp-stdint.h <<EOF
426
 
427
    /* Define intptr_t based on sizeof(void*) = $ac_cv_sizeof_void_p */
428
    #ifndef __uintptr_t_defined
429
    typedef u$acx_cv_type_intptr_t uintptr_t;
430
    #endif
431
    #ifndef __intptr_t_defined
432
    typedef $acx_cv_type_intptr_t  intptr_t;
433
    #endif
434
EOF
435
fi
436
 
437
# ------------- done intptr types, emit int_least types ------------
438
if test "$ac_cv_type_int_least32_t" != yes; then
439
  sed 's/^ *//' >> tmp-stdint.h <<EOF
440
 
441
    /* Define int_least types */
442
    typedef int8_t     int_least8_t;
443
    typedef int16_t    int_least16_t;
444
    typedef int32_t    int_least32_t;
445
    #ifdef _INT64_T
446
    typedef int64_t    int_least64_t;
447
    #endif
448
 
449
    typedef uint8_t    uint_least8_t;
450
    typedef uint16_t   uint_least16_t;
451
    typedef uint32_t   uint_least32_t;
452
    #ifdef _UINT64_T
453
    typedef uint64_t   uint_least64_t;
454
    #endif
455
EOF
456
fi
457
 
458
# ------------- done intptr types, emit int_fast types ------------
459
if test "$ac_cv_type_int_fast32_t" != yes; then
460
  dnl NOTE: The following code assumes that sizeof (int) > 1.
461
  dnl Fix when strange machines are reported.
462
  sed 's/^ *//' >> tmp-stdint.h <<EOF
463
 
464
    /* Define int_fast types.  short is often slow */
465
    typedef int8_t       int_fast8_t;
466
    typedef int          int_fast16_t;
467
    typedef int32_t      int_fast32_t;
468
    #ifdef _INT64_T
469
    typedef int64_t      int_fast64_t;
470
    #endif
471
 
472
    typedef uint8_t      uint_fast8_t;
473
    typedef unsigned int uint_fast16_t;
474
    typedef uint32_t     uint_fast32_t;
475
    #ifdef _UINT64_T
476
    typedef uint64_t     uint_fast64_t;
477
    #endif
478
EOF
479
fi
480
 
481
if test "$ac_cv_type_uintmax_t" != yes; then
482
  sed 's/^ *//' >> tmp-stdint.h <<EOF
483
 
484
    /* Define intmax based on what we found */
485
    #ifdef _INT64_T
486
    typedef int64_t       intmax_t;
487
    #else
488
    typedef long          intmax_t;
489
    #endif
490
    #ifdef _UINT64_T
491
    typedef uint64_t      uintmax_t;
492
    #else
493
    typedef unsigned long uintmax_t;
494
    #endif
495
EOF
496
fi
497
 
498
sed 's/^ *//' >> tmp-stdint.h <<EOF
499
 
500
  #endif /* GCC_GENERATED_STDINT_H */
501
EOF
502
 
503
if test -r ]_GCC_STDINT_H[ && cmp -s tmp-stdint.h ]_GCC_STDINT_H[; then
504
  rm -f tmp-stdint.h
505
else
506
  mv -f tmp-stdint.h ]_GCC_STDINT_H[
507
fi
508
 
509
], [
510
GCC="$GCC"
511
CC="$CC"
512
acx_cv_header_stdint="$acx_cv_header_stdint"
513
acx_cv_type_int8_t="$acx_cv_type_int8_t"
514
acx_cv_type_int16_t="$acx_cv_type_int16_t"
515
acx_cv_type_int32_t="$acx_cv_type_int32_t"
516
acx_cv_type_int64_t="$acx_cv_type_int64_t"
517
acx_cv_type_intptr_t="$acx_cv_type_intptr_t"
518
ac_cv_type_uintmax_t="$ac_cv_type_uintmax_t"
519
ac_cv_type_uintptr_t="$ac_cv_type_uintptr_t"
520
ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
521
ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
522
ac_cv_type_u_int32_t="$ac_cv_type_u_int32_t"
523
ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
524
ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
525
ac_cv_sizeof_void_p="$ac_cv_sizeof_void_p"
526
])
527
 
528
])

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.