summaryrefslogtreecommitdiffstats
path: root/cpukit/zlib
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/zlib')
-rw-r--r--cpukit/zlib/gzlib.c20
-rw-r--r--cpukit/zlib/zconf.h30
-rw-r--r--cpukit/zlib/zconf.h.cmakein30
-rw-r--r--cpukit/zlib/zconf.h.in30
4 files changed, 74 insertions, 36 deletions
diff --git a/cpukit/zlib/gzlib.c b/cpukit/zlib/gzlib.c
index 6fdb08a814..603e60ed54 100644
--- a/cpukit/zlib/gzlib.c
+++ b/cpukit/zlib/gzlib.c
@@ -5,7 +5,7 @@
#include "gzguts.h"
-#ifdef _LARGEFILE64_SOURCE
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
# define LSEEK lseek64
#else
# define LSEEK lseek
@@ -15,7 +15,7 @@
local void gz_reset OF((gz_statep));
local gzFile gz_open OF((const char *, int, const char *));
-#if defined UNDER_CE && defined NO_ERRNO_H
+#if defined UNDER_CE
/* Map the Windows error number in ERROR to a locale-dependent error message
string and return a pointer to it. Typically, the values for ERROR come
@@ -26,7 +26,7 @@ local gzFile gz_open OF((const char *, int, const char *));
The gz_strwinerror function does not change the current setting of
GetLastError. */
-char ZEXPORT *gz_strwinerror (error)
+char ZLIB_INTERNAL *gz_strwinerror (error)
DWORD error;
{
static char buf[1024];
@@ -65,7 +65,7 @@ char ZEXPORT *gz_strwinerror (error)
return buf;
}
-#endif /* UNDER_CE && NO_ERRNO_H */
+#endif /* UNDER_CE */
/* Reset gzip file state */
local void gz_reset(state)
@@ -172,6 +172,7 @@ local gzFile gz_open(path, fd, mode)
O_APPEND))),
0666);
if (state->fd == -1) {
+ free(state->path);
free(state);
return NULL;
}
@@ -217,7 +218,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL)
return NULL;
- sprintf(path, "<fd:%d>", fd);
+ sprintf(path, "<fd:%d>", fd); /* for debugging */
gz = gz_open(path, fd, mode);
free(path);
return gz;
@@ -305,7 +306,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
/* if within raw area while reading, just go there */
if (state->mode == GZ_READ && state->how == COPY &&
state->pos + offset >= state->raw) {
- ret = LSEEK(state->fd, offset, SEEK_CUR);
+ ret = LSEEK(state->fd, offset - state->have, SEEK_CUR);
if (ret == -1)
return -1;
state->have = 0;
@@ -432,7 +433,8 @@ int ZEXPORT gzeof(file)
return 0;
/* return end-of-file state */
- return state->mode == GZ_READ ? (state->eof && state->have == 0) : 0;
+ return state->mode == GZ_READ ?
+ (state->eof && state->strm.avail_in == 0 && state->have == 0) : 0;
}
/* -- see zlib.h -- */
@@ -480,7 +482,7 @@ void ZEXPORT gzclearerr(file)
memory). Simply save the error message as a static string. If there is an
allocation failure constructing the error message, then convert the error to
out of memory. */
-void ZEXPORT gz_error(state, err, msg)
+void ZLIB_INTERNAL gz_error(state, err, msg)
gz_statep state;
int err;
const char *msg;
@@ -520,7 +522,7 @@ void ZEXPORT gz_error(state, err, msg)
available) -- we need to do this to cover cases where 2's complement not
used, since C standard permits 1's complement and sign-bit representations,
otherwise we could just use ((unsigned)-1) >> 1 */
-unsigned ZEXPORT gz_intmax()
+unsigned ZLIB_INTERNAL gz_intmax()
{
unsigned p, q;
diff --git a/cpukit/zlib/zconf.h b/cpukit/zlib/zconf.h
index 58880245c1..02ce56c431 100644
--- a/cpukit/zlib/zconf.h
+++ b/cpukit/zlib/zconf.h
@@ -315,10 +315,6 @@
# endif
#endif
-#ifdef HAVE_VISIBILITY_PRAGMA
-# define ZEXTERN __attribute__((visibility ("default"))) extern
-#endif
-
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
@@ -364,8 +360,21 @@ typedef uLong FAR uLongf;
# define Z_HAVE_UNISTD_H
#endif
-#ifdef Z_HAVE_UNISTD_H
+#ifdef STDC
# include <sys/types.h> /* for off_t */
+#endif
+
+/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
+ * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
+ * though the former does not conform to the LFS document), but considering
+ * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
+ * equivalently requesting no 64-bit operations
+ */
+#if -_LARGEFILE64_SOURCE - -1 == 1
+# undef _LARGEFILE64_SOURCE
+#endif
+
+#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
@@ -375,19 +384,22 @@ typedef uLong FAR uLongf;
# endif
#endif
-#ifdef _LARGEFILE64_SOURCE
-# include <sys/types.h>
-#endif
-
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
+
#ifndef z_off_t
# define z_off_t long
#endif
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+# define z_off64_t off64_t
+#else
+# define z_off64_t z_off_t
+#endif
+
#if defined(__OS400__)
# define NO_vsnprintf
#endif
diff --git a/cpukit/zlib/zconf.h.cmakein b/cpukit/zlib/zconf.h.cmakein
index eec8ab04f7..a2f71b1f32 100644
--- a/cpukit/zlib/zconf.h.cmakein
+++ b/cpukit/zlib/zconf.h.cmakein
@@ -317,10 +317,6 @@
# endif
#endif
-#ifdef HAVE_VISIBILITY_PRAGMA
-# define ZEXTERN __attribute__((visibility ("default"))) extern
-#endif
-
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
@@ -366,8 +362,21 @@ typedef uLong FAR uLongf;
# define Z_HAVE_UNISTD_H
#endif
-#ifdef Z_HAVE_UNISTD_H
+#ifdef STDC
# include <sys/types.h> /* for off_t */
+#endif
+
+/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
+ * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
+ * though the former does not conform to the LFS document), but considering
+ * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
+ * equivalently requesting no 64-bit operations
+ */
+#if -_LARGEFILE64_SOURCE - -1 == 1
+# undef _LARGEFILE64_SOURCE
+#endif
+
+#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
@@ -377,19 +386,22 @@ typedef uLong FAR uLongf;
# endif
#endif
-#ifdef _LARGEFILE64_SOURCE
-# include <sys/types.h>
-#endif
-
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
+
#ifndef z_off_t
# define z_off_t long
#endif
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+# define z_off64_t off64_t
+#else
+# define z_off64_t z_off_t
+#endif
+
#if defined(__OS400__)
# define NO_vsnprintf
#endif
diff --git a/cpukit/zlib/zconf.h.in b/cpukit/zlib/zconf.h.in
index 58880245c1..02ce56c431 100644
--- a/cpukit/zlib/zconf.h.in
+++ b/cpukit/zlib/zconf.h.in
@@ -315,10 +315,6 @@
# endif
#endif
-#ifdef HAVE_VISIBILITY_PRAGMA
-# define ZEXTERN __attribute__((visibility ("default"))) extern
-#endif
-
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
@@ -364,8 +360,21 @@ typedef uLong FAR uLongf;
# define Z_HAVE_UNISTD_H
#endif
-#ifdef Z_HAVE_UNISTD_H
+#ifdef STDC
# include <sys/types.h> /* for off_t */
+#endif
+
+/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
+ * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
+ * though the former does not conform to the LFS document), but considering
+ * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
+ * equivalently requesting no 64-bit operations
+ */
+#if -_LARGEFILE64_SOURCE - -1 == 1
+# undef _LARGEFILE64_SOURCE
+#endif
+
+#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
@@ -375,19 +384,22 @@ typedef uLong FAR uLongf;
# endif
#endif
-#ifdef _LARGEFILE64_SOURCE
-# include <sys/types.h>
-#endif
-
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
+
#ifndef z_off_t
# define z_off_t long
#endif
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+# define z_off64_t off64_t
+#else
+# define z_off64_t z_off_t
+#endif
+
#if defined(__OS400__)
# define NO_vsnprintf
#endif