Skip to content

Commit 94b0fe8

Browse files
Linux has libbsd which provides an overlay that has all we need
1 parent 508d625 commit 94b0fe8

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

INSTALL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Prepare your system
109109
2. Install dtrace (to generate provider.h)
110110
sudo apt-get install systemtap-sdt-dev
111111
3. Install libdispatch pre-reqs
112-
sudo apt-get install libblocksruntime-dev libkqueue-dev libpthread-workqueue-dev
112+
sudo apt-get install libblocksruntime-dev libkqueue-dev libpthread-workqueue-dev libbsd-dev
113113

114114
Build:
115115
sh autogen.sh

configure.ac

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ AC_CHECK_HEADER(sys/event.h, [],
140140
[PKG_CHECK_MODULES(KQUEUE, libkqueue)]
141141
)
142142

143+
AC_CHECK_FUNCS([strlcpy getprogname], [],
144+
[PKG_CHECK_MODULES(BSD_OVERLAY, libbsd-overlay,[
145+
AC_DEFINE(HAVE_STRLCPY, 1, [])
146+
AC_DEFINE(HAVE_GETPROGNAME, 1, [])
147+
])], [#include <string.h>]
148+
)
149+
143150
#
144151
# Checks for header files.
145152
#
@@ -238,7 +245,7 @@ AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
238245
AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])
239246
AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/mount.h>]])
240247
AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
241-
AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sysconf getprogname])
248+
AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sysconf])
242249

243250
AC_CHECK_DECLS([POSIX_SPAWN_START_SUSPENDED],
244251
[have_posix_spawn_start_suspended=true], [have_posix_spawn_start_suspended=false],

os/linux_base.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ typedef void (*dispatch_mach_handler_function_t)(void*, dispatch_mach_reason_t,
7070

7171
typedef void (*dispatch_mach_msg_destructor_t)(void*);
7272

73-
typedef uint32_t voucher_activity_mode_t;
74-
7573
struct voucher_offsets_s {
7674
uint32_t vo_version;
7775
};

src/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ AM_CPPFLAGS=-I$(top_builddir) -I$(top_srcdir) \
5050
-I$(top_srcdir)/private -I$(top_srcdir)/os
5151

5252
DISPATCH_CFLAGS=-Wall $(VISIBILITY_FLAGS) $(OMIT_LEAF_FP_FLAGS) \
53-
$(MARCH_FLAGS) $(KQUEUE_CFLAGS)
53+
$(MARCH_FLAGS) $(KQUEUE_CFLAGS) $(BSD_OVERLAY_CFLAGS)
5454
AM_CFLAGS=$(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS)
5555
AM_OBJCFLAGS=$(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS)
5656
AM_CXXFLAGS=$(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS)
5757
AM_OBJCXXFLAGS=$(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS)
5858

59+
libdispatch_la_LIBADD = $(BSD_OVERLAY_LIBS)
5960
libdispatch_la_LDFLAGS=-avoid-version
6061

6162
if HAVE_DARWIN_LD

src/allocator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ _dispatch_malloc_init(void)
676676
malloc_set_zone_name(_dispatch_ccache_zone, "DispatchContinuations");
677677
}
678678
#else
679-
static inline void _dispatch_malloc_init(void) {}
679+
#define _dispatch_malloc_init() ((void)0)
680680
#endif // DISPATCH_USE_MALLOCZONE
681681

682682
static dispatch_continuation_t

src/internal.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,7 @@ DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
208208
#if !TARGET_OS_WIN32
209209
#include <sys/event.h>
210210
#include <sys/mount.h>
211-
#ifdef __linux__
212-
#include <shims/sys_queue.h>
213-
#else
214211
#include <sys/queue.h>
215-
#endif
216212
#include <sys/sysctl.h>
217213
#include <sys/socket.h>
218214
#include <sys/time.h>

src/shims/hw_config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ static inline uint32_t
8181
_dispatch_hw_get_config(_dispatch_hw_config_t c)
8282
{
8383
uint32_t val = 1;
84+
#if defined(__linux__)
85+
switch (c) {
86+
case _dispatch_hw_config_logical_cpus:
87+
case _dispatch_hw_config_physical_cpus:
88+
return sysconf(_SC_NPROCESSORS_CONF);
89+
case _dispatch_hw_config_active_cpus:
90+
return sysconf(_SC_NPROCESSORS_ONLN);
91+
}
92+
#else
8493
const char *name = NULL;
8594
int r;
8695
#if defined(__APPLE__)
@@ -106,6 +115,7 @@ _dispatch_hw_get_config(_dispatch_hw_config_t c)
106115
if (r > 0) val = (uint32_t)r;
107116
#endif
108117
}
118+
#endif
109119
return val;
110120
}
111121

src/shims/linux_stubs.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
#include <config/config.h>
2929

3030
#include "pthread.h"
31-
32-
#define program_invocation_short_name "hi"
33-
3431
#include "os/linux_base.h"
3532
#include "internal.h"
3633

@@ -63,7 +60,6 @@ unsigned long _dispatch_runloop_queue_probe(dispatch_queue_t dq) {
6360
}
6461
void _dispatch_runloop_queue_xref_dispose() { LINUX_PORT_ERROR(); }
6562

66-
void strlcpy() { LINUX_PORT_ERROR(); }
6763
void _dispatch_runloop_queue_dispose() { LINUX_PORT_ERROR(); }
6864
char* mach_error_string(mach_msg_return_t x) {
6965
LINUX_PORT_ERROR();
@@ -79,11 +75,6 @@ mach_port_t mach_task_self() {
7975
return (mach_port_t)pthread_self();
8076
}
8177

82-
int sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
83-
void *newp, size_t newlen) {
84-
LINUX_PORT_ERROR();
85-
}
86-
8778
/*
8879
* Stubbed out static data
8980
*/

src/shims/linux_stubs.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
#ifndef __DISPATCH__STUBS__INTERNAL
2323
#define __DISPATCH__STUBS__INTERNAL
2424

25-
int sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
26-
void *newp, size_t newlen);
27-
2825
mach_port_t pthread_mach_thread_np();
2926

3027
mach_port_t mach_task_self();

0 commit comments

Comments
 (0)