]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed minor compatibility issues with older compilers
authorYann Collet <cyan@fb.com>
Thu, 30 Aug 2018 22:54:14 +0000 (15:54 -0700)
committerYann Collet <cyan@fb.com>
Thu, 30 Aug 2018 23:00:57 +0000 (16:00 -0700)
contrib/largeNbDicts/Makefile
contrib/largeNbDicts/largeNbDicts.c
programs/util.h

index 0514e3d8233d57161172464f61f9ec5cc1d388e4..05b54fd35ade73faa0812ca087f3bae537723df8 100644 (file)
@@ -15,7 +15,7 @@ LIBZSTD = $(LIBDIR)/libzstd.a
 CPPFLAGS+= -I$(LIBDIR) -I$(LIBDIR)/common -I$(LIBDIR)/dictBuilder -I$(PROGDIR)
 
 CFLAGS  ?= -O3
-CFLAGS  += -std=c99
+CFLAGS  += -std=gnu99
 DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
             -Wstrict-aliasing=1 -Wswitch-enum \
             -Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \
index 5b982bd429afeac32c11509a0258af73d2083d81..0c5f89a8e47b6f1c07f2c1cfe421c0356134f3bd 100644 (file)
@@ -50,6 +50,8 @@
 
 /*---  Macros  ---*/
 #define CONTROL(c)   assert(c)
+#undef MIN
+#define MIN(a,b)   ((a) < (b) ? (a) : (b))
 
 
 /*---  Display Macros  ---*/
@@ -472,9 +474,6 @@ static size_t compressBlocks(size_t* cSizes,   /* optional (can be NULL). If pre
 
 /* ---  Benchmark  --- */
 
-typedef size_t (*BMK_benchFn_t)(const void* src, size_t srcSize, void* dst, size_t dstCapacity, void* customPayload);
-typedef size_t (*BMK_initFn_t)(void* initPayload);
-
 typedef struct {
     ZSTD_DCtx* dctx;
     size_t nbDicts;
index 76000d9915ffde774961fa207ba04ad2b9f56e2c..88d048409d17c137fccca254d18df4c20bfa0986 100644 (file)
@@ -319,15 +319,17 @@ UTIL_STATIC U32 UTIL_isDirectory(const char* infilename)
 
 UTIL_STATIC U32 UTIL_isLink(const char* infilename)
 {
-#if defined(_WIN32)
-    /* no symlinks on windows */
-    (void)infilename;
-#else
+/* macro guards, as defined in : https://linux.die.net/man/2/lstat */
+#if defined(_BSD_SOURCE) \
+    || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) \
+    || (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) \
+    || (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L))
     int r;
     stat_t statbuf;
     r = lstat(infilename, &statbuf);
     if (!r && S_ISLNK(statbuf.st_mode)) return 1;
 #endif
+    (void)infilename;
     return 0;
 }