sustrik / libdill

Structured concurrency in C
MIT License
1.68k stars 156 forks source link

On Cygwin compiling ctx.c fails - impossible to determine the main thread #201

Open arjenmarkus opened 4 years ago

arjenmarkus commented 4 years ago

Apparently the Cygwin platform is not supported as compiling ctx.c results in:

CC libdill_la-stack.lo CC libdill_la-ctx.lo ctx.c:102:2: error: #error "Cannot determine which thread is the main thread."

error "Cannot determine which thread is the main thread."

^~~~~ ctx.c: In function ‘dill_ctx_term’: ctx.c:123:8: warning: implicit declaration of function ‘dill_ismain’; did you mean ‘dill_clean’? [-Wimplicit-function-declaration] if(dill_ismain()) dill_main = NULL; ^~~ dill_clean make[1]: *** [Makefile:1729: libdill_la-ctx.lo] Error 1

Is there any workaround for this? Some research brought up the function pthread_equal() as the portable way to compare thread IDs. Of course, this would mean that some initialisation is required to make sure the ID of the main thread is stored. (For the moment my naïve workaround to use pthread_self() as with the __sun case works for my current very limited use case, connecting programs via TCP.)