File tree Expand file tree Collapse file tree 2 files changed +2
-28
lines changed Expand file tree Collapse file tree 2 files changed +2
-28
lines changed Original file line number Diff line number Diff line change @@ -214,31 +214,4 @@ PHPAPI ZEND_EXTERN_MODULE_GLOBALS(random)
214
214
215
215
# define RANDOM_G (v ) ZEND_MODULE_GLOBALS_ACCESSOR (random , v )
216
216
217
- /* Bytes swap */
218
- #ifdef _MSC_VER
219
- # include <stdlib.h>
220
- # define RANDOM_BSWAP64 (u ) _byteswap_uint64(u)
221
- #else
222
- # ifdef __GNUC__
223
- # define RANDOM_BSWAP64 (u ) __builtin_bswap64(u)
224
- # elif defined(__has_builtin )
225
- # if __has_builtin (__builtin_bswap64 )
226
- # define RANDOM_BSWAP64 (u ) __builtin_bswap64(u)
227
- # endif // __has_builtin(__builtin_bswap64)
228
- # endif // __GNUC__
229
- #endif // _MSC_VER
230
- #ifndef RANDOM_BSWAP64
231
- static inline uint64_t RANDOM_BSWAP64 (uint64_t u )
232
- {
233
- return (((u & 0xff00000000000000ULL ) >> 56 )
234
- | ((u & 0x00ff000000000000ULL ) >> 40 )
235
- | ((u & 0x0000ff0000000000ULL ) >> 24 )
236
- | ((u & 0x000000ff00000000ULL ) >> 8 )
237
- | ((u & 0x00000000ff000000ULL ) << 8 )
238
- | ((u & 0x0000000000ff0000ULL ) << 24 )
239
- | ((u & 0x000000000000ff00ULL ) << 40 )
240
- | ((u & 0x00000000000000ffULL ) << 56 ));
241
- }
242
- #endif
243
-
244
217
#endif /* PHP_RANDOM_H */
Original file line number Diff line number Diff line change 26
26
27
27
#include "Zend/zend_enum.h"
28
28
#include "Zend/zend_exceptions.h"
29
+ #include "zend_portability.h"
29
30
30
31
static inline void randomizer_common_init (php_random_randomizer * randomizer , zend_object * engine_object ) {
31
32
if (engine_object -> ce -> type == ZEND_INTERNAL_CLASS ) {
@@ -302,7 +303,7 @@ PHP_METHOD(Random_Randomizer, getBytes)
302
303
uint64_t tmp_ret = result .result ;
303
304
if (to_read >= sizeof (uint64_t ) && result .size == sizeof (uint64_t )) {
304
305
#ifdef WORDS_BIGENDIAN
305
- tmp_ret = RANDOM_BSWAP64 (tmp_ret );
306
+ tmp_ret = ZEND_BYTES_SWAP64 (tmp_ret );
306
307
#endif
307
308
memcpy (rptr , & tmp_ret , sizeof (uint64_t ));
308
309
to_read -= sizeof (uint64_t );
You can’t perform that action at this time.
0 commit comments