1 #ifndef OPENAFS_ROKEN_H
2 #define OPENAFS_ROKEN_H
8 /* Declarations for Microsoft Visual C runtime in Windows */
13 #ifndef __BITS_TYPES_DEFINED__
14 #define __BITS_TYPES_DEFINED__
16 typedef __int8 int8_t;
17 typedef __int16 int16_t;
18 typedef __int32 int32_t;
19 typedef __int64 int64_t;
20 typedef unsigned __int8 uint8_t;
21 typedef unsigned __int16 uint16_t;
22 typedef unsigned __int32 uint32_t;
23 typedef unsigned __int64 uint64_t;
24 typedef uint8_t u_int8_t;
25 typedef uint16_t u_int16_t;
26 typedef uint32_t u_int32_t;
27 typedef uint64_t u_int64_t;
29 #endif /* __BITS_TYPES_DEFINED__ */
33 typedef __int64 ssize_t;
39 /* The MSVC implementation of snprintf is not C99 compliant. */
40 #define snprintf rk_snprintf
41 #define vsnprintf rk_vsnprintf
42 #define vasnprintf rk_vasnprintf
43 #define vasprintf rk_vasprintf
44 #define asnprintf rk_asnprintf
45 #define asprintf rk_asprintf
48 #endif /* AFS_NT40_ENV */
50 #define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x))
53 #define min(a,b) (((a)<(b))?(a):(b))
56 #ifndef ROKEN_LIB_FUNCTION
58 #define ROKEN_LIB_FUNCTION
59 #define ROKEN_LIB_CALL __cdecl
61 #define ROKEN_LIB_FUNCTION
62 #define ROKEN_LIB_CALL
66 #ifndef HAVE___ATTRIBUTE__
67 #define __attribute__(x)
70 typedef int rk_socket_t;
72 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
73 ct_memcmp(const void *, const void *, size_t);
75 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_cloexec(int);
77 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_cloexec_file(FILE *);
79 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
80 net_write (rk_socket_t, const void *, size_t);
82 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
83 net_read (rk_socket_t, void *, size_t);
85 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL issuid(void);
87 #if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO)
89 #define snprintf rk_snprintf
91 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
92 rk_snprintf (char *, size_t, const char *, ...)
93 __attribute__ ((format (printf, 3, 4)));
96 #if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO)
97 #ifndef HAVE_VSNPRINTF
98 #define vsnprintf rk_vsnprintf
100 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
101 rk_vsnprintf (char *, size_t, const char *, va_list)
102 __attribute__((format (printf, 3, 0)));
105 #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO)
106 #ifndef HAVE_ASPRINTF
107 #define asprintf rk_asprintf
109 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
110 rk_asprintf (char **, const char *, ...)
111 __attribute__ ((format (printf, 2, 3)));
114 #if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO)
115 #ifndef HAVE_VASPRINTF
116 #define vasprintf rk_vasprintf
118 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
119 rk_vasprintf (char **, const char *, va_list)
120 __attribute__((format (printf, 2, 0)));
123 #if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO)
124 #ifndef HAVE_ASNPRINTF
125 #define asnprintf rk_asnprintf
127 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
128 rk_asnprintf (char **, size_t, const char *, ...)
129 __attribute__ ((format (printf, 3, 4)));
132 #if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO)
133 #ifndef HAVE_VASNPRINTF
134 #define vasnprintf rk_vasnprintf
136 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
137 vasnprintf (char **, size_t, const char *, va_list)
138 __attribute__((format (printf, 3, 0)));
142 #define strlcpy rk_strlcpy
143 ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
144 strlcpy (char *, const char *, size_t);
148 # ifdef HAVE_DIR_DD_FD
149 # define dirfd(x) ((x)->dd_fd)
151 # ifndef _WIN32 /* Windows code never calls dirfd */
152 # error Missing dirfd() and ->dd_fd
157 /* This is a bodge, but it's only used by the tests */
158 #define emalloc(x) malloc(x)
160 #ifndef HAVE_GETPROGNAME
161 ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL getprogname(void);
164 #ifndef _PATH_DEVNULL
165 #define _PATH_DEVNULL "/dev/null"
169 #endif /* OPENAFS_ROKEN_H */