[comp.windows.x] More fixes when compiling X11 with gcc

spaf@cs.purdue.EDU (Gene Spafford) (08/14/88)

If you compile X11 with the "-finline-functions" option, you
can gain some performance increases as the compiler turns 
static functions into inline code.   However, the code has
to be written properly in the first place so that the
definition of the static function must occur before the
first use of the function, otherwise the optimization fails.

Enclosed are context patches to 4 files in the standard
release (after patches 1-33 and the backing store changes)
that define static functions after their use.  The files are:
	lib/X/XOpenDis.c
	lib/Xaw/Load.c
	server/dix/events.c
	server/os/4.2bsd/access.c


*** /p1/X11/X11r2/lib/X/XOpenDis.c	Thu Feb 25 22:56:19 1988
--- /u25/X11/X.V11R2/lib/X/XOpenDis.c	Wed May 25 18:19:26 1988
***************
*** 26,31 ****
--- 26,46 ----
  extern Bool _XWireToEvent();
  extern Status _XUnknownNativeEvent();
  extern Bool _XUnknownWireEvent();
+ 
+ 
+ /* OutOfMemory is called if malloc fails.  XOpenDisplay returns NULL
+    after this returns. */
+ 
+ static OutOfMemory (dpy, setup)
+     Display *dpy;
+     char *setup;
+     {
+     _XDisconnectDisplay (dpy->fd);
+     _XFreeDisplayStructure (dpy);
+     Xfree (setup);
+     errno = ENOMEM;
+     }
+ 
  /* 
   * Connects to a server, creates a Display object and returns a pointer to
   * the newly created Display back to the caller.
***************
*** 396,415 ****
  	}
   	return(dpy);
  }
- 
- 
- /* OutOfMemory is called if malloc fails.  XOpenDisplay returns NULL
-    after this returns. */
- 
- static OutOfMemory (dpy, setup)
-     Display *dpy;
-     char *setup;
-     {
-     _XDisconnectDisplay (dpy->fd);
-     _XFreeDisplayStructure (dpy);
-     Xfree (setup);
-     errno = ENOMEM;
-     }
  
  
  /* XFreeDisplayStructure frees all the storage associated with a 
--- 411,416 ----
*** /p1/X11/X11r2/lib/Xaw/Load.c	Fri Feb 26 12:13:14 1988
--- /u25/X11/X.V11R2/lib/Xaw/Load.c	Fri May 27 16:35:49 1988
***************
*** 341,346 ****
--- 341,353 ----
      return(next);
  }
  
+ static xload_error(str1, str2)
+ char *str1, *str2;
+ {
+     (void) fprintf(stderr,"xload: %s %s\n", str1, str2);
+     exit(-1);
+ }
+ 
  #ifdef LOADSTUB
  
  /* ARGSUSED */
***************
*** 412,424 ****
  }
  
  #endif /* LOADSTUB */
- 
- static xload_error(str1, str2)
- char *str1, *str2;
- {
-     (void) fprintf(stderr,"xload: %s %s\n", str1, str2);
-     exit(-1);
- }
  
  /* ARGSUSED */
  static Boolean SetValues (current, request, new)
--- 419,424 ----
*** /p1/X11/X11r2/server/dix/events.c	Fri Feb 26 00:47:15 1988
--- /u25/X11/X.V11R2/server/dix/events.c	Tue May 24 13:45:19 1988
***************
*** 308,313 ****
--- 308,324 ----
      }
  }
  
+ 
+ /* returns true if b is a descendent of a */
+ static Bool
+ IsParent(a, b)
+     register WindowPtr a, b;
+ {
+     for (b = b->parent; b; b = b->parent)
+ 	if (b == a) return TRUE;
+     return FALSE;
+ }
+ 
  static void
  PostNewCursor()
  {
***************
*** 1651,1667 ****
      pWin->dontPropagateMask = mask;
      RecalculateDeliverableEvents(pWin);
      return Success;
- }
- 
- 
- /* returns true if b is a descendent of a */
- static Bool
- IsParent(a, b)
-     register WindowPtr a, b;
- {
-     for (b = b->parent; b; b = b->parent)
- 	if (b == a) return TRUE;
-     return FALSE;
  }
  
  static WindowPtr 
--- 1662,1667 ----
*** /p1/X11/X11r2/server/os/4.2bsd/access.c	Sat Feb 13 22:00:56 1988
--- /u25/X11/X.V11R2/server/os/4.2bsd/access.c	Tue May 24 13:47:37 1988
***************
*** 255,260 ****
--- 255,280 ----
      return FALSE;
  }
  
+ static int XFamily(af)
+     int af;
+ {
+     int i;
+     for (i = 0; i < FAMILIES; i++)
+         if (familyMap[i].af == af)
+             return familyMap[i].xf;
+     return -1;
+ }
+ 
+ static int UnixFamily(xf)
+     int xf;
+ {
+     int i;
+     for (i = 0; i < FAMILIES; i++)
+         if (familyMap[i].xf == xf)
+             return familyMap[i].af;
+     return -1;
+ }
+ 
  /* Add a host to the access control list.  This is the external interface
   * called from the dispatcher */
  
***************
*** 522,546 ****
  	return BadAccess;
      AccessEnabled = fEnabled;
      return Success;
- }
- 
- static int XFamily(af)
-     int af;
- {
-     int i;
-     for (i = 0; i < FAMILIES; i++)
-         if (familyMap[i].af == af)
-             return familyMap[i].xf;
-     return -1;
- }
- 
- static int UnixFamily(xf)
-     int xf;
- {
-     int i;
-     for (i = 0; i < FAMILIES; i++)
-         if (familyMap[i].xf == xf)
-             return familyMap[i].af;
-     return -1;
  }
  
--- 542,546 ----
-- 
Gene Spafford
NSF/Purdue/U of Florida  Software Engineering Research Center,
Dept. of Computer Sciences, Purdue University, W. Lafayette IN 47907-2004
Internet:  spaf@cs.purdue.edu	uucp:	...!{decwrl,gatech,ucbvax}!purdue!spaf