From 855fc53709e1ecd78f548f5a3909b847d63b159e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 9 Jul 2003 06:28:09 +0000 Subject: [PATCH] handle alloca properly --- configure.ac | 36 +++++++++++++++++++++++++ libs/audio/renderer/snd_mem.c | 4 --- libs/util/pakfile.c | 40 +++++++++++++++++++++++++--- libs/util/quakefs.c | 4 --- libs/util/riff.c | 4 --- libs/video/renderer/gl/gl_sky_clip.c | 4 --- libs/video/targets/old_keys.c | 4 --- 7 files changed, 72 insertions(+), 24 deletions(-) diff --git a/configure.ac b/configure.ac index f5e4e17c0..a36e95cd8 100644 --- a/configure.ac +++ b/configure.ac @@ -260,6 +260,41 @@ AC_TRY_LINK( ) AM_CONDITIONAL(BUILD_FNMATCH, test "$BUILD_FNMATCH" = "yes") +AC_MSG_CHECKING(for alloca in stdlib.h) +AC_TRY_COMPILE( + [#include ], + [void *(*foo)(size_t) = alloca;], + have_alloca_proto=yes + AC_MSG_RESULT(yes), + have_alloca_proto=no + AC_MSG_RESULT(no) +) + +if test "$have_alloca_proto" = no -a "$ac_cv_header_alloca_h" = yes; then + AC_MSG_CHECKING(for alloca in alloca.h) + AC_TRY_COMPILE( + [#include ] + [#include ], + [void *(*foo)(size_t) = alloca;], + have_alloca_proto=yes + AC_MSG_RESULT(yes), + have_alloca_proto=no + AC_MSG_RESULT(no) + ) +fi + +if test "$have_alloca_proto" = yes; then + AC_DEFINE(HAVE_ALLOCA_PROTO) +fi +AH_VERBATIM([HAVE_ALLOCA_PROTO], +[/* Define this if alloca is prototyped */ +#undef HAVE_ALLOCA_PROTO +#ifndef HAVE_ALLOCA_PROTO +#ifndef QFASM +void *alloca (int size); +#endif +#endif]) + AC_MSG_CHECKING(for fnmatch in fnmatch.h) AC_TRY_COMPILE( [#include "fnmatch.h"], @@ -1438,6 +1473,7 @@ else plugin_ldflags= plugin_libadd= fi +ASFLAGS="$ASFLAGS -DQFASM" CCASFLAGS="$ASFLAGS" CCAS="$AS" AC_SUBST(AS) diff --git a/libs/audio/renderer/snd_mem.c b/libs/audio/renderer/snd_mem.c index b19a2a3d9..03587e46b 100644 --- a/libs/audio/renderer/snd_mem.c +++ b/libs/audio/renderer/snd_mem.c @@ -48,10 +48,6 @@ static __attribute__ ((unused)) const char rcsid[] = #include "compat.h" #include "snd_render.h" -#ifdef _WIN32 -void *alloca(size_t size); -#endif - #define SAMPLE_GAP 4 typedef struct { diff --git a/libs/util/pakfile.c b/libs/util/pakfile.c index a0e3a035d..22e01c5e0 100644 --- a/libs/util/pakfile.c +++ b/libs/util/pakfile.c @@ -1,3 +1,39 @@ +/* + packfile.c + + pak file support + + Copyright (C) 2003 #AUTHOR# + + Author: #AUTHOR# + Date: #DATE# + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + +*/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +static __attribute__ ((unused)) const char rcsid[] = + "$Id$"; + #include #include #include @@ -11,10 +47,6 @@ #include "QF/pakfile.h" #include "QF/qendian.h" -#ifdef _WIN32 -void *alloca(size_t size); -#endif - static const char * pack_get_key (void *p, void *unused) { diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index 3dd100211..0c02e57b6 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -95,10 +95,6 @@ static __attribute__ ((unused)) const char rcsid[] = int fnmatch (const char *__pattern, const char *__string, int __flags); #endif -#ifdef _WIN32 -void *alloca(size_t size); -#endif - /* All of Quake's data access is through a hierchical file system, but the contents of the file system can be transparently merged from several diff --git a/libs/util/riff.c b/libs/util/riff.c index 57d949915..a68722b07 100644 --- a/libs/util/riff.c +++ b/libs/util/riff.c @@ -43,10 +43,6 @@ static __attribute__ ((unused)) const char rcsid[] = #include #include -#ifdef _WIN32 -void *alloca(size_t size); -#endif - #include "QF/dstring.h" #include "QF/qendian.h" #include "QF/riff.h" diff --git a/libs/video/renderer/gl/gl_sky_clip.c b/libs/video/renderer/gl/gl_sky_clip.c index 5fd3902a3..99aa9b555 100644 --- a/libs/video/renderer/gl/gl_sky_clip.c +++ b/libs/video/renderer/gl/gl_sky_clip.c @@ -59,10 +59,6 @@ static __attribute__ ((unused)) const char rcsid[] = #include "compat.h" -#ifdef _WIN32 -void *alloca(size_t size); -#endif - #define BOX_WIDTH 2056 /* cube face to sky texture offset conversion */ diff --git a/libs/video/targets/old_keys.c b/libs/video/targets/old_keys.c index 131998213..6c160e94c 100644 --- a/libs/video/targets/old_keys.c +++ b/libs/video/targets/old_keys.c @@ -44,10 +44,6 @@ static __attribute__ ((unused)) const char rcsid[] = # include #endif -#ifdef _WIN32 -void *alloca(size_t size); -#endif - #include #include