Merge commit 'dfc115332c94a2f62058ac7f2bce7631fbd20b3d'
[unleashed/tickless.git] / lib / libcrypto / compat / include / string.h
blob4bf7519b5be4a6ecd4b50c78f163a2602e1d5ecc
1 /*
2 * Public domain
3 * string.h compatibility shim
4 */
6 #ifndef LIBCRYPTOCOMPAT_STRING_H
7 #define LIBCRYPTOCOMPAT_STRING_H
9 #ifdef _MSC_VER
10 #if _MSC_VER >= 1900
11 #include <../ucrt/string.h>
12 #else
13 #include <../include/string.h>
14 #endif
15 #else
16 #include_next <string.h>
17 #endif
19 #include <sys/types.h>
21 #if defined(__sun) || defined(_AIX) || defined(__hpux)
22 /* Some functions historically defined in string.h were placed in strings.h by
23 * SUS. Use the same hack as OS X and FreeBSD use to work around on AIX,
24 * Solaris, and HPUX.
26 #include <strings.h>
27 #endif
29 #ifndef HAVE_STRCASECMP
30 int strcasecmp(const char *s1, const char *s2);
31 int strncasecmp(const char *s1, const char *s2, size_t len);
32 #endif
34 #ifndef HAVE_STRLCPY
35 size_t strlcpy(char *dst, const char *src, size_t siz);
36 #endif
38 #ifndef HAVE_STRLCAT
39 size_t strlcat(char *dst, const char *src, size_t siz);
40 #endif
42 #ifndef HAVE_STRNDUP
43 char * strndup(const char *str, size_t maxlen);
44 /* the only user of strnlen is strndup, so only build it if needed */
45 #ifndef HAVE_STRNLEN
46 size_t strnlen(const char *str, size_t maxlen);
47 #endif
48 #endif
50 #ifndef HAVE_STRSEP
51 char *strsep(char **stringp, const char *delim);
52 #endif
54 #ifndef HAVE_EXPLICIT_BZERO
55 void explicit_bzero(void *, size_t);
56 #endif
58 #ifndef HAVE_TIMINGSAFE_BCMP
59 int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
60 #endif
62 #ifndef HAVE_TIMINGSAFE_MEMCMP
63 int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
64 #endif
66 #ifndef HAVE_MEMMEM
67 void * memmem(const void *big, size_t big_len, const void *little,
68 size_t little_len);
69 #endif
71 #ifdef _WIN32
72 #include <errno.h>
74 static inline char *
75 posix_strerror(int errnum)
77 if (errnum == ECONNREFUSED) {
78 return "Connection refused";
80 return strerror(errnum);
83 #define strerror(errnum) posix_strerror(errnum)
85 #endif
87 #endif