@@ -88,11 +88,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
88
88
#define strtoull (x, y, z ) _strtoui64(x, y, z)
89
89
#define strcasecmp (x, y ) stricmp(x, y)
90
90
#define strncasecmp (x, y, n ) strnicmp(x, y, n)
91
-
92
- // We can't simply alias strlcpy() to MSVC's strcpy_s(), since strcpy_s
93
- // by default raises an assertion error and aborts the program if the
94
- // buffer is too small. So we need to define our own.
95
- #define strlcpy (x, y, n ) mystrlcpy(x, y, n)
96
91
#else
97
92
#define ALIGNOF (x ) __alignof__(x)
98
93
#endif
@@ -101,6 +96,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
101
96
#define strtok_r (x, y, z ) mystrtok_r(x, y, z)
102
97
#endif
103
98
99
+ // strlcpy is missing from glibc. thanks a lot, drepper.
100
+ // strlcpy is also missing from AIX and HP-UX because they aim to be weird.
101
+ // We can't simply alias strlcpy to MSVC's strcpy_s, since strcpy_s by
102
+ // default raises an assertion error and aborts the program if the buffer is
103
+ // too small.
104
+ #if defined(__FreeBSD__) || defined(__NetBSD__) || \
105
+ defined (__OpenBSD__) || defined(__DragonFly__) || \
106
+ defined(__APPLE__) || \
107
+ defined(__sun) || defined(sun) || \
108
+ defined(__QNX__) || defined(__QNXNTO__)
109
+ #define HAVE_STRLCPY
110
+ #endif
111
+
112
+ // So we need to define our own.
113
+ #ifndef HAVE_STRLCPY
114
+ #define strlcpy (d, s, n ) mystrlcpy(d, s, n)
115
+ #endif
116
+
104
117
#define PADDING (x, y ) ((ALIGNOF(y) - ((uintptr_t )(x) & (ALIGNOF(y) - 1 ))) & (ALIGNOF(y) - 1 ))
105
118
106
119
namespace porting
0 commit comments