1234757.patch revision 688
341N/A###############################################################################
341N/A# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
341N/A# Use subject to license terms.
341N/A#
341N/A# Permission is hereby granted, free of charge, to any person obtaining a
341N/A# copy of this software and associated documentation files (the
341N/A# "Software"), to deal in the Software without restriction, including
341N/A# without limitation the rights to use, copy, modify, merge, publish,
341N/A# distribute, and/or sell copies of the Software, and to permit persons
341N/A# to whom the Software is furnished to do so, provided that the above
341N/A# copyright notice(s) and this permission notice appear in all copies of
341N/A# the Software and that both the above copyright notice(s) and this
341N/A# permission notice appear in supporting documentation.
341N/A#
341N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
341N/A# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
341N/A# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
341N/A# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
341N/A# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
341N/A# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
341N/A# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
341N/A# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
341N/A# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
341N/A#
341N/A# Except as contained in this notice, the name of a copyright holder
341N/A# shall not be used in advertising or otherwise to promote the sale, use
341N/A# or other dealings in this Software without prior written authorization
341N/A# of the copyright holder.
341N/A#
341N/A
341N/A1234757: XInitThreads needs to be made less restrictive
341N/A
341N/AThis is a RFE to enhance XInitThreads so that it may be called:
341N/A
341N/A * By libraries used by the client, (without the client's intervention)
341N/A * At a later time, after other Xlib calls have already been made.
341N/A Currently, XInitThreads *Must* be the first Xlib call that the client
341N/A makes.
341N/A
341N/AFor Example, in order for XIL 1.3 to be MT HOT, it must be able to
341N/Amake the call to XInitThreads, even if the client has already made
341N/Aother Xlib calls.
341N/A
688N/Adiff -urp -x '*~' -x '*.orig' include/X11/Xlibint.h include/X11/Xlibint.h
688N/A--- include/X11/Xlibint.h 2009-02-20 15:17:13.000000000 -0800
688N/A+++ include/X11/Xlibint.h 2009-04-08 00:17:31.818676000 -0700
688N/A@@ -187,6 +187,29 @@ struct _XDisplay
341N/A struct _X11XCBPrivate *xcb; /* XCB glue private data */
341N/A };
341N/A
341N/A+#if defined(XTHREADS) && defined(SUNSOFT)
341N/A+struct _DisplayPtrLink {
341N/A+ Display *dpy;
341N/A+ struct _DisplayPtrLink *next;
341N/A+};
688N/A+
341N/A+typedef struct _DisplayPtrLink DisplayPtrLink;
688N/A+
341N/A+int InitDisplayArrayLock();
341N/A+
341N/A+void RemoveFromDisplayLink(
341N/A+#if NeedFunctionPrototypes
341N/A+ Display * /*dpy */
341N/A+#endif /* NeedFunctionPrototypes */
341N/A+);
341N/A+
341N/A+int AddToDisplayLink(
341N/A+#if NeedFunctionPrototypes
341N/A+ Display * /*dpy */
341N/A+#endif /* NeedFunctionPrototypes */
341N/A+);
341N/A+#endif /* XTHREADS && SUNSOFT */
341N/A+
341N/A #define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
341N/A
341N/A /*
341N/Adiff -urp -x '*~' -x '*.orig' src/OpenDis.c src/OpenDis.c
688N/A--- src/OpenDis.c 2009-04-06 16:48:55.000000000 -0700
688N/A+++ src/OpenDis.c 2009-04-08 00:17:31.819345000 -0700
341N/A@@ -62,6 +62,11 @@ typedef struct {
341N/A } _XBigReqState;
341N/A #endif /* !USE_XCB */
341N/A
341N/A+#if defined(XTHREADS) && defined(SUNSOFT)
341N/A+DisplayPtrLink *HeadDisplay=NULL;
341N/A+DisplayPtrLink *LastDisplay=NULL;
341N/A+#endif /* XTHREADS && SUNSOFT */
341N/A+
341N/A #ifdef XTHREADS
341N/A #include "locking.h"
341N/A int (*_XInitDisplayLock_fn)(Display *dpy) = NULL;
688N/A@@ -261,6 +266,13 @@ XOpenDisplay (
688N/A return(NULL);
341N/A }
341N/A
341N/A+#ifdef XTHREADS
341N/A+ if (AddToDisplayLink(dpy) == 0) {
341N/A+ OutOfMemory (dpy, setup);
341N/A+ return(NULL);
341N/A+ }
341N/A+#endif XTHREADS
341N/A+
341N/A if (!_XPollfdCacheInit(dpy)) {
341N/A OutOfMemory (dpy, setup);
341N/A return(NULL);
688N/A@@ -790,6 +802,10 @@ _XBigReqHandler(
688N/A
688N/A void _XFreeDisplayStructure(Display *dpy)
341N/A {
341N/A+#ifdef XTHREADS
341N/A+ RemoveFromDisplayLink(dpy);
341N/A+#endif XTHREADS
341N/A+
341N/A while (dpy->ext_procs) {
341N/A _XExtension *ext = dpy->ext_procs;
341N/A dpy->ext_procs = ext->next;
688N/A@@ -910,6 +926,107 @@ void _XFreeDisplayStructure(Display *dpy
341N/A Xfree ((char *)dpy);
341N/A }
341N/A
341N/A+#if defined(XTHREADS) && defined(SUNSOFT)
341N/A+int
341N/A+AddToDisplayLink(dpy)
341N/A+Display *dpy;
341N/A+{
341N/A+ if ( dpy->lock )
341N/A+ return 1;
688N/A+
341N/A+/*
341N/A+ * Attempt to allocate a display array. Return NULL if allocation fails.
341N/A+ */
341N/A+ if ( !HeadDisplay ) {
341N/A+ if ((HeadDisplay = (DisplayPtrLink *) Xcalloc
341N/A+ (1, sizeof(struct _DisplayPtrLink))) == NULL ) {
341N/A+ return 0;
341N/A+ }
688N/A+
341N/A+ HeadDisplay->dpy = dpy;
341N/A+ HeadDisplay->next = NULL;
341N/A+ LastDisplay = HeadDisplay;
341N/A+ return 1;
341N/A+ }
688N/A+
341N/A+ if ((LastDisplay->next = (DisplayPtrLink *) Xcalloc
341N/A+ (1, sizeof(struct _DisplayPtrLink))) == NULL ) {
341N/A+ return 0;
341N/A+ }
688N/A+
341N/A+ LastDisplay = LastDisplay->next;
341N/A+ LastDisplay->dpy = dpy;
341N/A+ LastDisplay->next = NULL;
341N/A+ return 1;
341N/A+}
341N/A+
341N/A+void
341N/A+RemoveFromDisplayLink(dpy)
341N/A+Display *dpy;
341N/A+{
341N/A+ DisplayPtrLink *tmp_display = HeadDisplay;
341N/A+ DisplayPtrLink *prev_display = HeadDisplay;
688N/A+
341N/A+ if ( dpy->lock )
341N/A+ return;
688N/A+
341N/A+ while ( tmp_display ) {
341N/A+ if ((tmp_display->dpy == dpy) && (tmp_display->dpy->fd == dpy->fd)){
341N/A+ break;
341N/A+ }
688N/A+
341N/A+ prev_display = tmp_display;
341N/A+ tmp_display = tmp_display->next;
341N/A+ }
341N/A+
341N/A+ /* Node not found */
341N/A+ if ( !tmp_display )
341N/A+ return;
341N/A+
341N/A+ /* If tmp_display is the first node */
341N/A+ if ( tmp_display == HeadDisplay ) {
341N/A+ if ( HeadDisplay->next )
341N/A+ HeadDisplay = HeadDisplay->next;
341N/A+ else {
341N/A+ HeadDisplay = NULL;
341N/A+ LastDisplay = NULL;
341N/A+ }
688N/A+ }
341N/A+ /* If tmp_display is the last node */
341N/A+ else if ( tmp_display == LastDisplay ) {
341N/A+ LastDisplay = prev_display;
341N/A+ LastDisplay->next = NULL;
341N/A+ }
341N/A+ /* tmp_display is in the middle of list*/
341N/A+ else
341N/A+ prev_display->next = tmp_display->next;
341N/A+
341N/A+ Xfree(tmp_display);
341N/A+ return;
341N/A+}
341N/A+
341N/A+int
341N/A+InitDisplayArrayLock()
341N/A+{
341N/A+ DisplayPtrLink *tmp_display = HeadDisplay;
341N/A+ DisplayPtrLink *prev_display = HeadDisplay;
688N/A+
341N/A+ while ( tmp_display ) {
341N/A+ if ((tmp_display->dpy) && (!tmp_display->dpy->lock)) {
341N/A+ /* Initialize the display lock */
341N/A+ if (_XInitDisplayLock_fn(tmp_display->dpy) != 0) {
341N/A+ OutOfMemory (tmp_display->dpy, NULL);
341N/A+ return 0;
341N/A+ }
341N/A+ }
341N/A+ tmp_display = tmp_display->next;
341N/A+ }
688N/A+
341N/A+ return 1;
341N/A+}
341N/A+
341N/A+#endif /* XTHREADS && SUNSOFT */
341N/A+
341N/A /* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
341N/A after this returns. */
341N/A
341N/Adiff -urp -x '*~' -x '*.orig' src/locking.c src/locking.c
688N/A--- src/locking.c 2009-04-06 16:29:10.000000000 -0700
688N/A+++ src/locking.c 2009-04-08 00:17:31.819992000 -0700
688N/A@@ -611,6 +611,11 @@ Status XInitThreads(void)
341N/A #endif
341N/A #endif
341N/A
341N/A+#ifdef SUNSOFT
341N/A+ if (InitDisplayArrayLock() == 0)
341N/A+ return 0;
341N/A+#endif
341N/A+
341N/A return 1;
341N/A }
341N/A