Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libpwq"]
path = libpwq
url = https://github.com/dgrove-oss/libpwq.git
8 changes: 7 additions & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ Prepare your system
2. Install dtrace (to generate provider.h)
sudo apt-get install systemtap-sdt-dev
3. Install libdispatch pre-reqs
sudo apt-get install libblocksruntime-dev libkqueue-dev libpthread-workqueue-dev libbsd-dev
sudo apt-get install libblocksruntime-dev libkqueue-dev libbsd-dev

Initialize git submodules:
We are using git submodules to incorporate a specific revision of the
upstream pthread_workqueue library into the build.
git submodule init
git submodule update

Build:
sh autogen.sh
Expand Down
11 changes: 11 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@

ACLOCAL_AMFLAGS = -I m4

if BUILD_OWN_PTHREAD_WORKQUEUES
SUBDIRS= \
dispatch \
libpwq \
man \
os \
private \
src \
tests
else
SUBDIRS= \
dispatch \
man \
os \
private \
src \
tests
endif

EXTRA_DIST= \
README.md \
Expand Down
19 changes: 16 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,25 @@ AS_IF([test -n "$apple_libpthread_source_path" -a -n "$apple_xnu_source_osfmk_pa
mkdir -p mach && ln -fsh "$apple_xnu_source_osfmk_path"/mach/coalition.h mach
])
AC_CHECK_HEADERS([pthread_machdep.h pthread/qos.h])
AC_CHECK_HEADERS([pthread/workqueue_private.h pthread_workqueue.h],
[AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])

# pthread_workqueues.
# Look for own version first, then system version.
AS_IF([test -f libpwq/configure.ac],
[AC_DEFINE(BUILD_OWN_PTHREAD_WORKQUEUES, 1, [Define if building pthread work queues from source])
AC_CONFIG_SUBDIRS([libpwq])
build_own_pthread_workqueue=true,
AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])
have_pthread_workqueues=true],
[have_pthread_workqueues=false]
[build_own_pthread_workqueue=false
AC_CHECK_HEADERS([pthread/workqueue_private.h pthread_workqueue.h],
[AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])
have_pthread_workqueues=true],
[have_pthread_workqueues=false]
)]
)
AM_CONDITIONAL(BUILD_OWN_PTHREAD_WORKQUEUES, $build_own_pthread_workqueues)
AM_CONDITIONAL(HAVE_PTHREAD_WORKQUEUES, $have_pthread_workqueues)

AC_CHECK_HEADERS([libproc_internal.h], [], [], [#include <mach/mach.h>])
AC_CHECK_FUNCS([pthread_workqueue_setdispatch_np _pthread_workqueue_init])
AS_IF([test -n "$apple_libpthread_source_path" -a -n "$apple_xnu_source_osfmk_path"], [
Expand Down
1 change: 1 addition & 0 deletions libpwq
Submodule libpwq added at 0a4aa2
11 changes: 8 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,18 @@ AM_CPPFLAGS=-I$(top_builddir) -I$(top_srcdir) \

DISPATCH_CFLAGS=-Wall $(VISIBILITY_FLAGS) $(OMIT_LEAF_FP_FLAGS) \
$(MARCH_FLAGS) $(KQUEUE_CFLAGS) $(BSD_OVERLAY_CFLAGS)
AM_CFLAGS=$(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS)
AM_CFLAGS= $(PTHREAD_WORKQUEUE_CFLAGS) $(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS)
AM_OBJCFLAGS=$(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS)
AM_CXXFLAGS=$(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS)
AM_OBJCXXFLAGS=$(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS)

if HAVE_PTHREAD_WORKQUEUES
PTHREAD_WORKQUEUE_LIBS=-lpthread_workqueue
if BUILD_OWN_PTHREAD_WORKQUEUES
PTHREAD_WORKQUEUE_LIBS=../libpwq/libpthread_workqueue.la
PTHREAD_WORKQUEUE_CFLAGS=-I../libpwq/include
else
if HAVE_PTHREAD_WORKQUEUES
PTHREAD_WORKQUEUE_LIBS=-lpthread_workqueue
endif
endif

libdispatch_la_LDFLAGS=-avoid-version
Expand Down
7 changes: 3 additions & 4 deletions src/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,11 @@ struct dispatch_root_queue_context_s {
typedef struct dispatch_root_queue_context_s *dispatch_root_queue_context_t;

#define WORKQ_PRIO_INVALID (-1)
#ifdef __linux__
#ifndef WORKQ_BG_PRIOQUEUE_CONDITIONAL
#define WORKQ_BG_PRIOQUEUE_CONDITIONAL WORKQ_PRIO_INVALID
#endif
#ifndef WORKQ_HIGH_PRIOQUEUE_CONDITIONAL
#define WORKQ_HIGH_PRIOQUEUE_CONDITIONAL WORKQ_PRIO_INVALID
#else
#define WORKQ_BG_PRIOQUEUE_CONDITIONAL WORKQ_BG_PRIOQUEUE
#define WORKQ_HIGH_PRIOQUEUE_CONDITIONAL WORKQ_HIGH_PRIOQUEUE
#endif

DISPATCH_CACHELINE_ALIGN
Expand Down
6 changes: 4 additions & 2 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ AM_OBJCFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CBLOCKS_FLAGS)
AM_CXXFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CXXBLOCKS_FLAGS) $(BSD_OVERLAY_CFLAGS)
AM_OBJCXXFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CXXBLOCKS_FLAGS)

if HAVE_PTHREAD_WORKQUEUES
PTHREAD_WORKQUEUE_LIBS=-lpthread_workqueue
if !BUILD_OWN_PTHREAD_WORKQUEUES
if HAVE_PTHREAD_WORKQUEUES
PTHREAD_WORKQUEUE_LIBS=-lpthread_workqueue
endif
endif

LDADD=libbsdtests.la ../src/libdispatch.la $(KQUEUE_LIBS) $(PTHREAD_WORKQUEUE_LIBS) $(BSD_OVERLAY_LIBS)
Expand Down