|
|
1.1 ! root 1: /* GNU Objective C Runtime forward tests program ! 2: Copyright (C) 1993 Free Software Foundation, Inc. ! 3: ! 4: Author: Kresten Krab Thorup ! 5: ! 6: This file is part of GNU CC. ! 7: ! 8: GNU CC is free software; you can redistribute it and/or modify it under the ! 9: terms of the GNU General Public License as published by the Free Software ! 10: Foundation; either version 2, or (at your option) any later version. ! 11: ! 12: GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY ! 13: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! 14: FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ! 15: details. ! 16: ! 17: You should have received a copy of the GNU General Public License along with ! 18: GNU CC; see the file COPYING. If not, write to the Free Software ! 19: Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ! 20: ! 21: ! 22: #include <stdio.h> ! 23: #include "gstddef.h" ! 24: ! 25: static char* flags = ""; ! 26: ! 27: void try_func (a, b) ! 28: size_t a; ! 29: size_t b; ! 30: { ! 31: if ((a==5432) && (b==12)) ! 32: printf(flags); ! 33: exit (0); ! 34: } ! 35: ! 36: void do_apply (xx, y) ! 37: void* xx; ! 38: size_t y; ! 39: { ! 40: __builtin_apply((void*)try_func, xx, 200) ; ! 41: } ! 42: ! 43: #define try(what) \ ! 44: what[0] = 5432; \ ! 45: what[1] = 12; \ ! 46: do_apply(af, 1234) ! 47: ! 48: void test_apply (a, b) ! 49: size_t a; ! 50: size_t b; ! 51: { ! 52: union frame { ! 53: struct { size_t* args; } a; ! 54: struct { size_t* args; size_t regs[2]; } b; ! 55: struct { size_t* args; void* struct_return; size_t regs[2]; } c; ! 56: } *af; ! 57: af = __builtin_apply_args(); ! 58: if ((af->b.regs[0] == 2345) && (af->b.regs[1] == 6789)) ! 59: { flags=" -DREG_ARGS\n"; try (af->b.regs); } ! 60: if ((af->c.regs[0] == 2345) && (af->c.regs[1] == 6789)) ! 61: { flags=" -DREG_ARGS -DSTRUCT_RETURN\n"; try (af->c.regs); } ! 62: if ((af->a.args[0] == 2345) && (af->a.args[1] == 6789)) ! 63: { flags=" -DSTACK_ARGS\n"; try (af->a.args); } ! 64: exit (0); ! 65: } ! 66: ! 67: void main () ! 68: { ! 69: test_apply (2345, 6789); ! 70: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.