aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-02-10 15:37:34 +0000
committerWerner Koch <[email protected]>2020-02-10 15:37:34 +0000
commit21d9bd8b87a9f793a106095e3838eb71825189d7 (patch)
tree642a2f63f8ad6b52e03426f4047829a8be1886fd
parentgpg: Make really sure that --verify-files always returns an error. (diff)
downloadgnupg-21d9bd8b87a9f793a106095e3838eb71825189d7.tar.gz
gnupg-21d9bd8b87a9f793a106095e3838eb71825189d7.zip
build: Always use EXTERN_UNLESS_MAIN_MODULE pattern.
* common/util.h (EXTERN_UNLESS_MAIN_MODULE): Add the definion only here but now without the Norcroft-C. Change all other places where it gets defined. * common/iobuf.h (iobuf_debug_mode): Declare unconditionally as extern. * common/iobuf.c (iobuf_debug_mode): Define it here. * agent/gpg-agent.c (INCLUDED_BY_MAIN_MODULE): Define here and also in all main modules of all other programs. * g10/main.h: Put util.h before the local header files. -- This change is required for use with gcc/ld's LTO feature which does not allow common blocks. Further gcc 10 will make -fno-common the default and thus this chnage is always needed. What a pitty. Co-authored-by: Tomáš Mráz GnuPG-bug-id: 4831 Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--agent/agent.h1
-rw-r--r--agent/gpg-agent.c1
-rw-r--r--agent/preset-passphrase.c1
-rw-r--r--agent/protect-tool.c1
-rw-r--r--agent/t-protect.c1
-rw-r--r--common/iobuf.c1
-rw-r--r--common/iobuf.h9
-rw-r--r--common/util.h7
-rw-r--r--dirmngr/dirmngr.c1
-rw-r--r--dirmngr/dirmngr.h1
-rw-r--r--g10/gpgcompose.c1
-rw-r--r--g10/main.h2
-rw-r--r--g10/options.h8
-rw-r--r--g10/test.c1
-rw-r--r--g13/g13-common.h2
-rw-r--r--g13/g13-syshelp.c1
-rw-r--r--g13/g13.c1
-rw-r--r--scd/scdaemon.c1
-rw-r--r--scd/scdaemon.h1
-rw-r--r--sm/gpgsm.c2
-rw-r--r--sm/gpgsm.h1
-rw-r--r--tools/gpg-wks-client.c1
-rw-r--r--tools/gpg-wks-server.c1
-rw-r--r--tools/gpg-wks.h1
-rw-r--r--tools/gpgconf.c1
-rw-r--r--tools/gpgconf.h1
-rw-r--r--tools/gpgtar.c1
-rw-r--r--tools/gpgtar.h2
28 files changed, 35 insertions, 18 deletions
diff --git a/agent/agent.h b/agent/agent.h
index e934ec8db..e10e02b8c 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -55,6 +55,7 @@
/* A large struct name "opt" to keep global flags */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* Debug flags (DBG_foo_VALUE) */
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 793fc44eb..27cb70cf3 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -49,6 +49,7 @@
#endif
#include <npth.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL
#include "agent.h"
#include <assuan.h> /* Malloc hooks and socket wrappers. */
diff --git a/agent/preset-passphrase.c b/agent/preset-passphrase.c
index 7a9ea1b44..3b402598f 100644
--- a/agent/preset-passphrase.c
+++ b/agent/preset-passphrase.c
@@ -44,6 +44,7 @@
# include <windows.h> /* To initialize the sockets. fixme */
#endif
+#define INCLUDED_BY_MAIN_MODULE 1
#include "agent.h"
#include "../common/simple-pwquery.h"
#include "../common/i18n.h"
diff --git a/agent/protect-tool.c b/agent/protect-tool.c
index ec7b47695..3bba5c6ba 100644
--- a/agent/protect-tool.c
+++ b/agent/protect-tool.c
@@ -38,6 +38,7 @@
#include <fcntl.h> /* for setmode() */
#endif
+#define INCLUDED_BY_MAIN_MODULE 1
#include "agent.h"
#include "../common/i18n.h"
#include "../common/get-passphrase.h"
diff --git a/agent/t-protect.c b/agent/t-protect.c
index d17c19325..88b552585 100644
--- a/agent/t-protect.c
+++ b/agent/t-protect.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <assert.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "agent.h"
diff --git a/common/iobuf.c b/common/iobuf.c
index 589bdf9f6..efbf21cbc 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -118,6 +118,7 @@ struct close_cache_s
typedef struct close_cache_s *close_cache_t;
static close_cache_t close_cache;
+int iobuf_debug_mode;
#ifdef HAVE_W32_SYSTEM
diff --git a/common/iobuf.h b/common/iobuf.h
index 22e02daad..624e154d8 100644
--- a/common/iobuf.h
+++ b/common/iobuf.h
@@ -249,14 +249,7 @@ struct iobuf_struct
int subno;
};
-#ifndef EXTERN_UNLESS_MAIN_MODULE
-#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
-#define EXTERN_UNLESS_MAIN_MODULE extern
-#else
-#define EXTERN_UNLESS_MAIN_MODULE
-#endif
-#endif
-EXTERN_UNLESS_MAIN_MODULE int iobuf_debug_mode;
+extern int iobuf_debug_mode;
/* Returns whether the specified filename corresponds to a pipe. In
diff --git a/common/util.h b/common/util.h
index 24722227a..4d763f078 100644
--- a/common/util.h
+++ b/common/util.h
@@ -55,6 +55,13 @@
# define GPG_ERR_DNS_TIMEOUT 718
#endif
+#ifndef EXTERN_UNLESS_MAIN_MODULE
+# if !defined (INCLUDED_BY_MAIN_MODULE)
+# define EXTERN_UNLESS_MAIN_MODULE extern
+# else
+# define EXTERN_UNLESS_MAIN_MODULE
+# endif
+#endif
/* Hash function used with libksba. */
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index 998a605d3..3ec6139e5 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -55,6 +55,7 @@
#endif /*HTTP_USE_GNUTLS*/
+#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL
#include "dirmngr.h"
diff --git a/dirmngr/dirmngr.h b/dirmngr/dirmngr.h
index 1663ed14d..1b52a1d8e 100644
--- a/dirmngr/dirmngr.h
+++ b/dirmngr/dirmngr.h
@@ -76,6 +76,7 @@ struct fingerprint_list_s
/* A large struct named "opt" to keep global flags. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* debug flags (DBG_foo_VALUE) */
diff --git a/g10/gpgcompose.c b/g10/gpgcompose.c
index bba31592d..229a4e5ea 100644
--- a/g10/gpgcompose.c
+++ b/g10/gpgcompose.c
@@ -20,6 +20,7 @@
#include <config.h>
#include <errno.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "gpg.h"
#include "packet.h"
#include "keydb.h"
diff --git a/g10/main.h b/g10/main.h
index 90e164fda..fe666edf8 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -22,9 +22,9 @@
#include "../common/types.h"
#include "../common/iobuf.h"
+#include "../common/util.h"
#include "keydb.h"
#include "keyedit.h"
-#include "../common/util.h"
/* It could be argued that the default cipher should be 3DES rather
than AES128, and the default compression should be 0
diff --git a/g10/options.h b/g10/options.h
index 4510819b9..efe7f52d0 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -30,14 +30,6 @@
#include "../common/session-env.h"
#include "../common/compliance.h"
-#ifndef EXTERN_UNLESS_MAIN_MODULE
-/* Norcraft can't cope with common symbols */
-#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
-#define EXTERN_UNLESS_MAIN_MODULE extern
-#else
-#define EXTERN_UNLESS_MAIN_MODULE
-#endif
-#endif
/* Declaration of a keyserver spec type. The definition is found in
../common/keyserver.h. */
diff --git a/g10/test.c b/g10/test.c
index 375f361a7..648148a10 100644
--- a/g10/test.c
+++ b/g10/test.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "gpg.h"
/* A unit test consists of one or more tests. Tests can be broken
diff --git a/g13/g13-common.h b/g13/g13-common.h
index acf25b843..42b8deebd 100644
--- a/g13/g13-common.h
+++ b/g13/g13-common.h
@@ -32,7 +32,6 @@
#include "../common/session-env.h"
#include "../common/strlist.h"
-
/* Debug values and macros. */
#define DBG_MOUNT_VALUE 1 /* Debug mount or device stuff. */
#define DBG_CRYPTO_VALUE 4 /* Debug low level crypto. */
@@ -48,6 +47,7 @@
/* A large struct named "opt" to keep global flags. Note that this
struct is used by g13 and g13-syshelp and thus some fields may only
make sense for one of them. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* Debug flags (DBG_foo_VALUE). */
diff --git a/g13/g13-syshelp.c b/g13/g13-syshelp.c
index bf71ac20f..4ce74ee4c 100644
--- a/g13/g13-syshelp.c
+++ b/g13/g13-syshelp.c
@@ -31,6 +31,7 @@
#endif
#include <unistd.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "g13-syshelp.h"
#include <gcrypt.h>
diff --git a/g13/g13.c b/g13/g13.c
index 4b925ed59..6265b9f24 100644
--- a/g13/g13.c
+++ b/g13/g13.c
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <npth.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "g13.h"
#include <gcrypt.h>
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index 8cbd0ee08..ab3e1d94a 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -37,6 +37,7 @@
#include <signal.h>
#include <npth.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL
#include "scdaemon.h"
#include <ksba.h>
diff --git a/scd/scdaemon.h b/scd/scdaemon.h
index 73589ade8..bf0afcb0f 100644
--- a/scd/scdaemon.h
+++ b/scd/scdaemon.h
@@ -44,6 +44,7 @@
/* A large struct name "opt" to keep global flags. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* Debug flags (DBG_foo_VALUE). */
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index a01a7c873..387e4d2e4 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -28,6 +28,8 @@
#include <fcntl.h>
/*#include <mcheck.h>*/
+#define INCLUDED_BY_MAIN_MODULE 1
+
#include "gpgsm.h"
#include <gcrypt.h>
#include <assuan.h> /* malloc hooks */
diff --git a/sm/gpgsm.h b/sm/gpgsm.h
index addd857b1..a9fb4c89b 100644
--- a/sm/gpgsm.h
+++ b/sm/gpgsm.h
@@ -52,6 +52,7 @@ struct keyserver_spec
/* A large struct named "opt" to keep global flags. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* debug flags (DBG_foo_VALUE) */
diff --git a/tools/gpg-wks-client.c b/tools/gpg-wks-client.c
index 050c8aa21..5ec670e57 100644
--- a/tools/gpg-wks-client.c
+++ b/tools/gpg-wks-client.c
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h"
#include "../common/status.h"
#include "../common/i18n.h"
diff --git a/tools/gpg-wks-server.c b/tools/gpg-wks-server.c
index 2082fb87d..8cdbfaf36 100644
--- a/tools/gpg-wks-server.c
+++ b/tools/gpg-wks-server.c
@@ -32,6 +32,7 @@
#include <sys/stat.h>
#include <dirent.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h"
#include "../common/init.h"
#include "../common/sysutils.h"
diff --git a/tools/gpg-wks.h b/tools/gpg-wks.h
index 9acd7c37f..6c5dc8b17 100644
--- a/tools/gpg-wks.h
+++ b/tools/gpg-wks.h
@@ -30,6 +30,7 @@
/* We keep all global options in the structure OPT. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
int verbose;
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index 708b37002..945d0e528 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "gpgconf.h"
#include "../common/i18n.h"
#include "../common/sysutils.h"
diff --git a/tools/gpgconf.h b/tools/gpgconf.h
index 192259789..adb90a1f6 100644
--- a/tools/gpgconf.h
+++ b/tools/gpgconf.h
@@ -23,6 +23,7 @@
#include "../common/util.h"
/* We keep all global options in the structure OPT. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
int verbose; /* Verbosity level. */
diff --git a/tools/gpgtar.c b/tools/gpgtar.c
index b33aa6d0f..e5cbde4af 100644
--- a/tools/gpgtar.c
+++ b/tools/gpgtar.c
@@ -34,6 +34,7 @@
#include <string.h>
#include <assert.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h"
#include "../common/i18n.h"
#include "../common/sysutils.h"
diff --git a/tools/gpgtar.h b/tools/gpgtar.h
index e74a001f4..8ccd358e0 100644
--- a/tools/gpgtar.h
+++ b/tools/gpgtar.h
@@ -23,7 +23,9 @@
#include "../common/util.h"
#include "../common/strlist.h"
+
/* We keep all global options in the structure OPT. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
int verbose;