1234757.patch revision 1064
341N/A###############################################################################
1064N/A# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
341N/A#
341N/A# Permission is hereby granted, free of charge, to any person obtaining a
919N/A# copy of this software and associated documentation files (the "Software"),
919N/A# to deal in the Software without restriction, including without limitation
919N/A# the rights to use, copy, modify, merge, publish, distribute, sublicense,
919N/A# and/or sell copies of the Software, and to permit persons to whom the
919N/A# Software is furnished to do so, subject to the following conditions:
919N/A#
919N/A# The above copyright notice and this permission notice (including the next
919N/A# paragraph) shall be included in all copies or substantial portions of the
919N/A# Software.
919N/A#
919N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
919N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
919N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
919N/A# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
919N/A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
919N/A# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
919N/A# DEALINGS IN THE SOFTWARE.
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
1064N/A--- include/X11/Xlibint.h 2010-10-04 18:02:06.000000000 -0700
1064N/A+++ include/X11/Xlibint.h 2010-11-21 18:47:51.771637018 -0800
1064N/A@@ -199,6 +199,10 @@ struct _XDisplay
962N/A void *cookiejar; /* cookie events returned but not claimed */
341N/A };
341N/A
341N/A+#if defined(XTHREADS) && defined(SUNSOFT)
1064N/A+int InitDisplayArrayLock(void);
1064N/A+#endif /* XTHREADS && SUNSOFT */
1064N/A+
1064N/A #define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
1064N/A
1064N/A /*
1064N/Adiff -urp -x '*~' -x '*.orig' src/OpenDis.c src/OpenDis.c
1064N/A--- src/OpenDis.c 2010-09-21 18:25:24.000000000 -0700
1064N/A+++ src/OpenDis.c 2010-11-21 18:47:51.772360199 -0800
1064N/A@@ -38,6 +38,21 @@ in this Software without prior written a
1064N/A #include "XKBlib.h"
1064N/A #endif /* XKB */
1064N/A
1064N/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;
341N/A+DisplayPtrLink *HeadDisplay=NULL;
341N/A+DisplayPtrLink *LastDisplay=NULL;
1064N/A+
1064N/A+static int AddToDisplayLink(Display *dpy);
1064N/A+static void RemoveFromDisplayLink(Display *dpy);
1064N/A+
341N/A+#endif /* XTHREADS && SUNSOFT */
341N/A+
341N/A #ifdef XTHREADS
341N/A #include "locking.h"
341N/A int (*_XInitDisplayLock_fn)(Display *dpy) = NULL;
1064N/A@@ -227,6 +232,13 @@ fallback_success:
688N/A return(NULL);
341N/A }
341N/A
341N/A+#ifdef XTHREADS
341N/A+ if (AddToDisplayLink(dpy) == 0) {
1064N/A+ OutOfMemory (dpy);
341N/A+ return(NULL);
341N/A+ }
341N/A+#endif XTHREADS
341N/A+
341N/A if (!_XPollfdCacheInit(dpy)) {
1064N/A OutOfMemory (dpy);
341N/A return(NULL);
1064N/A@@ -600,6 +612,10 @@ fallback_success:
688N/A
688N/A void _XFreeDisplayStructure(Display *dpy)
341N/A {
341N/A+#ifdef XTHREADS
341N/A+ RemoveFromDisplayLink(dpy);
341N/A+#endif XTHREADS
341N/A+
962N/A /* move all cookies in the EQ to the jar, then free them. */
962N/A if (dpy->qfree) {
962N/A _XQEvent *qelt = dpy->qfree;
1064N/A@@ -728,6 +744,105 @@ void _XFreeDisplayStructure(Display *dpy
341N/A Xfree ((char *)dpy);
341N/A }
341N/A
341N/A+#if defined(XTHREADS) && defined(SUNSOFT)
1064N/A+static int
1064N/A+AddToDisplayLink(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+
1064N/A+static void
1064N/A+RemoveFromDisplayLink(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
1064N/A+InitDisplayArrayLock(void)
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) {
1064N/A+ OutOfMemory (tmp_display->dpy);
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
1064N/A--- src/locking.c 2010-09-03 22:52:39.000000000 -0700
1064N/A+++ src/locking.c 2010-11-21 18:47:51.772597162 -0800
962N/A@@ -612,6 +612,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