[Xorg-commit] xc/lib/Xt Alloc.c,1.1.4.1,1.1.4.2 Initialize.c,1.1.4.2,1.1.4.3 Vendor.c,1.1.4.1,1.1.4.2

Kaleb Keithley xorg-commit at pdx.freedesktop.org
Wed May 9 17:30:30 EEST 2007


Committed by: kaleb

Update of /cvs/xorg/xc/lib/Xt
In directory pdx:/home/kaleb/xorg/xc.XORG-CURRENT/lib/Xt

Modified Files:
      Tag: XORG-CURRENT
	Alloc.c Initialize.c Vendor.c 
Log Message:
merge most of XFree86 RC3 (4.3.99.903) from vendor branch.
bug #214


Index: Alloc.c
===================================================================
RCS file: /cvs/xorg/xc/lib/Xt/Alloc.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/Alloc.c	17 Nov 2003 19:03:41 -0000	1.1.4.1
+++ b/Alloc.c	23 Feb 2004 21:34:34 -0000	1.1.4.2
@@ -58,7 +58,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/Xt/Alloc.c,v 1.9 2001/12/14 19:56:07 dawes Exp $ */
+/* $XFree86: xc/lib/Xt/Alloc.c,v 1.10 2003/12/30 01:45:07 tsi Exp $ */
 
 /*
  * X Toolkit Memory Allocation Routines
@@ -117,7 +117,7 @@
 {
     char *ptr;
 
-#if defined (MALLOC_0_RETURNS_NULL) && defined(XTMALLOC_BC)
+#if defined(MALLOC_0_RETURNS_NULL) && defined(XTMALLOC_BC)
     /* preserve this (broken) behavior until everyone fixes their apps */
     if (!size) size = 1;
 #endif
@@ -132,12 +132,12 @@
     unsigned size;
 {
    if (ptr == NULL) {
-#if MALLOC_0_RETURNS_NULL
+#ifdef MALLOC_0_RETURNS_NULL
 	if (!size) size = 1;
 #endif
 	return(XtMalloc(size));
    } else if ((ptr = Xrealloc(ptr, size)) == NULL
-#if MALLOC_0_RETURNS_NULL
+#ifdef MALLOC_0_RETURNS_NULL
 		&& size
 #endif
 	)
@@ -151,7 +151,7 @@
 {
     char *ptr;
 
-#if defined (MALLOC_0_RETURNS_NULL) && defined(XTMALLOC_BC)
+#if defined(MALLOC_0_RETURNS_NULL) && defined(XTMALLOC_BC)
     /* preserve this (broken) behavior until everyone fixes their apps */
     if (!size) num = size = 1;
 #endif

Index: Initialize.c
===================================================================
RCS file: /cvs/xorg/xc/lib/Xt/Initialize.c,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -u -d -r1.1.4.2 -r1.1.4.3
--- a/Initialize.c	26 Nov 2003 22:48:39 -0000	1.1.4.2
+++ b/Initialize.c	23 Feb 2004 21:34:34 -0000	1.1.4.3
@@ -32,7 +32,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/Xt/Initialize.c,v 3.21 2003/04/21 16:34:27 herrb Exp $ */
+/* $XFree86: xc/lib/Xt/Initialize.c,v 3.22 2003/12/22 21:10:25 dickey Exp $ */
 
 /*
 
@@ -184,6 +184,66 @@
 #define _XtInherit __XtInherit
 #endif
 
+
+#if defined(__CYGWIN__)
+/*
+ * The Symbol _XtInherit is used in two different manners.
+ * First it could be used as a generic function and second
+ * as an absolute address reference, which will be used to
+ * check the initialisation process of several other libraries.
+ * Because of this the symbol must be accessable by all
+ * client dll's and applications.  In unix environments
+ * this is no problem, because the used shared libraries
+ * format (elf) supports this immediatly.  Under Windows
+ * this isn't true, because a functions address in a dll
+ * is different from the same function in another dll or
+ * applications, because the used Portable Executable
+ * File adds a code stub to each client to provide the
+ * exported symbol name.  This stub uses an indirect
+ * pointer to get the original symbol address, which is
+ * then jumped to, like in this example: 
+ *
+ * --- client ---                                     --- dll ----
+ *  ... 
+ *  call foo 
+ * 
+ * foo: jmp (*_imp_foo)               ---->           foo: .... 
+ *      nop
+ *      nop       
+ * 
+ * _imp_foo: .long <index of foo in dll export table, is
+ *		    set to the real address by the runtime linker>
+ * 
+ * Now it is clear why the clients symbol foo isn't the same
+ * as in the dll and we can think about how to deal which
+ * this two above mentioned requirements, to export this
+ * symbol to all clients and to allow calling this symbol
+ * as a function.  The solution I've used exports the
+ * symbol _XtInherit as data symbol, because global data
+ * symbols are exported to all clients.  But how to deal
+ * with the second requirement, that this symbol should
+ * be used as function.  The Trick is to build a little
+ * code stub in the data section in the exact manner as
+ * above explained.  This is done with the assembler code 
+ * below.
+ * 
+ * Ralf Habacker
+ *
+ * References: 
+ * msdn          http://msdn.microsoft.com/msdnmag/issues/02/02/PE/PE.asp
+ * cygwin-xfree: http://www.cygwin.com/ml/cygwin-xfree/2003-10/msg00000.html
+ */
+
+asm (".data\n\
+ .globl __XtInherit        \n\
+ __XtInherit:      jmp *_y \n\
+  _y: .long ___XtInherit   \n\
+    .text                 \n"); 
+
+#define _XtInherit __XtInherit
+#endif
+
+
 void _XtInherit()
 {
     XtErrorMsg("invalidProcedure","inheritanceProc",XtCXtToolkitError,

Index: Vendor.c
===================================================================
RCS file: /cvs/xorg/xc/lib/Xt/Vendor.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/Vendor.c	17 Nov 2003 19:03:42 -0000	1.1.4.1
+++ b/Vendor.c	23 Feb 2004 21:34:34 -0000	1.1.4.2
@@ -46,7 +46,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/Xt/Vendor.c,v 1.7 2002/05/31 18:45:46 dawes Exp $ */
+/* $XFree86: xc/lib/Xt/Vendor.c,v 1.8 2003/12/22 21:10:25 dickey Exp $ */
 
 /* Make sure all wm properties can make it out of the resource manager */
 
@@ -64,9 +64,11 @@
  *
  ***************************************************************************/
 
-#ifdef __UNIXOS2__
+#if defined(__UNIXOS2__) || defined(__CYGWIN__)
 /* to fix the EditRes problem because of wrong linker semantics */
 extern WidgetClass vendorShellWidgetClass;
+
+#if defined(__UNIXOS2__)
 unsigned long _DLL_InitTerm(unsigned long mod,unsigned long flag)
 {
         switch (flag) {
@@ -82,6 +84,23 @@
 }
 #endif
 
+#if defined(__CYGWIN__)
+int __stdcall
+DllMain(unsigned long mod_handle, unsigned long flag, void *routine)
+{
+  switch (flag)
+    {
+    case 1: /* DLL_PROCESS_ATTACH - process attach */
+      vendorShellWidgetClass = (WidgetClass)(&vendorShellClassRec);
+      break;
+    case 0: /* DLL_PROCESS_DETACH - process detach */
+      break;
+    }
+  return 1;
+}
+#endif
+#endif
+
 externaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = {
   {
     /* superclass         */    (WidgetClass) &wmShellClassRec,





More information about the xorg-commit mailing list