Skip to content

Commit 51b2ce9

Browse files
committed
Drop pstdbool.h and pstdint.h
Shimming compilation environments to pre-C99 is no longer worth the space it takes up.
1 parent a5dc284 commit 51b2ce9

File tree

8 files changed

+40
-1037
lines changed

8 files changed

+40
-1037
lines changed

CREDITS.md

-5
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ not be complete. Please amend with any corrections.
121121
- Copyright The Mbed TLS Contributors
122122
- `%extensions/crypt/mbedtls/*`
123123

124-
**pstdint.h**
125-
- Copyright (c) 2005-2016 Paul Hsieh
126-
- BSD License
127-
- `%src/include/pstdint.h`
128-
129124
**qsort**
130125
- Copyright (c) 1992, 1993 The Regents of the University of California.
131126
- `%src/core/f-qsort.c`

src/core/a-constants.c

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
#include <stdlib.h> // size_t and other types used in rebol.h
4545
#include <assert.h>
4646

47-
#include "pstdint.h" // polyfill <stdint.h> for pre-C99/C++11 compilers
48-
#include "pstdbool.h" // polyfill <stdbool.h> for pre-C99/C++11 compilers
4947
#include "c-enhanced.h"
5048

5149
#include "tmp-constants.h" // need the extern definitions

src/include/c-enhanced.h

+32-51
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,25 @@
3838
#define C_ENHANCED_H
3939

4040

41-
//=//// EXPECTS <stdint.h> OR "pstdint.h" SHIM INCLUDED ///////////////////=//
42-
//
43-
// Rebol's initial design targeted C89 and old-ish compilers on a variety of
44-
// systems. A comment in that code said:
45-
//
46-
// "One of the biggest flaws in the C language was not
47-
// to indicate bitranges of integers. So, we do that here.
48-
// You cannot 'abstractly remove' the range of a number.
49-
// It is a critical part of its definition."
50-
//
51-
// Once C99 arrived, the file <stdint.h> offered several basic types, and
52-
// basically covered the needs:
53-
//
54-
// http://en.cppreference.com/w/c/types/integer
55-
//
56-
// The code was changed to use either the C99 types -or- a portable shim that
57-
// could mimic the types (with the same names) on older compilers. It should
58-
// be included before %c-enhanced.h is included.
59-
//
60-
//=////////////////////////////////////////////////////////////////////////=//
61-
//
62-
// Note: INT32_MAX and INT32_C can be missing in C++ builds on some older
63-
// compilers without __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS:
64-
//
65-
// https://sourceware.org/bugzilla/show_bug.cgi?id=15366
41+
#if !defined(DEBUG_CHECK_OPTIONALS)
42+
#define DEBUG_CHECK_OPTIONALS 0
43+
#endif
44+
45+
#if !defined(DEBUG_CHECK_NEVERNULL)
46+
#define DEBUG_CHECK_NEVERNULL 0
47+
#endif
48+
49+
50+
// Ren-C assumes the availability of <stdint.h> and <stdbool.h>
6651
//
67-
// You can run into this since pstdint.h falls back on stdint.h if it
68-
// thinks it can. Put those on the command line if needed.
52+
// If for some reason the only barrier to compiling the codebase is lack of
53+
// these definitions, there are shims on the Internet that implement them
54+
// (look for pstdint.h and pstdbool.h) But lack of variadic macros is likely
55+
// to be a bigger showstopper on older platforms.
6956
//
70-
// !!! One aspect of pstdint.h is that it considers 64-bit "optional".
71-
// Some esoteric platforms may have a more hidden form of 64-bit support,
72-
// e.g. this case from R3-Alpha for "Windows VC6 nonstandard typing":
57+
// * One aspect of pstdint.h is that it considers 64-bit "optional".
58+
// Some esoteric platforms may have a more hidden form of 64-bit support,
59+
// e.g. this case from R3-Alpha for "Windows VC6 nonstandard typing":
7360
//
7461
// #if (defined(_MSC_VER) && (_MSC_VER <= 1200))
7562
// typedef _int64 i64;
@@ -78,26 +65,18 @@
7865
// #define U64_C(c) c ## U64
7966
// #endif
8067
//
81-
// If %pstdint.h isn't trying hard enough for an unsupported platform of
82-
// interest to get 64-bit integers, then patches should be made there.
68+
// If %pstdint.h isn't trying hard enough for an unsupported platform of
69+
// interest to get 64-bit integers, then patches should be made there.
8370
//
84-
85-
#if !defined(DEBUG_CHECK_OPTIONALS)
86-
#define DEBUG_CHECK_OPTIONALS 0
87-
#endif
88-
89-
#if !defined(DEBUG_CHECK_NEVERNULL)
90-
#define DEBUG_CHECK_NEVERNULL 0
91-
#endif
92-
93-
94-
//=//// EXPECTS <stdbool.h> OR "pstdbool.h" SHIM INCLUDED /////////////////=//
71+
// * INT32_MAX and INT32_C can be missing in C++ builds on some older
72+
// compilers without __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS:
9573
//
96-
// Historically Rebol used TRUE and FALSE uppercase macros, but so long as
97-
// C99 has added bool to the language, there's not much point in being
98-
// compatible with codebases that have `char* true = "Spandau";` or similar
99-
// in them. So Rebol can use `true` and `false.
74+
// https://sourceware.org/bugzilla/show_bug.cgi?id=15366
10075
//
76+
#include <stdint.h>
77+
#if !defined(__cplusplus)
78+
#include <stdbool.h>
79+
#endif
10180

10281

10382
//=//// EXPECTS <assert.h> TO BE INCLUDED, PATCH BUG //////////////////////=//
@@ -182,10 +161,12 @@
182161

183162
//=//// CPLUSPLUS_11 PREPROCESSOR DEFINE //////////////////////////////////=//
184163
//
185-
// Because the goal of Ren-C is ultimately to be built with C, the C++ build
186-
// is just for static analysis and debug checks. This means there's not much
187-
// value in trying to tailor reduced versions of the checks to old ANSI C++98
188-
// compilers, so the "C++ build" is an "at least C++11 build".
164+
// Because the goal of Ren-C is generally to be buildable as C, the C++ build
165+
// is mostly for static analysis and debug checks. (But also exceptions with
166+
// try/catch, on platforms where setjmp()/longjmp() are not viable.)
167+
//
168+
// There's not much value in trying to tailor reduced versions of the checks
169+
// to ANSI C++98 compilers, so the "C++ build" is an "at least C++11 build".
189170
//
190171
// Besides being a little less verbose to use, testing via a #define allows
191172
// override when using with Microsoft Visual Studio via a command line

src/include/pstdbool.h

-52
This file was deleted.

0 commit comments

Comments
 (0)