From cfb106b16b769dde6307a4874af7014bea2c0eb6 Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 4 Jul 2003 23:18:26 +0000 Subject: [PATCH] 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. svn path=/trunk/timing/; revision=5060 --- timing/timing.c | 2 ++ timing/timing.h | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/timing/timing.c b/timing/timing.c index f6c31cb..556c405 100644 --- a/timing/timing.c +++ b/timing/timing.c @@ -26,6 +26,8 @@ #include "timing.h" +/* see timing.h for an explanation of _mangle() */ + /* * Returns milliseconds no matter what. */ diff --git a/timing/timing.h b/timing/timing.h index 8fa181b..8e00c77 100644 --- a/timing/timing.h +++ b/timing/timing.h @@ -11,6 +11,12 @@ typedef __int64 int64_t; 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);