diff --git a/ol-unix.c b/ol-unix.c index 6c4da65e..40307f38 100644 --- a/ol-unix.c +++ b/ol-unix.c @@ -13,6 +13,16 @@ #include #include +#if !defined(HAVE_STRNLEN) /* Implement for platforms that lack strnlen */ +size_t strnlen (register const char* s, size_t maxlen) { + register const char *e; + size_t n; + + for (e = s, n = 0; *e && n < maxlen; e++, n++); + return n; +} +#endif + void ol_tcp_io(EV_P_ ev_io* watcher, int revents); void ol_tcp_connect(ol_handle* handle, ol_req* req); diff --git a/ol.h b/ol.h index bc593cbd..bbc9eaf6 100644 --- a/ol.h +++ b/ol.h @@ -18,13 +18,18 @@ typedef void (*ol_connect_cb)(ol_req* req, ol_err e); typedef void (*ol_shutdown_cb)(ol_req* req); -#if defined(__unix__) || defined(__POSIX__) +#if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__) # include "ol-unix.h" #else # include "ol-win.h" #endif +#if !defined(__APPLE__) /* FIXME: detect during configure */ +# define HAVE_STRNLEN +#endif + + typedef enum { OL_UNKNOWN_HANDLE = 0, OL_TCP,