Windows: Build hcrypto shared library
[openafs.git] / src / crypto / hcrypto / roken.h
1 #ifndef OPENAFS_ROKEN_H
2 #define OPENAFS_ROKEN_H
3
4 #ifdef AFS_NT40_ENV
5 #include <windows.h>
6
7 #ifdef _MSC_VER
8 /* Declarations for Microsoft Visual C runtime in Windows */
9 #include <process.h>
10
11 #include <io.h>
12
13 #ifndef __BITS_TYPES_DEFINED__
14 #define __BITS_TYPES_DEFINED__
15
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;
28
29 #endif /* __BITS_TYPES_DEFINED__ */
30
31 #ifndef HAVE_SSIZE_T
32 #ifdef _WIN64
33 typedef __int64 ssize_t;
34 #else
35 typedef int ssize_t;
36 #endif
37 #endif
38
39 #endif /* _MSC_VER */
40 #endif /* AFS_NT40_ENV */
41
42 #define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x))
43
44 #ifndef min
45 #define min(a,b) (((a)<(b))?(a):(b))
46 #endif
47
48 #ifndef ROKEN_LIB_FUNCTION
49 #ifdef _WIN32
50 #define ROKEN_LIB_FUNCTION
51 #define ROKEN_LIB_CALL     __cdecl
52 #else
53 #define ROKEN_LIB_FUNCTION
54 #define ROKEN_LIB_CALL
55 #endif
56 #endif
57
58 typedef int rk_socket_t;
59
60 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
61     ct_memcmp(const void *, const void *, size_t);
62
63 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_cloexec(int);
64
65 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_cloexec_file(FILE *);
66
67 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
68     net_write (rk_socket_t, const void *, size_t);
69
70 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
71     net_read (rk_socket_t, void *, size_t);
72
73 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL issuid(void);
74
75 #ifndef HAVE_STRLCPY
76 #define strlcpy rk_strlcpy
77 ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
78     strlcpy (char *, const char *, size_t);
79 #endif
80
81 #ifndef HAVE_DIRFD
82 # ifdef HAVE_DIR_DD_FD
83 #  define dirfd(x) ((x)->dd_fd)
84 # else
85 #  ifndef _WIN32 /* Windows code never calls dirfd */
86 #   error Missing dirfd() and ->dd_fd
87 #  endif
88 # endif
89 #endif
90
91 /* This is a bodge, but it's only used by the tests */
92 #define emalloc(x) malloc(x)
93
94 #ifndef HAVE_GETPROGNAME
95 ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL getprogname(void);
96 #endif
97
98 #endif /* OPENAFS_ROKEN_H */