Skip to content

libpwq as git submodule #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2016
Merged
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't this supposed to be upstream now, or am I confused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I did the integration with swift/utils/build-script last week I found some autotools fixes (similar issues as #34 in libdispatch) that need to get upstreamed to libpwq. I have an unmerged pull request open (mheily/libpwq#8) but in the short run I think we should go with my fork until everything is working & integrated into the swift build (there may be more fixes to libpwq that we don't know about yet).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough

9 changes: 7 additions & 2 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,17 @@ 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
./configure
cd src && dtrace -h -s provider.d
make

Note: the build currently fails building tests, but libdispatch.so should
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather write this:

if BUILD_OWN_PTHREAD_WORKQUEUES
PTHREAD_WORKQUES_SUBDIR = libpwq
else
PTHREAD_WORKQUES_SUBDIR =
endif

and add that variable in SUBDIRS, else maintaining the list below will be a pain. or is it not working?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had tried variations on this (and I tried this variation just now), but annoyingly it doesn't quite work. The autoreconf and configure steps work correctly. But in the generated top-level Makefile we end up with the SUBDIRS definition with the PTHREAD_WORKQUEUE_SUBDIR variable defined textually before PTHREAD_WORKQUEUE_SUBDIR. This causes 'make' to not recurse into libpwq and the library doesn't get built.

I'm certainly not an autotools guru, but I wasn't able to get anything to work where SUBDIRS included a conditionally defined variable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, ISTR that SUBDIRS is magical and a pain so fine. we'll live with that.

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 9faa79
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