Download src/php/php-src/Zend/zend_bitset.h from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 8.03 kB
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/zend_bitset.h
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/zend_bitset.h
-
curl -L -o zend_bitset.h https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/zend_bitset.h
8.03 kB
| /* | |
| +----------------------------------------------------------------------+ | |
| | Zend OPcache JIT | | |
| +----------------------------------------------------------------------+ | |
| | Copyright (c) The PHP Group | | |
| +----------------------------------------------------------------------+ | |
| | This source file is subject to version 3.01 of the PHP license, | | |
| | that is bundled with this package in the file LICENSE, and is | | |
| | available through the world-wide-web at the following url: | | |
| | https://www.php.net/license/3_01.txt | | |
| | If you did not receive a copy of the PHP license and are unable to | | |
| | obtain it through the world-wide-web, please send a note to | | |
| | license@php.net so we can mail you a copy immediately. | | |
| +----------------------------------------------------------------------+ | |
| | Authors: Dmitry Stogov <dmitry@php.net> | | |
| +----------------------------------------------------------------------+ | |
| */ | |
| typedef zend_ulong *zend_bitset; | |
| /* Number of trailing zero bits (0x01 -> 0; 0x40 -> 6; 0x00 -> LEN) */ | |
| ZEND_ATTRIBUTE_CONST static zend_always_inline int zend_ulong_ntz(zend_ulong num) | |
| { | |
| return __builtin_ctzl(num); | |
| return __builtin_ctzll(num); | |
| unsigned long index; | |
| if (!BitScanForward64(&index, num)) { | |
| if (!BitScanForward(&index, num)) { | |
| return SIZEOF_ZEND_LONG * 8; | |
| } | |
| return (int) index; | |
| int n; | |
| if (num == Z_UL(0)) return SIZEOF_ZEND_LONG * 8; | |
| n = 1; | |
| if ((num & 0xffffffff) == 0) {n += 32; num = num >> Z_UL(32);} | |
| if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;} | |
| if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;} | |
| if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;} | |
| if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;} | |
| return n - (num & 1); | |
| } | |
| /* Number of leading zero bits (Undefined for zero) */ | |
| ZEND_ATTRIBUTE_CONST static zend_always_inline int zend_ulong_nlz(zend_ulong num) | |
| { | |
| return __builtin_clzl(num); | |
| return __builtin_clzll(num); | |
| unsigned long index; | |
| if (!BitScanReverse64(&index, num)) { | |
| if (!BitScanReverse(&index, num)) { | |
| return SIZEOF_ZEND_LONG * 8; | |
| } | |
| return (int) (SIZEOF_ZEND_LONG * 8 - 1)- index; | |
| zend_ulong x; | |
| int n; | |
| n = 64; | |
| x = num >> 32; if (x != 0) {n -= 32; num = x;} | |
| n = 32; | |
| x = num >> 16; if (x != 0) {n -= 16; num = x;} | |
| x = num >> 8; if (x != 0) {n -= 8; num = x;} | |
| x = num >> 4; if (x != 0) {n -= 4; num = x;} | |
| x = num >> 2; if (x != 0) {n -= 2; num = x;} | |
| x = num >> 1; if (x != 0) return n - 2; | |
| return n - num; | |
| } | |
| /* Returns the number of zend_ulong words needed to store a bitset that is N | |
| bits long. */ | |
| static inline uint32_t zend_bitset_len(uint32_t n) | |
| { | |
| return (n + ((sizeof(zend_long) * 8) - 1)) / (sizeof(zend_long) * 8); | |
| } | |
| static inline bool zend_bitset_in(zend_bitset set, uint32_t n) | |
| { | |
| return ZEND_BIT_TEST(set, n); | |
| } | |
| static inline void zend_bitset_incl(zend_bitset set, uint32_t n) | |
| { | |
| set[ZEND_BITSET_ELM_NUM(n)] |= Z_UL(1) << ZEND_BITSET_BIT_NUM(n); | |
| } | |
| static inline void zend_bitset_excl(zend_bitset set, uint32_t n) | |
| { | |
| set[ZEND_BITSET_ELM_NUM(n)] &= ~(Z_UL(1) << ZEND_BITSET_BIT_NUM(n)); | |
| } | |
| static inline void zend_bitset_clear(zend_bitset set, uint32_t len) | |
| { | |
| memset(set, 0, len * ZEND_BITSET_ELM_SIZE); | |
| } | |
| static inline bool zend_bitset_empty(zend_bitset set, uint32_t len) | |
| { | |
| uint32_t i; | |
| for (i = 0; i < len; i++) { | |
| if (set[i]) { | |
| return 0; | |
| } | |
| } | |
| return 1; | |
| } | |
| static inline void zend_bitset_fill(zend_bitset set, uint32_t len) | |
| { | |
| memset(set, 0xff, len * ZEND_BITSET_ELM_SIZE); | |
| } | |
| static inline bool zend_bitset_equal(zend_bitset set1, zend_bitset set2, uint32_t len) | |
| { | |
| return memcmp(set1, set2, len * ZEND_BITSET_ELM_SIZE) == 0; | |
| } | |
| static inline void zend_bitset_copy(zend_bitset set1, zend_bitset set2, uint32_t len) | |
| { | |
| memcpy(set1, set2, len * ZEND_BITSET_ELM_SIZE); | |
| } | |
| static inline void zend_bitset_intersection(zend_bitset set1, zend_bitset set2, uint32_t len) | |
| { | |
| uint32_t i; | |
| for (i = 0; i < len; i++) { | |
| set1[i] &= set2[i]; | |
| } | |
| } | |
| static inline void zend_bitset_union(zend_bitset set1, zend_bitset set2, uint32_t len) | |
| { | |
| uint32_t i; | |
| for (i = 0; i < len; i++) { | |
| set1[i] |= set2[i]; | |
| } | |
| } | |
| static inline void zend_bitset_difference(zend_bitset set1, zend_bitset set2, uint32_t len) | |
| { | |
| uint32_t i; | |
| for (i = 0; i < len; i++) { | |
| set1[i] = set1[i] & ~set2[i]; | |
| } | |
| } | |
| static inline void zend_bitset_union_with_intersection(zend_bitset set1, zend_bitset set2, zend_bitset set3, zend_bitset set4, uint32_t len) | |
| { | |
| uint32_t i; | |
| for (i = 0; i < len; i++) { | |
| set1[i] = set2[i] | (set3[i] & set4[i]); | |
| } | |
| } | |
| static inline void zend_bitset_union_with_difference(zend_bitset set1, zend_bitset set2, zend_bitset set3, zend_bitset set4, uint32_t len) | |
| { | |
| uint32_t i; | |
| for (i = 0; i < len; i++) { | |
| set1[i] = set2[i] | (set3[i] & ~set4[i]); | |
| } | |
| } | |
| static inline bool zend_bitset_subset(zend_bitset set1, zend_bitset set2, uint32_t len) | |
| { | |
| uint32_t i; | |
| for (i = 0; i < len; i++) { | |
| if (set1[i] & ~set2[i]) { | |
| return 0; | |
| } | |
| } | |
| return 1; | |
| } | |
| static inline int zend_bitset_first(zend_bitset set, uint32_t len) | |
| { | |
| uint32_t i; | |
| for (i = 0; i < len; i++) { | |
| if (set[i]) { | |
| return ZEND_BITSET_ELM_SIZE * 8 * i + zend_ulong_ntz(set[i]); | |
| } | |
| } | |
| return -1; /* empty set */ | |
| } | |
| static inline int zend_bitset_last(zend_bitset set, uint32_t len) | |
| { | |
| uint32_t i = len; | |
| while (i > 0) { | |
| i--; | |
| if (set[i]) { | |
| int j = ZEND_BITSET_ELM_SIZE * 8 * i - 1; | |
| zend_ulong x = set[i]; | |
| while (x != Z_UL(0)) { | |
| x = x >> Z_UL(1); | |
| j++; | |
| } | |
| return j; | |
| } | |
| } | |
| return -1; /* empty set */ | |
| } | |
| static inline int zend_bitset_pop_first(zend_bitset set, uint32_t len) { | |
| int i = zend_bitset_first(set, len); | |
| if (i >= 0) { | |
| zend_bitset_excl(set, i); | |
| } | |
| return i; | |
| } | |