halayli / lthread

lthread, a multicore enabled coroutine library written in C
Other
814 stars 82 forks source link

Mac OS X changes #1

Closed markpeek closed 12 years ago

markpeek commented 12 years ago

Initial changes to support MacOS X.

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;

@@ -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;

halayli commented 12 years ago

Merging Mark's OSX changes

halayli commented 12 years ago

Great!

Merged it, and all is well so far. memqueue uses lthread and it seems to be working fine.

I modified the Makefile to include -lpthread, it was erroring on linux.

On Dec 24, 2011, at 1:11 PM, Mark Peek wrote:

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);

You can merge this Pull Request by running:

git pull https://github.com/markpeek/lthread macosxchanges

Or you can view, comment on it, or merge it online at:

https://github.com/halayli/lthread/pull/1

-- Commit Summary --

  • Initial changes to support MacOS X.
  • Linux changes to migrate TLS to using pthread_{set,get}specific.

-- File Changes --

M src/epoll.c (5) M src/kqueue.c (4) M src/lthread.c (93) M src/lthread_int.h (14) M src/lthread_sched.c (10) M src/lthread_socket.c (33) M src/poller.c (2) M src/poller.h (2)

-- Patch Links --

https://github.com/halayli/lthread/pull/1.patch https://github.com/halayli/lthread/pull/1.diff


Reply to this email directly or view it on GitHub: https://github.com/halayli/lthread/pull/1