diff options
author | Werner Koch <wk@gnupg.org> | 2018-03-14 10:07:42 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2018-03-14 10:07:42 +0100 |
commit | c36a60687976d98b54dac17f699dfca4918a737c (patch) | |
tree | 4b1d2ef11fa0ca76876d3262976e7c4984e89b64 /src | |
parent | c0c5fb51c5e87954af0b60fea7f543352998e1cc (diff) | |
download | libgpg-error-c36a60687976d98b54dac17f699dfca4918a737c.tar.gz |
core: Fix building on W64
* src/w32-add.h: Remove hack to define pid_t.
* src/gpg-error.h.in: Eval macro to define pid_t.
* src/mkheader.c (have_sys_types_h, sys_types_h_included): New.
(parse_config_h): Test for sys/types.h.
(write_special): Protect inclusion of sys/types.h. Define new macro
'define:pid_t'.
--
Regression-due-to: 1865c0ba1769b407a3c504f1ab0a4278704a9fc1
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpg-error.h.in | 1 | ||||
-rw-r--r-- | src/mkheader.c | 36 | ||||
-rw-r--r-- | src/w32-add.h | 4 |
3 files changed, 35 insertions, 6 deletions
diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in index f942098..cc2e361 100644 --- a/src/gpg-error.h.in +++ b/src/gpg-error.h.in @@ -405,6 +405,7 @@ const char *gpgrt_check_version (const char *req_version); const char *gpg_error_check_version (const char *req_version); /* System specific type definitions. */ +@define:pid_t@ @define:gpgrt_ssize_t@ @define:gpgrt_off_t@ diff --git a/src/mkheader.c b/src/mkheader.c index 997cab5..2fc5fad 100644 --- a/src/mkheader.c +++ b/src/mkheader.c @@ -30,6 +30,7 @@ static const char *hdr_version_number; /* Values take from the supplied config.h. */ static int have_stdint_h; +static int have_sys_types_h; static int have_w32_system; static int have_w64_system; static char *replacement_for_off_type; @@ -37,6 +38,7 @@ static int use_posix_threads; /* Various state flags. */ static int stdint_h_included; +static int sys_types_h_included; /* The usual free wrapper. */ @@ -151,6 +153,8 @@ parse_config_h (const char *fname) continue; /* oops */ if (!strcmp (p1, "HAVE_STDINT_H")) have_stdint_h = 1; + else if (!strcmp (p1, "HAVE_SYS_TYPES_H")) + have_sys_types_h = 1; else if (!strcmp (p1, "HAVE_W32_SYSTEM")) have_w32_system = 1; else if (!strcmp (p1, "HAVE_W64_SYSTEM")) @@ -474,8 +478,12 @@ write_special (const char *fname, int lnr, const char *tag) } else { - fputs ("#include <sys/types.h>\n" - "typedef ssize_t gpgrt_ssize_t;\n", stdout); + if (!sys_types_h_included) + { + fputs ("#include <sys/types.h>\n", stdout); + sys_types_h_included = 1; + } + fputs ("typedef ssize_t gpgrt_ssize_t;\n", stdout); } } else if (!strcmp (tag, "api_ssize_t")) @@ -485,6 +493,30 @@ write_special (const char *fname, int lnr, const char *tag) else fputs ("ssize_t", stdout); } + else if (!strcmp (tag, "define:pid_t")) + { + if (have_sys_types_h) + { + if (!sys_types_h_included) + { + fputs ("#include <sys/types.h>\n", stdout); + sys_types_h_included = 1; + } + } + else if (have_w64_system) + { + if (!stdint_h_included && have_stdint_h) + { + fputs ("#include <stdint.h>\n", stdout); + stdint_h_included = 1; + } + fputs ("typedef int64_t pid_t\n", stdout); + } + else + { + fputs ("typedef int pid_t\n", stdout); + } + } else if (!strcmp (tag, "include:err-sources")) { write_sources_or_codes (NULL); diff --git a/src/w32-add.h b/src/w32-add.h index 6f9f12a..07e3c7d 100644 --- a/src/w32-add.h +++ b/src/w32-add.h @@ -3,10 +3,6 @@ ## peculiarity of the script the first used line must not ## start with a hash mark. -/* Fixme: This is a quick hack. We need to check whether the compiler - * actually in use already knows that type. */ -typedef int pid_t; - /* Decide whether to use the format_arg attribute. */ #if _GPG_ERR_GCC_VERSION > 20800 # define _GPG_ERR_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a))) |