]>
git.saurik.com Git - apple/libc.git/blob - ppc/sys/genassym.h
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * genassym.h -- macros of use with genassym.c and assymdefs.c
29 #import <architecture/ppc/reg_help.h>
30 #import <architecture/ppc/macro_help.h>
32 #define PRINT_OFFSET(ptr_type, field) \
34 print_define("", #ptr_type, #field); \
35 print_hex((unsigned) &(((ptr_type)0)->field)); \
38 #define PRINT_BIT_FIELD(reg_type, field) \
41 CONTENTS(__reg) = 0; \
42 __reg.field = (typeof (__reg.field)) -1; \
43 print_define("", #reg_type, #field); \
44 print_hex(CONTENTS(__reg)); \
47 #define PRINT_ENUM(item) \
49 print_define("", "", #item); \
50 print_hex((unsigned)item); \
53 #define PRINT_DEFINE(macro) \
55 print_define("", "", #macro); \
56 print_str(STRINGIFY(macro)); \
59 #define PRINT_CONSTANT(macro) \
61 print_define("", "", #macro); \
62 print_hex((unsigned)macro); \
65 #define PRINT_REGADDR(macro) \
67 print_define("", "", #macro); \
68 print_hex((unsigned) ¯o); \
71 #define PRINT_REG_PAIR(struct_ptr, name0, name1) \
73 print_define("", #struct_ptr, #name0 "_" #name1); \
74 print_hex((unsigned) &(((struct_ptr)0)->U_##name0##_##name1)); \
77 #define PRINT_BIT_POS(reg_type, field) \
80 CONTENTS(__reg) = 0; \
82 print_define("", #reg_type, #field "_BIT"); \
83 print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
86 #define PRINT_FIELD_INFO(reg_type, field) \
89 CONTENTS(__reg) = 0; \
91 print_define("", #reg_type, #field "_OFF"); \
92 print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
93 print_define("", #reg_type, #field "_WIDTH"); \
94 print_dec((int) field_width(#reg_type, #field, CONTENTS(__reg)));\
97 #define PRINT_L2_SIZE(type) \
99 print_define("L2_SIZEOF", #type, ""); \
100 print_dec((int) log2(sizeof(type), #type)); \
103 #define PRINT_SIZEOF(type) \
105 print_define("SIZEOF", #type, ""); \
106 print_dec((int) sizeof(type)); \
109 #define PRINT_L2_CONSTANT(macro) \
111 print_define("L2", "", #macro); \
112 print_dec((int) log2(macro, #macro)); \
119 extern void comment(cmt_level_t level
, const char *cmt
);
120 extern void print_define(const char *prefix
, const char *type_name
,
122 extern void print_dec(int val
);
123 extern void print_hex(unsigned val
);
124 extern void print_str(const char *str
);
125 extern unsigned bit_num(char *reg_type
, char *field
, unsigned bits
);
126 extern unsigned field_width(char *reg_type
, char *field
, unsigned bits
);
127 extern unsigned log2(unsigned val
, char *type
);
128 extern void assymdefs(void);