xserver: Branch 'xorg-server-1.5-apple' - 3 commits
Jeremy Huddleston
jeremyhu at kemper.freedesktop.org
Thu Apr 17 13:21:36 PDT 2008
dix/main.c | 14 ----------
hw/xquartz/Makefile.am | 6 ++--
hw/xquartz/X11Application.m | 9 ++++--
hw/xquartz/darwin.h | 4 ++
hw/xquartz/quartz.c | 1
hw/xquartz/quartz.h | 5 +++
hw/xquartz/threadSafety.c | 59 ++++++++++++++++++++++++++++++++++++++++++++
hw/xquartz/threadSafety.h | 43 ++++++++++++++++++++++++++++++++
8 files changed, 121 insertions(+), 20 deletions(-)
New commits:
commit d9f456adfcfdf1ffbbecbba31962639c94225f27
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Thu Apr 17 13:17:58 2008 -0700
XQuartz: Fixed some missing prototypes
(cherry picked from commit 95056afc562cfe58b116f5c36e4624018e79ff4a)
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 6a8cf7c..fb9f13c 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -52,6 +52,7 @@
#include "windowstr.h"
#include "colormapst.h"
#include "globals.h"
+#include "mi.h"
// System headers
#include <sys/types.h>
diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h
index ffe06f9..e116023 100644
--- a/hw/xquartz/quartz.h
+++ b/hw/xquartz/quartz.h
@@ -131,4 +131,9 @@ void QuartzInitInput(int argc, char **argv);
void QuartzGiveUp(void);
void QuartzProcessEvent(xEvent *xe);
void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
+
+void QuartzShow(int x, int y); // (x, y) = cursor loc
+void QuartzHide(void);
+void QuartzSetRootClip(BOOL enable);
+void QuartzSpaceChanged(uint32_t space_id);
#endif
commit e1a4eef65e9ac7f318b536196c4de7183898fbd0
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Thu Apr 17 13:12:56 2008 -0700
XQuartz: Added framework for asserting which thread we're in.
(cherry picked from commit 00beb982510e7a82d77e1f1d43e77c84d7bf74c2)
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 6854557..1c97ac8 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -34,7 +34,8 @@ libXquartz_la_SOURCES = \
quartzForeground.c \
quartzKeyboard.c \
quartzPasteboard.c \
- quartzStartup.c
+ quartzStartup.c \
+ threadSafety.c
EXTRA_DIST = \
X11Application.h \
@@ -50,4 +51,5 @@ EXTRA_DIST = \
quartzCommon.h \
quartzForeground.h \
quartzKeyboard.h \
- quartzPasteboard.h
+ quartzPasteboard.h \
+ threadSafety.h
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 28bb6fb..31ac563 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -738,7 +738,7 @@ void X11ApplicationShowHideMenubar (int state) {
[n release];
}
-static void * create_thread (void *func, void *arg) {
+static pthread_t create_thread (void *func, void *arg) {
pthread_attr_t attr;
pthread_t tid;
@@ -748,7 +748,7 @@ static void * create_thread (void *func, void *arg) {
pthread_create (&tid, &attr, func, arg);
pthread_attr_destroy (&attr);
- return (void *) tid;
+ return tid;
}
static void check_xinitrc (void) {
@@ -819,7 +819,10 @@ void X11ApplicationMain (int argc, const char **argv, void (*server_thread) (voi
aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
NSMaxY([[NSScreen mainScreen] visibleFrame]);
- if (!create_thread (server_thread, server_arg)) {
+ APPKIT_THREAD = pthread_self();
+ SERVER_THREAD = create_thread (server_thread, server_arg);
+
+ if (!SERVER_THREAD) {
ErrorF("can't create secondary thread\n");
exit (1);
}
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index df92d8b..3231077 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -34,6 +34,8 @@
#include <X11/extensions/XKB.h>
#include <assert.h>
+#include "threadSafety.h"
+
typedef struct {
void *framebuffer;
int x;
@@ -123,7 +125,7 @@ void DarwinSendDDXEvent(int type, int argc, ...);
#ifdef ENABLE_DEBUG_LOG
extern FILE *debug_log_fp;
#define DEBUG_LOG_NAME "x11-debug.txt"
-#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%x:%s:%s:%d " msg, pthread_self(), __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
+#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%s:%d " msg, threadSafetyID(pthread_self()), __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
#else
#define DEBUG_LOG(msg, args...)
#endif
diff --git a/hw/xquartz/threadSafety.c b/hw/xquartz/threadSafety.c
new file mode 100644
index 0000000..ff19863
--- /dev/null
+++ b/hw/xquartz/threadSafety.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2008 Apple, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "threadSafety.h"
+#include "os.h"
+
+#include <execinfo.h>
+
+pthread_t SERVER_THREAD;
+pthread_t APPKIT_THREAD;
+
+static void spewCallStack(void) {
+ void* callstack[128];
+ int i, frames = backtrace(callstack, 128);
+ char** strs = backtrace_symbols(callstack, frames);
+
+ for (i = 0; i < frames; ++i) {
+ ErrorF("%s\n", strs[i]);
+ }
+
+ free(strs);
+}
+
+void threadAssert(pthread_t tid) {
+ if(pthread_equal(pthread_self(), tid))
+ return;
+
+ /* NOOOO! */
+ ErrorF("Thread Assertion Failed: self=%s, expected=%s\n",
+ threadSafetyID(pthread_self()), threadSafetyID(tid));
+ spewCallStack();
+}
diff --git a/hw/xquartz/threadSafety.h b/hw/xquartz/threadSafety.h
new file mode 100644
index 0000000..050469e
--- /dev/null
+++ b/hw/xquartz/threadSafety.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2008 Apple, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+
+#ifndef _XQ_THREAD_SAFETY_H_
+#define _XQ_THREAD_SAFETY_H_
+
+#include <pthread.h>
+
+extern pthread_t SERVER_THREAD;
+extern pthread_t APPKIT_THREAD;
+
+#define threadSafetyID(tid) (pthread_equal((tid), SERVER_THREAD) ? "X Server Thread" : "Appkit Thread")
+
+/* Print message to ErrorF if we're in the wrong thread */
+void threadAssert(pthread_t tid);
+
+#define TA_SERVER() threadAssert(SERVER_THREAD)
+#define TA_APPKIT() threadAssert(APPKIT_THREAD)
+
+#endif _XQ_THREAD_SAFETY_H_
commit 0f84df88d02f660b7fefc0d7e139aa4cb731ec48
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Thu Apr 17 12:32:03 2008 -0700
Removed some of our debugging spam from dix main.
(cherry picked from commit a56aca1a6b2e37fc9ffeb85c1f4c7f85598ba5b2)
diff --git a/dix/main.c b/dix/main.c
index 8f6507f..db43473 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -113,9 +113,6 @@ Equipment Corporation.
#include "dispatch.h" /* InitProcVectors() */
#endif
-#include <pthread.h>
-pthread_key_t threadname_key=0;
-
#ifdef DPMSExtension
#define DPMS_SERVER
#include <X11/extensions/dpms.h>
@@ -251,17 +248,6 @@ main(int argc, char *argv[], char *envp[])
char *xauthfile;
HWEventQueueType alwaysCheckForInput[2];
- if(threadname_key == 0) ErrorF("pthread_key_create returned %d\n", pthread_key_create(&threadname_key, NULL));
- ErrorF("threadname_key = %d\n", threadname_key);
- if(pthread_getspecific(threadname_key) == NULL) {
- char *nameptr = malloc(32);
- sprintf(nameptr, "main thread %d", random());
- // strcpy(nameptr, "main thread");
- ErrorF("calling: pthread_setspecific(%d, %s)=%d\n", threadname_key, nameptr, pthread_setspecific(threadname_key, nameptr));
- if (pthread_getspecific(threadname_key) != NULL) ErrorF("current thread: %s\n", (char *)pthread_getspecific(threadname_key));
- } else {
- if (pthread_getspecific(threadname_key) != NULL) ErrorF("thread was already: %s\n", (char *)pthread_getspecific(threadname_key));
- }
display = "0";
InitGlobals();
More information about the xorg-commit
mailing list