Skip to content

Commit b556f53

Browse files
authored
bpo-46670: Test if a macro is defined, not its value (GH-31178)
* audioop.c: #ifdef WORDS_BIGENDIAN * ctypes.h: #ifdef USING_MALLOC_CLOSURE_DOT_C * _ctypes/malloc_closure.c: #ifdef HAVE_FFI_CLOSURE_ALLOC and #ifdef USING_APPLE_OS_LIBFFI * pytime.c: #ifdef __APPLE__ * unicodeobject.c: #ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
1 parent 097f74a commit b556f53

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

Modules/_ctypes/callbacks.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
418418
goto error;
419419
}
420420
#if HAVE_FFI_PREP_CLOSURE_LOC
421-
# if USING_APPLE_OS_LIBFFI
421+
# ifdef USING_APPLE_OS_LIBFFI
422422
# define HAVE_FFI_PREP_CLOSURE_LOC_RUNTIME __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)
423423
# else
424424
# define HAVE_FFI_PREP_CLOSURE_LOC_RUNTIME 1
@@ -430,7 +430,7 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
430430
} else
431431
#endif
432432
{
433-
#if USING_APPLE_OS_LIBFFI && defined(__arm64__)
433+
#if defined(USING_APPLE_OS_LIBFFI) && defined(__arm64__)
434434
PyErr_Format(PyExc_NotImplementedError, "ffi_prep_closure_loc() is missing");
435435
goto error;
436436
#else

Modules/_ctypes/callproc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ static int _call_function_pointer(int flags,
826826
cc = FFI_STDCALL;
827827
#endif
828828

829-
# if USING_APPLE_OS_LIBFFI
829+
# ifdef USING_APPLE_OS_LIBFFI
830830
# define HAVE_FFI_PREP_CIF_VAR_RUNTIME __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)
831831
# elif HAVE_FFI_PREP_CIF_VAR
832832
# define HAVE_FFI_PREP_CIF_VAR_RUNTIME true

Modules/_ctypes/ctypes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ PyObject *_ctypes_get_errobj(int **pspace);
362362
extern PyObject *ComError;
363363
#endif
364364

365-
#if USING_MALLOC_CLOSURE_DOT_C
365+
#ifdef USING_MALLOC_CLOSURE_DOT_C
366366
void Py_ffi_closure_free(void *p);
367367
void *Py_ffi_closure_alloc(size_t size, void** codeloc);
368368
#else

Modules/_ctypes/malloc_closure.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ static void more_core(void)
9191
/* put the item back into the free list */
9292
void Py_ffi_closure_free(void *p)
9393
{
94-
#if HAVE_FFI_CLOSURE_ALLOC
95-
#if USING_APPLE_OS_LIBFFI
94+
#ifdef HAVE_FFI_CLOSURE_ALLOC
95+
#ifdef USING_APPLE_OS_LIBFFI
9696
if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
9797
#endif
9898
ffi_closure_free(p);
9999
return;
100-
#if USING_APPLE_OS_LIBFFI
100+
#ifdef USING_APPLE_OS_LIBFFI
101101
}
102102
#endif
103103
#endif
@@ -109,12 +109,12 @@ void Py_ffi_closure_free(void *p)
109109
/* return one item from the free list, allocating more if needed */
110110
void *Py_ffi_closure_alloc(size_t size, void** codeloc)
111111
{
112-
#if HAVE_FFI_CLOSURE_ALLOC
113-
#if USING_APPLE_OS_LIBFFI
112+
#ifdef HAVE_FFI_CLOSURE_ALLOC
113+
#ifdef USING_APPLE_OS_LIBFFI
114114
if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
115115
#endif
116116
return ffi_closure_alloc(size, codeloc);
117-
#if USING_APPLE_OS_LIBFFI
117+
#ifdef USING_APPLE_OS_LIBFFI
118118
}
119119
#endif
120120
#endif

Modules/audioop.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static const int stepsizeTable[89] = {
297297
#define GETINT16(cp, i) GETINTX(int16_t, (cp), (i))
298298
#define GETINT32(cp, i) GETINTX(int32_t, (cp), (i))
299299

300-
#if WORDS_BIGENDIAN
300+
#ifdef WORDS_BIGENDIAN
301301
#define GETINT24(cp, i) ( \
302302
((unsigned char *)(cp) + (i))[2] + \
303303
(((unsigned char *)(cp) + (i))[1] << 8) + \
@@ -314,7 +314,7 @@ static const int stepsizeTable[89] = {
314314
#define SETINT16(cp, i, val) SETINTX(int16_t, (cp), (i), (val))
315315
#define SETINT32(cp, i, val) SETINTX(int32_t, (cp), (i), (val))
316316

317-
#if WORDS_BIGENDIAN
317+
#ifdef WORDS_BIGENDIAN
318318
#define SETINT24(cp, i, val) do { \
319319
((unsigned char *)(cp) + (i))[2] = (int)(val); \
320320
((unsigned char *)(cp) + (i))[1] = (int)(val) >> 8; \

Objects/unicodeobject.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6161
#endif
6262

6363
#ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
64-
#include "pycore_fileutils.h" // _Py_LocaleUsesNonUnicodeWchar()
64+
# include "pycore_fileutils.h" // _Py_LocaleUsesNonUnicodeWchar()
6565
#endif
6666

6767
/* Uncomment to display statistics on interned strings at exit
@@ -3344,7 +3344,7 @@ PyUnicode_AsWideChar(PyObject *unicode,
33443344
}
33453345
unicode_copy_as_widechar(unicode, w, size);
33463346

3347-
#if HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
3347+
#ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
33483348
/* Oracle Solaris uses non-Unicode internal wchar_t form for
33493349
non-Unicode locales and hence needs conversion first. */
33503350
if (_Py_LocaleUsesNonUnicodeWchar()) {
@@ -3381,7 +3381,7 @@ PyUnicode_AsWideCharString(PyObject *unicode,
33813381
}
33823382
unicode_copy_as_widechar(unicode, buffer, buflen + 1);
33833383

3384-
#if HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
3384+
#ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
33853385
/* Oracle Solaris uses non-Unicode internal wchar_t form for
33863386
non-Unicode locales and hence needs conversion first. */
33873387
if (_Py_LocaleUsesNonUnicodeWchar()) {

Python/pytime.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ _PyTime_GetSystemClockWithInfo(_PyTime_t *t, _Py_clock_info_t *info)
962962
}
963963

964964

965-
#if __APPLE__
965+
#ifdef __APPLE__
966966
static int
967967
py_mach_timebase_info(_PyTime_t *pnumer, _PyTime_t *pdenom, int raise)
968968
{

0 commit comments

Comments
 (0)