Skip to content

Commit 9e18dd1

Browse files
authored
CDRIVER-4521 Remove C89 compatibility macros (#1181)
* Format bson-compat.h * CDRIVER-4521 Remove C89 compatibility macros in bson-compat.h * Update other pre-C99 compatibility macros
1 parent a8560d7 commit 9e18dd1

File tree

4 files changed

+4
-135
lines changed

4 files changed

+4
-135
lines changed

src/libbson/src/bson/bson-compat.h

Lines changed: 2 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -145,134 +145,6 @@ typedef SSIZE_T ssize_t;
145145
* all its bits to 1. */
146146
#define BSON_NUMERIC_LIMITS_MAX_UNSIGNED(T) ((T) (~((T) 0)))
147147

148-
/* Define numeric limit constants if not already available for C90
149-
* compatibility. These can be removed once C99 is declared the minimum
150-
* supported C standard. */
151-
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
152-
153-
#ifndef SCHAR_MAX
154-
#define SCHAR_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (signed char)
155-
#endif
156-
157-
#ifndef SHRT_MAX
158-
#define SHRT_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (short)
159-
#endif
160-
161-
#ifndef INT_MAX
162-
#define INT_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int)
163-
#endif
164-
165-
#ifndef LONG_MAX
166-
#define LONG_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (long)
167-
#endif
168-
169-
#ifndef LLONG_MAX
170-
#define LLONG_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (long long)
171-
#endif
172-
173-
#ifndef UCHAR_MAX
174-
#define UCHAR_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned char)
175-
#endif
176-
177-
#ifndef USHRT_MAX
178-
#define USHRT_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned short)
179-
#endif
180-
181-
#ifndef UINT_MAX
182-
#define UINT_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned int)
183-
#endif
184-
185-
#ifndef ULONG_MAX
186-
#define ULONG_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned long)
187-
#endif
188-
189-
#ifndef ULLONG_MAX
190-
#define ULLONG_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (unsigned long long)
191-
#endif
192-
193-
#ifndef INT8_MAX
194-
#define INT8_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int8_t)
195-
#endif
196-
197-
#ifndef INT16_MAX
198-
#define INT16_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int16_t)
199-
#endif
200-
201-
#ifndef INT32_MAX
202-
#define INT32_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int32_t)
203-
#endif
204-
205-
#ifndef INT64_MAX
206-
#define INT64_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (int64_t)
207-
#endif
208-
209-
#ifndef UINT8_MAX
210-
#define UINT8_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint8_t)
211-
#endif
212-
213-
#ifndef UINT16_MAX
214-
#define UINT16_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint16_t)
215-
#endif
216-
217-
#ifndef UINT32_MAX
218-
#define UINT32_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint32_t)
219-
#endif
220-
221-
#ifndef UINT64_MAX
222-
#define UINT64_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (uint64_t)
223-
#endif
224-
225-
#ifndef SIZE_MAX
226-
#define SIZE_MAX BSON_NUMERIC_LIMITS_MAX_UNSIGNED (size_t)
227-
#endif
228-
229-
#ifndef PTRDIFF_MAX
230-
#define PTRDIFF_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (ptrdiff_t)
231-
#endif
232-
233-
#ifndef SCHAR_MIN
234-
#define SCHAR_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (signed char, SCHAR_MAX)
235-
#endif
236-
237-
#ifndef SHRT_MIN
238-
#define SHRT_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (short, SHRT_MAX)
239-
#endif
240-
241-
#ifndef INT_MIN
242-
#define INT_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int, INT_MAX)
243-
#endif
244-
245-
#ifndef LONG_MIN
246-
#define LONG_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (long, LONG_MAX)
247-
#endif
248-
249-
#ifndef LLONG_MIN
250-
#define LLONG_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (long long, LLONG_MAX)
251-
#endif
252-
253-
#ifndef INT8_MIN
254-
#define INT8_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int8_t, INT8_MAX)
255-
#endif
256-
257-
#ifndef INT16_MIN
258-
#define INT16_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int16_t, INT16_MAX)
259-
#endif
260-
261-
#ifndef INT32_MIN
262-
#define INT32_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int32_t, INT32_MAX)
263-
#endif
264-
265-
#ifndef INT64_MIN
266-
#define INT64_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (int64_t, INT64_MAX)
267-
#endif
268-
269-
#ifndef PTRDIFF_MIN
270-
#define PTRDIFF_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (ptrdiff_t, PTRDIFF_MAX)
271-
#endif
272-
273-
#endif /* !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L */
274-
275-
276148
#ifndef SSIZE_MAX
277149
#define SSIZE_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (ssize_t)
278150
#endif
@@ -303,9 +175,9 @@ typedef signed char bool;
303175
#define bson_sync_synchronize() __sync_synchronize ()
304176
#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || \
305177
defined(__i686__) || defined(__x86_64__)
306-
#define bson_sync_synchronize() asm volatile("mfence" ::: "memory")
178+
#define bson_sync_synchronize() asm volatile ("mfence" ::: "memory")
307179
#else
308-
#define bson_sync_synchronize() asm volatile("sync" ::: "memory")
180+
#define bson_sync_synchronize() asm volatile ("sync" ::: "memory")
309181
#endif
310182
#elif defined(_MSC_VER)
311183
#define bson_sync_synchronize() MemoryBarrier ()

src/libbson/src/bson/bson-macros.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@
189189

190190
#if defined(_MSC_VER)
191191
#define BSON_FUNC __FUNCTION__
192-
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L
193-
#define BSON_FUNC __FUNCTION__
194192
#else
195193
#define BSON_FUNC __func__
196194
#endif

src/libbson/src/bson/bson-memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ BSON_STATIC_ASSERT2 (bson_mem_vtable_t,
3333
// For compatibility with C standards prior to C11.
3434
static void *
3535
_aligned_alloc_impl (size_t alignment, size_t num_bytes)
36-
#if __STDC_VERSION__ >= 201112L && !defined(_WIN32)
36+
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(_WIN32)
3737
{
3838
return aligned_alloc (alignment, num_bytes);
3939
}

src/libbson/src/bson/bson-timegm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
#endif
4141
#endif
4242

43-
#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901) && \
44-
!defined restrict
43+
#if !defined(__STDC_VERSION__) && !defined restrict
4544
#define restrict /* empty */
4645
#endif
4746

0 commit comments

Comments
 (0)