]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/testjump.c
xnu-792.6.76.tar.gz
[apple/xnu.git] / osfmk / ppc / testjump.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
37839358
A
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
1c79356b 11 *
37839358
A
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
37839358
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * @OSF_FREE_COPYRIGHT@
24 */
25
26#define VERBOSE 0
27
28#include <ppc/setjmp.h>
29
30int recursed(jmp_buf_t *bufp, int retval, int depth)
31{
32 int mumbojumbo[16];
33 int i;
34
35#if VERBOSE
36 for (i=0;i<depth;i++)
37 printf(" ");
38 printf("in recursed(0x%x,%d,%d)\n",bufp,retval,depth);
39#endif
40 if (depth == 0) {
41#if VERBOSE
42 printf("LONGJUMPING from depth %d to buffer at 0x%x!\n",retval, bufp);
43#endif
44 _longjmp(bufp, retval);
45 printf("SHOULDN'T GET HERE\n");
46 } else {
47 recursed(bufp,retval,depth-1);
48 }
49 return mumbojumbo[15]=-1; /* make sure we generate our own frame */
50}
51
52int testjump()
53{
54 jmp_buf_t buf;
55 int val;
56 int i;
57
58 printf("calling setjmp\n");
59
60 val = _setjmp(&buf);
61#if VERBOSE
62 for (i=0; i<64; i++) {
63 if ((i % 8) == 0) printf("\n%2d :",i);
64 printf(" %8x",buf.jmp_buf[i]);
65 }
66#endif
67 printf("\nsetjmp returned %d, structure at 0x%x\n",val,&buf);
68
69 if (val < 5)
70 recursed(&buf,val+1,val+1);
71
72 printf("returning from setjmp/longjmp test\n");
73}
74