classification
Title: func alloca inside ctypes lib needs #include on solaris
Type: compile error Stage:
Components: Extension Modules Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: theller Nosy List: gregcouch, jafo, mthibaut, theller
Priority: normal Keywords: patch

Created on 2007-11-27 21:15 by mthibaut, last changed 2008-03-18 15:04 by theller. This issue is now closed.

Messages (8)
msg57887 - (view) Author: Maarten Thibaut (mthibaut) Date: 2007-11-27 21:19
On Solaris, alloca() is a #define which is inside <alloca.h>. 

Ctypes fails to compile because the #define is missing. Please fix by
adding the following at the front of these 2 files:

#if defined (__SVR4) && defined (__sun)
#   include <alloca.h>
#endif
msg57897 - (view) Author: Maarten Thibaut (mthibaut) Date: 2007-11-27 23:27
forgot to mention the files:

Modules/_ctypes/callproc.c
Modules/_ctypes/libffi/src/sparc/ffi.c
msg57918 - (view) Author: Greg Couch (gregcouch) Date: 2007-11-28 18:18
A better solution would be to use the HAVE_ALLOCA and HAVE_ALLOCA_H
defines that fficonfig.h provides to decide whether or not to include
alloca.h.  And in callproc.c whether or not to provide a workaround
using malloc (I'm assuming non-gcc sparc compilers also support alloca
for sparc/ffi.c, but I don't know for sure).
msg57922 - (view) Author: Greg Couch (gregcouch) Date: 2007-11-28 23:42
Turns out callproc.c forgot to include <ffi_common.h> after <ffi.h>
which conditionally includes alloca.h.  So it's a one-line fix.
msg57946 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2007-11-29 18:48
> Greg Couch added the comment:
> 
> Turns out callproc.c forgot to include <ffi_common.h> after <ffi.h>
> which conditionally includes alloca.h.  So it's a one-line fix.
> 

This would not work.  <ffi_common.h> is a file private to libffi;
when Python is configured to use the system ffi-library (--with-systemffi)
this file is not available.

I would tend to replace the three alloca() calls in the function
_CallProc() in callbacks.c with calls to malloc().  All the other
occurrences of alloca() are only compiled on windows.
msg57950 - (view) Author: Greg Couch (gregcouch) Date: 2007-11-29 19:31
That's a disappointment.  <ffi_common.h> has the right logic in it
already.  Perhaps it should be copied to callproc.c.  I'm less concerned
about alloca not being there at all because it seems to be a pervasive
extension in non-gcc compilers, but using malloc is fine too.  Please go
ahead and fix this as you see fit.  I've started issue 1516 about using
non-gcc compilers to compile _ctypes/libffi.
msg63813 - (view) Author: Sean Reifschneider (jafo) * (Python committer) Date: 2008-03-18 00:12
Fix is inline.
msg63919 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2008-03-18 15:04
I applied the patch to SVN trunk as rev 61520.  It would probably be
better to have a configure test for alloca.h.
History
Date User Action Args
2008-03-18 15:04:32thellersetstatus: open -> closed
resolution: fixed
messages: + msg63919
2008-03-18 00:12:44jafosetkeywords: + patch
nosy: + jafo
messages: + msg63813
2007-11-29 19:31:47gregcouchsetmessages: + msg57950
2007-11-29 18:48:18thellersetmessages: + msg57946
2007-11-28 23:42:01gregcouchsetmessages: + msg57922
2007-11-28 18:18:32gregcouchsetnosy: + gregcouch
messages: + msg57918
2007-11-27 23:27:34mthibautsetmessages: + msg57897
2007-11-27 22:22:57gvanrossumsetassignee: theller
nosy: + theller
2007-11-27 21:19:51mthibautsetcomponents: + Extension Modules, - Library (Lib)
2007-11-27 21:19:39mthibautsetmessages: + msg57887
2007-11-27 21:15:13mthibautcreate