Commit 3e253c60 authored by Jeremy Huddleston's avatar Jeremy Huddleston

XQuartz: Remove the threadSafety dead-ish code

It's been a few years now since we've needed this to debug thread
boundaries, so punt it out to clean up the namespace polution.
Signed-off-by: default avatarJeremy Huddleston <jeremyhu@apple.com>
parent a52c8078
......@@ -33,8 +33,7 @@ libXquartz_la_SOURCES = \
quartzCocoa.m \
quartzKeyboard.c \
quartzStartup.c \
quartzRandR.c \
threadSafety.c
quartzRandR.c
EXTRA_DIST = \
X11Application.h \
......@@ -50,5 +49,4 @@ EXTRA_DIST = \
quartzKeyboard.h \
quartzRandR.h \
sanitizedCarbon.h \
sanitizedCocoa.h \
threadSafety.h
sanitizedCocoa.h
......@@ -34,8 +34,6 @@
#include <X11/extensions/XKB.h>
#include <assert.h>
#include "threadSafety.h"
#include "darwinfb.h"
// From darwin.c
......@@ -80,7 +78,7 @@ extern int darwinMainScreenY;
#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, "%s:%s:%s:%d " msg, threadSafetyID(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:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
#else
#define DEBUG_LOG(msg, args...)
#endif
......
......@@ -197,8 +197,6 @@ static void DarwinUpdateModifiers(
static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) {
XQuartzEvent *e = &(ie->xquartz_event);
TA_SERVER();
switch(e->subtype) {
case kXquartzControllerNotify:
DEBUG_LOG("kXquartzControllerNotify\n");
......@@ -381,8 +379,6 @@ void ProcessInputEvents(void) {
char nullbyte;
int x = sizeof(nullbyte);
TA_SERVER();
mieqProcessInputEvents();
// Empty the signaling pipe
......
......@@ -56,8 +56,6 @@
#include "X11Application.h"
#include "threadSafety.h"
#ifdef NDEBUG
#undef NDEBUG
#include <assert.h>
......
......@@ -84,10 +84,7 @@ void QuartzInitServer(int argc, char **argv, char **envp) {
args->argv = argv;
args->envp = envp;
APPKIT_THREAD_ID = pthread_self();
SERVER_THREAD_ID = create_thread(server_thread, args);
if (!SERVER_THREAD_ID) {
if (!create_thread(server_thread, args)) {
FatalError("can't create secondary thread\n");
}
}
......
/*
* 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"
pthread_t APPKIT_THREAD_ID;
pthread_t SERVER_THREAD_ID;
#include <AvailabilityMacros.h>
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
#include <execinfo.h>
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);
}
#else
void spewCallStack(void) {
return;
}
#endif
void _threadSafetyAssert(pthread_t tid, const char *file, const char *fun, int line) {
if(pthread_equal(pthread_self(), tid))
return;
/* NOOOO! */
ErrorF("Thread Assertion Failed: self=%s, expected=%s\n%s:%s:%d\n",
threadSafetyID(pthread_self()), threadSafetyID(tid),
file, fun, line);
spewCallStack();
}
const char *threadSafetyID(pthread_t tid) {
if(pthread_equal(tid, APPKIT_THREAD_ID)) {
return "Appkit Thread";
} else if(pthread_equal(tid, SERVER_THREAD_ID)) {
return "Xserver Thread";
} else {
return "Unknown Thread";
}
}
/*
* 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_
#define DEBUG_THREADS 1
#include <pthread.h>
extern pthread_t APPKIT_THREAD_ID;
extern pthread_t SERVER_THREAD_ID;
/* Dump the call stack */
void spewCallStack(void);
/* Print message to ErrorF if we're in the wrong thread */
void _threadSafetyAssert(pthread_t tid, const char *file, const char *fun, int line);
/* Get a string that identifies our thread nicely */
const char *threadSafetyID(pthread_t tid);
#define threadSafetyAssert(tid) _threadSafetyAssert(tid, __FILE__, __FUNCTION__, __LINE__)
#ifdef DEBUG_THREADS
#define TA_APPKIT() threadSafetyAssert(APPKIT_THREAD_ID)
#define TA_SERVER() threadSafetyAssert(SERVER_THREAD_ID)
#else
#define TA_SERVER()
#define TA_APPKIT()
#endif
#endif /* _XQ_THREAD_SAFETY_H_ */
......@@ -57,8 +57,6 @@
#include "xprEvent.h"
Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) {
TA_SERVER();
switch(e->subtype) {
case kXquartzWindowState:
DEBUG_LOG("kXquartzWindowState\n");
......
......@@ -44,8 +44,6 @@
#include "windowstr.h"
#include "quartz.h"
#include "threadSafety.h"
#include <pthread.h>
#define DEFINE_ATOM_HELPER(func,atom_name) \
......@@ -93,8 +91,6 @@ static inline xp_error
xprConfigureWindow(xp_window_id id, unsigned int mask,
const xp_window_changes *values)
{
TA_SERVER();
return xp_configure_window(id, mask, values);
}
......@@ -106,8 +102,6 @@ xprSetNativeProperty(RootlessWindowPtr pFrame)
unsigned int native_id;
long data;
TA_SERVER();
err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id);
if (err == Success)
{
......@@ -137,8 +131,6 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
unsigned int mask = 0;
xp_error err;
TA_SERVER();
wc.x = newX;
wc.y = newY;
wc.width = pFrame->width;
......@@ -209,8 +201,7 @@ static void
xprDestroyFrame(RootlessFrameID wid)
{
xp_error err;
TA_SERVER();
pthread_mutex_lock(&window_hash_mutex);
x_hash_table_remove(window_hash, wid);
pthread_mutex_unlock(&window_hash_mutex);
......@@ -229,8 +220,6 @@ xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
{
xp_window_changes wc;
TA_SERVER();
wc.x = newX;
wc.y = newY;
// ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
......@@ -248,8 +237,6 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
{
xp_window_changes wc;
TA_SERVER();
wc.x = newX;
wc.y = newY;
wc.width = newW;
......@@ -270,8 +257,6 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
xp_window_changes wc;
unsigned int mask = XP_STACKING;
TA_SERVER();
/* Stack frame below nextWid it if it exists, or raise
frame above everything otherwise. */
......@@ -309,8 +294,6 @@ xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
{
xp_window_changes wc;
TA_SERVER();
if (pShape != NULL)
{
wc.shape_nrects = RegionNumRects(pShape);
......@@ -336,8 +319,6 @@ xprUnmapFrame(RootlessFrameID wid)
{
xp_window_changes wc;
TA_SERVER();
wc.stack_mode = XP_UNMAPPED;
wc.sibling = 0;
......@@ -356,8 +337,6 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
unsigned int rowbytes[2];
xp_error err;
TA_SERVER();
err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL);
if (err != Success)
FatalError("Could not lock window %i for drawing.", (int)x_cvt_vptr_to_uint(wid));
......@@ -374,8 +353,7 @@ static void
xprStopDrawing(RootlessFrameID wid, Bool flush)
{
xp_error err;
TA_SERVER();
err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush);
if(err != Success)
FatalError("Could not unlock window %i after drawing.", (int)x_cvt_vptr_to_uint(wid));
......@@ -388,8 +366,6 @@ xprStopDrawing(RootlessFrameID wid, Bool flush)
static void
xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
{
TA_SERVER();
xp_flush_window(x_cvt_vptr_to_uint(wid));
}
......@@ -401,8 +377,6 @@ static void
xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
int shift_x, int shift_y)
{
TA_SERVER();
xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y);
}
......@@ -416,8 +390,6 @@ xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
{
DeleteProperty(serverClient, oldWin, xa_native_window_id());
TA_SERVER();
xprSetNativeProperty(pFrame);
}
......@@ -429,8 +401,6 @@ static Bool xprDoReorderWindow(RootlessWindowPtr pFrame)
{
WindowPtr pWin = pFrame->win;
TA_SERVER();
return AppleWMDoReorderWindow(pWin);
}
......@@ -443,8 +413,6 @@ static void
xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
int dx, int dy)
{
TA_SERVER();
xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid),
dstNrects, dstRects, dx, dy);
}
......@@ -479,8 +447,6 @@ xprInit(ScreenPtr pScreen)
{
RootlessInit(pScreen, &xprRootlessProcs);
TA_SERVER();
rootless_CopyBytes_threshold = xp_copy_bytes_threshold;
rootless_CopyWindow_threshold = xp_scroll_area_threshold;
......@@ -578,8 +544,6 @@ xprHideWindows(Bool hide)
int screen;
WindowPtr pRoot, pWin;
TA_SERVER();
for (screen = 0; screen < screenInfo.numScreens; screen++) {
RootlessFrameID prevWid = NULL;
pRoot = screenInfo.screens[screen]->root;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment