Skip to content

CDRIVER-4521 Remove C89 compatibility macros #1181

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

Merged
merged 3 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 2 additions & 130 deletions src/libbson/src/bson/bson-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,134 +145,6 @@ typedef SSIZE_T ssize_t;
* all its bits to 1. */
#define BSON_NUMERIC_LIMITS_MAX_UNSIGNED(T) ((T) (~((T) 0)))

/* Define numeric limit constants if not already available for C90
* compatibility. These can be removed once C99 is declared the minimum
* supported C standard. */
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L

#ifndef SCHAR_MAX
#define SCHAR_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (signed char)
#endif

#ifndef SHRT_MAX
#define SHRT_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (short)
#endif

#ifndef INT_MAX
#define INT_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int)
#endif

#ifndef LONG_MAX
#define LONG_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (long)
#endif

#ifndef LLONG_MAX
#define LLONG_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (long long)
#endif

#ifndef UCHAR_MAX
#define UCHAR_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned char)
#endif

#ifndef USHRT_MAX
#define USHRT_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned short)
#endif

#ifndef UINT_MAX
#define UINT_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned int)
#endif

#ifndef ULONG_MAX
#define ULONG_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned long)
#endif

#ifndef ULLONG_MAX
#define ULLONG_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned long long)
#endif

#ifndef INT8_MAX
#define INT8_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int8_t)
#endif

#ifndef INT16_MAX
#define INT16_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int16_t)
#endif

#ifndef INT32_MAX
#define INT32_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int32_t)
#endif

#ifndef INT64_MAX
#define INT64_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int64_t)
#endif

#ifndef UINT8_MAX
#define UINT8_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint8_t)
#endif

#ifndef UINT16_MAX
#define UINT16_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint16_t)
#endif

#ifndef UINT32_MAX
#define UINT32_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint32_t)
#endif

#ifndef UINT64_MAX
#define UINT64_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint64_t)
#endif

#ifndef SIZE_MAX
#define SIZE_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (size_t)
#endif

#ifndef PTRDIFF_MAX
#define PTRDIFF_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (ptrdiff_t)
#endif

#ifndef SCHAR_MIN
#define SCHAR_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (signed char, SCHAR_MAX)
#endif

#ifndef SHRT_MIN
#define SHRT_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (short, SHRT_MAX)
#endif

#ifndef INT_MIN
#define INT_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int, INT_MAX)
#endif

#ifndef LONG_MIN
#define LONG_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (long, LONG_MAX)
#endif

#ifndef LLONG_MIN
#define LLONG_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (long long, LLONG_MAX)
#endif

#ifndef INT8_MIN
#define INT8_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int8_t, INT8_MAX)
#endif

#ifndef INT16_MIN
#define INT16_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int16_t, INT16_MAX)
#endif

#ifndef INT32_MIN
#define INT32_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int32_t, INT32_MAX)
#endif

#ifndef INT64_MIN
#define INT64_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int64_t, INT64_MAX)
#endif

#ifndef PTRDIFF_MIN
#define PTRDIFF_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (ptrdiff_t, PTRDIFF_MAX)
#endif

#endif /* !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L */


#ifndef SSIZE_MAX
#define SSIZE_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (ssize_t)
#endif
Expand Down Expand Up @@ -303,9 +175,9 @@ typedef signed char bool;
#define bson_sync_synchronize() __sync_synchronize ()
#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || \
defined(__i686__) || defined(__x86_64__)
#define bson_sync_synchronize() asm volatile("mfence" ::: "memory")
#define bson_sync_synchronize() asm volatile ("mfence" ::: "memory")
#else
#define bson_sync_synchronize() asm volatile("sync" ::: "memory")
#define bson_sync_synchronize() asm volatile ("sync" ::: "memory")
#endif
#elif defined(_MSC_VER)
#define bson_sync_synchronize() MemoryBarrier ()
Expand Down
2 changes: 0 additions & 2 deletions src/libbson/src/bson/bson-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@

#if defined(_MSC_VER)
#define BSON_FUNC __FUNCTION__
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L
#define BSON_FUNC __FUNCTION__
#else
#define BSON_FUNC __func__
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/libbson/src/bson/bson-memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ BSON_STATIC_ASSERT2 (bson_mem_vtable_t,
// For compatibility with C standards prior to C11.
static void *
_aligned_alloc_impl (size_t alignment, size_t num_bytes)
#if __STDC_VERSION__ >= 201112L && !defined(_WIN32)
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(_WIN32)
{
return aligned_alloc (alignment, num_bytes);
}
Expand Down
3 changes: 1 addition & 2 deletions src/libbson/src/bson/bson-timegm.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
#endif
#endif

#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901) && \
!defined restrict
#if !defined(__STDC_VERSION__) && !defined restrict
#define restrict /* empty */
#endif

Expand Down