xquartz: Remove check for libdispatch now that we don't support pre-SnowLeopard

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
This commit is contained in:
Jeremy Huddleston Sequoia 2021-01-27 13:09:50 -08:00
parent 5ad4910272
commit f699aac2ea
7 changed files with 1 additions and 229 deletions

View File

@ -684,10 +684,6 @@ case $host_os in
fi
fi
AC_CHECK_FUNC(dispatch_async,
AC_DEFINE([HAVE_LIBDISPATCH], 1, [Define to 1 if you have the libdispatch (GCD) available]),
[])
if test "x$XQUARTZ" = xyes ; then
XQUARTZ=yes
XVFB=no

View File

@ -64,11 +64,9 @@ xpbproxy_run(void);
#define XSERVER_VERSION "?"
#endif
#ifdef HAVE_LIBDISPATCH
#include <dispatch/dispatch.h>
static dispatch_queue_t eventTranslationQueue;
#endif
#ifndef __has_feature
#define __has_feature(x) 0
@ -486,13 +484,9 @@ message_kit_thread(SEL selector, NSObject *arg)
if (for_appkit) [super sendEvent:e];
if (for_x) {
#ifdef HAVE_LIBDISPATCH
dispatch_async(eventTranslationQueue, ^{
[self sendX11NSEvent:e];
});
#else
[self sendX11NSEvent:e];
#endif
}
}
@ -1225,11 +1219,9 @@ X11ApplicationMain(int argc, char **argv, char **envp)
aquaMenuBarHeight = NSHeight([primaryScreen frame]) - NSMaxY([primaryScreen visibleFrame]);
}
#ifdef HAVE_LIBDISPATCH
eventTranslationQueue = dispatch_queue_create(
BUNDLE_ID_PREFIX ".X11.NSEventsToX11EventsQueue", NULL);
assert(eventTranslationQueue != NULL);
#endif
/* Set the key layout seed before we start the server */
last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();

View File

@ -31,7 +31,6 @@
#include <dix-config.h>
#else
#define DEBUG_CONSOLE_REDIRECT 1
#define HAVE_LIBDISPATCH 1
#endif
#include <assert.h>
@ -49,22 +48,10 @@
#define BUF_SIZE 512
#ifdef HAVE_LIBDISPATCH
#include <dispatch/dispatch.h>
static dispatch_queue_t redirect_serial_q;
static dispatch_group_t read_source_group;
#else
#include <pthread.h>
static pthread_t redirect_pthread;
static pthread_mutex_t redirect_fds_lock = PTHREAD_MUTEX_INITIALIZER;
static int kq;
/* Notifications to our reader thread */
#define ASL_REDIRECT_TERMINATE ((void *)(uintptr_t)1)
#endif
typedef struct {
int level;
@ -75,9 +62,7 @@ typedef struct {
char *buf;
char *w;
#ifdef HAVE_LIBDISPATCH
dispatch_source_t read_source;
#endif
} asl_redirect;
static asl_redirect *redirect_fds = NULL;
@ -153,7 +138,6 @@ _read_redirect(int fd, int flush)
return total_read;
}
#ifdef HAVE_LIBDISPATCH
static void
read_from_source(void *_source)
{
@ -181,79 +165,6 @@ cancel_source(void *_source)
dispatch_group_leave(read_source_group);
}
#else /* !HAVE_LIBDISPATCH */
static void *
redirect_thread(void *ctx __unused)
{
struct kevent ev;
int n;
while (1) {
n = kevent(kq, NULL, 0, &ev, 1, NULL);
/* Bail on errors */
if (n < 0) {
asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent failure: %s",
strerror(errno));
break;
}
/* This should not happen */
if (n == 0)
continue;
switch (ev.filter) {
case EVFILT_READ:
pthread_mutex_lock(&redirect_fds_lock);
{
int fd = ev.ident;
int close_fd = 0;
asl_redirect *aslr = &redirect_fds[fd];
if (fd < 0 || fd >= n_redirect_fds || aslr->buf == NULL) {
asl_log(NULL, NULL, ASL_LEVEL_ERR,
"Unexpected file descriptor: %d",
fd);
goto next;
}
if (ev.flags & EV_EOF) {
close_fd = 1;
if (EOF != _read_redirect(fd, 1)) {
asl_log(
NULL, NULL, ASL_LEVEL_ERR,
"kevent reported EOF on %d, but read doesn't concur.",
fd);
}
}
else {
close_fd = (EOF == _read_redirect(fd, 0));
}
if (close_fd) {
EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0);
kevent(kq, &ev, 1, NULL, 0, NULL);
close(fd);
free(aslr->buf);
memset(aslr, 0, sizeof(*aslr));
}
}
next:
pthread_mutex_unlock(&redirect_fds_lock);
case EVFILT_TIMER:
if (ev.udata == ASL_REDIRECT_TERMINATE)
return NULL;
default:
;
;
}
}
return NULL;
}
#endif
static void
redirect_atexit(void)
@ -262,7 +173,6 @@ redirect_atexit(void)
if (redirect_fds[STDOUT_FILENO].buf)
fflush(stdout);
#ifdef HAVE_LIBDISPATCH
{
int i;
@ -276,42 +186,19 @@ redirect_atexit(void)
dispatch_time(DISPATCH_TIME_NOW, 3LL *
NSEC_PER_SEC));
}
#else
{
struct kevent ev;
/* Tell our reader thread it is time to pack up and go home */
EV_SET(&ev, 0, EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, 0,
ASL_REDIRECT_TERMINATE);
kevent(kq, &ev, 1, NULL, 0, NULL);
pthread_join(redirect_pthread, NULL);
}
#endif
}
#ifdef HAVE_LIBDISPATCH
static void
xq_asl_init(void *ctx __unused)
#else
static void
xq_asl_init(void)
#endif
{
assert((redirect_fds = calloc(16, sizeof(*redirect_fds))) != NULL);
n_redirect_fds = 16;
#ifdef HAVE_LIBDISPATCH
redirect_serial_q = dispatch_queue_create("com.apple.asl-redirect", NULL);
assert(redirect_serial_q != NULL);
read_source_group = dispatch_group_create();
assert(read_source_group != NULL);
#else
assert((kq = kqueue()) != -1);
assert(pthread_create(&redirect_pthread, NULL, redirect_thread,
NULL) == 0);
#endif
atexit(redirect_atexit);
}
@ -319,26 +206,15 @@ xq_asl_init(void)
int
xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
{
#ifdef HAVE_LIBDISPATCH
int err __block = 0;
static dispatch_once_t once_control;
dispatch_once_f(&once_control, NULL, xq_asl_init);
#else
int err = 0;
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
assert(pthread_once(&once_control, xq_asl_init) == 0);
#endif
if (fd < 0)
return EBADF;
#ifdef HAVE_LIBDISPATCH
#define BLOCK_DONE return
dispatch_sync(redirect_serial_q, ^
#else
#define BLOCK_DONE goto done
assert(pthread_mutex_lock(&redirect_fds_lock) == 0);
#endif
{
/* Reallocate if we need more space */
if (fd >= n_redirect_fds) {
@ -380,7 +256,6 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
O_NONBLOCK);
/* Start listening */
#ifdef HAVE_LIBDISPATCH
{
dispatch_source_t read_source =
dispatch_source_create(
@ -395,20 +270,8 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
dispatch_group_enter(read_source_group);
dispatch_resume(read_source);
}
#else
{
struct kevent ev;
EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
kevent(kq, &ev, 1, NULL, 0, NULL);
}
#endif
}
#ifdef HAVE_LIBDISPATCH
);
#else
done:
assert(pthread_mutex_unlock(&redirect_fds_lock) == 0);
#endif
#undef BLOCK_DONE
return err;

View File

@ -44,11 +44,7 @@
#include <stdbool.h>
#include <signal.h>
#ifdef HAVE_LIBDISPATCH
#include <dispatch/dispatch.h>
#else
#include <pthread.h>
#endif
#include <sys/socket.h>
#include <sys/un.h>
@ -115,23 +111,6 @@ static char *pref_app_to_run;
static char *pref_login_shell;
static char *pref_startx_script;
#ifndef HAVE_LIBDISPATCH
/*** Pthread Magics ***/
static pthread_t
create_thread(void *(*func)(void *), void *arg)
{
pthread_attr_t attr;
pthread_t tid;
pthread_attr_init(&attr);
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_create(&tid, &attr, func, arg);
pthread_attr_destroy(&attr);
return tid;
}
#endif
/*** Mach-O IPC Stuffs ***/
@ -239,16 +218,9 @@ typedef struct {
/* This thread accepts an incoming connection and hands off the file
* descriptor for the new connection to accept_fd_handoff()
*/
#ifdef HAVE_LIBDISPATCH
static void
socket_handoff(socket_handoff_t *handoff_data)
{
#else
static void *
socket_handoff_thread(void *arg)
{
socket_handoff_t *handoff_data = (socket_handoff_t *)arg;
#endif
int launchd_fd = -1;
int connected_fd;
@ -283,9 +255,6 @@ socket_handoff_thread(void *arg)
launchd_fd);
DarwinListenOnOpenFD(launchd_fd);
#ifndef HAVE_LIBDISPATCH
return NULL;
#endif
}
static int
@ -369,14 +338,10 @@ do_request_fd_handoff_socket(mach_port_t port, string_t filename)
strlcpy(filename, handoff_data->filename, STRING_T_SIZE);
#ifdef HAVE_LIBDISPATCH
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0), ^ {
socket_handoff(handoff_data);
});
#else
create_thread(socket_handoff_thread, handoff_data);
#endif
#ifdef DEBUG
ErrorF(

View File

@ -52,9 +52,7 @@
#include <sys/uio.h>
#include <unistd.h>
#ifdef HAVE_LIBDISPATCH
#include <dispatch/dispatch.h>
#endif
#include "rootlessWindow.h"
#include "xprEvent.h"
@ -79,7 +77,7 @@ QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev)
/* There's no need to do xp_window_bring_all_to_front on Leopard,
* and we don't care about the result, so just do it async.
*/
#if defined(HAVE_LIBDISPATCH) && defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 6
#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 6
# if defined(XPLUGIN_VERSION_MIN_REQUIRED) && XPLUGIN_VERSION_MIN_REQUIRED < 6
if (&xp_window_bring_all_to_front) {
# endif

View File

@ -43,11 +43,7 @@
#include "windowstr.h"
#include "quartz.h"
#ifdef HAVE_LIBDISPATCH
#include <dispatch/dispatch.h>
#else
#include <pthread.h>
#endif
#ifdef DEBUG_XP_LOCK_WINDOW
#include <execinfo.h>
@ -70,11 +66,7 @@ DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
static x_hash_table * window_hash;
/* Need to guard window_hash since xprIsX11Window can be called from any thread. */
#ifdef HAVE_LIBDISPATCH
static dispatch_queue_t window_hash_serial_q;
#else
static pthread_rwlock_t window_hash_rwlock;
#endif
/* Prototypes for static functions */
static Bool
@ -209,15 +201,9 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
return FALSE;
}
#ifdef HAVE_LIBDISPATCH
dispatch_async(window_hash_serial_q, ^ {
x_hash_table_insert(window_hash, pFrame->wid, pFrame);
});
#else
pthread_rwlock_wrlock(&window_hash_rwlock);
x_hash_table_insert(window_hash, pFrame->wid, pFrame);
pthread_rwlock_unlock(&window_hash_rwlock);
#endif
xprSetNativeProperty(pFrame);
@ -232,15 +218,9 @@ xprDestroyFrame(RootlessFrameID wid)
{
xp_error err;
#ifdef HAVE_LIBDISPATCH
dispatch_async(window_hash_serial_q, ^ {
x_hash_table_remove(window_hash, wid);
});
#else
pthread_rwlock_wrlock(&window_hash_rwlock);
x_hash_table_remove(window_hash, wid);
pthread_rwlock_unlock(&window_hash_rwlock);
#endif
err = xp_destroy_window(x_cvt_vptr_to_uint(wid));
if (err != Success)
@ -293,9 +273,7 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
{
xp_window_changes wc;
unsigned int mask = XP_STACKING;
#ifdef HAVE_LIBDISPATCH
__block
#endif
RootlessWindowRec * winRec;
/* Stack frame below nextWid it if it exists, or raise
@ -310,15 +288,9 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
wc.sibling = x_cvt_vptr_to_uint(nextWid);
}
#ifdef HAVE_LIBDISPATCH
dispatch_sync(window_hash_serial_q, ^ {
winRec = x_hash_table_lookup(window_hash, wid, NULL);
});
#else
pthread_rwlock_rdlock(&window_hash_rwlock);
winRec = x_hash_table_lookup(window_hash, wid, NULL);
pthread_rwlock_unlock(&window_hash_rwlock);
#endif
if (winRec) {
if (XQuartzIsRootless)
@ -519,13 +491,9 @@ xprInit(ScreenPtr pScreen)
rootless_CopyWindow_threshold = xp_scroll_area_threshold;
assert((window_hash = x_hash_table_new(NULL, NULL, NULL, NULL)));
#ifdef HAVE_LIBDISPATCH
assert((window_hash_serial_q =
dispatch_queue_create(BUNDLE_ID_PREFIX ".X11.xpr_window_hash",
NULL)));
#else
assert(0 == pthread_rwlock_init(&window_hash_rwlock, NULL));
#endif
return TRUE;
}
@ -537,19 +505,12 @@ xprInit(ScreenPtr pScreen)
WindowPtr
xprGetXWindow(xp_window_id wid)
{
#ifdef HAVE_LIBDISPATCH
RootlessWindowRec *winRec __block;
dispatch_sync(window_hash_serial_q, ^ {
winRec =
x_hash_table_lookup(window_hash,
x_cvt_uint_to_vptr(wid), NULL);
});
#else
RootlessWindowRec *winRec;
pthread_rwlock_rdlock(&window_hash_rwlock);
winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
pthread_rwlock_unlock(&window_hash_rwlock);
#endif
return winRec != NULL ? winRec->win : NULL;
}

View File

@ -116,9 +116,6 @@
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the libdispatch (GCD) available */
#undef HAVE_LIBDISPATCH
/* Define to 1 if you have the <linux/agpgart.h> header file. */
#undef HAVE_LINUX_AGPGART_H