diff options
author | Pete Batard <pete@akeo.ie> | 2012-06-06 10:53:43 +0100 |
---|---|---|
committer | Pete Batard <pete@akeo.ie> | 2012-06-06 10:53:43 +0100 |
commit | dd06d6004cc3f9228bbc6886b91aa53ae17afe50 (patch) | |
tree | 50099a8a927c724971f556a3f502c30a5c23b20f | |
parent | 0c089c7a1466cfad947bb8ddad69d52de76fb698 (diff) |
Linux: Fix a major regression in threads_posix.c
* On some Linux platforms, libusbx compilation breaks with:
error: implicit declaration of function ‘pthread_mutexattr_settype’
* This regression, introduced in 463dda06db5da5de0eab32820c7af60605625afe,
is due to pthread.h needing __USE_UNIX98, which is tied to _XOPEN_SOURCE
or _GNU_SOURCE being correctly defined, and which the inclusion of
<unistd.h> before the _XOPEN_SOURCE override modified
* As _GNU_LINUX ensures the definition of __USE_UNIX98 and we require it
for syscalls, we now only define _GNU_SOURCE for Linux.
-rw-r--r-- | libusb/os/threads_posix.c | 15 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 7 insertions, 10 deletions
diff --git a/libusb/os/threads_posix.c b/libusb/os/threads_posix.c index dc182b7..9769f58 100644 --- a/libusb/os/threads_posix.c +++ b/libusb/os/threads_posix.c @@ -20,6 +20,11 @@ */ #if defined(__linux__) || defined(__OpenBSD__) +# if defined(__linux__) +# define _GNU_SOURCE +# else +# define _BSD_SOURCE +# endif # include <unistd.h> # include <sys/syscall.h> #elif defined(__APPLE__) @@ -28,15 +33,6 @@ # include <windows.h> #endif -#ifdef _XOPEN_SOURCE -# if _XOPEN_SOURCE < 500 -# undef _XOPEN_SOURCE -# define _XOPEN_SOURCE 500 -# endif -#else -#define _XOPEN_SOURCE 500 -#endif /* _XOPEN_SOURCE */ - #include "threads_posix.h" int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) @@ -50,6 +46,7 @@ int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) return err; } + /* mutexattr_settype requires _GNU_SOURCE or _XOPEN_SOURCE >= 500 on Linux */ err = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE); if (err != 0) goto finish; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index f56fbab..8d7dc39 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10520 +#define LIBUSB_NANO 10521 |