Skip to content

Commit

Permalink
ext/bcmath: Fixed an issue where macros may become undefined (#14179)
Browse files Browse the repository at this point in the history
  • Loading branch information
SakiTakamachi committed May 10, 2024
1 parent 2956f55 commit e976c2d
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions ext/bcmath/libbcmath/src/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,34 @@
#define SWAR_REPEAT(x) (SWAR_ONES * (x))

/* Bytes swap */
#if defined(_MSC_VER)
#ifdef _MSC_VER
# include <stdlib.h>
# define BSWAP32(u) _byteswap_ulong(u)
# define BSWAP64(u) _byteswap_uint64(u)
# define BC_BSWAP32(u) _byteswap_ulong(u)
# define BC_BSWAP64(u) _byteswap_uint64(u)
#else
# ifdef __has_builtin
# ifdef __GNUC__
# define BC_BSWAP32(u) __builtin_bswap32(u)
# define BC_BSWAP64(u) __builtin_bswap64(u)
# elif defined(__has_builtin)
# if __has_builtin(__builtin_bswap32)
# define BSWAP32(u) __builtin_bswap32(u)
# define BC_BSWAP32(u) __builtin_bswap32(u)
# endif // __has_builtin(__builtin_bswap32)
# if __has_builtin(__builtin_bswap64)
# define BSWAP64(u) __builtin_bswap64(u)
# define BC_BSWAP64(u) __builtin_bswap64(u)
# endif // __has_builtin(__builtin_bswap64)
# elif defined(__GNUC__)
# define BSWAP32(u) __builtin_bswap32(u)
# define BSWAP64(u) __builtin_bswap64(u)
# endif // __has_builtin
#endif // defined(_MSC_VER)
#ifndef BSWAP32
inline uint32_t BSWAP32(uint32_t u)
# endif // __GNUC__
#endif // _MSC_VER
#ifndef BC_BSWAP32
static inline uint32_t BC_BSWAP32(uint32_t u)
{
return (((u & 0xff000000) >> 24)
| ((u & 0x00ff0000) >> 8)
| ((u & 0x0000ff00) << 8)
| ((u & 0x000000ff) << 24));
}
#endif
#ifndef BSWAP64
inline uint64_t BSWAP64(uint64_t u)
#ifndef BC_BSWAP64
static inline uint64_t BC_BSWAP64(uint64_t u)
{
return (((u & 0xff00000000000000ULL) >> 56)
| ((u & 0x00ff000000000000ULL) >> 40)
Expand All @@ -82,17 +82,17 @@ inline uint64_t BSWAP64(uint64_t u)
#endif

#if SIZEOF_SIZE_T >= 8
#define BC_BSWAP(u) BSWAP64(u)
#define BC_UINT_T uint64_t
# define BC_BSWAP(u) BC_BSWAP64(u)
# define BC_UINT_T uint64_t
#else
#define BC_BSWAP(u) BSWAP32(u)
#define BC_UINT_T uint32_t
# define BC_BSWAP(u) BC_BSWAP32(u)
# define BC_UINT_T uint32_t
#endif

#ifdef WORDS_BIGENDIAN
#define BC_LITTLE_ENDIAN 0
# define BC_LITTLE_ENDIAN 0
#else
#define BC_LITTLE_ENDIAN 1
# define BC_LITTLE_ENDIAN 1
#endif


Expand Down

0 comments on commit e976c2d

Please sign in to comment.