|
39 | 39 | #define OIIO_HARDENING_DEBUG 3 |
40 | 40 |
|
41 | 41 | // OIIO_HARDENING_DEFAULT defines the default hardening level we actually use. |
42 | | -// By default, we use NONE for release builds and DEBUG for debug builds. But |
43 | | -// any translation unit (including clients of OIIO) may override this by |
44 | | -// defining OIIO_HARDENING_DEFAULT before including any OIIO headers. But note |
45 | | -// that this only affects calls to inline functions or templates defined in |
46 | | -// the headers. Non-inline functions compiled into the OIIO library, including |
47 | | -// OIIO internal code itself, will have been compiled with whatever hardening |
48 | | -// level was selected when the library was built. |
| 42 | +// By default, we use FAST for release builds and DEBUG for debug builds. But |
| 43 | +// it can be overridden: |
| 44 | +// - For OIIO internals, at OIIO build time with the `OIIO_HARDENING` CMake |
| 45 | +// variable. |
| 46 | +// - For other projects using OIIO's headers, any translation unit may |
| 47 | +// override this by defining OIIO_HARDENING_DEFAULT before including any |
| 48 | +// OIIO headers. But note that this only affects calls to inline functions |
| 49 | +// or templates defined in the headers. Non-inline functions compiled into |
| 50 | +// the OIIO library itself will have been compiled with whatever hardening |
| 51 | +// level was selected when the library was built. |
49 | 52 | #ifndef OIIO_HARDENING_DEFAULT |
50 | 53 | # ifdef NDEBUG |
51 | | -# define OIIO_HARDENING_DEFAULT OIIO_HARDENING_NONE |
| 54 | +# define OIIO_HARDENING_DEFAULT OIIO_HARDENING_FAST |
52 | 55 | # else |
53 | 56 | # define OIIO_HARDENING_DEFAULT OIIO_HARDENING_DEBUG |
54 | 57 | # endif |
55 | 58 | #endif |
56 | 59 |
|
57 | 60 |
|
58 | | -/// Choices for what to do when a contract assertion fails. |
59 | | -/// This mimics the C++26 standard's std::contract behavior. |
| 61 | +// Choices for what to do when a contract assertion fails. |
| 62 | +// This mimics the C++26 standard's std::contract behavior. |
60 | 63 | #define OIIO_ASSERTION_RESPONSE_IGNORE 0 |
61 | 64 | #define OIIO_ASSERTION_RESPONSE_OBSERVE 1 |
62 | 65 | #define OIIO_ASSERTION_RESPONSE_ENFORCE 2 |
63 | 66 | #define OIIO_ASSERTION_RESPONSE_QUICK_ENFORCE 3 |
64 | 67 |
|
65 | 68 | // OIIO_ASSERTION_RESPONSE_DEFAULT defines the default response to failed |
66 | | -// contract assertions. By default, in NONE hardening mode and in release |
67 | | -// builds, we do nothing. In all other cases, we abort. But any translation |
| 69 | +// contract assertions. By default, we enforce them, UNLESS we are a release |
| 70 | +// mode build that has set the hardening mode to NONE. But any translation |
68 | 71 | // unit (including clients of OIIO) may override this by defining |
69 | 72 | // OIIO_ASSERTION_RESPONSE_DEFAULT before including any OIIO headers. But note |
70 | 73 | // that this only affects calls to inline functions or templates defined in |
71 | | -// the headers. Non-inline functions compiled into the OIIO library, including |
72 | | -// OIIO internal code itself, will have been compiled with whatever response |
73 | | -// was selected when the library was built. |
| 74 | +// the headers. Non-inline functions compiled into the OIIO library itself |
| 75 | +// will have been compiled with whatever response was selected when the |
| 76 | +// library was built. |
74 | 77 | #ifndef OIIO_ASSERTION_RESPONSE_DEFAULT |
75 | 78 | # if OIIO_HARDENING_DEFAULT == OIIO_HARDENING_NONE && defined(NDEBUG) |
76 | | -# define OIIO_ASSERTION_RESPONSE_DEFAULT OIIO_ASSERTION_RESPONSE_ENFORCE |
| 79 | +# define OIIO_ASSERTION_RESPONSE_DEFAULT OIIO_ASSERTION_RESPONSE_IGNORE |
77 | 80 | # else |
78 | 81 | # define OIIO_ASSERTION_RESPONSE_DEFAULT OIIO_ASSERTION_RESPONSE_ENFORCE |
79 | 82 | # endif |
|
0 commit comments