[PD-dev] pd-0.43.0 port to NetBSD

Thomas Klausner tk at giga.or.at
Sat Sep 17 01:22:21 CEST 2011


Hi Miller,

> I can't evaluate the changes here that have to do with the build system
> but can work on getting rid of alloca dependencies.  I didn't know there
> were any platforms left that didn't support alloca.  (In fact I was celebrating
> that I would be able to replace more malloc calls with alloca to simplify
> things here and there.)

Thanks for the reply.

The problem is not that alloca() is not supported, it's just that the
alloca.h header is not available on all systems.

Gnulib documents it as:
Portability problems fixed by Gnulib:

    This header file is missing on some platforms: FreeBSD 6.0, NetBSD
    5.0, OpenBSD 3.8, AIX 4.3.2, mingw. 

http://www.gnu.org/software/hello/manual/gnulib/alloca_002eh.html

The ubuntu man page says:

	BUGS

        The  alloca() function is machine and compiler dependent.  On
	many systems its implementation is buggy.  Its use is discouraged.
 
The Mac OS X man page claims similarly.
The NetBSD man page says:

CAVEATS
     Few limitations can be mentioned:

     o   The alloca() function is machine dependent; its use is discouraged.

     o   The alloca() function is slightly unsafe because it cannot ensure
         that the pointer returned points to a valid and usable block of mem-
         ory.  The allocation made may exceed the bounds of the stack, or even
         go further into other objects in memory, and alloca() cannot deter-
         mine such an error.  Avoid alloca() with large unbounded allocations.

     o   Since alloca() modifies the stack at runtime, it causes problems to
         certain security features.  See security(7) for a discussion.

On NetBSD, alloca() is provided by stdlib.h.

Perhaps the easiest way is to let configure check for alloca.h and
stdlib.h and include one or the other, depending on what's available
on the system. Would you like diffs for that?
 Thomas



More information about the Pd-dev mailing list