mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 04:56:20 +00:00
[Library] Update zlibng (#1255)
* Update zlibng * Set cmake path more directly in zlibng to hopefully fix an issue with the build on drone * I'm dumb, missing / in path * Mackal helps with a dumb gitignore issue * Adding all the files, not sure what's ignoring them and im tired of looking * Some tweaks to zlibng build to hopefully get it to build properly. works on msvc now
This commit is contained in:
+76
-69
@@ -10,14 +10,22 @@
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#if defined(HAVE_INTERNAL)
|
||||
# define ZLIB_INTERNAL __attribute__((visibility ("internal")))
|
||||
#elif defined(HAVE_HIDDEN)
|
||||
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||
#if defined(HAVE_VISIBILITY_INTERNAL)
|
||||
# define Z_INTERNAL __attribute__((visibility ("internal")))
|
||||
#elif defined(HAVE_VISIBILITY_HIDDEN)
|
||||
# define Z_INTERNAL __attribute__((visibility ("hidden")))
|
||||
#else
|
||||
# define ZLIB_INTERNAL
|
||||
# define Z_INTERNAL
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
# define Z_REGISTER register
|
||||
#else
|
||||
# define Z_REGISTER
|
||||
#endif
|
||||
|
||||
#ifndef Z_TLS
|
||||
# define Z_TLS
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -25,19 +33,20 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#ifdef ZLIB_COMPAT
|
||||
# include "zlib.h"
|
||||
# include "zlib.h"
|
||||
#else
|
||||
# include "zlib-ng.h"
|
||||
# include "zlib-ng.h"
|
||||
#endif
|
||||
#include "zbuild.h"
|
||||
|
||||
typedef unsigned char uch; /* Included for compatibility with external code only */
|
||||
typedef uint16_t ush; /* Included for compatibility with external code only */
|
||||
typedef unsigned long ulg;
|
||||
typedef unsigned long ulg;
|
||||
|
||||
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */
|
||||
/* (size given to avoid silly warnings with Visual C++) */
|
||||
|
||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||
#define ERR_MSG(err) PREFIX(z_errmsg)[Z_NEED_DICT-(err)]
|
||||
|
||||
#define ERR_RETURN(strm, err) return (strm->msg = ERR_MSG(err), (err))
|
||||
/* To be used only when the state is known to be valid */
|
||||
@@ -67,6 +76,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
|
||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
||||
|
||||
#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
|
||||
|
||||
/* target dependencies */
|
||||
|
||||
#ifdef AMIGA
|
||||
@@ -89,9 +100,6 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
|
||||
#ifdef OS2
|
||||
# define OS_CODE 6
|
||||
# if defined(M_I86) && !defined(Z_SOLO)
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||
@@ -102,7 +110,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
# define OS_CODE 13
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
# define OS_CODE 10
|
||||
#endif
|
||||
|
||||
@@ -114,16 +122,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
# define fdopen(fd, type) _fdopen(fd, type)
|
||||
#endif
|
||||
|
||||
/* provide prototypes for these when building zlib without LFS */
|
||||
#if !defined(WIN32) && !defined(__MSYS__) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||
# include "zbuild.h" /* For PREFIX() */
|
||||
ZEXTERN uint32_t ZEXPORT PREFIX(adler32_combine64)(uint32_t, uint32_t, z_off_t);
|
||||
ZEXTERN uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t, uint32_t, z_off_t);
|
||||
#endif
|
||||
|
||||
/* MS Visual Studio does not allow inline in C, only C++.
|
||||
But it provides __inline instead, so use that. */
|
||||
#if defined(_MSC_VER) && !defined(inline)
|
||||
#if defined(_MSC_VER) && !defined(inline) && !defined(__cplusplus)
|
||||
# define inline __inline
|
||||
#endif
|
||||
|
||||
@@ -131,51 +132,47 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
|
||||
#ifndef OS_CODE
|
||||
# define OS_CODE 3 /* assume Unix */
|
||||
#endif
|
||||
|
||||
#ifndef F_OPEN
|
||||
# define F_OPEN(name, mode) fopen((name), (mode))
|
||||
#endif
|
||||
|
||||
/* functions */
|
||||
|
||||
/* Diagnostic functions */
|
||||
#ifdef ZLIB_DEBUG
|
||||
# include <stdio.h>
|
||||
extern int ZLIB_INTERNAL z_verbose;
|
||||
extern void ZLIB_INTERNAL z_error(char *m);
|
||||
# define Assert(cond, msg) {if(!(cond)) z_error(msg);}
|
||||
# define Trace(x) {if (z_verbose >= 0) fprintf x;}
|
||||
# define Tracev(x) {if (z_verbose > 0) fprintf x;}
|
||||
# define Tracevv(x) {if (z_verbose > 1) fprintf x;}
|
||||
# define Tracec(c, x) {if (z_verbose > 0 && (c)) fprintf x;}
|
||||
# define Tracecv(c, x) {if (z_verbose > 1 && (c)) fprintf x;}
|
||||
# include <stdio.h>
|
||||
extern int Z_INTERNAL z_verbose;
|
||||
extern void Z_INTERNAL z_error(char *m);
|
||||
# define Assert(cond, msg) {if (!(cond)) z_error(msg);}
|
||||
# define Trace(x) {if (z_verbose >= 0) fprintf x;}
|
||||
# define Tracev(x) {if (z_verbose > 0) fprintf x;}
|
||||
# define Tracevv(x) {if (z_verbose > 1) fprintf x;}
|
||||
# define Tracec(c, x) {if (z_verbose > 0 && (c)) fprintf x;}
|
||||
# define Tracecv(c, x) {if (z_verbose > 1 && (c)) fprintf x;}
|
||||
#else
|
||||
# define Assert(cond, msg)
|
||||
# define Trace(x)
|
||||
# define Tracev(x)
|
||||
# define Tracevv(x)
|
||||
# define Tracec(c, x)
|
||||
# define Tracecv(c, x)
|
||||
# define Assert(cond, msg)
|
||||
# define Trace(x)
|
||||
# define Tracev(x)
|
||||
# define Tracevv(x)
|
||||
# define Tracec(c, x)
|
||||
# define Tracecv(c, x)
|
||||
#endif
|
||||
|
||||
void ZLIB_INTERNAL *zcalloc(void *opaque, unsigned items, unsigned size);
|
||||
void ZLIB_INTERNAL zcfree(void *opaque, void *ptr);
|
||||
void Z_INTERNAL *zng_calloc(void *opaque, unsigned items, unsigned size);
|
||||
void Z_INTERNAL zng_cfree(void *opaque, void *ptr);
|
||||
|
||||
#define ZALLOC(strm, items, size) (*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (void *)(addr))
|
||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||
|
||||
/* Reverse the bytes in a value. Use compiler intrinsics when
|
||||
possible to take advantage of hardware implementations. */
|
||||
#if defined(WIN32) && (_MSC_VER >= 1300)
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# pragma intrinsic(_byteswap_ulong)
|
||||
# define ZSWAP16(q) _byteswap_ushort(q)
|
||||
# define ZSWAP32(q) _byteswap_ulong(q)
|
||||
# define ZSWAP64(q) _byteswap_uint64(q)
|
||||
|
||||
#elif defined(__Clang__) || (defined(__GNUC__) && \
|
||||
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)))
|
||||
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
|
||||
# define ZSWAP16(q) __builtin_bswap16(q)
|
||||
# define ZSWAP32(q) __builtin_bswap32(q)
|
||||
# define ZSWAP64(q) __builtin_bswap64(q)
|
||||
@@ -201,7 +198,7 @@ void ZLIB_INTERNAL zcfree(void *opaque, void *ptr);
|
||||
#else
|
||||
# define ZSWAP16(q) ((((q) & 0xff) << 8) | (((q) & 0xff00) >> 8))
|
||||
# define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
||||
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
||||
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
||||
# define ZSWAP64(q) \
|
||||
((q & 0xFF00000000000000u) >> 56u) | \
|
||||
((q & 0x00FF000000000000u) >> 40u) | \
|
||||
@@ -215,33 +212,43 @@ void ZLIB_INTERNAL zcfree(void *opaque, void *ptr);
|
||||
|
||||
/* Only enable likely/unlikely if the compiler is known to support it */
|
||||
#if (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__INTEL_COMPILER) || defined(__Clang__)
|
||||
# ifndef likely
|
||||
# define likely(x) __builtin_expect(!!(x), 1)
|
||||
# endif
|
||||
# ifndef unlikely
|
||||
# define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
# endif
|
||||
# define LIKELY_NULL(x) __builtin_expect((x) != 0, 0)
|
||||
# define LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
# define UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
# define PREFETCH_L1(addr) __builtin_prefetch(addr, 0, 3)
|
||||
# define PREFETCH_L2(addr) __builtin_prefetch(addr, 0, 2)
|
||||
# define PREFETCH_RW(addr) __builtin_prefetch(addr, 1, 2)
|
||||
#elif defined(__WIN__)
|
||||
# include <xmmintrin.h>
|
||||
# define LIKELY_NULL(x) x
|
||||
# define LIKELY(x) x
|
||||
# define UNLIKELY(x) x
|
||||
# define PREFETCH_L1(addr) _mm_prefetch((char *) addr, _MM_HINT_T0)
|
||||
# define PREFETCH_L2(addr) _mm_prefetch((char *) addr, _MM_HINT_T1)
|
||||
# define PREFETCH_RW(addr) _mm_prefetch((char *) addr, _MM_HINT_T1)
|
||||
#else
|
||||
# ifndef likely
|
||||
# define likely(x) x
|
||||
# endif
|
||||
# ifndef unlikely
|
||||
# define unlikely(x) x
|
||||
# endif
|
||||
# define LIKELY_NULL(x) x
|
||||
# define LIKELY(x) x
|
||||
# define UNLIKELY(x) x
|
||||
# define PREFETCH_L1(addr) addr
|
||||
# define PREFETCH_L2(addr) addr
|
||||
# define PREFETCH_RW(addr) addr
|
||||
#endif /* (un)likely */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define ALIGNED_(x) __declspec(align(x))
|
||||
# define ALIGNED_(x) __declspec(align(x))
|
||||
#else
|
||||
#if defined(__GNUC__)
|
||||
#define ALIGNED_(x) __attribute__ ((aligned(x)))
|
||||
#endif
|
||||
# if defined(__GNUC__)
|
||||
# define ALIGNED_(x) __attribute__ ((aligned(x)))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(X86_CPUID)
|
||||
# include "arch/x86/x86.h"
|
||||
#elif defined(__aarch64__) || defined(__arm__) || defined(_M_ARM)
|
||||
# include "arch/arm/arm.h"
|
||||
#if defined(X86_FEATURES)
|
||||
# include "arch/x86/x86.h"
|
||||
#elif defined(ARM_FEATURES)
|
||||
# include "arch/arm/arm.h"
|
||||
#elif defined(POWER_FEATURES)
|
||||
# include "arch/power/power.h"
|
||||
#endif
|
||||
|
||||
#endif /* ZUTIL_H_ */
|
||||
|
||||
Reference in New Issue
Block a user