tsystem.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* Get common system includes and various definitions and declarations
  2. based on target macros.
  3. Copyright (C) 2000-2019 Free Software Foundation, Inc.
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify it under
  6. the terms of the GNU General Public License as published by the Free
  7. Software Foundation; either version 3, or (at your option) any later
  8. version.
  9. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. for more details.
  13. Under Section 7 of GPL version 3, you are granted additional
  14. permissions described in the GCC Runtime Library Exception, version
  15. 3.1, as published by the Free Software Foundation.
  16. You should have received a copy of the GNU General Public License and
  17. a copy of the GCC Runtime Library Exception along with this program;
  18. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. <http://www.gnu.org/licenses/>. */
  20. #ifndef GCC_TSYSTEM_H
  21. #define GCC_TSYSTEM_H
  22. /* System headers (e.g. stdio.h, stdlib.h, unistd.h) sometimes
  23. indirectly include getopt.h. Our -I flags will cause gcc's gnu
  24. getopt.h to be included, not the platform's copy. In the default
  25. case, gnu getopt.h will provide us with a no-argument prototype
  26. which will generate -Wstrict-prototypes warnings. None of the
  27. target files actually use getopt, so it is safe to tell gnu
  28. getopt.h we never need this prototype. */
  29. #ifndef HAVE_DECL_GETOPT
  30. #define HAVE_DECL_GETOPT 1
  31. #endif
  32. /* We want everything from the glibc headers. */
  33. #define _GNU_SOURCE 1
  34. /* GCC supplies these headers. */
  35. #include <stddef.h>
  36. #include <float.h>
  37. #ifdef inhibit_libc
  38. #ifndef malloc
  39. extern void *malloc (size_t);
  40. #endif
  41. #ifndef free
  42. extern void free (void *);
  43. #endif
  44. #ifndef atexit
  45. extern int atexit (void (*)(void));
  46. #endif
  47. #ifndef abort
  48. extern void abort (void) __attribute__ ((__noreturn__));
  49. #endif
  50. #ifndef strlen
  51. extern size_t strlen (const char *);
  52. #endif
  53. #ifndef memcpy
  54. extern void *memcpy (void *, const void *, size_t);
  55. #endif
  56. #ifndef memset
  57. extern void *memset (void *, int, size_t);
  58. #endif
  59. #else /* ! inhibit_libc */
  60. /* We disable this when inhibit_libc, so that gcc can still be built without
  61. needing header files first. */
  62. /* ??? This is not a good solution, since prototypes may be required in
  63. some cases for correct code. */
  64. /* GCC supplies this header. */
  65. #include <stdarg.h>
  66. /* All systems have this header. */
  67. #include <stdio.h>
  68. /* All systems have this header. */
  69. #include <sys/types.h>
  70. /* All systems have this header. */
  71. #include <errno.h>
  72. #ifndef errno
  73. extern int errno;
  74. #endif
  75. /* If these system headers do not exist, fixincludes must create them. */
  76. #include <string.h>
  77. #include <stdlib.h>
  78. #include <unistd.h>
  79. /* GCC supplies this header. */
  80. #include <limits.h>
  81. /* If these system headers do not exist, fixincludes must create them. */
  82. #include <time.h>
  83. #endif /* inhibit_libc */
  84. /* Define a generic NULL if one hasn't already been defined. */
  85. #ifndef NULL
  86. #define NULL 0
  87. #endif
  88. /* GCC always provides __builtin_alloca(x). */
  89. #undef alloca
  90. #define alloca(x) __builtin_alloca(x)
  91. #ifdef ENABLE_RUNTIME_CHECKING
  92. #define gcc_assert(EXPR) ((void)(!(EXPR) ? abort (), 0 : 0))
  93. #else
  94. /* Include EXPR, so that unused variable warnings do not occur. */
  95. #define gcc_assert(EXPR) ((void)(0 && (EXPR)))
  96. #endif
  97. /* Use gcc_unreachable() to mark unreachable locations (like an
  98. unreachable default case of a switch. Do not use gcc_assert(0). */
  99. #define gcc_unreachable() (abort ())
  100. #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
  101. #define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X))
  102. /* Filename handling macros. */
  103. #include "filenames.h"
  104. #endif /* ! GCC_TSYSTEM_H */