[PATCH 1/4] Hide a number of private symbols

Julien Cristau jcristau at debian.org
Fri Jul 31 04:49:39 PDT 2009


Add _X_HIDDEN for some symbols that aren't used outside of Xlib.
Make _XKeyInitialize static (with the associated code movement inside
src/KeyBind.c)
---
 src/CrGC.c      |    2 +-
 src/CrGlCur.c   |    6 +-
 src/Font.c      |    2 +-
 src/IntAtom.c   |    4 +-
 src/Key.h       |    4 -
 src/KeyBind.c   |  166 ++++++++++++++++++++++++++++++------------------------
 src/OpenDis.c   |    5 +-
 src/StrKeysym.c |    2 +-
 src/XlibInt.c   |    6 +-
 src/evtomask.c  |    3 +-
 src/globals.c   |    2 +-
 src/xcb_disp.c  |    2 +
 src/xcb_io.c    |    2 +-
 13 files changed, 112 insertions(+), 94 deletions(-)

diff --git a/src/CrGC.c b/src/CrGC.c
index 23fd279..2400a3d 100644
--- a/src/CrGC.c
+++ b/src/CrGC.c
@@ -162,7 +162,7 @@ _XGenerateGCList (
     }
 
 
-int
+_X_HIDDEN int
 _XUpdateGCCache (
     register GC gc,
     register unsigned long mask,
diff --git a/src/CrGlCur.c b/src/CrGlCur.c
index 8125593..f791498 100644
--- a/src/CrGlCur.c
+++ b/src/CrGlCur.c
@@ -181,7 +181,7 @@ _XTryShapeCursor (Display	    *dpy,
     return None;
 }
 
-void
+_X_HIDDEN void
 _XNoticeCreateBitmap (Display	    *dpy,
 		      Pixmap	    pid,
 		      unsigned int  width,
@@ -194,7 +194,7 @@ _XNoticeCreateBitmap (Display	    *dpy,
 	(*func) (dpy, pid, width, height);
 }
 
-void
+_X_HIDDEN void
 _XNoticePutBitmap (Display	*dpy,
 		   Drawable	draw,
 		   XImage	*image)
@@ -206,7 +206,7 @@ _XNoticePutBitmap (Display	*dpy,
 	(*func) (dpy, draw, image);
 }
 
-Cursor
+_X_HIDDEN Cursor
 _XTryShapeBitmapCursor (Display		*dpy,
 			Pixmap		source,
 			Pixmap		mask,
diff --git a/src/Font.c b/src/Font.c
index 244cd2d..38011d7 100644
--- a/src/Font.c
+++ b/src/Font.c
@@ -651,7 +651,7 @@ _XF86BigfontQueryFont (
     return fs;
 }
 
-void
+_X_HIDDEN void
 _XF86BigfontFreeFontMetrics (XFontStruct *fs)
 {
 #ifdef HAS_SHM
diff --git a/src/IntAtom.c b/src/IntAtom.c
index d1e76b0..2e0ac33 100644
--- a/src/IntAtom.c
+++ b/src/IntAtom.c
@@ -39,7 +39,7 @@ from The Open Group.
 #define REHASHVAL(sig) ((((sig) % (TABLESIZE-3)) + 2) | 1)
 #define REHASH(idx,rehash) ((idx + rehash) & (TABLESIZE-1))
 
-void
+_X_HIDDEN void
 _XFreeAtomTable(Display *dpy)
 {
     register Entry *table;
@@ -114,7 +114,7 @@ nomatch:    if (idx == firstidx)
     return None;
 }
 
-void
+_X_HIDDEN void
 _XUpdateAtomCache(
     Display *dpy,
     const char *name,
diff --git a/src/Key.h b/src/Key.h
index a0ca795..5cfabbe 100644
--- a/src/Key.h
+++ b/src/Key.h
@@ -7,10 +7,6 @@
 extern const unsigned char _XkeyTable[];
 #endif
 
-extern int
-_XKeyInitialize(
-    Display *dpy);
-
 extern XrmDatabase
 _XInitKeysymDB(
         void);
diff --git a/src/KeyBind.c b/src/KeyBind.c
index e8becf0..52e2198 100644
--- a/src/KeyBind.c
+++ b/src/KeyBind.c
@@ -121,48 +121,6 @@ KeyCodetoKeySym(register Display *dpy, KeyCode keycode, int col)
     return syms[col];
 }
 
-KeySym
-XKeycodeToKeysym(Display *dpy,
-#if NeedWidePrototypes
-		 unsigned int kc,
-#else
-		 KeyCode kc,
-#endif
-		 int col)
-{
-    if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
-	return NoSymbol;
-    return KeyCodetoKeySym(dpy, kc, col);
-}
-
-KeyCode
-XKeysymToKeycode(
-    Display *dpy,
-    KeySym ks)
-{
-    register int i, j;
-
-    if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
-	return (KeyCode) 0;
-    for (j = 0; j < dpy->keysyms_per_keycode; j++) {
-	for (i = dpy->min_keycode; i <= dpy->max_keycode; i++) {
-	    if (KeyCodetoKeySym(dpy, (KeyCode) i, j) == ks)
-		return i;
-	}
-    }
-    return 0;
-}
-
-KeySym
-XLookupKeysym(
-    register XKeyEvent *event,
-    int col)
-{
-    if ((! event->display->keysyms) && (! _XKeyInitialize(event->display)))
-	return NoSymbol;
-    return KeyCodetoKeySym(event->display, event->keycode, col);
-}
-
 static void
 ResetModMap(
     Display *dpy)
@@ -231,36 +189,7 @@ InitModMap(
     return 1;
 }
 
-int
-XRefreshKeyboardMapping(register XMappingEvent *event)
-{
-
-    if(event->request == MappingKeyboard) {
-	/* XXX should really only refresh what is necessary
-	 * for now, make initialize test fail
-	 */
-	LockDisplay(event->display);
-	if (event->display->keysyms) {
-	     Xfree ((char *)event->display->keysyms);
-	     event->display->keysyms = NULL;
-	}
-	UnlockDisplay(event->display);
-    }
-    if(event->request == MappingModifier) {
-	LockDisplay(event->display);
-	if (event->display->modifiermap) {
-	    XFreeModifiermap(event->display->modifiermap);
-	    event->display->modifiermap = NULL;
-	}
-	UnlockDisplay(event->display);
-	/* go ahead and get it now, since initialize test may not fail */
-	if (event->display->keysyms)
-	    (void) InitModMap(event->display);
-    }
-    return 1;
-}
-
-int
+static int
 _XKeyInitialize(
     Display *dpy)
 {
@@ -291,6 +220,89 @@ _XKeyInitialize(
     return 1;
 }
 
+#ifdef XKB
+_X_HIDDEN
+#endif
+KeySym
+XKeycodeToKeysym(Display *dpy,
+#if NeedWidePrototypes
+		 unsigned int kc,
+#else
+		 KeyCode kc,
+#endif
+		 int col)
+{
+    if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+	return NoSymbol;
+    return KeyCodetoKeySym(dpy, kc, col);
+}
+
+#ifdef XKB
+_X_HIDDEN
+#endif
+KeyCode
+XKeysymToKeycode(
+    Display *dpy,
+    KeySym ks)
+{
+    register int i, j;
+
+    if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+	return (KeyCode) 0;
+    for (j = 0; j < dpy->keysyms_per_keycode; j++) {
+	for (i = dpy->min_keycode; i <= dpy->max_keycode; i++) {
+	    if (KeyCodetoKeySym(dpy, (KeyCode) i, j) == ks)
+		return i;
+	}
+    }
+    return 0;
+}
+
+#ifdef XKB
+_X_HIDDEN
+#endif
+KeySym
+XLookupKeysym(
+    register XKeyEvent *event,
+    int col)
+{
+    if ((! event->display->keysyms) && (! _XKeyInitialize(event->display)))
+	return NoSymbol;
+    return KeyCodetoKeySym(event->display, event->keycode, col);
+}
+
+#ifdef XKB
+_X_HIDDEN
+#endif
+int
+XRefreshKeyboardMapping(register XMappingEvent *event)
+{
+
+    if(event->request == MappingKeyboard) {
+	/* XXX should really only refresh what is necessary
+	 * for now, make initialize test fail
+	 */
+	LockDisplay(event->display);
+	if (event->display->keysyms) {
+	     Xfree ((char *)event->display->keysyms);
+	     event->display->keysyms = NULL;
+	}
+	UnlockDisplay(event->display);
+    }
+    if(event->request == MappingModifier) {
+	LockDisplay(event->display);
+	if (event->display->modifiermap) {
+	    XFreeModifiermap(event->display->modifiermap);
+	    event->display->modifiermap = NULL;
+	}
+	UnlockDisplay(event->display);
+	/* go ahead and get it now, since initialize test may not fail */
+	if (event->display->keysyms)
+	    (void) InitModMap(event->display);
+    }
+    return 1;
+}
+
 static void
 UCSConvertCase( register unsigned code,
                 KeySym *lower,
@@ -758,7 +770,7 @@ XConvertCase(
     }
 }
 
-int
+_X_HIDDEN int
 _XTranslateKey(	register Display *dpy,
 		KeyCode keycode,
 		register unsigned int modifiers,
@@ -818,7 +830,7 @@ _XTranslateKey(	register Display *dpy,
     return 1;
 }
 
-int
+_X_HIDDEN int
 _XTranslateKeySym(
     Display *dpy,
     register KeySym symbol,
@@ -878,6 +890,9 @@ _XTranslateKeySym(
 }
 
 /*ARGSUSED*/
+#ifdef XKB
+_X_HIDDEN
+#endif
 int
 XLookupString (
     register XKeyEvent *event,
@@ -1026,6 +1041,9 @@ XRebindKeysym (
     return 0;
 }
 
+#ifdef XKB
+_X_HIDDEN
+#endif
 unsigned
 _XKeysymToModifiers(
     Display *dpy,
diff --git a/src/OpenDis.c b/src/OpenDis.c
index 230ae56..e9c084a 100644
--- a/src/OpenDis.c
+++ b/src/OpenDis.c
@@ -64,8 +64,8 @@ typedef struct {
 
 #ifdef XTHREADS
 #include "locking.h"
-int  (*_XInitDisplayLock_fn)(Display *dpy) = NULL;
-void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL;
+_X_HIDDEN int  (*_XInitDisplayLock_fn)(Display *dpy) = NULL;
+_X_HIDDEN void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL;
 
 #define InitDisplayLock(d)	(_XInitDisplayLock_fn ? (*_XInitDisplayLock_fn)(d) : Success)
 #define FreeDisplayLock(d)	if (_XFreeDisplayLock_fn) (*_XFreeDisplayLock_fn)(d)
@@ -788,6 +788,7 @@ _XBigReqHandler(
  * before the first possible call on this.
  */
 
+_X_HIDDEN
 void _XFreeDisplayStructure(Display *dpy)
 {
 	/* move all cookies in the EQ to the jar, then free them. */
diff --git a/src/StrKeysym.c b/src/StrKeysym.c
index a6d7b2d..a7c735e 100644
--- a/src/StrKeysym.c
+++ b/src/StrKeysym.c
@@ -50,7 +50,7 @@ static Bool initialized;
 static XrmDatabase keysymdb;
 static XrmQuark Qkeysym[2];
 
-XrmDatabase
+_X_HIDDEN XrmDatabase
 _XInitKeysymDB(void)
 {
     if (!initialized)
diff --git a/src/XlibInt.c b/src/XlibInt.c
index 9505b3f..f62b66b 100644
--- a/src/XlibInt.c
+++ b/src/XlibInt.c
@@ -602,7 +602,7 @@ _XPrivSyncFunction (Display *dpy)
     return 0;
 }
 
-void _XSetPrivSyncFunction(Display *dpy)
+_X_HIDDEN void _XSetPrivSyncFunction(Display *dpy)
 {
     if (!(dpy->flags & XlibDisplayPrivSync)) {
 	dpy->savedsynchandler = dpy->synchandler;
@@ -611,7 +611,7 @@ void _XSetPrivSyncFunction(Display *dpy)
     }
 }
 
-void _XSetSeqSyncFunction(Display *dpy)
+_X_HIDDEN void _XSetSeqSyncFunction(Display *dpy)
 {
     if (sync_hazard(dpy))
 	_XSetPrivSyncFunction (dpy);
@@ -1538,7 +1538,7 @@ _XGetMiscCode(
     }
 }
 
-int
+_X_HIDDEN int
 _XIDHandler(
     register Display *dpy)
 {
diff --git a/src/evtomask.c b/src/evtomask.c
index fbbb998..de42353 100644
--- a/src/evtomask.c
+++ b/src/evtomask.c
@@ -30,12 +30,13 @@ in this Software without prior written authorization from The Open Group.
 #include <config.h>
 #endif
 #include <X11/X.h>
+#include <X11/Xfuncproto.h>
 
 /*
  * This array can be used given an event type to determine the mask bits
  * that could have generated it.
  */
-long const _Xevent_to_mask [LASTEvent] = {
+_X_HIDDEN long const _Xevent_to_mask [LASTEvent] = {
 	0,						/* no event 0 */
 	0,						/* no event 1 */
 	KeyPressMask,					/* KeyPress */
diff --git a/src/globals.c b/src/globals.c
index 30ff11d..e98481f 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -87,7 +87,7 @@ ZEROINIT (_XQEvent *, _qfree, NULL);
  * Debugging information and display list; used to be in XOpenDis.c
  */
 ZEROINIT (int, _Xdebug, 0);
-ZEROINIT (Display *, _XHeadOfDisplayList, NULL);
+_X_HIDDEN ZEROINIT (Display *, _XHeadOfDisplayList, NULL);
 
 
 
diff --git a/src/xcb_disp.c b/src/xcb_disp.c
index 2625966..3ff836b 100644
--- a/src/xcb_disp.c
+++ b/src/xcb_disp.c
@@ -50,6 +50,7 @@ void XSetAuthorization(char *name, int namelen, char *data, int datalen)
 	_XUnlockMutex(_Xglobal_lock);
 }
 
+_X_HIDDEN
 int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *screenp)
 {
 	char *host;
@@ -105,6 +106,7 @@ int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *scr
 	return !xcb_connection_has_error(c);
 }
 
+_X_HIDDEN
 void _XFreeX11XCBStructure(Display *dpy)
 {
 	/* reply_data was allocated by system malloc, not Xmalloc */
diff --git a/src/xcb_io.c b/src/xcb_io.c
index 4f0159c..23c1fa5 100644
--- a/src/xcb_io.c
+++ b/src/xcb_io.c
@@ -353,7 +353,7 @@ void _XFlush(Display *dpy)
 
 static const XID inval_id = ~0UL;
 
-int _XIDHandler(Display *dpy)
+_X_HIDDEN int _XIDHandler(Display *dpy)
 {
 	XID next;
 
-- 
1.6.3.3



More information about the xorg-devel mailing list