Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext/bcmath: Fixed an issue where macros may become undefined #14179

Merged
merged 4 commits into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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