The current AC_FUNC_ALLOCA description is:

 -- Macro: AC_FUNC_ALLOCA
     Check how to get 'alloca'.  Tries to get a builtin version by
     checking for 'alloca.h' or the predefined C preprocessor macros
     '__GNUC__' and '_AIX'.  If this macro finds 'alloca.h', it defines
     'HAVE_ALLOCA_H'.

     If those attempts fail, it looks for the function in the standard C
     library.  If any of those methods succeed, it defines
     'HAVE_ALLOCA'.  Otherwise, it sets the output variable 'ALLOCA' to
     '${LIBOBJDIR}alloca.o' and defines 'C_ALLOCA' (so programs can
     periodically call 'alloca (0)' to garbage collect).  This variable
     is separate from 'LIBOBJS' so multiple programs can share the value
     of 'ALLOCA' without needing to create an actual library, in case
     only some of them use the code in 'LIBOBJS'.  The '${LIBOBJDIR}'
     prefix serves the same purpose as in 'LIBOBJS' (*note AC_LIBOBJ vs
     LIBOBJS::).

     This macro does not try to get 'alloca' from the System V R3
     'libPW' or the System V R4 'libucb' because those libraries contain
     some incompatible functions that cause trouble.  Some versions do
     not even contain 'alloca' or contain a buggy version.  If you still
     want to use their 'alloca', use 'ar' to extract 'alloca.o' from
     them instead of compiling 'alloca.c'.

     Source files that use 'alloca' should start with a piece of code
     like the following, to declare it properly.

          #ifdef STDC_HEADERS
          # include <stdlib.h>
          # include <stddef.h>
          #else
          # ifdef HAVE_STDLIB_H
          #  include <stdlib.h>
          # endif
          #endif
          #ifdef HAVE_ALLOCA_H
          # include <alloca.h>
          #elif !defined alloca
          # ifdef __GNUC__
          #  define alloca __builtin_alloca
          # elif defined _AIX
          #  define alloca __alloca
          # elif defined _MSC_VER
          #  include <malloc.h>
          #  define alloca _alloca
          # elif !defined HAVE_ALLOCA
          #  ifdef  __cplusplus
          extern "C"
          #  endif
          void *alloca (size_t);
          # endif
          #endif

The conditions under which 'HAVE_ALLOCA' is defined are not clear.

In particular, the line

          # elif !defined HAVE_ALLOCA

seems surprising. I would have thought that it should have been

          # elif defined HAVE_ALLOCA

(i.e. the function exists, but <alloca.h> is not there to declare
it, so that the code needs to do the declaration). If alloca() is
completely missing, one should not use it, so that declaring it
may not be a good idea. If this is for the case where the user
compiles alloca.c, then this should be handled in a separate case.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Reply via email to