atexit: clean up all the atexit code and fix the improper casts
authorAlan Cox <alan@linux.intel.com>
Wed, 21 Jan 2015 20:24:27 +0000 (20:24 +0000)
committerAlan Cox <alan@linux.intel.com>
Wed, 21 Jan 2015 20:24:27 +0000 (20:24 +0000)
commit875b6aeaa1d26ca8f3bf28ecec3e1fed43c0b756
tree884784760f6f12fdc464aef62520aae07d3e7456
parent8dde53734dfbfbc25fbaa9e54635aed9b17e3101
atexit: clean up all the atexit code and fix the improper casts

Turns out atexit isn't a cc65 bug rather an interesting property of the
compiler.

cc65 requires the called function to unstack the arguments so that it can
fold together the argument popping and local recovery. This means that
calling a function declared as foo(void) cast as foo(int) doesn't work and
trashes your local variables.

A new to me and excitingly novel way of shooting yourself in the boot, but
perfectly valid compiler behaviour.
Library/include/stdlib.h
Library/libs/atexit.c
Library/libs/stdio0.c