halayli/lthread — pull request #1 by markpeek (2011-12-24 21:10:59+00:00)
Title: Mac OS X changes

Initial changes to support MacOS X.
- Conditionalize MacOS X to use kqueue.
- Use SO_NOSIGPIPE instead of MSG_NOSIG.
- Migrate TLS to using pthread_{set,get}specific.
- Tweak swap assembly.

Compiled and minimally tested with multi-pthread test on MacOS X 10.7, FreeBSD 9, and Linux. Note: my Linux compile had this error as well and I didn't spend a lot of time looking into it. You might want to sort it out with the below patch or tweaking the gcc flags:

gcc -Werror -fPIC -g -I ../ "-g" -Wall -c lthread.c lthread_socket.c lthread_sched.c ../common/rbtree.c ../common/time.c poller.c
lthread_sched.c: In function ‘lthread_join’:
lthread_sched.c:95:9: error: variable ‘fd’ set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors

diff --git a/src/lthread_sched.c b/src/lthread_sched.c
index 10bfdac..2cf361c 100644
--- a/src/lthread_sched.c
+++ b/src/lthread_sched.c
@@ -92,7 +92,6 @@ lthread_join()
sched_t *sched;
lthread_t *lt = NULL, *lttmp = NULL;
int p = 0;
- int fd = 0;

sched = lthread_get_sched();

@@ -117,7 +116,7 @@ lthread_join()
/* 4. fire up lthreads that are ready to run */
while (sched->total_new_events) {
p = --sched->total_new_events;
- fd = get_fd(&sched->eventlist[p]);
+ get_fd(&sched->eventlist[p]);
lt = (lthread_t *)get_data(&sched->eventlist[p]);
if (lt == NULL)
assert(0);