]>
Commit | Line | Data |
---|---|---|
0cb2b158 TP |
1 | Fix thread detection with uClibc in timer_time.m4 |
2 | ||
3 | The timer_time.m4 gl_TIMER_TIME function determines which libraries | |
4 | need to be linked to get access to the timer function, generally -lrt | |
5 | for Linux systems. On platforms where threads are used, librt | |
6 | typically uses thread functions from libpthread. | |
7 | ||
8 | However, the test to determine whether the platform has thread or not | |
9 | is incorrect: it assumes that if the C library is uClibc, then threads | |
10 | are not available. This is actually not true: uClibc has configurable | |
11 | thread support, and when thread support is available, librt calls | |
12 | libpthread functions. | |
13 | ||
14 | This is important when static linking is used, because otherwise only | |
15 | -lrt is used at link time, which fails because librt calls undefined | |
16 | thread functions. Both -lrt and -lpthread must be passed. | |
17 | ||
18 | This problem is fixed by making the uClibc thread detection a bit | |
19 | smarter, thanks to the usage of the __HAS_NO_THREADS__ macro defined | |
20 | in <bits/uClibc_config.h>, which itself is included by <features.h>. | |
21 | ||
22 | Signed-off-by: Thomas Petazzoni <[email protected]> | |
23 | ||
24 | Index: b/m4/timer_time.m4 | |
25 | =================================================================== | |
26 | --- a/m4/timer_time.m4 | |
27 | +++ b/m4/timer_time.m4 | |
28 | @@ -28,7 +28,7 @@ | |
29 | #include <features.h> | |
30 | #ifdef __GNU_LIBRARY__ | |
31 | #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)) \ | |
32 | - && !defined __UCLIBC__ | |
33 | + && !(__UCLIBC__ && __HAS_NO_THREADS__) | |
34 | Thread emulation available | |
35 | #endif | |
36 | #endif |