Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 93f6e60

Browse filesBrowse files
committed
gh-134486: Fix missing alloca symbol in _ctypes on NetBSD.
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.
1 parent 979d81a commit 93f6e60
Copy full SHA for 93f6e60

File tree

4 files changed

+16
-18
lines changed
Filter options

4 files changed

+16
-18
lines changed
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The :mod:`ctypes` module now performs a more portable test for the
2+
definition of :manpage:`alloca(3)`, fixing a compilation failure on
3+
NetBSD.

‎Modules/_ctypes/callbacks.c

Copy file name to clipboardExpand all lines: Modules/_ctypes/callbacks.c
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,9 @@
1111
#include "pycore_call.h" // _PyObject_CallNoArgs()
1212
#include "pycore_runtime.h" // _Py_ID()
1313

14-
#ifdef MS_WIN32
15-
# include <malloc.h>
16-
#endif
17-
1814
#include <ffi.h>
1915
#include "ctypes.h"
2016

21-
#ifdef HAVE_ALLOCA_H
22-
/* AIX needs alloca.h for alloca() */
23-
#include <alloca.h>
24-
#endif
25-
2617
/**************************************************************/
2718

2819
static int

‎Modules/_ctypes/callproc.c

Copy file name to clipboardExpand all lines: Modules/_ctypes/callproc.c
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,8 @@ module _ctypes
7777
#include <mach-o/dyld.h>
7878
#endif
7979

80-
#ifdef MS_WIN32
81-
#include <malloc.h>
82-
#endif
83-
8480
#include <ffi.h>
8581
#include "ctypes.h"
86-
#ifdef HAVE_ALLOCA_H
87-
/* AIX needs alloca.h for alloca() */
88-
#include <alloca.h>
89-
#endif
9082

9183
#ifdef _Py_MEMORY_SANITIZER
9284
#include <sanitizer/msan_interface.h>

‎Modules/_ctypes/ctypes.h

Copy file name to clipboardExpand all lines: Modules/_ctypes/ctypes.h
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
#if defined (__SVR4) && defined (__sun)
1+
/* Get a definition of alloca(). */
2+
#if (defined (__SVR4) && defined (__sun)) || defined(HAVE_ALLOCA_H)
23
# include <alloca.h>
4+
#elif defined(MS_WIN32)
5+
# include <malloc.h>
6+
#endif
7+
8+
/* If the system does not define alloca(), we have to hope for a compiler builtin. */
9+
#ifndef alloca
10+
# if defined __GNUC__ || (__clang_major__ >= 4)
11+
# define alloca __builtin_alloca
12+
# else
13+
# error "Could not define alloca() on your platform."
14+
# endif
315
#endif
416

517
#include <stdbool.h>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.