summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@wingomac.bcn.oblong.net>2009-05-26 17:39:58 +0200
committerAndy Wingo <wingo@wingomac.bcn.oblong.net>2009-05-26 17:46:03 +0200
commit442f3f20ddd33b43743ea181d95024c10622df52 (patch)
treed59eab83bc18303d1c4972961ef1ffefbbc601bd
parentd9a9e18205f4da1486a70dbd5690b8fdc593cb10 (diff)
downloadguile-442f3f20ddd33b43743ea181d95024c10622df52.tar.gz
symbols are now hidden unless explicitly exported by SCM_API
* libguile/__scm.h (SCM_API, SCM_INTERNAL): Take the reverse strategy: symbols will be hidden by default, and only exported with SCM_API. In addition to working on Mac OS, it has the several nice efficiency benefits on Linux, and unifies codepaths with Win32. * libguile/Makefile.am: Define BUILDING_LIBGUILE when building Guile.
-rw-r--r--libguile/Makefile.am4
-rw-r--r--libguile/__scm.h26
2 files changed, 14 insertions, 16 deletions
diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index 369b24951..63f2ef2bf 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -32,10 +32,10 @@ DEFAULT_INCLUDES =
## Check for headers in $(srcdir)/.., so that #include
## <libguile/MUMBLE.h> will find MUMBLE.h in this dir when we're
## building. Also look for Gnulib headers in `lib'.
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir) \
+AM_CPPFLAGS = -DBUILDING_LIBGUILE=1 -I$(top_srcdir) -I$(top_builddir) \
-I$(top_srcdir)/lib -I$(top_builddir)/lib
-AM_CFLAGS = $(GCC_CFLAGS)
+AM_CFLAGS = $(GCC_CFLAGS) $(CFLAG_VISIBILITY)
## The Gnulib Libtool archive.
gnulib_library = $(top_builddir)/lib/libgnu.la
diff --git a/libguile/__scm.h b/libguile/__scm.h
index 3672b1c09..07d7b4d3d 100644
--- a/libguile/__scm.h
+++ b/libguile/__scm.h
@@ -98,13 +98,10 @@
#define SCM_UNLIKELY(_expr) SCM_EXPECT ((_expr), 0)
/* The SCM_INTERNAL macro makes it possible to explicitly declare a function
- * as having "internal" linkage. */
-#if (defined __GNUC__) && \
- ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ == 3))
-# define SCM_INTERNAL extern __attribute__ ((__visibility__ ("internal")))
-#else
-# define SCM_INTERNAL extern
-#endif
+ * as having "internal" linkage. However our current tack on this problem is
+ * to use GCC 4's -fvisibility=hidden, making functions internal by default,
+ * and then SCM_API marks them for export. */
+#define SCM_INTERNAL extern
@@ -154,13 +151,14 @@
/* SCM_API is a macro prepended to all function and data definitions
- which should be exported or imported in the resulting dynamic link
- library (DLL) in the Win32 port. */
-
-#if defined (SCM_IMPORT)
-# define SCM_API __declspec (dllimport) extern
-#elif defined (SCM_EXPORT) || defined (DLL_EXPORT)
-# define SCM_API __declspec (dllexport) extern
+ which should be exported from libguile. */
+
+#if BUILDING_LIBGUILE && HAVE_VISIBILITY
+# define SCM_API extern __attribute__((__visibility__("default")))
+#elif BUILDING_LIBGUILE && defined _MSC_VER
+# define SCM_API __declspec(dllexport) extern
+#elif defined _MSC_VER
+# define SCM_API __declspec(dllimport) extern
#else
# define SCM_API extern
#endif