1 /* Compiled and run by foreign-stack-alignment.lisp
3 * stack_alignment_offset(int) returns the offset of the first argument from a
4 * given alignment. run (1) from main, to obtain the good value with no
5 * lisp involved (2) from lisp both with and without callbacks to see that
6 * we have not messed the alignment.
8 * trampoline(int(*)()) is here so that we can get callbacks on the
12 /* This software is part of the SBCL system. See the README file for
15 * While most of SBCL is derived from the CMU CL system, the test
16 * files (like this one) were written from scratch after the fork
19 * This software is in the public domain and is provided with
20 * absolutely no warranty. See the COPYING and CREDITS files for
27 /* <nikodemus> bwahahahaaa!
28 * <Xophe> oh dear. He's finally flipped
29 * <lisppaste> nikodemus pasted "stack_alignment_offset" at
30 * http://paste.lisp.org/display/13231
32 * <Xophe> along with a big / * This code is really twisted * / comment :-)
36 stack_alignment_offset (int alignment)
38 return ((unsigned int)&alignment) % alignment;
42 trampoline (int(*callback)(void))
47 int main (int argc, char** argv)
50 printf("wrong number of arguments: %d\n", argc-1);
54 printf("%d\n", stack_alignment_offset(atoi(argv[1])));