[net.lang.c] C startup in /lib/crt0.o

dan@bbn-prophet.arpa (Dan Franklin) (04/28/86)

I don't know why P1003.1 might object to onexit(), but I always
thought it was a bit bizarre that it could not be declared correctly
in C.  It requires a recursive typedef

	typedef onexit_t onexit_t(onexit_t);

which would, if it worked, define "onexit_t" to be a function whose
sole argument, and return value, were of type "onexit_t".  (The usage
is that a caller supplies it with a function to be invoked on exit, and
gets back some other function that the caller must arrange to be invoked
on exit.)

Even more odd is that the purpose of this unusual calling sequence is to
permit a program to cascade an indefinite number of functions to be
performed before exiting, but X3J11 still specifies that the
implementation must support the registration of at least 32 functions
(April 1985 draft, but I bet this hasn't changed).  If the number of
functions can be finite and small, then obviously you can define onexit()
to take one argument which is a function to call; no funny return value,
no additional arrangements to be made by the caller.  The routine would
just keep a static array of functions to call.  And it could be declared
in C.  The additional benefit to be gained by the current "generalization"
to any number of functions seems marginal to me.

	Dan Franklin