Movatterモバイル変換
[0]ホーム
[Python-Dev] [win32] Killing MSVC's _alloca
Gerhard Haeringhaering_python@gmx.de
Fri, 4 Oct 2002 22:23:48 +0200
* Guido van Rossum <guido@python.org> [2002-10-04 15:40 -0400]:> > Trying to get around to my mingw32 port again. I currently don't> > have Visual C++ installed, but why is this nonstandard _alloca> > needed? Can't it simply be replaced by alloca? Doesn't MSVC have> > alloca?>> It seems that it does. But I guess _alloca is more politically> correct, since alloca is not standard C.I don't see how this applies, as neither form is standard C, but in practise,alloca is supported by all compilers I use, be it Windows or Linux. And I don'tcare about P. C. ;-)> > For the moment, I'm as far as building posixmodule.c, which I> > succeeded by doing a> >> > #define _alloca alloca> >> > If there's a way to kill MSVC peculiarities, could this please be done?>> I'd be happy to do a global subst of _alloca -> alloca.>> Mark, do you see any reason why this might *not* work?>> Could it break other compilers?No, as it's only used in platform-specific code as seen below:$ find . -name *.[ch]|xargs grep -w _alloca./Modules/posixmodule.c:s1 = (char *)_alloca(i);./Modules/posixmodule.c:s2 = (char *)_alloca(x);./Modules/posixmodule.c:s2 = (char *)_alloca(x);./Python/pythonrun.c:/* _alloca throws a stack overflow exception if there's./Python/pythonrun.c:_alloca(PYOS_STACK_MARGIN * sizeof(void*));$ find . -name *.[ch]|xargs grep -w alloca./Modules/mpzmodule.c:** alloca with arg < 0 (when casted to a signed./PC/_winreg.c:#include "malloc.h" /* for alloca */./PC/_winreg.c:retBuf = (char *)alloca(len);./PC/_winreg.c:retValueBuf = (char *)alloca(retValueSize);./PC/_winreg.c:retDataBuf = (char *)alloca(retDataSize);./PC/_winreg.c:retBuf = (char *)alloca(bufSize);./PC/_winreg.c:retBuf = (char *)alloca(bufSize);./PC/import_nt.c:#include "malloc.h" /* for alloca */./PC/import_nt.c:/* alloca == no free required, but memory only local to fn,./PC/import_nt.c:moduleKey = alloca(bufSize); ./PC/os2vacpp/getpathp.c:#include "malloc.h" // for alloca - see comments below!./PC/os2vacpp/getpathp.c:// alloca == no free required, but memory only local to fn../PC/os2vacpp/getpathp.c:keyBuf = alloca(sizeof(keyPrefix)-1 + versionLen + sizeof(keySuffix)); // chars only, plus 1 NULL.So, alloca and _alloca are only used in platform specific Windows and OS/2code. The MSVC specific code is a little inconsistent, it uses both _alloca andalloca forms depending on the source file.> A conservative approach would be to add #ifdef CYGWIN around the> #define you propose.Not even more #ifdefs, please. I'd suggest the global replace _alloca ->alloca.-- Gerhard
[8]ページ先頭