Skip to content

Commit 9a55cb2

Browse files
committed
Fix win build
1 parent 488d4c3 commit 9a55cb2

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (PHP_LIBARCHIVE != "no") {
77
CHECK_HEADER_ADD_INCLUDE("archive.h", "CFLAGS_ARCHIVE",
88
PHP_LIBARCHIVE + "/include;" + PHP_PHP_BUILD + "/include")) {
99

10-
EXTENSION("archive", "libarchive.c stream.c", true, "/DLIBARCHIVE_STATIC");
10+
EXTENSION("archive", "libarchive.c stream.c", true, "/DLIBARCHIVE_STATIC /Zc:preprocessor");
1111

1212
// Always-needed Windows system libs.
1313
var libs = "bcrypt.lib xmllite.lib crypt32.lib ws2_32.lib";

libarchive.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ static void entry_oh_free_obj(zend_object *zobj)
9292
#define _DJB_PASTE(a,b) a##b
9393
#define _DJB_SEL(n) _DJB_PASTE(_DJB_,n)
9494
/* zend_inline_hash_func sets the high bit of the result */
95-
#define DJB(...) (_DJB_SEL(_DJB_COUNT(__VA_ARGS__))(__VA_ARGS__) | ((zend_ulong)1 << (8 * sizeof(zend_ulong) - 1)))
95+
/* MSVC C mode rejects sizeof in case-label constant expressions; derive the
96+
high bit purely from bitwise ops so both compilers are happy. */
97+
#ifdef _MSC_VER
98+
#define _DJB_HIGH_BIT ((zend_ulong)~(zend_ulong)0 ^ ((zend_ulong)~(zend_ulong)0 >> 1))
99+
#else
100+
#define _DJB_HIGH_BIT ((zend_ulong)1 << (8 * sizeof(zend_ulong) - 1))
101+
#endif
102+
#define DJB(...) (_DJB_SEL(_DJB_COUNT(__VA_ARGS__))(__VA_ARGS__) | _DJB_HIGH_BIT)
96103

97104
#define ENTRY_HASH_PATHNAME DJB('p','a','t','h','n','a','m','e')
98105
#define ENTRY_HASH_SIZE DJB('s','i','z','e')

0 commit comments

Comments
 (0)