diff options
author | Peter Stuge <peter@stuge.se> | 2010-05-11 00:51:43 +0100 |
---|---|---|
committer | Daniel Drake <dan@reactivated.net> | 2010-05-12 22:11:29 -0300 |
commit | 23b5db8b3e353176dfa0635bfb6f0e2658f6e3de (patch) | |
tree | fa8d63b97d0ae45724eb2ebd2cc13853dae93993 /configure.ac | |
parent | a04cbb0095a78aeed3f65aaf06c46069d0ac184a (diff) | |
download | libusb-23b5db8b3e353176dfa0635bfb6f0e2658f6e3de.tar.gz |
Add internal abstraction for POSIX Threads
This prepares for a Windows backend without dependency on pthreads-w32.
pthread_* is renamed to usbi_* and PTHREAD_* to USBI_*.
A usbi_mutex_static_t and usbi_mutex_static_lock() and _unlock() are
introduced for statically initialized mutexes, since they may be
implemented using other types when pthreads mutexes aren't used.
Move -pthread from libusb/Makefile.am to host-specific THREAD_CFLAGS in
configure.ac. This will enable optional use of -lpthread for cygwin.
[dsd: minor tweaks, and roll in a change based on patches from Pete
Batard to only build dpfp_threaded example when we're using pthreads]
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 4668cf0..ba9814f 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,8 @@ case $host in AC_MSG_RESULT([Linux]) backend="linux" AC_CHECK_LIB(rt, clock_gettime) + threads="posix" + THREAD_CFLAGS="-pthread" AM_LDFLAGS="" ;; *-darwin*) @@ -28,6 +30,8 @@ case $host in AC_DEFINE(USBI_OS_HANDLES_TIMEOUT, [], [Backend handles timeout]) AC_MSG_RESULT([Darwin/MacOS X]) backend="darwin" + threads="posix" + THREAD_CFLAGS="-pthread" AM_LDFLAGS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -no-undefined" ;; *) @@ -36,6 +40,7 @@ esac AM_CONDITIONAL([OS_LINUX], [test "x$backend" == "xlinux"]) AM_CONDITIONAL([OS_DARWIN], [test "x$backend" == "xdarwin"]) +AM_CONDITIONAL([THREADS_POSIX], [test "x$threads" == "xposix"]) # Library versioning lt_major="0" @@ -120,6 +125,8 @@ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="") CFLAGS="$saved_cflags" +AC_SUBST([THREAD_CFLAGS]) + AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow" AC_SUBST(VISIBILITY_CFLAGS) |