+#ifdef _MSC_VER
+ #define ALIGNOF(x) __alignof(x)
+ #define strtok_r(x, y, z) strtok_s(x, y, z)
+ #define strtof(x, y) (float)strtod(x, y)
+ #define strtoll(x, y, z) _strtoi64(x, y, z)
+ #define strtoull(x, y, z) _strtoui64(x, y, z)
+ #define strcasecmp(x, y) stricmp(x, y)
+ #define strncasecmp(x, y, n) strnicmp(x, y, n)
+#else
+ #define ALIGNOF(x) __alignof__(x)
+#endif
+
+#ifdef __MINGW32__
+ #define strtok_r(x, y, z) mystrtok_r(x, y, z)
+#endif
+
+// strlcpy is missing from glibc. thanks a lot, drepper.
+// strlcpy is also missing from AIX and HP-UX because they aim to be weird.
+// We can't simply alias strlcpy to MSVC's strcpy_s, since strcpy_s by
+// default raises an assertion error and aborts the program if the buffer is
+// too small.
+#if defined(__FreeBSD__) || defined(__NetBSD__) || \
+ defined(__OpenBSD__) || defined(__DragonFly__) || \
+ defined(__APPLE__) || \
+ defined(__sun) || defined(sun) || \
+ defined(__QNX__) || defined(__QNXNTO__)
+ #define HAVE_STRLCPY
+#endif
+
+// So we need to define our own.
+#ifndef HAVE_STRLCPY
+ #define strlcpy(d, s, n) mystrlcpy(d, s, n)
+#endif
+
+#define PADDING(x, y) ((ALIGNOF(y) - ((uintptr_t)(x) & (ALIGNOF(y) - 1))) & (ALIGNOF(y) - 1))
+
+#if defined(__APPLE__)
+ #include <mach-o/dyld.h>
+ #include <CoreFoundation/CoreFoundation.h>
+#endif
+
+#ifndef _WIN32 // Posix
+ #include <sys/time.h>
+ #include <time.h>
+ #if defined(__MACH__) && defined(__APPLE__)
+ #include <mach/clock.h>
+ #include <mach/mach.h>
+ #endif
+#endif
+