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