comile lib_fiber for MacOSX

This commit is contained in:
zsx 2018-04-22 23:46:17 +08:00
parent d1ffac36cd
commit 4c1e1ae197
6 changed files with 20 additions and 2 deletions

View File

@ -76,7 +76,8 @@ endif
# For Darwin
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
CFLAGS += -DMACOSX -Wno-invalid-source-encoding \
-Wno-extended-offsetof
-Wno-extended-offsetof \
-Wno-deprecated-declarations
endif
# For Linux

View File

@ -302,7 +302,7 @@ unsigned long __pthread_self(void)
return GetCurrentThreadId();
}
#elif defined(__linux__)
#elif defined(__linux__) || defined(__APPLE__)
unsigned long __pthread_self(void)
{
return (unsigned long) pthread_self();

View File

@ -11,6 +11,12 @@
# define HAS_SELECT
# define HAS_POLL
# define HAS_KQUEUE
#elif defined(__APPLE__)
# define SYS_UNIX
# define HAS_SELECT
# define HAS_POLL
# define HAS_KQUEUE
# define _XOPEN_SOURCE
#elif defined(_WIN32) || defined(_WIN64)
# if(_MSC_VER >= 1300)
# undef FD_SETSIZE

View File

@ -485,7 +485,11 @@ int acl_fiber_yield(void)
// when switched overflows, it will be set to 0, then n saved last
// switched's value will larger than switched, so we need to use
// abs function to avoiding this problem
#if defined(__APPLE__)
return __thread_fiber->switched - n - 1;
#else
return abs(__thread_fiber->switched - n - 1);
#endif
}
int acl_fiber_ndead(void)

View File

@ -218,11 +218,13 @@ struct hostent *gethostbyname(const char *name)
return acl_fiber_gethostbyname(name);
}
#ifndef __APPLE__
int gethostbyname_r(const char *name, struct hostent *ent,
char *buf, size_t buflen, struct hostent **result, int *h_errnop)
{
return acl_fiber_gethostbyname_r(name, ent, buf, buflen,
result, h_errnop);
}
#endif
#endif /* SYS_UNIX */

View File

@ -45,6 +45,11 @@
#include <sys/resource.h>
#include <ucontext.h>
#if defined(__APPLE__)
# include <sys/types.h>
# include <sys/uio.h>
#endif
#define STRDUP strdup
#define GETPID getpid