diff options
author | Werner Koch <wk@gnupg.org> | 2014-09-11 14:33:46 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2014-09-11 14:37:21 +0200 |
commit | 5a4684f3b0db4cd5c13f94b1319c245ef96ce91d (patch) | |
tree | eb3c5750c13c246b14ff2ed1646616face838be0 | |
parent | 4138644d74f127c1f4abf7455fe1e21f56d6e07e (diff) | |
download | libgpg-error-5a4684f3b0db4cd5c13f94b1319c245ef96ce91d.tar.gz |
Fix problems with ssize_t and off_t.
* configure.ac (AC_SYS_LARGEFILE): New.
(AC_CHECK_HEADERS): Check for stdint.h.
(AC_CHECK_SIZEOF): Add for int, long and long long.
(REPLACEMENT_FOR_OFF_T): New ac_define.
* src/mkheader.c (have_stdint_h, have_w32_system, have_w64_system)
(replacement_for_off_type, stdint_h_included): New.
(xfree, xstrdup): New.
(parse_config_h): New.
(write_special): Support "define:gpgrt_off_t", "define:gpgrt_ssize_t",
"api_ssize_t" tags.
(main): Add config.h arg. Call parse_config_h. Fix substitute code.
* src/Makefile.am (gpg-error.h): Pass config.h to mkheader.
* src/gpg-error.h.in: Include definitions for gpgrt_ssize_t and
gpgrt_off_t. Let mkheader insert ssize_t keywords. Chnage all off_t
to gpgrt_off_t.
* src/estream.c: Change all off_t to gpgrt_off_t. Chnage all ssize_t
to gpgrt_ssize_t.
* src/visibility.c (gpgrt_fseeko): Use gpgrt_off_t.
(gpgrt_ftello): Ditto.
(gpgrt_getline): Use gpgrt_ssize_t.
(gpgrt_read_line): Ditto.
-rw-r--r-- | NEWS | 12 | ||||
-rw-r--r-- | configure.ac | 34 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/estream.c | 80 | ||||
-rw-r--r-- | src/gpg-error.h.in | 21 | ||||
-rw-r--r-- | src/gpgrt-int.h | 12 | ||||
-rw-r--r-- | src/mkheader.c | 169 | ||||
-rw-r--r-- | src/visibility.c | 8 |
8 files changed, 271 insertions, 70 deletions
@@ -1,6 +1,18 @@ Noteworthy changes in version 1.15 (unreleased) [C__/A__/R_] ----------------------------------------------- + * This releases fixes problems with the use of off_t and ssize_t by + the estream functions introduced with 1.14. Although this is + technically an ABI break on some platforms, we take this as a + simple bug fix for 1.14. The new functions are very unlikely in + use by any code and thus no breakage should happen. The 1.14 + tarball will be removed from the archive. + + * Add type gpgrt_off_t which is guaranteed to be 64 bit. + + * Add type gpgrt_ssize_t to make use on Windows easier. On Unix + platforms this is an alias for ssize_t. + Noteworthy changes in version 1.14 (2014-09-08) [C12/A12/R0] ----------------------------------------------- diff --git a/configure.ac b/configure.ac index 61dc357..d951e9d 100644 --- a/configure.ac +++ b/configure.ac @@ -110,6 +110,12 @@ if test "$have_w32_system" != yes; then gl_THREADLIB_EARLY fi +# We build libgpg-error with large file support so that we have a 64 +# bit off_t. Our external interface uses the gpgrt_off_t which is +# anyway specified as 64 bit. Thus the same libgpg-error can be used +# by software which is not build with large file support. +AC_SYS_LARGEFILE + LT_PREREQ([2.2.6]) LT_INIT([win32-dll disable-static]) @@ -154,7 +160,7 @@ AM_GNU_GETTEXT([external]) # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([stdlib.h locale.h]) +AC_CHECK_HEADERS([stdlib.h locale.h stdint.h]) AC_FUNC_STRERROR_R case "${host_os}" in solaris*) @@ -170,9 +176,35 @@ esac AC_CHECK_FUNCS([flockfile vasprintf]) +# # Checks for typedefs, structures, and compiler characteristics. +# AC_C_CONST +AC_CHECK_SIZEOF(int) +AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(long long) + +# Find a 64 bit integer type to be used instead of off_t. We prefer +# the standard integer types over int64_t and finally try long long. +if test "$ac_cv_sizeof_int" = "8"; then + replacement_for_off_t="int" +elif test "$ac_cv_sizeof_long" = "8"; then + replacement_for_off_t="long" +elif test "$ac_cv_header_stdint_h" = yes; then + replacement_for_off_t="int64_t" +elif test "$ac_cv_sizeof_long_long" = "8"; then + replacement_for_off_t="long long" +else + AC_MSG_ERROR([[ +*** +*** No 64 bit signed integer type found. Can't build this library. +***]]) +fi +AC_DEFINE_UNQUOTED(REPLACEMENT_FOR_OFF_T, "$replacement_for_off_t", + [Used by mkheader to insert the replacement type.]) + + # # Setup gcc specific options diff --git a/src/Makefile.am b/src/Makefile.am index 55a9bb9..d019fd7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -271,10 +271,11 @@ endif # We also depend on versioninfo.rc because that is build by # config.status and thus has up-to-date version numbers. -gpg-error.h: Makefile mkheader $(parts_of_gpg_error_h) versioninfo.rc +gpg-error.h: Makefile mkheader $(parts_of_gpg_error_h) \ + versioninfo.rc ../config.h $(pre_mkheader_cmds) ./mkheader $(host_os) $(host_triplet) $(srcdir)/gpg-error.h.in \ - $(PACKAGE_VERSION) $(VERSION_NUMBER) >$@ + ../config.h $(PACKAGE_VERSION) $(VERSION_NUMBER) >$@ install-data-local: diff --git a/src/estream.c b/src/estream.c index 7a5646e..d16938e 100644 --- a/src/estream.c +++ b/src/estream.c @@ -165,7 +165,7 @@ struct _gpgrt_stream_internal void *opaque; /* Opaque data. */ unsigned int modeflags; /* Flags for the backend. */ char *printable_fname; /* Malloced filename for es_fname_get. */ - off_t offset; + gpgrt_off_t offset; gpgrt_cookie_read_function_t func_read; gpgrt_cookie_write_function_t func_write; gpgrt_cookie_seek_function_t func_seek; @@ -607,11 +607,11 @@ func_mem_create (void *_GPGRT__RESTRICT *_GPGRT__RESTRICT cookie, /* Read function for memory objects. */ -static ssize_t +static gpgrt_ssize_t es_func_mem_read (void *cookie, void *buffer, size_t size) { estream_cookie_mem_t mem_cookie = cookie; - ssize_t ret; + gpgrt_ssize_t ret; if (size > mem_cookie->data_len - mem_cookie->offset) size = mem_cookie->data_len - mem_cookie->offset; @@ -628,11 +628,11 @@ es_func_mem_read (void *cookie, void *buffer, size_t size) /* Write function for memory objects. */ -static ssize_t +static gpgrt_ssize_t es_func_mem_write (void *cookie, const void *buffer, size_t size) { estream_cookie_mem_t mem_cookie = cookie; - ssize_t ret; + gpgrt_ssize_t ret; size_t nleft; if (!size) @@ -715,10 +715,10 @@ es_func_mem_write (void *cookie, const void *buffer, size_t size) /* Seek function for memory objects. */ static int -es_func_mem_seek (void *cookie, off_t *offset, int whence) +es_func_mem_seek (void *cookie, gpgrt_off_t *offset, int whence) { estream_cookie_mem_t mem_cookie = cookie; - off_t pos_new; + gpgrt_off_t pos_new; switch (whence) { @@ -879,12 +879,12 @@ func_fd_create (void **cookie, int fd, unsigned int modeflags, int no_close) } /* Read function for fd objects. */ -static ssize_t +static gpgrt_ssize_t es_func_fd_read (void *cookie, void *buffer, size_t size) { estream_cookie_fd_t file_cookie = cookie; - ssize_t bytes_read; + gpgrt_ssize_t bytes_read; if (IS_INVALID_FD (file_cookie->fd)) { @@ -908,11 +908,11 @@ es_func_fd_read (void *cookie, void *buffer, size_t size) } /* Write function for fd objects. */ -static ssize_t +static gpgrt_ssize_t es_func_fd_write (void *cookie, const void *buffer, size_t size) { estream_cookie_fd_t file_cookie = cookie; - ssize_t bytes_written; + gpgrt_ssize_t bytes_written; if (IS_INVALID_FD (file_cookie->fd)) { @@ -937,10 +937,10 @@ es_func_fd_write (void *cookie, const void *buffer, size_t size) /* Seek function for fd objects. */ static int -es_func_fd_seek (void *cookie, off_t *offset, int whence) +es_func_fd_seek (void *cookie, gpgrt_off_t *offset, int whence) { estream_cookie_fd_t file_cookie = cookie; - off_t offset_new; + gpgrt_off_t offset_new; int err; if (IS_INVALID_FD (file_cookie->fd)) @@ -1039,11 +1039,11 @@ es_func_w32_create (void **cookie, HANDLE hd, } /* Read function for W32 handle objects. */ -static ssize_t +static gpgrt_ssize_t es_func_w32_read (void *cookie, void *buffer, size_t size) { estream_cookie_w32_t w32_cookie = cookie; - ssize_t bytes_read; + gpgrt_ssize_t bytes_read; if (w32_cookie->hd == INVALID_HANDLE_VALUE) { @@ -1081,11 +1081,11 @@ es_func_w32_read (void *cookie, void *buffer, size_t size) } /* Write function for W32 handle objects. */ -static ssize_t +static gpgrt_ssize_t es_func_w32_write (void *cookie, const void *buffer, size_t size) { estream_cookie_w32_t w32_cookie = cookie; - ssize_t bytes_written; + gpgrt_ssize_t bytes_written; if (w32_cookie->hd == INVALID_HANDLE_VALUE) { @@ -1118,7 +1118,7 @@ es_func_w32_write (void *cookie, const void *buffer, size_t size) /* Seek function for W32 handle objects. */ static int -es_func_w32_seek (void *cookie, off_t *offset, int whence) +es_func_w32_seek (void *cookie, gpgrt_off_t *offset, int whence) { estream_cookie_w32_t w32_cookie = cookie; DWORD method; @@ -1165,7 +1165,8 @@ es_func_w32_seek (void *cookie, off_t *offset, int whence) if (post_syscall_func) post_syscall_func (); #endif - *offset = (unsigned long long)newoff.QuadPart; + /* Note that gpgrt_off_t is always 64 bit. */ + *offset = (gpgrt_off_t)newoff.QuadPart; return 0; } @@ -1253,12 +1254,12 @@ func_fp_create (void **cookie, FILE *fp, } /* Read function for FILE* objects. */ -static ssize_t +static gpgrt_ssize_t es_func_fp_read (void *cookie, void *buffer, size_t size) { estream_cookie_fp_t file_cookie = cookie; - ssize_t bytes_read; + gpgrt_ssize_t bytes_read; if (file_cookie->fp) { @@ -1276,7 +1277,7 @@ es_func_fp_read (void *cookie, void *buffer, size_t size) } /* Write function for FILE* objects. */ -static ssize_t +static gpgrt_ssize_t es_func_fp_write (void *cookie, const void *buffer, size_t size) { estream_cookie_fp_t file_cookie = cookie; @@ -1319,7 +1320,7 @@ es_func_fp_write (void *cookie, const void *buffer, size_t size) /* Seek function for FILE* objects. */ static int -es_func_fp_seek (void *cookie, off_t *offset, int whence) +es_func_fp_seek (void *cookie, gpgrt_off_t *offset, int whence) { estream_cookie_fp_t file_cookie = cookie; long int offset_new; @@ -1592,7 +1593,7 @@ es_fill (estream_t stream) else { gpgrt_cookie_read_function_t func_read = stream->intern->func_read; - ssize_t ret; + gpgrt_ssize_t ret; ret = (*func_read) (stream->intern->cookie, stream->buffer, stream->buffer_size); @@ -1632,7 +1633,7 @@ es_flush (estream_t stream) { size_t bytes_written; size_t data_flushed; - ssize_t ret; + gpgrt_ssize_t ret; if (! func_write) { @@ -1649,7 +1650,8 @@ es_flush (estream_t stream) data_flushed = 0; err = 0; - while ((((ssize_t) (stream->data_offset - data_flushed)) > 0) && (! err)) + while ((((gpgrt_ssize_t) (stream->data_offset - data_flushed)) > 0) + && !err) { ret = (*func_write) (stream->intern->cookie, stream->buffer + data_flushed, @@ -1896,7 +1898,7 @@ es_read_nbf (estream_t _GPGRT__RESTRICT stream, { gpgrt_cookie_read_function_t func_read = stream->intern->func_read; size_t data_read; - ssize_t ret; + gpgrt_ssize_t ret; int err; data_read = 0; @@ -2077,12 +2079,12 @@ es_unreadn (estream_t _GPGRT__RESTRICT stream, /* Seek in STREAM. */ static int -es_seek (estream_t _GPGRT__RESTRICT stream, off_t offset, int whence, - off_t *_GPGRT__RESTRICT offset_new) +es_seek (estream_t _GPGRT__RESTRICT stream, gpgrt_off_t offset, int whence, + gpgrt_off_t *_GPGRT__RESTRICT offset_new) { gpgrt_cookie_seek_function_t func_seek = stream->intern->func_seek; int err, ret; - off_t off; + gpgrt_off_t off; if (! func_seek) { @@ -2142,7 +2144,7 @@ es_write_nbf (estream_t _GPGRT__RESTRICT stream, { gpgrt_cookie_write_function_t func_write = stream->intern->func_write; size_t data_written; - ssize_t ret; + gpgrt_ssize_t ret; int err; if (bytes_to_write && (! func_write)) @@ -2613,10 +2615,10 @@ es_set_buffering (estream_t _GPGRT__RESTRICT stream, } -static off_t +static gpgrt_off_t es_offset_calculate (estream_t stream) { - off_t offset; + gpgrt_off_t offset; offset = stream->intern->offset + stream->data_offset; if (offset < stream->unread_data_len) @@ -3496,7 +3498,7 @@ _gpgrt_fseek (estream_t stream, long int offset, int whence) int -_gpgrt_fseeko (estream_t stream, off_t offset, int whence) +_gpgrt_fseeko (estream_t stream, gpgrt_off_t offset, int whence) { int err; @@ -3521,10 +3523,10 @@ _gpgrt_ftell (estream_t stream) } -off_t +gpgrt_off_t _gpgrt_ftello (estream_t stream) { - off_t ret = -1; + gpgrt_off_t ret = -1; lock_stream (stream); ret = es_offset_calculate (stream); @@ -3748,7 +3750,7 @@ _gpgrt_fputs (const char *_GPGRT__RESTRICT s, estream_t _GPGRT__RESTRICT stream) } -ssize_t +gpgrt_ssize_t _gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, size_t *_GPGRT__RESTRICT n, estream_t _GPGRT__RESTRICT stream) { @@ -3799,7 +3801,7 @@ _gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, out: - return err ? err : (ssize_t)line_n; + return err ? err : (gpgrt_ssize_t)line_n; } @@ -3832,7 +3834,7 @@ _gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, allow the caller to append a CR,LF,Nul. The buffer should be released using gpgrt_free. */ -ssize_t +gpgrt_ssize_t _gpgrt_read_line (estream_t stream, char **addr_of_buffer, size_t *length_of_buffer, size_t *max_length) diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in index 4b1c0a0..80ce391 100644 --- a/src/gpg-error.h.in +++ b/src/gpg-error.h.in @@ -87,7 +87,6 @@ extern "C" { typedef enum { @include:err-sources@ - /* This is one more than the largest allowed entry. */ GPG_ERR_SOURCE_DIM = 128 } gpg_err_source_t; @@ -100,11 +99,9 @@ typedef enum typedef enum { @include:err-codes@ - /* The following error codes are used to map system errors. */ #define GPG_ERR_SYSTEM_ERROR (1 << 15) @include:errnos@ - /* This is one more than the largest allowed entry. */ GPG_ERR_CODE_DIM = 65536 } gpg_err_code_t; @@ -289,6 +286,10 @@ const char *gpg_error_check_version (const char *req_version); /* The version number of this header. */ #define GPG_ERROR_VERSION_NUMBER @version-number@ +/* System specific type definitions. */ +@define:gpgrt_ssize_t@ +@define:gpgrt_off_t@ + @include:os-add@ /* Self-documenting convenience functions. */ @@ -388,13 +389,13 @@ typedef struct _gpgrt__stream *gpgrt_stream_t; typedef struct _gpgrt__stream *estream_t; #endif -typedef ssize_t (*gpgrt_cookie_read_function_t) (void *cookie, +typedef @api_ssize_t@ (*gpgrt_cookie_read_function_t) (void *cookie, void *buffer, size_t size); -typedef ssize_t (*gpgrt_cookie_write_function_t) (void *cookie, +typedef @api_ssize_t@ (*gpgrt_cookie_write_function_t) (void *cookie, const void *buffer, size_t size); typedef int (*gpgrt_cookie_seek_function_t) (void *cookie, - off_t *pos, int whence); + gpgrt_off_t *pos, int whence); typedef int (*gpgrt_cookie_close_function_t) (void *cookie); struct _gpgrt_cookie_io_functions @@ -498,9 +499,9 @@ void gpgrt_clearerr_unlocked (gpgrt_stream_t stream); int gpgrt_fflush (gpgrt_stream_t stream); int gpgrt_fseek (gpgrt_stream_t stream, long int offset, int whence); -int gpgrt_fseeko (gpgrt_stream_t stream, off_t offset, int whence); +int gpgrt_fseeko (gpgrt_stream_t stream, gpgrt_off_t offset, int whence); long int gpgrt_ftell (gpgrt_stream_t stream); -off_t gpgrt_ftello (gpgrt_stream_t stream); +gpgrt_off_t gpgrt_ftello (gpgrt_stream_t stream); void gpgrt_rewind (gpgrt_stream_t stream); int gpgrt_fgetc (gpgrt_stream_t stream); @@ -555,10 +556,10 @@ int gpgrt_fputs (const char *_GPGRT__RESTRICT s, int gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s, gpgrt_stream_t _GPGRT__RESTRICT stream); -ssize_t gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, +@api_ssize_t@ gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, size_t *_GPGRT__RESTRICT n, gpgrt_stream_t stream); -ssize_t gpgrt_read_line (gpgrt_stream_t stream, +@api_ssize_t@ gpgrt_read_line (gpgrt_stream_t stream, char **addr_of_buffer, size_t *length_of_buffer, size_t *max_length); void gpgrt_free (void *a); diff --git a/src/gpgrt-int.h b/src/gpgrt-int.h index df7c606..0e6f69c 100644 --- a/src/gpgrt-int.h +++ b/src/gpgrt-int.h @@ -162,12 +162,12 @@ int _gpgrt_fputs (const char *_GPGRT__RESTRICT s, int _gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s, gpgrt_stream_t _GPGRT__RESTRICT stream); -ssize_t _gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, - size_t *_GPGRT__RESTRICT n, - gpgrt_stream_t stream); -ssize_t _gpgrt_read_line (gpgrt_stream_t stream, - char **addr_of_buffer, size_t *length_of_buffer, - size_t *max_length); +gpgrt_ssize_t _gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, + size_t *_GPGRT__RESTRICT n, + gpgrt_stream_t stream); +gpgrt_ssize_t _gpgrt_read_line (gpgrt_stream_t stream, + char **addr_of_buffer, size_t *length_of_buffer, + size_t *max_length); int _gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream, const char *_GPGRT__RESTRICT format, ...) diff --git a/src/mkheader.c b/src/mkheader.c index 43e7fd8..9fe0695 100644 --- a/src/mkheader.c +++ b/src/mkheader.c @@ -28,6 +28,105 @@ static char *srcdir; static const char *hdr_version; static const char *hdr_version_number; +/* Values take from the supplied config.h. */ +static int have_stdint_h; +static int have_w32_system; +static int have_w64_system; +static char *replacement_for_off_type; + +/* Various state flags. */ +static int stdint_h_included; + + +/* The usual free wrapper. */ +static void +xfree (void *a) +{ + if (a) + free (a); +} + + +static char * +xstrdup (const char *string) +{ + char *p; + + p = malloc (strlen (string)+1); + if (!p) + { + fputs (PGM ": out of core\n", stderr); + exit (1); + } + strcpy (p, string); + return p; +} + + +/* Parse the supplied config.h file and extract required info. + Returns 0 on success. */ +static int +parse_config_h (const char *fname) +{ + FILE *fp; + char line[LINESIZE]; + int lnr = 0; + char *p1; + + fp = fopen (fname, "r"); + if (!fp) + { + fprintf (stderr, "%s:%d: can't open file: %s", + fname, lnr, strerror (errno)); + return 1; + } + + while (fgets (line, LINESIZE, fp)) + { + size_t n = strlen (line); + + lnr++; + if (!n || line[n-1] != '\n') + { + fprintf (stderr, + "%s:%d: trailing linefeed missing, line too long or " + "embedded nul character\n", fname, lnr); + break; + } + line[--n] = 0; + + if (strncmp (line, "#define ", 8)) + continue; /* We are only interested in define lines. */ + p1 = strtok (line + 8, " \t"); + if (!*p1) + continue; /* oops */ + if (!strcmp (p1, "HAVE_STDINT_H")) + have_stdint_h = 1; + else if (!strcmp (p1, "HAVE_W32_SYSTEM")) + have_w32_system = 1; + else if (!strcmp (p1, "HAVE_W64_SYSTEM")) + have_w64_system = 1; + else if (!strcmp (p1, "REPLACEMENT_FOR_OFF_T")) + { + p1 = strtok (NULL, "\""); + if (!*p1) + continue; /* oops */ + xfree (replacement_for_off_type); + replacement_for_off_type = xstrdup (p1); + } + } + + if (ferror (fp)) + { + fprintf (stderr, "%s:%d: error reading file: %s\n", + fname, lnr, strerror (errno)); + return 1; + } + + fclose (fp); + return 0; +} + /* Write LINE to stdout. The function is allowed to modify LINE. */ static void @@ -283,12 +382,57 @@ write_special (const char *fname, int lnr, const char *tag) putchar ('\"'); fputs (hdr_version, stdout); putchar ('\"'); - putchar ('\n'); } else if (!strcmp (tag, "version-number")) { fputs (hdr_version_number, stdout); - putchar ('\n'); + } + else if (!strcmp (tag, "define:gpgrt_off_t")) + { + if (!replacement_for_off_type) + { + fprintf (stderr, "%s:%d: replacement for off_t not defined\n", + fname, lnr); + exit (1); + } + else + { + if (!strcmp (replacement_for_off_type, "int64_t") + && !stdint_h_included && have_stdint_h) + { + fputs ("#include <stdint.h>\n\n", stdout); + stdint_h_included = 1; + } + printf ("typedef %s gpgrt_off_t;\n", replacement_for_off_type); + } + } + else if (!strcmp (tag, "define:gpgrt_ssize_t")) + { + 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 gpgrt_ssize_t;\n", stdout); + } + else if (have_w32_system) + { + fputs ("typedef long gpgrt_ssize_t;\n", stdout); + } + else + { + fputs ("#include <sys/types.h>\n" + "typedef ssize_t gpgrt_ssize_t;\n", stdout); + } + } + else if (!strcmp (tag, "api_ssize_t")) + { + if (have_w32_system) + fputs ("gpgrt_ssize_t", stdout); + else + fputs ("ssize_t", stdout); } else if (!strcmp (tag, "include:err-sources")) { @@ -336,24 +480,27 @@ main (int argc, char **argv) int lnr = 0; const char *fname, *s; char *p1, *p2; + const char *config_h; if (argc) { argc--; argv++; } - if (argc != 5) + if (argc != 6) { fputs ("usage: " PGM - " host_os host_triplet template.h version version_number\n", + " host_os host_triplet template.h config.h" + " version version_number\n", stderr); return 1; } host_os = argv[0]; host_triplet = argv[1]; fname = argv[2]; - hdr_version = argv[3]; - hdr_version_number = argv[4]; + config_h = argv[3]; + hdr_version = argv[4]; + hdr_version_number = argv[5]; srcdir = malloc (strlen (fname) + 2 + 1); if (!srcdir) @@ -368,6 +515,9 @@ main (int argc, char **argv) else strcpy (srcdir, "./"); + if (parse_config_h (config_h)) + return 1; + fp = fopen (fname, "r"); if (!fp) { @@ -407,7 +557,6 @@ main (int argc, char **argv) printf ("Do not edit. Generated from %s for %s.", s? s+1 : fname, host_triplet); fputs (p2, stdout); - putchar ('\n'); } else if (!write_special (fname, lnr, p1)) { @@ -415,8 +564,12 @@ main (int argc, char **argv) fputs (p1, stdout); putchar ('@'); fputs (p2, stdout); - putchar ('\n'); } + else if (p2 && *p2) + { + fputs (p2, stdout); + } + putchar ('\n'); } if (ferror (fp)) diff --git a/src/visibility.c b/src/visibility.c index f1bbca6..f0d7fd1 100644 --- a/src/visibility.c +++ b/src/visibility.c @@ -346,7 +346,7 @@ gpgrt_fseek (estream_t stream, long int offset, int whence) } int -gpgrt_fseeko (estream_t stream, off_t offset, int whence) +gpgrt_fseeko (estream_t stream, gpgrt_off_t offset, int whence) { return _gpgrt_fseeko (stream, offset, whence); } @@ -357,7 +357,7 @@ gpgrt_ftell (estream_t stream) return _gpgrt_ftell (stream); } -off_t +gpgrt_off_t gpgrt_ftello (estream_t stream) { return _gpgrt_ftello (stream); @@ -468,14 +468,14 @@ gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s, return _gpgrt_fputs_unlocked (s, stream); } -ssize_t +gpgrt_ssize_t gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, size_t *_GPGRT__RESTRICT n, estream_t _GPGRT__RESTRICT stream) { return _gpgrt_getline (lineptr, n, stream); } -ssize_t +gpgrt_ssize_t gpgrt_read_line (estream_t stream, char **addr_of_buffer, size_t *length_of_buffer, size_t *max_length) |