[xiph-cvs] cvs commit: timing timing.c timing.h
Ralph Giles
giles at xiph.org
Fri Jul 4 16:18:27 PDT 2003
giles 03/07/04 19:18:26
Modified: . configure.in
src shout.c
. timing.c timing.h
Log:
Add a name mangling mechanism so we can safely compile in code we share with applications that might link with use. Currently only hooked up for the timing liblet, but thread is the real target.
Basically we define _mangle() in config.h, and use that in timing.h (if available) to prepend the package name to all the symbols in the header and including C files. It's thus fairly invisible.
Unfortunately the prefix is hardwired, so it's another thing that has to be maintained by hand (not that is changes often, but we can't make it a macro). AH_VERBATIM seems to be the only way to add a macro that takes arguments, and it explicitly doesn't do shell expansion. Further, @PACKAGE@ substitution doesn't happen on config.h.in. Insert standard autotools frustration here.
Revision Changes Path
1.59 +8 -1 libshout/configure.in
Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/libshout/configure.in,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- configure.in 4 Jul 2003 02:20:41 -0000 1.58
+++ configure.in 4 Jul 2003 23:18:26 -0000 1.59
@@ -1,5 +1,5 @@
# Process this file with autoconf to produce a configure script.
-# $Id: configure.in,v 1.58 2003/07/04 02:20:41 brendan Exp $
+# $Id: configure.in,v 1.59 2003/07/04 23:18:26 giles Exp $
m4_define(libshout_major, 2)
m4_define(libshout_minor, 0)
@@ -25,6 +25,13 @@
AM_INIT_AUTOMAKE([libshout], libshout_version)
AM_MAINTAINER_MODE
+
+dnl create our name mangling macro
+dnl the prefix must be hardwired because of AH limitations
+AH_VERBATIM([_mangle], [
+/* name mangling to protect code we share with other libraries */
+#define _mangle(proc) shout ## _ ## proc
+])
AC_PROG_CC
AM_PROG_LIBTOOL
<p><p>1.43 +2 -2 libshout/src/shout.c
Index: shout.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/shout.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- shout.c 2 Jul 2003 16:39:51 -0000 1.42
+++ shout.c 4 Jul 2003 23:18:26 -0000 1.43
@@ -12,8 +12,8 @@
#include <shout/shout.h>
#include <net/sock.h>
-#include <timing/timing.h>
-#include <httpp/httpp.h>
+#include "timing/timing.h"
+#include "httpp/httpp.h"
#include "shout_private.h"
#include "util.h"
<p><p>1.11 +2 -0 timing/timing.c
Index: timing.c
===================================================================
RCS file: /usr/local/cvsroot/timing/timing.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- timing.c 5 Jun 2003 19:18:00 -0000 1.10
+++ timing.c 4 Jul 2003 23:18:26 -0000 1.11
@@ -26,6 +26,8 @@
#include "timing.h"
+/* see timing.h for an explanation of _mangle() */
+
/*
* Returns milliseconds no matter what.
*/
<p><p>1.5 +6 -0 timing/timing.h
Index: timing.h
===================================================================
RCS file: /usr/local/cvsroot/timing/timing.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- timing.h 7 Feb 2002 01:04:09 -0000 1.4
+++ timing.h 4 Jul 2003 23:18:26 -0000 1.5
@@ -11,6 +11,12 @@
typedef unsigned __int64 uint64_t;
#endif
+/* config.h should be included before we are to define _mangle */
+#ifdef _mangle
+# define timing_get_time _mangle(timing_get_time)
+# define timing_sleep _mangle(timing_sleep)
+#endif
+
uint64_t timing_get_time(void);
void timing_sleep(uint64_t sleeptime);
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list