xref: /illumos-gate/usr/src/lib/libc/amd64/genassym.c (revision bdf0047c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include <stdio.h>
28 #include <stddef.h>
29 #include <signal.h>
30 #include <ucontext.h>
31 #include <sys/stack.h>
32 #include <sys/synch.h>
33 #include <sys/synch32.h>
34 #include "thr_uberdata.h"
35 
36 /*
37  * This file generates two values used by _lwp_mutex_unlock.s:
38  *	a) the byte offset (in lwp_mutex_t) of the word containing the lock byte
39  *	b) a mask to extract the waiter field from the word containing it
40  * It also generates offsets into the ucontext_t structure, needed by the
41  * getcontext() function, which is written in assembly, as well as offsets
42  * into the ulwp_t (thread) structure needed by certain assembler functions.
43  */
44 
45 int
main(void)46 main(void)
47 {
48 	(void) printf("#define\tMUTEX_LOCK_WORD\t0x%x\n",
49 	    offsetof(lwp_mutex_t, mutex_lockword));
50 	(void) printf("#define\tWAITER_MASK\t0x00ff0000\n");
51 
52 	(void) printf("#define\tSIG_SETMASK\t0x%x\n", SIG_SETMASK);
53 	(void) printf("#define\tMASKSET0\t0x%x\n", MASKSET0);
54 	(void) printf("#define\tMASKSET1\t0x%x\n", MASKSET1);
55 	(void) printf("#define\tMASKSET2\t0x%x\n", MASKSET2);
56 	(void) printf("#define\tMASKSET3\t0x%x\n", MASKSET3);
57 	(void) printf("#define\tSIGSEGV\t0x%x\n", SIGSEGV);
58 
59 	(void) printf("#define\tRIP_OFF\t0x%x\n", REG_RIP * 8);
60 	(void) printf("#define\tRAX_OFF\t0x%x\n", REG_RAX * 8);
61 	(void) printf("#define\tRSP_OFF\t0x%x\n", REG_RSP * 8);
62 
63 	return (0);
64 }
65