mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
gh-134486: Fix missing alloca() symbol in _ctypes on NetBSD (#134487)
Previously the module would fail to load because the `alloca()` symbol was undefined. Now we check for GCC/Clang builtins for systems who do not define `alloca()` in headers.
This commit is contained in:
parent
99a9ab1c64
commit
b8f55266bf
4 changed files with 16 additions and 18 deletions
|
|
@ -0,0 +1,3 @@
|
|||
The :mod:`ctypes` module now performs a more portable test for the
|
||||
definition of :manpage:`alloca(3)`, fixing a compilation failure on
|
||||
NetBSD.
|
||||
|
|
@ -11,18 +11,9 @@
|
|||
#include "pycore_call.h" // _PyObject_CallNoArgs()
|
||||
#include "pycore_runtime.h" // _Py_ID()
|
||||
|
||||
#ifdef MS_WIN32
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include <ffi.h>
|
||||
#include "ctypes.h"
|
||||
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
/* AIX needs alloca.h for alloca() */
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -77,16 +77,8 @@ module _ctypes
|
|||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
#ifdef MS_WIN32
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include <ffi.h>
|
||||
#include "ctypes.h"
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
/* AIX needs alloca.h for alloca() */
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
#ifdef _Py_MEMORY_SANITIZER
|
||||
#include <sanitizer/msan_interface.h>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
#if defined (__SVR4) && defined (__sun)
|
||||
/* Get a definition of alloca(). */
|
||||
#if (defined (__SVR4) && defined (__sun)) || defined(HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
#elif defined(MS_WIN32)
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
|
||||
/* If the system does not define alloca(), we have to hope for a compiler builtin. */
|
||||
#ifndef alloca
|
||||
# if defined __GNUC__ || (__clang_major__ >= 4)
|
||||
# define alloca __builtin_alloca
|
||||
# else
|
||||
# error "Could not define alloca() on your platform."
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue