File tree Expand file tree Collapse file tree 4 files changed +16
-18
lines changed Expand file tree Collapse file tree 4 files changed +16
-18
lines changed Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff line change 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
2819static  int 
Original file line number Diff line number Diff 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> 
Original file line number Diff line number Diff line change 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> 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments