[PATCH:xscope 11/24] Move ILong, IShort, etal to inline functions in x11.h
Alan Coopersmith
alan.coopersmith at oracle.com
Fri Aug 31 22:17:53 PDT 2012
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
scope.h | 3 ++-
server.c | 57 --------------------------------------------------------
x11.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 58 insertions(+), 65 deletions(-)
diff --git a/scope.h b/scope.h
index 426d67a..2fb627d 100644
--- a/scope.h
+++ b/scope.h
@@ -100,7 +100,6 @@ extern char AudioServerHostName[MAXHOSTNAMELEN];
/* ********************************************** */
#include "fd.h"
-#include "proto.h"
#define BUFFER_SIZE (1024 * 32)
@@ -124,4 +123,6 @@ extern long ServerBasePort;
extern char ScopeEnabled;
extern long TranslateText;
+#include "proto.h"
+
#endif /* XSCOPE_SCOPE_H */
diff --git a/server.c b/server.c
index 5226a03..d822ea9 100644
--- a/server.c
+++ b/server.c
@@ -127,63 +127,6 @@ PrintTime(void)
/* */
/* ************************************************************ */
-/* we will need to be able to interpret the values stored in the
- requests as various built-in types. The following routines
- support the types built into X11 */
-
-long
-pad(long n)
-{
- /* round up to next multiple of 4 */
- return ((n + 3) & ~0x3);
-}
-
-uint32_t
-ILong(const unsigned char buf[])
-{
- /* check for byte-swapping */
- if (littleEndian)
- return ((((((buf[3] << 8) | buf[2]) << 8) | buf[1]) << 8) | buf[0]);
- return ((((((buf[0] << 8) | buf[1]) << 8) | buf[2]) << 8) | buf[3]);
-}
-
-uint16_t
-IShort(const unsigned char buf[])
-{
- /* check for byte-swapping */
- if (littleEndian)
- return (buf[1] << 8) | buf[0];
- return ((buf[0] << 8) | buf[1]);
-}
-
-uint16_t
-IChar2B(const unsigned char buf[])
-{
- /* CHAR2B is like an IShort, but not byte-swapped */
- return ((buf[0] << 8) | buf[1]);
-}
-
-uint8_t
-IByte(const unsigned char buf[])
-{
- return (buf[0]);
-}
-
-Boolean
-IBool(const unsigned char buf[])
-{
- if (buf[0] != 0)
- return (true);
- else
- return (false);
-}
-
-
-/* ************************************************************ */
-/* */
-/* */
-/* ************************************************************ */
-
/* we will need to save bytes until we get a complete request to
interpret. The following procedures provide this ability */
diff --git a/x11.h b/x11.h
index 2a8b6bb..ed0f3d6 100644
--- a/x11.h
+++ b/x11.h
@@ -531,13 +531,64 @@ extern void PrintValueRec(unsigned long key, unsigned long cmask, short ctype);
/* */
/* ************************************************************ */
+/* we will need to be able to interpret the values stored in the
+ requests as various built-in types. The following routines
+ support the types built into X11 */
+
+static inline long
+pad(long n)
+{
+ /* round up to next multiple of 4 */
+ return ((n + 3) & ~0x3);
+}
+
+static inline uint32_t
+ILong(const unsigned char buf[])
+{
+ /* check for byte-swapping */
+ if (littleEndian)
+ return ((((((buf[3] << 8) | buf[2]) << 8) | buf[1]) << 8) | buf[0]);
+ return ((((((buf[0] << 8) | buf[1]) << 8) | buf[2]) << 8) | buf[3]);
+}
+
+static inline uint16_t
+IShort(const unsigned char buf[])
+{
+ /* check for byte-swapping */
+ if (littleEndian)
+ return (buf[1] << 8) | buf[0];
+ return ((buf[0] << 8) | buf[1]);
+}
+
+static inline uint16_t
+IChar2B(const unsigned char buf[])
+{
+ /* CHAR2B is like an IShort, but not byte-swapped */
+ return ((buf[0] << 8) | buf[1]);
+}
+
+static inline uint8_t
+IByte(const unsigned char buf[])
+{
+ return (buf[0]);
+}
+
+static inline Boolean
+IBool(const unsigned char buf[])
+{
+ if (buf[0] != 0)
+ return (true);
+ else
+ return (false);
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
/* declaration of the types of some common functions */
-extern uint32_t ILong(const unsigned char *buf);
-extern uint16_t IShort(const unsigned char *buf);
-extern uint16_t IChar2B(const unsigned char *buf);
-extern uint8_t IByte(const unsigned char *buf);
-extern Boolean IBool(const unsigned char *buf);
extern int PrintString8(const unsigned char *buf, int number, const char *name);
extern int PrintString16(const unsigned char *buf, int number,
@@ -552,8 +603,6 @@ extern long PrintList(const unsigned char *buf, long number, short ListType,
extern long PrintListSTR(const unsigned char *buf, long number,
const char *name);
-extern long pad(long n);
-
extern const char *REQUESTHEADER, *EVENTHEADER, *ERRORHEADER, *REPLYHEADER;
#define GC_function 0x00000001L
--
1.7.9.2
More information about the xorg-devel
mailing list