From f8dfb1eddb257ca659bdd3df087597d88a39a6dc Mon Sep 17 00:00:00 2001 From: Arnab Animesh Das Date: Sun, 17 Nov 2024 11:05:34 +0530 Subject: [PATCH] Add unistd.h and make it configure script independent --- contrib/iostream/zfstream.cpp | 6 ++++++ contrib/iostream/zfstream.h | 6 ++++++ contrib/iostream2/zstream.h | 5 +++++ contrib/iostream3/zfstream.h | 6 ++++++ examples/gun.c | 6 +++++- examples/gzappend.c | 6 +++++- examples/gzjoin.c | 6 +++++- examples/gzlog.c | 7 +++++-- gzread.c | 6 ++++++ gzwrite.c | 5 +++++ test/minigzip.c | 7 +++++-- 11 files changed, 59 insertions(+), 7 deletions(-) diff --git a/contrib/iostream/zfstream.cpp b/contrib/iostream/zfstream.cpp index d0cd85faa..26e3dfae4 100644 --- a/contrib/iostream/zfstream.cpp +++ b/contrib/iostream/zfstream.cpp @@ -1,4 +1,10 @@ + +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ +#endif #include "zfstream.h" gzfilebuf::gzfilebuf() : diff --git a/contrib/iostream/zfstream.h b/contrib/iostream/zfstream.h index ed79098a3..0309a2413 100644 --- a/contrib/iostream/zfstream.h +++ b/contrib/iostream/zfstream.h @@ -2,6 +2,12 @@ #ifndef zfstream_h #define zfstream_h + +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ +#endif #include #include "zlib.h" diff --git a/contrib/iostream2/zstream.h b/contrib/iostream2/zstream.h index 43d2332b7..bc29cd5fb 100644 --- a/contrib/iostream2/zstream.h +++ b/contrib/iostream2/zstream.h @@ -24,6 +24,11 @@ * $Id: zstream.h 1.1 1997-06-25 12:00:56+02 tyge Exp tyge $ */ +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ +#endif #include #include #include diff --git a/contrib/iostream3/zfstream.h b/contrib/iostream3/zfstream.h index 3dabc0f97..ab9665582 100644 --- a/contrib/iostream3/zfstream.h +++ b/contrib/iostream3/zfstream.h @@ -10,6 +10,12 @@ #ifndef ZFSTREAM_H #define ZFSTREAM_H + +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ +#endif #include // not iostream, since we don't need cin/cout #include #include "zlib.h" diff --git a/examples/gun.c b/examples/gun.c index dbd181c07..711ffae09 100644 --- a/examples/gun.c +++ b/examples/gun.c @@ -62,7 +62,11 @@ #include /* strerror(), strcmp(), strlen(), memcpy() */ #include /* errno */ #include /* open() */ -#include /* read(), write(), close(), chown(), unlink() */ +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ +#endif #include #include /* stat(), chmod() */ #include /* utime() */ diff --git a/examples/gzappend.c b/examples/gzappend.c index 23e93cf68..9273ec5b9 100644 --- a/examples/gzappend.c +++ b/examples/gzappend.c @@ -81,7 +81,11 @@ #include #include #include -#include +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ +#endif #include "zlib.h" #define local static diff --git a/examples/gzjoin.c b/examples/gzjoin.c index 89e809844..bb7290c74 100644 --- a/examples/gzjoin.c +++ b/examples/gzjoin.c @@ -56,7 +56,11 @@ #include /* fputs(), fprintf(), fwrite(), putc() */ #include /* exit(), malloc(), free() */ #include /* open() */ -#include /* close(), read(), lseek() */ +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ +#endif #include "zlib.h" /* crc32(), crc32_combine(), inflateInit2(), inflate(), inflateEnd() */ diff --git a/examples/gzlog.c b/examples/gzlog.c index da1b02e73..d89f89597 100644 --- a/examples/gzlog.c +++ b/examples/gzlog.c @@ -228,8 +228,11 @@ #include /* malloc, free */ #include /* strlen, strrchr, strcpy, strncpy, strcmp */ #include /* open */ -#include /* lseek, read, write, close, unlink, sleep, */ - /* ftruncate, fsync */ +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ +#endif #include /* errno */ #include /* time, ctime */ #include /* stat */ diff --git a/gzread.c b/gzread.c index 2d4ca4290..15b56822b 100644 --- a/gzread.c +++ b/gzread.c @@ -3,6 +3,12 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ + +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ +#endif #include "gzguts.h" /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from diff --git a/gzwrite.c b/gzwrite.c index 435b4621b..8e5dd37a7 100644 --- a/gzwrite.c +++ b/gzwrite.c @@ -3,6 +3,11 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ +#endif #include "gzguts.h" /* Initialize state for writing a gzip file. Mark initialization by setting diff --git a/test/minigzip.c b/test/minigzip.c index 541f3716b..3d3b67144 100644 --- a/test/minigzip.c +++ b/test/minigzip.c @@ -173,8 +173,11 @@ static char *string_copy(char *dst, char const *src, z_size_t len) { #ifdef Z_SOLO /* for Z_SOLO, create simplified gz* functions using deflate and inflate */ -#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE) -# include /* for unlink() */ + +#if defined( unix ) || defined( __unix ) || defined( __unix__ ) || \ + (defined( __APPLE__ ) && defined( __MACH__ )) || \ + HAVE_UNISTD_H +#include /* lseek, read, write, close, chown, unlink, sleep, ftruncate, fsync */ #endif static void *myalloc(void *q, unsigned n, unsigned m) {