aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-08-22 17:08:08 +0000
committerWerner Koch <[email protected]>2014-08-25 14:37:46 +0000
commit216e7def2118a1774fa7ebeb45b8635b9fe6ba42 (patch)
treebcccb2ca1de195b79554f8d5fce6a77540829771 /src
parentFirst set of changes to include estream into the API. (diff)
downloadlibgpg-error-216e7def2118a1774fa7ebeb45b8635b9fe6ba42.tar.gz
libgpg-error-216e7def2118a1774fa7ebeb45b8635b9fe6ba42.zip
Implement symbol visibility.
* configure.ac: New option --enable-ld-version-script. (GPGRT_USE_VISIBILITY): New ac_define. (HAVE_LD_VERSION_SCRIPT): New am_conditional. * src/gpg-error.vers: New. * src/gpgrt-int.h: New. * src/visibility.c, src/visibility.h: New. Lot of changes to symbold names. -- This is only doe for the old API. The estream API needs to be added.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am37
-rw-r--r--src/code-from-errno.c10
-rw-r--r--src/code-to-errno.c6
-rw-r--r--src/estream.c4
-rw-r--r--src/estream.h2
-rw-r--r--src/gpg-error.def.in32
-rw-r--r--src/gpg-error.vers42
-rw-r--r--src/gpgrt-int.h49
-rw-r--r--src/init.c8
-rw-r--r--src/posix-lock.c8
-rw-r--r--src/posix-thread.c2
-rw-r--r--src/strerror.c8
-rw-r--r--src/strsource.c8
-rw-r--r--src/version.c2
-rw-r--r--src/visibility.c104
-rw-r--r--src/visibility.h91
-rw-r--r--src/w32-lock.c8
-rw-r--r--src/w32-thread.c2
18 files changed, 376 insertions, 47 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 20871a4..55a9bb9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -76,7 +76,7 @@ EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \
mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \
mkheader.c gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \
err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 \
- gpg-error.def.in versioninfo.rc.in \
+ gpg-error.vers gpg-error.def.in versioninfo.rc.in \
$(lock_obj_pub)
BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
@@ -90,6 +90,10 @@ CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \
gpg-extra/errno.h mkheader $(tmp_files) lock-obj-pub.native.h
+
+#
+# {{{ Begin Windows part
+#
if HAVE_W32_SYSTEM
arch_sources = w32-gettext.c w32-lock.c w32-lock-obj.h w32-thread.c
RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
@@ -115,7 +119,13 @@ uninstall-def-file:
libgpg_error_la_DEPENDENCIES = $(gpg_error_res) gpg-error.def
intllibs =
+#
+# }}} End Windows part
+#
else
+#
+# {{{ Begin Unix part
+#
arch_sources = posix-lock.c posix-lock-obj.h posix-thread.c
gpg_error_res =
no_undefined =
@@ -126,16 +136,29 @@ uninstall-def-file:
intllibs = @LTLIBINTL@
endif
+#
+# }}} End Unix part
+#
+if HAVE_LD_VERSION_SCRIPT
+ libgpg_error_vers_opt = -Wl,--version-script=$(srcdir)/gpg-error.vers
+else
+ libgpg_error_vers_opt =
+endif
-libgpg_error_la_LDFLAGS = -version-info \
- @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@ \
- $(no_undefined) $(export_symbols)
+libgpg_error_la_LDFLAGS = \
+ $(no_undefined) $(export_symbols) $(libgpg_error_vers_opt) \
+ -version-info \
+ @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@
libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \
- init.c init.h version.c lock.h thread.h \
- estream.c estream.h estream-printf.c estream-printf.h \
- strsource.c strerror.c code-to-errno.c code-from-errno.c
+ gpgrt-int.h init.c init.h version.c lock.h thread.h \
+ estream.c estream-printf.c estream-printf.h \
+ strsource.c strerror.c code-to-errno.c code-from-errno.c \
+ visibility.c visibility.h
+
+# libgpg_error_la_DEPENDENCIES = \
+# $(srcdir)/gpg-error.vers
# Note that RCCOMPILE needs the same defines as ..._la_CPPFLAGS but
# without the extra_cppflags because they may include am -idirafter
diff --git a/src/code-from-errno.c b/src/code-from-errno.c
index 96fcf20..6064270 100644
--- a/src/code-from-errno.c
+++ b/src/code-from-errno.c
@@ -7,12 +7,12 @@
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
libgpg-error is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with libgpg-error; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -22,7 +22,7 @@
#include <config.h>
#endif
-#include <errno.h>
+#include <errno.h>
#include <gpg-error.h>
@@ -32,7 +32,7 @@
GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
this). */
gpg_err_code_t
-gpg_err_code_from_errno (int err)
+_gpg_err_code_from_errno (int err)
{
int idx;
@@ -52,7 +52,7 @@ gpg_err_code_from_errno (int err)
returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
(report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
gpg_err_code_t
-gpg_err_code_from_syserror (void)
+_gpg_err_code_from_syserror (void)
{
int err = errno;
int idx;
diff --git a/src/code-to-errno.c b/src/code-to-errno.c
index 5873aad..6ba6d87 100644
--- a/src/code-to-errno.c
+++ b/src/code-to-errno.c
@@ -7,12 +7,12 @@
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
libgpg-error is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with libgpg-error; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -29,7 +29,7 @@
/* Retrieve the system error for the error code CODE. This returns 0
if CODE is not a system error code. */
int
-gpg_err_code_to_errno (gpg_err_code_t code)
+_gpg_err_code_to_errno (gpg_err_code_t code)
{
if (!(code & GPG_ERR_SYSTEM_ERROR))
return 0;
diff --git a/src/estream.c b/src/estream.c
index 2e31b51..5a1a80b 100644
--- a/src/estream.c
+++ b/src/estream.c
@@ -101,7 +101,7 @@
# include "../common/util.h"
#endif
-#include "estream.h"
+#include "gpgrt-int.h"
#include "estream-printf.h"
@@ -1143,8 +1143,6 @@ es_func_w32_read (void *cookie, void *buffer, size_t size)
else
{
_set_errno (map_w32_to_errno (ec));
- log_debug ("estream: ReadFile returned %d\n",
- (int)GetLastError ());
bytes_read = -1;
}
}
diff --git a/src/estream.h b/src/estream.h
index dd17031..cfb7eec 100644
--- a/src/estream.h
+++ b/src/estream.h
@@ -1,4 +1,4 @@
-/* estream.h - Interanl defiinitions for the Extended Stream I/O Library
+/* gpgrt-int.h - Internal definitions
* Copyright (C) 2014 g10 Code GmbH
*
* This file is part of libgpg-error.
diff --git a/src/gpg-error.def.in b/src/gpg-error.def.in
index 2ea482a..97bc00f 100644
--- a/src/gpg-error.def.in
+++ b/src/gpg-error.def.in
@@ -1,5 +1,25 @@
-/* gpg-error.def.in - Exported symbols
- * Needs to be processed by CPP.
+/* libgpg-error.def - Exported symbols for W32
+ * Copyright (C) 2014 g10 Code GmbH
+ *
+ * This file is part of libgpg-error.
+ *
+ * libgpg-error is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * libgpg-error is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Note: This file should be updated manually and the ordinals shall
+ * never be changed. Also check gpg-error.vers and visibility.h.
+ *
+ * This file needs to be pre-processed.
*/
#include <config.h>
@@ -10,7 +30,7 @@ EXPORTS
gpg_strsource @3
gpg_err_code_from_errno @4
gpg_err_code_to_errno @5
- gpg_err_init @6
+ /* Not anymore used. */
gpg_err_code_from_syserror @7
gpg_err_set_errno @8
#ifdef HAVE_W32CE_SYSTEM
@@ -26,7 +46,7 @@ EXPORTS
_gpg_w32_gettext_localename @16
_gpg_w32_gettext_use_utf8 @17
#endif
- gpg_err_deinit @18
+ /* Not anymore used. */
gpg_error_check_version @19
gpgrt_lock_init @20
@@ -34,3 +54,7 @@ EXPORTS
gpgrt_lock_unlock @22
gpgrt_lock_destroy @23
gpgrt_yield @24
+
+
+
+;; end of file with public symbols for Windows.
diff --git a/src/gpg-error.vers b/src/gpg-error.vers
new file mode 100644
index 0000000..8e67081
--- /dev/null
+++ b/src/gpg-error.vers
@@ -0,0 +1,42 @@
+# libgpg-error.vers - What symbols to export -*- std -*-
+# Copyright (C) 2014 g10 Code GmbH
+#
+# This file is part of libgpg-error.
+#
+# libgpg-error is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# libgpg-error is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# NOTE: When adding new functions, please make sure to add them to
+# visibility.h and gpg-error.def.in as well.
+
+
+GPG_ERROR_1.0 {
+ global:
+ gpg_strerror;
+ gpg_strerror_r;
+ gpg_strsource;
+ gpg_err_code_from_errno;
+ gpg_err_code_to_errno;
+ gpg_err_code_from_syserror;
+ gpg_err_set_errno;
+ gpg_error_check_version;
+
+ gpgrt_lock_init;
+ gpgrt_lock_lock;
+ gpgrt_lock_unlock;
+ gpgrt_lock_destroy;
+ gpgrt_yield;
+
+ local:
+ *;
+};
diff --git a/src/gpgrt-int.h b/src/gpgrt-int.h
new file mode 100644
index 0000000..044fe74
--- /dev/null
+++ b/src/gpgrt-int.h
@@ -0,0 +1,49 @@
+/* gpgrt-int.h - Internal definitions
+ * Copyright (C) 2014 g10 Code GmbH
+ *
+ * This file is part of libgpg-error.
+ *
+ * libgpg-error is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * libgpg-error is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GPGRT_GPGRT_INT_H
+#define _GPGRT_GPGRT_INT_H
+
+#include "gpg-error.h"
+#include "visibility.h"
+
+/* Local error function prototypes. */
+const char *_gpg_strerror (gpg_error_t err);
+int _gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
+const char *_gpg_strsource (gpg_error_t err);
+gpg_err_code_t _gpg_err_code_from_errno (int err);
+int _gpg_err_code_to_errno (gpg_err_code_t code);
+gpg_err_code_t _gpg_err_code_from_syserror (void);
+void _gpg_err_set_errno (int err);
+
+const char *_gpg_error_check_version (const char *req_version);
+
+gpg_err_code_t _gpgrt_lock_init (gpgrt_lock_t *lockhd);
+gpg_err_code_t _gpgrt_lock_lock (gpgrt_lock_t *lockhd);
+gpg_err_code_t _gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
+gpg_err_code_t _gpgrt_lock_destroy (gpgrt_lock_t *lockhd);
+gpg_err_code_t _gpgrt_yield (void);
+
+
+/* Local prototypes for estream. */
+int _gpgrt_es_init (void);
+
+
+
+#endif /*_GPGRT_GPGRT_INT_H*/
diff --git a/src/init.c b/src/init.c
index 40fa2a8..b7cc2fd 100644
--- a/src/init.c
+++ b/src/init.c
@@ -26,10 +26,8 @@
#include <string.h>
#include <errno.h>
-#include <gpg-error.h>
-
+#include "gpgrt-int.h"
#include "gettext.h"
-#include "estream.h"
#include "init.h"
#ifdef HAVE_W32CE_SYSTEM
@@ -365,7 +363,7 @@ _gpg_w32ce_strerror (int err)
void
-gpg_err_set_errno (int err)
+_gpg_err_set_errno (int err)
{
#ifdef HAVE_W32CE_SYSTEM
SetLastError (err);
@@ -430,7 +428,7 @@ DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
#else /*!HAVE_W32_SYSTEM*/
void
-gpg_err_set_errno (int err)
+_gpg_err_set_errno (int err)
{
errno = err;
}
diff --git a/src/posix-lock.c b/src/posix-lock.c
index 5b0cab5..22bb734 100644
--- a/src/posix-lock.c
+++ b/src/posix-lock.c
@@ -114,7 +114,7 @@ get_lock_object (gpgrt_lock_t *lockhd)
gpg_err_code_t
-gpgrt_lock_init (gpgrt_lock_t *lockhd)
+_gpgrt_lock_init (gpgrt_lock_t *lockhd)
{
_gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd;
int rc;
@@ -149,7 +149,7 @@ gpgrt_lock_init (gpgrt_lock_t *lockhd)
gpg_err_code_t
-gpgrt_lock_lock (gpgrt_lock_t *lockhd)
+_gpgrt_lock_lock (gpgrt_lock_t *lockhd)
{
_gpgrt_lock_t *lock = get_lock_object (lockhd);
int rc;
@@ -172,7 +172,7 @@ gpgrt_lock_lock (gpgrt_lock_t *lockhd)
gpg_err_code_t
-gpgrt_lock_unlock (gpgrt_lock_t *lockhd)
+_gpgrt_lock_unlock (gpgrt_lock_t *lockhd)
{
_gpgrt_lock_t *lock = get_lock_object (lockhd);
int rc;
@@ -197,7 +197,7 @@ gpgrt_lock_unlock (gpgrt_lock_t *lockhd)
/* Note: Use this function only if no other thread holds or waits for
this lock. */
gpg_err_code_t
-gpgrt_lock_destroy (gpgrt_lock_t *lockhd)
+_gpgrt_lock_destroy (gpgrt_lock_t *lockhd)
{
_gpgrt_lock_t *lock = get_lock_object (lockhd);
int rc;
diff --git a/src/posix-thread.c b/src/posix-thread.c
index a739e40..bef0386 100644
--- a/src/posix-thread.c
+++ b/src/posix-thread.c
@@ -45,7 +45,7 @@
gpg_err_code_t
-gpgrt_yield (void)
+_gpgrt_yield (void)
{
#if USE_POSIX_THREADS
# ifdef _POSIX_PRIORITY_SCHEDULING
diff --git a/src/strerror.c b/src/strerror.c
index dc56040..b0efb3d 100644
--- a/src/strerror.c
+++ b/src/strerror.c
@@ -7,12 +7,12 @@
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
libgpg-error is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with libgpg-error; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -35,7 +35,7 @@
/* Return a pointer to a string containing a description of the error
code in the error value ERR. This function is not thread-safe. */
const char *
-gpg_strerror (gpg_error_t err)
+_gpg_strerror (gpg_error_t err)
{
gpg_err_code_t code = gpg_err_code (err);
@@ -134,7 +134,7 @@ system_strerror_r (int no, char *buf, size_t buflen)
large enough, ERANGE is returned and BUF contains as much of the
beginning of the error string as fits into the buffer. */
int
-gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen)
+_gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen)
{
gpg_err_code_t code = gpg_err_code (err);
const char *errstr;
diff --git a/src/strsource.c b/src/strsource.c
index 66d783c..6604eb0 100644
--- a/src/strsource.c
+++ b/src/strsource.c
@@ -2,17 +2,17 @@
Copyright (C) 2003 g10 Code GmbH
This file is part of libgpg-error.
-
+
libgpg-error is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
libgpg-error is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with libgpg-error; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -30,7 +30,7 @@
/* Return a pointer to a string containing a description of the error
source in the error value ERR. */
const char *
-gpg_strsource (gpg_error_t err)
+_gpg_strsource (gpg_error_t err)
{
gpg_err_source_t source = gpg_err_source (err);
return dgettext (PACKAGE, msgstr + msgidx[msgidxof (source)]);
diff --git a/src/version.c b/src/version.c
index 5b40537..8bfe625 100644
--- a/src/version.c
+++ b/src/version.c
@@ -113,7 +113,7 @@ compare_versions (const char *my_version, const char *req_version)
* and the version string is simply returned.
*/
const char *
-gpg_error_check_version (const char *req_version)
+_gpg_error_check_version (const char *req_version)
{
if (req_version && req_version[0] == 1 && req_version[1] == 1)
return cright_blurb ();
diff --git a/src/visibility.c b/src/visibility.c
new file mode 100644
index 0000000..f7832ae
--- /dev/null
+++ b/src/visibility.c
@@ -0,0 +1,104 @@
+/* visibility.c - Wrapper for all public functions.
+ * Copyright (C) 2014 g10 Code GmbH
+ *
+ * This file is part of libgpg-error.
+ *
+ * libgpg-error is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * libgpg-error is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdarg.h>
+
+#define _GPGRT_INCL_BY_VISIBILITY_C 1
+#include "gpgrt-int.h"
+
+const char *
+gpg_strerror (gpg_error_t err)
+{
+ return _gpg_strerror (err);
+}
+
+int
+gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen)
+{
+ return _gpg_strerror_r (err, buf, buflen);
+}
+
+const char *
+gpg_strsource (gpg_error_t err)
+{
+ return _gpg_strsource (err);
+}
+
+gpg_err_code_t
+gpg_err_code_from_errno (int err)
+{
+ return _gpg_err_code_from_errno (err);
+}
+
+int
+gpg_err_code_to_errno (gpg_err_code_t code)
+{
+ return _gpg_err_code_to_errno (code);
+}
+
+gpg_err_code_t
+gpg_err_code_from_syserror (void)
+{
+ return _gpg_err_code_from_syserror ();
+}
+
+void
+gpg_err_set_errno (int err)
+{
+ _gpg_err_set_errno (err);
+}
+
+
+const char *
+gpg_error_check_version (const char *req_version)
+{
+ return _gpg_error_check_version (req_version);
+}
+
+
+gpg_err_code_t
+gpgrt_lock_init (gpgrt_lock_t *lockhd)
+{
+ return _gpgrt_lock_init (lockhd);
+}
+
+gpg_err_code_t
+gpgrt_lock_lock (gpgrt_lock_t *lockhd)
+{
+ return _gpgrt_lock_lock (lockhd);
+}
+
+gpg_err_code_t
+gpgrt_lock_unlock (gpgrt_lock_t *lockhd)
+{
+ return _gpgrt_lock_unlock (lockhd);
+}
+
+gpg_err_code_t
+gpgrt_lock_destroy (gpgrt_lock_t *lockhd)
+{
+ return _gpgrt_lock_destroy (lockhd);
+}
+
+gpg_err_code_t
+gpgrt_yield (void)
+{
+ return _gpgrt_yield ();
+}
diff --git a/src/visibility.h b/src/visibility.h
new file mode 100644
index 0000000..95d7d76
--- /dev/null
+++ b/src/visibility.h
@@ -0,0 +1,91 @@
+/* visibility.h - Set visibility attribute
+ * Copyright (C) 2014 g10 Code GmbH
+ *
+ * This file is part of libgpg-error.
+ *
+ * libgpg-error is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * libgpg-error is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GPGRT_VISIBILITY_H
+#define _GPGRT_VISIBILITY_H
+
+/* Include the main header here so that public symbols are mapped to
+ the internal underscored ones. */
+#ifdef _GPGRT_INCL_BY_VISIBILITY_C
+# include "gpgrt-int.h"
+#endif
+
+
+/* Our use of the ELF visibility feature works by passing
+ -fvisibiliy=hidden on the command line and by explicitly marking
+ all exported functions as visible.
+
+ NOTE: When adding new functions, please make sure to add them to
+ gpg-error.vers and gpg-error.def.in as well. */
+
+#ifdef _GPGRT_INCL_BY_VISIBILITY_C
+
+# ifdef GPGRT_USE_VISIBILITY
+# define MARK_VISIBLE(name) \
+ extern __typeof__ (name) name __attribute__ ((visibility("default")));
+# else
+# define MARK_VISIBLE(name) /* */
+# endif
+
+MARK_VISIBLE (gpg_strerror)
+MARK_VISIBLE (gpg_strerror_r)
+MARK_VISIBLE (gpg_strsource)
+MARK_VISIBLE (gpg_err_code_from_errno)
+MARK_VISIBLE (gpg_err_code_to_errno)
+MARK_VISIBLE (gpg_err_code_from_syserror)
+MARK_VISIBLE (gpg_err_set_errno)
+
+MARK_VISIBLE (gpg_error_check_version)
+
+MARK_VISIBLE (gpgrt_lock_init)
+MARK_VISIBLE (gpgrt_lock_lock)
+MARK_VISIBLE (gpgrt_lock_unlock)
+MARK_VISIBLE (gpgrt_lock_destroy)
+MARK_VISIBLE (gpgrt_yield)
+
+
+
+#undef MARK_VISIBLE
+
+#else /*!_GPGRT_INCL_BY_VISIBILITY_C*/
+
+/* To avoid accidental use of the public functions inside Libgpg-error,
+ we redefine them to catch such errors. */
+
+#define gpg_strerror _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpg_strerror_r _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpg_strsource _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpg_err_code_from_errno _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpg_err_code_to_errno _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpg_err_code_from_syserror _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpg_err_set_errno _gpgrt_USE_UNDERSCORED_FUNCTION
+
+#define gpg_error_check_version _gpgrt_USE_UNDERSCORED_FUNCTION
+
+#define gpgrt_lock_init _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpgrt_lock_lock _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpgrt_lock_unlock _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpgrt_lock_destroy _gpgrt_USE_UNDERSCORED_FUNCTION
+#define gpgrt_yield _gpgrt_USE_UNDERSCORED_FUNCTION
+
+
+
+#endif /*!_GPGRT_INCL_BY_VISIBILITY_C*/
+
+#endif /*_GPGRT_VISIBILITY_H*/
diff --git a/src/w32-lock.c b/src/w32-lock.c
index 56a0ed5..3aac1ae 100644
--- a/src/w32-lock.c
+++ b/src/w32-lock.c
@@ -50,7 +50,7 @@ get_lock_object (gpgrt_lock_t *lockhd)
gpg_err_code_t
-gpgrt_lock_init (gpgrt_lock_t *lockhd)
+_gpgrt_lock_init (gpgrt_lock_t *lockhd)
{
_gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd;
@@ -76,7 +76,7 @@ gpgrt_lock_init (gpgrt_lock_t *lockhd)
gpg_err_code_t
-gpgrt_lock_lock (gpgrt_lock_t *lockhd)
+_gpgrt_lock_lock (gpgrt_lock_t *lockhd)
{
_gpgrt_lock_t *lock = get_lock_object (lockhd);
@@ -106,7 +106,7 @@ gpgrt_lock_lock (gpgrt_lock_t *lockhd)
gpg_err_code_t
-gpgrt_lock_unlock (gpgrt_lock_t *lockhd)
+_gpgrt_lock_unlock (gpgrt_lock_t *lockhd)
{
_gpgrt_lock_t *lock = get_lock_object (lockhd);
@@ -120,7 +120,7 @@ gpgrt_lock_unlock (gpgrt_lock_t *lockhd)
/* Note: Use this function only if no other thread holds or waits for
this lock. */
gpg_err_code_t
-gpgrt_lock_destroy (gpgrt_lock_t *lockhd)
+_gpgrt_lock_destroy (gpgrt_lock_t *lockhd)
{
_gpgrt_lock_t *lock = get_lock_object (lockhd);
diff --git a/src/w32-thread.c b/src/w32-thread.c
index f86be35..53d26b4 100644
--- a/src/w32-thread.c
+++ b/src/w32-thread.c
@@ -37,7 +37,7 @@
gpg_err_code_t
-gpgrt_yield (void)
+_gpgrt_yield (void)
{
Sleep (0);
return 0;