Thread (4 messages) 4 messages, 3 authors, 2012-09-06

[Buildroot] json-c fix, question about -D_REENTRANT

flat view

From: Thomas Petazzoni <hidden>
Date: 2012-08-25 14:13:11

Hello,

The attached patch fixes the build of json-c when thread support is
not available. This library does not require thread support: it was
compatible with -D_REENTRANT in all cases, which is only possible when
thread support is available.

However, I didn't commit this directly, because I am not sure what the
right fix is. My fix is to just get rid of -D_REENTRANT.

However, according to
http://pauillac.inria.fr/~xleroy/linuxthreads/faq.html#H, all code
used in a multithreaded application should be built with -D_REENTRANT,
even if this code itself is not creating/manipulating threads.

So, technically, removing -D_REENTRANT seems like an incorrect: it
should be kept if the toolchain supports thread.

However, looking quickly at a number of other libraries, I don't see
any of them being careful about this. I know the -pthread gcc options
passes both the -lpthread linker option and the -D_REENTRANT compiler
option, but I don't see -pthread being used in libraries that don't
need thread support, but that may be used in a multithreaded
application.

Am I missing something?

Thanks,

Thomas
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help