Skip to content

Commit 5f69f03

Browse files
committed
Fix win build
1 parent 488d4c3 commit 5f69f03

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

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)