porting.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* Misc system-specific crap */
  2. #ifndef _PORTING_H_
  3. #define _PORTING_H_
  4. #ifdef HAVE_CONFIG_H
  5. #include <config.h>
  6. #endif
  7. #include <ctype.h>
  8. #include <dirent.h>
  9. #include <errno.h>
  10. #include <fcntl.h>
  11. #include <limits.h>
  12. #include <stdarg.h>
  13. #include <stdint.h>
  14. #include <stdio.h>
  15. #include <string.h>
  16. #include <strings.h>
  17. #include <stdlib.h>
  18. #include <unistd.h>
  19. #include <sys/param.h>
  20. #include <sys/stat.h>
  21. #include <sys/types.h>
  22. #ifdef __LDSO_LDD_SUPPORT__
  23. # include <sys/wait.h>
  24. #endif
  25. #if defined(_WIN32) || defined(_WINNT)
  26. # include "mmap-windows.c"
  27. #else
  28. # include <sys/mman.h>
  29. #endif
  30. #ifdef BUILDING_LINKAGE
  31. #include <link.h>
  32. /* makefile will include elf.h for us */
  33. #include "bswap.h"
  34. #include "dl-defs.h"
  35. #endif
  36. /* __WORDSIZE ist used for __ELF_NATIVE_CLASS, which is used for ElfW().
  37. We want to provide the wordsize of the target, not of the host, when
  38. compiling readelf.host
  39. */
  40. #include <link.h>
  41. #ifdef ARCH_NATIVE_BIT
  42. #undef __WORDSIZE
  43. #define __WORDSIZE ARCH_NATIVE_BIT
  44. #endif
  45. #ifdef DMALLOC
  46. #include <dmalloc.h>
  47. #endif
  48. #ifndef ARRAY_SIZE
  49. # define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
  50. #endif
  51. /* For SunOS */
  52. #ifndef PATH_MAX
  53. #define PATH_MAX _POSIX_PATH_MAX
  54. #endif
  55. #ifndef UCLIBC_RUNTIME_PREFIX
  56. # define UCLIBC_RUNTIME_PREFIX "/"
  57. #endif
  58. #undef UCLIBC_ENDIAN_HOST
  59. #define UCLIBC_ENDIAN_LITTLE 1234
  60. #define UCLIBC_ENDIAN_BIG 4321
  61. #if defined(BYTE_ORDER)
  62. # if BYTE_ORDER == LITTLE_ENDIAN
  63. # define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_LITTLE
  64. # elif BYTE_ORDER == BIG_ENDIAN
  65. # define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_BIG
  66. # endif
  67. #elif defined(__BYTE_ORDER)
  68. # if __BYTE_ORDER == __LITTLE_ENDIAN
  69. # define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_LITTLE
  70. # elif __BYTE_ORDER == __BIG_ENDIAN
  71. # define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_BIG
  72. # endif
  73. #endif
  74. #if !defined(UCLIBC_ENDIAN_HOST)
  75. # error "Unknown host byte order!"
  76. #endif
  77. #if defined __GNUC__ || defined __ICC
  78. # define attribute_noreturn __attribute__ ((__noreturn__))
  79. #else
  80. # define attribute_noreturn
  81. #endif
  82. #endif