Issue 1506: func alloca inside ctypes lib needs #include <alloca.h> on solaris (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/45847

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 2022-04-11 14:56 by admin. 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
2022-04-11 14:56:28 admin set github: 45847
2008-03-18 15:04:32 theller set status: open -> closedresolution: fixedmessages: +
2008-03-18 00:12:44 jafo set keywords: + patchnosy: + jafomessages: +
2007-11-29 19:31:47 gregcouch set messages: +
2007-11-29 18:48:18 theller set messages: +
2007-11-28 23:42:01 gregcouch set messages: +
2007-11-28 18🔞32 gregcouch set nosy: + gregcouchmessages: +
2007-11-27 23:27:34 mthibaut set messages: +
2007-11-27 22:22:57 gvanrossum set assignee: thellernosy: + theller
2007-11-27 21:19:51 mthibaut set components: + Extension Modules, - Library (Lib)
2007-11-27 21:19:39 mthibaut set messages: +
2007-11-27 21:15:13 mthibaut create