[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lib-symbol-visibility: Fix a misnomer
From: |
Bruno Haible |
Subject: |
lib-symbol-visibility: Fix a misnomer |
Date: |
Sat, 16 Sep 2023 11:34:38 +0200 |
The macro DLL_EXPORTED was used for Windows-specific purposes in the beginning.
But since it possibly expands to
__attribute__((__visibility__("default")))
on ELF, macOS, AIX, Cygwin platforms, it is no longer Windows-specific. But
the term "DLL" makes us think that it is. This patch fixes the misnomer.
2023-09-16 Bruno Haible <bruno@clisp.org>
lib-symbol-visibility: Fix a misnomer.
* doc/lib-symbol-visibility.texi: Rename LIBFOO_DLL_EXPORTED to
LIBFOO_SHLIB_EXPORTED. Prefer the term "shared library", since the term
"DLL" applies only to Windows.
* lib/relocatable.h (RELOCATABLE_SHLIB_EXPORTED): Renamed from
RELOCATABLE_DLL_EXPORTED. Prefer the term "shared library", since the
term "DLL" applies only to Windows.
* lib/mbtowc-lock.c (SHLIB_EXPORTED): Renamed from DLL_EXPORTED.
* lib/nl_langinfo-lock.c (SHLIB_EXPORTED): Likewise.
* lib/setlocale-lock.c (SHLIB_EXPORTED): Likewise.
diff --git a/doc/lib-symbol-visibility.texi b/doc/lib-symbol-visibility.texi
index 5a3b3cdbfb..904c1fdc5d 100644
--- a/doc/lib-symbol-visibility.texi
+++ b/doc/lib-symbol-visibility.texi
@@ -140,16 +140,16 @@
Define a macro specific to your library like this.
@smallexample
#if HAVE_VISIBILITY && BUILDING_LIBFOO
-# define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default")))
+# define LIBFOO_SHLIB_EXPORTED __attribute__((__visibility__("default")))
#else
-# define LIBFOO_DLL_EXPORTED
+# define LIBFOO_SHLIB_EXPORTED
#endif
@end smallexample
This macro should be enabled in all public header files of your library.
@item
Annotate all variable, function and class declarations in all public header
-files of your library with @samp{LIBFOO_DLL_EXPORTED}. This annotation
+files of your library with @samp{LIBFOO_SHLIB_EXPORTED}. This annotation
can occur at different locations: between the @samp{extern} and the
type or return type, or just before the entity being declared, or after
the entire declarator. My preference is to put it right after @samp{extern},
@@ -168,17 +168,17 @@
the definition of the macro mentioned above, to something like this:
@smallexample
#if HAVE_VISIBILITY && BUILDING_LIBFOO
-# define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default")))
+# define LIBFOO_SHLIB_EXPORTED __attribute__((__visibility__("default")))
#elif (defined _WIN32 && !defined __CYGWIN__) && @@BUILDING_SHARED@@ &&
BUILDING_LIBFOO
# if defined DLL_EXPORT
-# define LIBFOO_DLL_EXPORTED __declspec(dllexport)
+# define LIBFOO_SHLIB_EXPORTED __declspec(dllexport)
# else
-# define LIBFOO_DLL_EXPORTED
+# define LIBFOO_SHLIB_EXPORTED
# endif
#elif (defined _WIN32 && !defined __CYGWIN__) && @@BUILDING_SHARED@@
-# define LIBFOO_DLL_EXPORTED __declspec(dllimport)
+# define LIBFOO_SHLIB_EXPORTED __declspec(dllimport)
#else
-# define LIBFOO_DLL_EXPORTED
+# define LIBFOO_SHLIB_EXPORTED
#endif
@end smallexample
@noindent
@@ -198,5 +198,6 @@
@noindent
And @code{DLL_EXPORT} is defined by Libtool, on Windows platforms, when
-compiling for a DLL. It is not defined when Libtool compiles an object
-file meant to be linked statically into some executable.
+compiling for a shared library (called DLL under Windows).
+It is not defined when Libtool compiles an object file meant to be linked
+statically into some executable.
diff --git a/lib/mbtowc-lock.c b/lib/mbtowc-lock.c
index 6ca6e10f94..c4d0b088f6 100644
--- a/lib/mbtowc-lock.c
+++ b/lib/mbtowc-lock.c
@@ -37,14 +37,14 @@ typedef int dummy;
/* Macro for exporting a symbol (function, not variable) defined in this file,
when compiled into a shared library. */
-# ifndef DLL_EXPORTED
+# ifndef SHLIB_EXPORTED
# if HAVE_VISIBILITY
/* Override the effect of the compiler option '-fvisibility=hidden'. */
-# define DLL_EXPORTED __attribute__((__visibility__("default")))
+# define SHLIB_EXPORTED __attribute__((__visibility__("default")))
# elif defined _WIN32 || defined __CYGWIN__
-# define DLL_EXPORTED __declspec(dllexport)
+# define SHLIB_EXPORTED __declspec(dllexport)
# else
-# define DLL_EXPORTED
+# define SHLIB_EXPORTED
# endif
# endif
@@ -59,7 +59,7 @@ typedef int dummy;
because the latter is not guaranteed to be a stable ABI in the future. */
/* Make sure the function gets exported from DLLs. */
-DLL_EXPORTED CRITICAL_SECTION *gl_get_mbtowc_lock (void);
+SHLIB_EXPORTED CRITICAL_SECTION *gl_get_mbtowc_lock (void);
static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
static CRITICAL_SECTION lock;
@@ -96,7 +96,7 @@ gl_get_mbtowc_lock (void)
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
/* Make sure the function gets exported from shared libraries. */
-DLL_EXPORTED pthread_mutex_t *gl_get_mbtowc_lock (void);
+SHLIB_EXPORTED pthread_mutex_t *gl_get_mbtowc_lock (void);
/* Returns the internal lock used by mbrtowc and mbrtoc32. */
pthread_mutex_t *
@@ -123,7 +123,7 @@ atomic_init (void)
}
/* Make sure the function gets exported from shared libraries. */
-DLL_EXPORTED mtx_t *gl_get_mbtowc_lock (void);
+SHLIB_EXPORTED mtx_t *gl_get_mbtowc_lock (void);
/* Returns the internal lock used by mbrtowc and mbrtoc32. */
mtx_t *
diff --git a/lib/nl_langinfo-lock.c b/lib/nl_langinfo-lock.c
index e5cdcd3e77..fb12299959 100644
--- a/lib/nl_langinfo-lock.c
+++ b/lib/nl_langinfo-lock.c
@@ -37,14 +37,14 @@ typedef int dummy;
/* Macro for exporting a symbol (function, not variable) defined in this file,
when compiled into a shared library. */
-# ifndef DLL_EXPORTED
+# ifndef SHLIB_EXPORTED
# if HAVE_VISIBILITY
/* Override the effect of the compiler option '-fvisibility=hidden'. */
-# define DLL_EXPORTED __attribute__((__visibility__("default")))
+# define SHLIB_EXPORTED __attribute__((__visibility__("default")))
# elif defined _WIN32 || defined __CYGWIN__
-# define DLL_EXPORTED __declspec(dllexport)
+# define SHLIB_EXPORTED __declspec(dllexport)
# else
-# define DLL_EXPORTED
+# define SHLIB_EXPORTED
# endif
# endif
@@ -59,7 +59,7 @@ typedef int dummy;
because the latter is not guaranteed to be a stable ABI in the future. */
/* Make sure the function gets exported from DLLs. */
-DLL_EXPORTED CRITICAL_SECTION *gl_get_nl_langinfo_lock (void);
+SHLIB_EXPORTED CRITICAL_SECTION *gl_get_nl_langinfo_lock (void);
static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
static CRITICAL_SECTION lock;
@@ -96,7 +96,7 @@ gl_get_nl_langinfo_lock (void)
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
/* Make sure the function gets exported from shared libraries. */
-DLL_EXPORTED pthread_mutex_t *gl_get_nl_langinfo_lock (void);
+SHLIB_EXPORTED pthread_mutex_t *gl_get_nl_langinfo_lock (void);
/* Returns the internal lock used by nl_langinfo. */
pthread_mutex_t *
@@ -123,7 +123,7 @@ atomic_init (void)
}
/* Make sure the function gets exported from shared libraries. */
-DLL_EXPORTED mtx_t *gl_get_nl_langinfo_lock (void);
+SHLIB_EXPORTED mtx_t *gl_get_nl_langinfo_lock (void);
/* Returns the internal lock used by nl_langinfo. */
mtx_t *
diff --git a/lib/relocatable.h b/lib/relocatable.h
index fcbbb21934..ae2a880c07 100644
--- a/lib/relocatable.h
+++ b/lib/relocatable.h
@@ -33,11 +33,11 @@ extern "C" {
/* This can be enabled through the configure --enable-relocatable option. */
#if ENABLE_RELOCATABLE
-/* When building a DLL, we must export some functions. Note that because
- this is a private .h file, we don't need to use __declspec(dllimport)
- in any case. */
+/* When building a shared library, we must export some functions.
+ Note that because this is a private .h file, we don't need to use
+ __declspec(dllimport) in any case. */
#if HAVE_VISIBILITY && BUILDING_DLL
-# define RELOCATABLE_DLL_EXPORTED __attribute__((__visibility__("default")))
+# define RELOCATABLE_SHLIB_EXPORTED __attribute__((__visibility__("default")))
#elif defined _MSC_VER && BUILDING_DLL
/* When building with MSVC, exporting a symbol means that the object file
contains a "linker directive" of the form /EXPORT:symbol. This can be
@@ -45,16 +45,16 @@ extern "C" {
"dumpbin /directives FILE" commands.
The symbols from this file should be exported if and only if the object
file gets included in a DLL. Libtool, on Windows platforms, defines
- the C macro DLL_EXPORT (together with PIC) when compiling for a DLL
- and does not define it when compiling an object file meant to be linked
- statically into some executable. */
+ the C macro DLL_EXPORT (together with PIC) when compiling for a shared
+ library (called DLL under Windows) and does not define it when compiling
+ an object file meant to be linked statically into some executable. */
# if defined DLL_EXPORT
-# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
+# define RELOCATABLE_SHLIB_EXPORTED __declspec(dllexport)
# else
-# define RELOCATABLE_DLL_EXPORTED
+# define RELOCATABLE_SHLIB_EXPORTED
# endif
#else
-# define RELOCATABLE_DLL_EXPORTED
+# define RELOCATABLE_SHLIB_EXPORTED
#endif
/* Sets the original and the current installation prefix of the package.
@@ -62,7 +62,7 @@ extern "C" {
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
-extern RELOCATABLE_DLL_EXPORTED void
+extern RELOCATABLE_SHLIB_EXPORTED void
set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix);
diff --git a/lib/setlocale-lock.c b/lib/setlocale-lock.c
index b70ba09b00..593f63711b 100644
--- a/lib/setlocale-lock.c
+++ b/lib/setlocale-lock.c
@@ -37,14 +37,14 @@ typedef int dummy;
/* Macro for exporting a symbol (function, not variable) defined in this file,
when compiled into a shared library. */
-# ifndef DLL_EXPORTED
+# ifndef SHLIB_EXPORTED
# if HAVE_VISIBILITY
/* Override the effect of the compiler option '-fvisibility=hidden'. */
-# define DLL_EXPORTED __attribute__((__visibility__("default")))
+# define SHLIB_EXPORTED __attribute__((__visibility__("default")))
# elif defined _WIN32 || defined __CYGWIN__
-# define DLL_EXPORTED __declspec(dllexport)
+# define SHLIB_EXPORTED __declspec(dllexport)
# else
-# define DLL_EXPORTED
+# define SHLIB_EXPORTED
# endif
# endif
@@ -59,7 +59,7 @@ typedef int dummy;
because the latter is not guaranteed to be a stable ABI in the future. */
/* Make sure the function gets exported from DLLs. */
-DLL_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
+SHLIB_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
static CRITICAL_SECTION lock;
@@ -96,7 +96,7 @@ gl_get_setlocale_null_lock (void)
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
/* Make sure the function gets exported from shared libraries. */
-DLL_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void);
+SHLIB_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void);
/* Returns the internal lock used by setlocale_null_r. */
pthread_mutex_t *
@@ -123,7 +123,7 @@ atomic_init (void)
}
/* Make sure the function gets exported from shared libraries. */
-DLL_EXPORTED mtx_t *gl_get_setlocale_null_lock (void);
+SHLIB_EXPORTED mtx_t *gl_get_setlocale_null_lock (void);
/* Returns the internal lock used by setlocale_null_r. */
mtx_t *
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lib-symbol-visibility: Fix a misnomer,
Bruno Haible <=