Skip to content

Commit e7ca00f

Browse files
committed
Merge pull request apple#13 from KatashiMonosato/port-transform-and-use-libbsd
Port transform and use libbsd
2 parents b2ccfeb + b850646 commit e7ca00f

19 files changed

+72
-90
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ config.status
2828
config
2929
configure
3030
libtool
31-
31+
.dirstamp

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
#
@@ -241,7 +248,7 @@ AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
241248
AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])
242249
AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/mount.h>]])
243250
AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
244-
AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sysconf getprogname])
251+
AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sysconf])
245252

246253
AC_CHECK_DECLS([POSIX_SPAWN_START_SUSPENDED],
247254
[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
};

private/voucher_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ dispatch_queue_create_with_accounting_override_voucher(const char *label,
404404

405405
#ifdef __APPLE__
406406
#include <mach/mach.h>
407-
#endif
408407

409408
/*!
410409
* @function voucher_create_with_mach_msg
@@ -428,6 +427,7 @@ OS_VOUCHER_EXPORT OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT OS_NOTHROW
428427
voucher_t
429428
voucher_create_with_mach_msg(mach_msg_header_t *msg);
430429

430+
#endif
431431
__END_DECLS
432432

433433
#endif // __OS_VOUCHER_PRIVATE__

src/Makefile.am

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ 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_LDFLAGS=-avoid-version
60-
libdispatch_la_LIBADD=$(KQUEUE_LIBS) $(PTHREAD_WORKQUEUE_LIBS)
61-
6259
if HAVE_PTHREAD_WORKQUEUES
6360
PTHREAD_WORKQUEUE_LIBS=-lpthread_workqueue
6461
endif
6562

63+
libdispatch_la_LDFLAGS=-avoid-version
64+
libdispatch_la_LIBADD=$(KQUEUE_LIBS) $(PTHREAD_WORKQUEUE_LIBS) $(BSD_OVERLAY_LIBS)
65+
6666
if HAVE_DARWIN_LD
6767
libdispatch_la_LDFLAGS+=-Wl,-compatibility_version,1 \
6868
-Wl,-current_version,$(VERSION) -Wl,-dead_strip \

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/init.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ DISPATCH_VTABLE_INSTANCE(source,
335335
.do_debug = _dispatch_source_debug,
336336
);
337337

338+
#if HAVE_MACH
338339
DISPATCH_VTABLE_INSTANCE(mach,
339340
.do_type = DISPATCH_MACH_CHANNEL_TYPE,
340341
.do_kind = "mach-channel",
@@ -351,6 +352,7 @@ DISPATCH_VTABLE_INSTANCE(mach_msg,
351352
.do_invoke = _dispatch_mach_msg_invoke,
352353
.do_debug = _dispatch_mach_msg_debug,
353354
);
355+
#endif
354356

355357
#if !USE_OBJC
356358
DISPATCH_VTABLE_INSTANCE(data,
@@ -793,6 +795,7 @@ _dispatch_client_callout2(void *ctxt, size_t i, void (*f)(void *, size_t))
793795
_dispatch_set_unwind_tsd(u);
794796
}
795797

798+
#if HAVE_MACH
796799
#undef _dispatch_client_callout4
797800
void
798801
_dispatch_client_callout4(void *ctxt, dispatch_mach_reason_t reason,
@@ -807,6 +810,7 @@ _dispatch_client_callout4(void *ctxt, dispatch_mach_reason_t reason,
807810
_dispatch_free_unwind_tsd();
808811
_dispatch_set_unwind_tsd(u);
809812
}
813+
#endif
810814

811815
#endif // DISPATCH_USE_CLIENT_CALLOUT
812816

src/inline_internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ DISPATCH_NOTHROW void
3838
_dispatch_client_callout(void *ctxt, dispatch_function_t f);
3939
DISPATCH_NOTHROW void
4040
_dispatch_client_callout2(void *ctxt, size_t i, void (*f)(void *, size_t));
41+
#if HAVE_MACH
4142
DISPATCH_NOTHROW void
4243
_dispatch_client_callout4(void *ctxt, dispatch_mach_reason_t reason,
4344
dispatch_mach_msg_t dmsg, mach_error_t error,
4445
dispatch_mach_handler_function_t f);
46+
#endif
4547

4648
#else // !DISPATCH_USE_CLIENT_CALLOUT
4749

@@ -59,6 +61,7 @@ _dispatch_client_callout2(void *ctxt, size_t i, void (*f)(void *, size_t))
5961
return f(ctxt, i);
6062
}
6163

64+
#if HAVE_MACH
6265
DISPATCH_ALWAYS_INLINE
6366
static inline void
6467
_dispatch_client_callout4(void *ctxt, dispatch_mach_reason_t reason,
@@ -67,6 +70,7 @@ _dispatch_client_callout4(void *ctxt, dispatch_mach_reason_t reason,
6770
{
6871
return f(ctxt, reason, dmsg, error);
6972
}
73+
#endif
7074

7175
#endif // !DISPATCH_USE_CLIENT_CALLOUT
7276

src/internal.h

Lines changed: 1 addition & 5 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>
@@ -328,10 +324,10 @@ DISPATCH_NOINLINE
328324
void _dispatch_bug_client(const char* msg);
329325
DISPATCH_NOINLINE
330326
void _dispatch_bug_mach_client(const char *msg, mach_msg_return_t kr);
327+
#endif
331328
DISPATCH_NOINLINE
332329
void _dispatch_bug_kevent_client(const char* msg, const char* filter,
333330
const char *operation, int err);
334-
#endif
335331

336332
DISPATCH_NOINLINE DISPATCH_NORETURN
337333
void _dispatch_abort(size_t line, long val);

0 commit comments

Comments
 (0)