No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / iscsi / dist / include / compat.h
blob5194d244f13666730a35c57fb3240cfe883ce1ff
1 #ifndef COMPAT_H_
2 #define COMPAT_H_
4 #include "config.h"
6 #include <sys/types.h>
8 #ifdef HAVE_STDINT_H
9 #include <stdint.h>
10 #endif
12 #ifdef HAVE_ASM_BYTEORDER_H
13 #include <asm/byteorder.h>
14 #endif
16 #ifdef HAVE_SYS_BYTEORDER_H
17 # include <sys/byteorder.h>
18 # if defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
19 # undef _BIG_ENDIAN
20 # define _BIG_ENDIAN 4321
21 # define _BYTE_ORDER _BIG_ENDIAN
22 # elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
23 # undef _LITTLE_ENDIAN
24 # define _LITTLE_ENDIAN 1234
25 # define _BYTE_ORDER _LITTLE_ENDIAN
26 # endif
27 #endif
29 #ifdef HAVE_BYTESWAP_H
30 #include <byteswap.h>
31 #endif
33 #ifdef HAVE_MACHINE_ENDIAN_H
34 #include <machine/endian.h>
35 #endif
37 #ifdef HAVE_LIBKERN_OSBYTEORDER_H
38 #include <libkern/OSByteOrder.h>
39 #endif
41 #ifndef HAVE_STRLCPY
42 size_t strlcpy(char *, const char *, size_t);
43 #endif
45 #ifndef __UNCONST
46 #define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
47 #endif
49 #ifdef HAVE_HTOBE64
50 # define ISCSI_HTOBE64(x) htobe64(x)
51 # define ISCSI_BE64TOH(x) be64toh(x)
52 #else
53 # if defined(HAVE_LIBKERN_OSBYTEORDER_H)
54 # define ISCSI_HTOBE64(x) (x) = OSSwapBigToHostInt64((u_int64_t)(x))
55 # elif _BYTE_ORDER == _BIG_ENDIAN
56 # define ISCSI_HTOBE64(x) (x)
57 # elif defined(HAVE___BSWAP64)
58 # define ISCSI_HTOBE64(x) (x) = __bswap64((u_int64_t)(x))
59 # else /* LITTLE_ENDIAN */
60 # define ISCSI_HTOBE64(x) (((uint64_t)(ISCSI_NTOHL((uint32_t)(((x) << 32) >> 32))) << 32) | (uint32_t)ISCSI_NTOHL(((uint32_t)((x) >> 32))))
61 # endif /* LITTLE_ENDIAN */
62 # define ISCSI_BE64TOH(x) ISCSI_HTOBE64(x)
63 #endif
65 #ifndef _DIAGASSERT
66 # ifndef __static_cast
67 # define __static_cast(x,y) (x)y
68 # endif
69 #define _DIAGASSERT(e) (__static_cast(void,0))
70 #endif
72 /* Added for busybox, which doesn't define INFTIM */
73 #ifndef INFTIM
74 #define INFTIM -1
75 #endif
77 #endif /* COMPAT_H_ */