Fix build for Apple/OSX.

This commit is contained in:
Josh Roesslein 2011-04-01 00:42:29 -05:00 committed by Ryan Dahl
parent 37ea7d572d
commit 3ad2274989
2 changed files with 16 additions and 1 deletions

View File

@ -13,6 +13,16 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#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_io(EV_P_ ev_io* watcher, int revents);
void ol_tcp_connect(ol_handle* handle, ol_req* req); void ol_tcp_connect(ol_handle* handle, ol_req* req);

7
ol.h
View File

@ -18,13 +18,18 @@ typedef void (*ol_connect_cb)(ol_req* req, ol_err e);
typedef void (*ol_shutdown_cb)(ol_req* req); typedef void (*ol_shutdown_cb)(ol_req* req);
#if defined(__unix__) || defined(__POSIX__) #if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)
# include "ol-unix.h" # include "ol-unix.h"
#else #else
# include "ol-win.h" # include "ol-win.h"
#endif #endif
#if !defined(__APPLE__) /* FIXME: detect during configure */
# define HAVE_STRNLEN
#endif
typedef enum { typedef enum {
OL_UNKNOWN_HANDLE = 0, OL_UNKNOWN_HANDLE = 0,
OL_TCP, OL_TCP,