VirtualBox

source: vbox/trunk/include/iprt/asmdefs.mac@ 47356

Last change on this file since 47356 was 47224, checked in by vboxsync, 11 years ago

iprt/asmdefs.mac: RT_MAKE_U32_FROM_U8 fix.

  • Property eol-style set to native
File size: 19.3 KB
Line 
1;; @file
2; IPRT - Global YASM/NASM macros
3;
4
5;
6; Copyright (C) 2006-2012 Oracle Corporation
7;
8; This file is part of VirtualBox Open Source Edition (OSE), as
9; available from http://www.virtualbox.org. This file is free software;
10; you can redistribute it and/or modify it under the terms of the GNU
11; General Public License (GPL) as published by the Free Software
12; Foundation, in version 2 as it comes in the "COPYING" file of the
13; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15;
16; The contents of this file may alternatively be used under the terms
17; of the Common Development and Distribution License Version 1.0
18; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19; VirtualBox OSE distribution, in which case the provisions of the
20; CDDL are applicable instead of those of the GPL.
21;
22; You may elect to license modified versions of this file under the
23; terms and conditions of either the GPL or the CDDL or both.
24;
25
26%ifndef ___iprt_asmdefs_mac
27%define ___iprt_asmdefs_mac
28
29
30;; @defgroup grp_rt_cdefs_size Size Constants
31; (Of course, these are binary computer terms, not SI.)
32; @{
33;; 1 K (Kilo) (1 024).
34%define _1K 000000400h
35;; 4 K (Kilo) (4 096).
36%define _4K 000001000h
37;; 32 K (Kilo) (32 678).
38%define _32K 000008000h
39;; 64 K (Kilo) (65 536).
40%define _64K 000010000h
41;; 128 K (Kilo) (131 072).
42%define _128K 000020000h
43;; 256 K (Kilo) (262 144).
44%define _256K 000040000h
45;; 512 K (Kilo) (524 288).
46%define _512K 000080000h
47;; 1 M (Mega) (1 048 576).
48%define _1M 000100000h
49;; 2 M (Mega) (2 097 152).
50%define _2M 000200000h
51;; 4 M (Mega) (4 194 304).
52%define _4M 000400000h
53;; 1 G (Giga) (1 073 741 824).
54%define _1G 040000000h
55;; 2 G (Giga) (2 147 483 648).
56%define _2G 00000000080000000h
57;; 4 G (Giga) (4 294 967 296).
58%define _4G 00000000100000000h
59;; 1 T (Tera) (1 099 511 627 776).
60%define _1T 00000010000000000h
61;; 1 P (Peta) (1 125 899 906 842 624).
62%define _1P 00004000000000000h
63;; 1 E (Exa) (1 152 921 504 606 846 976).
64%define _1E 01000000000000000h
65;; 2 E (Exa) (2 305 843 009 213 693 952).
66%define _2E 02000000000000000h
67;; @}
68
69
70;;
71; Make the mask for the given bit.
72%define RT_BIT(bit) (1 << bit)
73
74;;
75; Makes a 32-bit unsigned (not type safe, but whatever) out of four byte values.
76%define RT_MAKE_U32_FROM_U8(b0, b1, b2, b3) ( (b3 << 24) | (b2 << 16) | (b1 << 8) | b0 )
77
78
79;;
80; Align code, pad with INT3.
81%define ALIGNCODE(alignment) align alignment, db 0cch
82
83;;
84; Align data, pad with ZEROs.
85%define ALIGNDATA(alignment) align alignment, db 0
86
87;;
88; Align BSS, pad with ZEROs.
89%define ALIGNBSS(alignment) align alignment, resb 1
90
91;;
92; NAME_OVERLOAD can be defined by a .asm module to modify all the
93; names created using the name macros in this files.
94; This is handy when you've got some kind of template code.
95%ifndef NAME_OVERLOAD
96 %define NAME_OVERLOAD(name) name
97%endif
98
99;;
100; Mangles the given name so it can be referenced using DECLASM() in the
101; C/C++ world.
102%ifndef ASM_FORMAT_BIN
103 %ifdef RT_ARCH_X86
104 %ifdef RT_OS_OS2
105 %define NAME(name) _ %+ NAME_OVERLOAD(name)
106 %endif
107 %ifdef RT_OS_WINDOWS
108 %define NAME(name) _ %+ NAME_OVERLOAD(name)
109 %endif
110 %endif
111 %ifdef RT_OS_DARWIN
112 %define NAME(name) _ %+ NAME_OVERLOAD(name)
113 %endif
114%endif
115%ifndef NAME
116 %define NAME(name) NAME_OVERLOAD(name)
117%endif
118
119;;
120; Mangles the given C name so it will _import_ the right symbol.
121%ifdef ASM_FORMAT_PE
122 %define IMPNAME(name) __imp_ %+ NAME(name)
123%else
124 %define IMPNAME(name) NAME(name)
125%endif
126
127;;
128; Gets the pointer to an imported object.
129%ifdef ASM_FORMAT_PE
130 %ifdef RT_ARCH_AMD64
131 %define IMP(name) qword [IMPNAME(name) wrt rip]
132 %else
133 %define IMP(name) dword [IMPNAME(name)]
134 %endif
135%else
136 %define IMP(name) IMPNAME(name)
137%endif
138
139;;
140; Declares an imported object for use with IMP2.
141; @note May change the current section!
142%macro EXTERN_IMP2 1
143 extern IMPNAME(%1)
144 BEGINDATA
145 %ifdef ASM_FORMAT_MACHO
146 g_Imp2_ %+ %1: RTCCPTR_DEF IMPNAME(%1)
147 %endif
148%endmacro
149
150;;
151; Gets the pointer to an imported object, version 2.
152%ifdef ASM_FORMAT_PE
153 %ifdef RT_ARCH_AMD64
154 %define IMP2(name) qword [IMPNAME(name) wrt rip]
155 %else
156 %define IMP2(name) dword [IMPNAME(name)]
157 %endif
158%elifdef ASM_FORMAT_ELF
159 %ifdef PIC
160 %ifdef RT_ARCH_AMD64
161 %define IMP2(name) qword [rel IMPNAME(name) wrt ..got]
162 %else
163 %define IMP2(name) IMPNAME(name) wrt ..plt
164 %endif
165 %endif
166%elifdef ASM_FORMAT_MACHO
167 %define IMP2(name) RTCCPTR_PRE [g_Imp2_ %+ name xWrtRIP]
168%endif
169%ifndef IMP2
170 %define IMP2(name) IMPNAME(name)
171%endif
172
173
174
175;;
176; Global marker which is DECLASM() compatible.
177%macro GLOBALNAME 1,
178%ifndef ASM_FORMAT_BIN
179global NAME(%1)
180%endif
181NAME(%1):
182%endmacro
183
184;;
185; Global exported marker which is DECLASM() compatible.
186%macro EXPORTEDNAME 1,
187 %ifdef ASM_FORMAT_PE
188 export %1=NAME(%1)
189 %endif
190 %ifdef __NASM__
191 %ifdef ASM_FORMAT_OMF
192 export NAME(%1) NAME(%1)
193 %endif
194%endif
195GLOBALNAME %1
196%endmacro
197
198;;
199; Global marker which is DECLASM() compatible.
200%macro GLOBALNAME_EX 2,
201%ifndef ASM_FORMAT_BIN
202 %ifdef ASM_FORMAT_ELF
203global NAME(%1):%2
204 %else
205global NAME(%1)
206 %endif
207%endif
208NAME(%1):
209%endmacro
210
211;;
212; Global exported marker which is DECLASM() compatible.
213%macro EXPORTEDNAME_EX 2,
214 %ifdef ASM_FORMAT_PE
215 export %1=NAME(%1)
216 %endif
217 %ifdef __NASM__
218 %ifdef ASM_FORMAT_OMF
219 export NAME(%1) NAME(%1)
220 %endif
221%endif
222GLOBALNAME_EX %1, %2
223%endmacro
224
225;;
226; Begins a C callable procedure.
227%macro BEGINPROC 1
228GLOBALNAME_EX %1, function hidden
229%endmacro
230
231;;
232; Begins a C callable exported procedure.
233%macro BEGINPROC_EXPORTED 1
234EXPORTEDNAME_EX %1, function
235%endmacro
236
237;;
238; Ends a C callable procedure.
239%macro ENDPROC 1
240GLOBALNAME_EX %1 %+ _EndProc, function hidden
241%ifdef ASM_FORMAT_ELF
242size NAME(%1) NAME(%1 %+ _EndProc) - NAME(%1)
243size NAME(%1 %+ _EndProc) 0
244%endif
245 db 0xCC, 0xCC, 0xCC, 0xCC
246%endmacro
247
248
249;
250; Do OMF and Mach-O/Yasm segment definitions
251;
252; Both format requires this to get the segment order right, in the Mach-O/Yasm case
253; it's only to make sure the .bss section ends up last (it's not declared here).
254;
255%ifdef ASM_FORMAT_OMF
256
257 ; 16-bit segments first (OMF / OS/2 specific).
258 %ifdef RT_INCL_16BIT_SEGMENTS
259 segment DATA16 public CLASS=FAR_DATA align=16 use16
260 segment DATA16_INIT public CLASS=FAR_DATA align=16 use16
261 group DGROUP16 DATA16 DATA16_INIT
262
263 ;;
264 ; Begins 16-bit data
265 %macro BEGINDATA16 0
266 segment DATA16
267 %endmacro
268
269 ;;
270 ; Begins 16-bit init data
271 %macro BEGINDATA16INIT 0
272 segment DATA16_INIT
273 %endmacro
274
275 segment CODE16 public CLASS=FAR_CODE align=16 use16
276 segment CODE16_INIT public CLASS=FAR_CODE align=16 use16
277 group CGROUP16 CODE16 CODE16_INIT
278
279 ;;
280 ; Begins 16-bit code
281 %macro BEGINCODE16 0
282 segment CODE16
283 %endmacro
284
285 ;;
286 ; Begins 16-bit init code
287 %macro BEGINCODE16INIT 0
288 segment CODE16_INIT
289 %endmacro
290
291 %endif
292
293 ; 32-bit segments.
294 segment TEXT32 public CLASS=CODE align=16 use32 flat
295 segment DATA32 public CLASS=DATA align=16 use32 flat
296 segment BSS32 public CLASS=BSS align=16 use32 flat
297
298 ; Make the TEXT32 segment default.
299 segment TEXT32
300%endif
301
302%ifdef ASM_FORMAT_MACHO
303 %ifdef __YASM__
304 section .text
305 section .data
306 %endif
307%endif
308
309
310;;
311; Begins code
312%ifdef ASM_FORMAT_OMF
313 %macro BEGINCODE 0
314 segment TEXT32
315 %endmacro
316%else
317%macro BEGINCODE 0
318 section .text
319%endmacro
320%endif
321
322;;
323; Begins constant (read-only) data
324;
325; @remarks This is mapped to the CODE section/segment when there isn't
326; any dedicated const section/segment. (There is code that
327; assumes this, so don't try change it.)
328%ifdef ASM_FORMAT_OMF
329 %macro BEGINCONST 0
330 segment TEXT32
331 %endmacro
332%else
333 %macro BEGINCONST 0
334 %ifdef ASM_FORMAT_MACHO ;; @todo check the other guys too.
335 section .rodata
336 %else
337 section .text
338 %endif
339 %endmacro
340%endif
341
342;;
343; Begins initialized data
344%ifdef ASM_FORMAT_OMF
345 %macro BEGINDATA 0
346 segment DATA32
347 %endmacro
348%else
349%macro BEGINDATA 0
350 section .data
351%endmacro
352%endif
353
354;;
355; Begins uninitialized data
356%ifdef ASM_FORMAT_OMF
357 %macro BEGINBSS 0
358 segment BSS32
359 %endmacro
360%else
361%macro BEGINBSS 0
362 section .bss
363%endmacro
364%endif
365
366
367
368;; @def ARCH_BITS
369; Defines the bit count of the current context.
370%ifndef ARCH_BITS
371 %ifdef RT_ARCH_AMD64
372 %define ARCH_BITS 64
373 %else
374 %define ARCH_BITS 32
375 %endif
376%endif
377
378;; @def HC_ARCH_BITS
379; Defines the host architechture bit count.
380%ifndef HC_ARCH_BITS
381 %ifndef IN_RC
382 %define HC_ARCH_BITS ARCH_BITS
383 %else
384 %define HC_ARCH_BITS 32
385 %endif
386%endif
387
388;; @def R3_ARCH_BITS
389; Defines the host ring-3 architechture bit count.
390%ifndef R3_ARCH_BITS
391 %ifdef IN_RING3
392 %define R3_ARCH_BITS ARCH_BITS
393 %else
394 %define R3_ARCH_BITS HC_ARCH_BITS
395 %endif
396%endif
397
398;; @def R0_ARCH_BITS
399; Defines the host ring-0 architechture bit count.
400%ifndef R0_ARCH_BITS
401 %ifdef IN_RING0
402 %define R0_ARCH_BITS ARCH_BITS
403 %else
404 %define R0_ARCH_BITS HC_ARCH_BITS
405 %endif
406%endif
407
408;; @def GC_ARCH_BITS
409; Defines the guest architechture bit count.
410%ifndef GC_ARCH_BITS
411 %ifdef IN_RC
412 %define GC_ARCH_BITS ARCH_BITS
413 %else
414 %define GC_ARCH_BITS 32
415 %endif
416%endif
417
418
419
420;; @def RTHCPTR_DEF
421; The pesudo-instruction used to declare an initialized pointer variable in the host context.
422%if HC_ARCH_BITS == 64
423 %define RTHCPTR_DEF dq
424%else
425 %define RTHCPTR_DEF dd
426%endif
427
428;; @def RTHCPTR_RES
429; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
430; variable of the host context.
431%if HC_ARCH_BITS == 64
432 %define RTHCPTR_RES resq
433%else
434 %define RTHCPTR_RES resd
435%endif
436
437;; @def RTHCPTR_PRE
438; The memory operand prefix used for a pointer in the host context.
439%if HC_ARCH_BITS == 64
440 %define RTHCPTR_PRE qword
441%else
442 %define RTHCPTR_PRE dword
443%endif
444
445;; @def RTHCPTR_CB
446; The size in bytes of a pointer in the host context.
447%if HC_ARCH_BITS == 64
448 %define RTHCPTR_CB 8
449%else
450 %define RTHCPTR_CB 4
451%endif
452
453
454
455;; @def RTR0PTR_DEF
456; The pesudo-instruction used to declare an initialized pointer variable in the ring-0 host context.
457%if R0_ARCH_BITS == 64
458 %define RTR0PTR_DEF dq
459%else
460 %define RTR0PTR_DEF dd
461%endif
462
463;; @def RTR0PTR_RES
464; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
465; variable of the ring-0 host context.
466%if R0_ARCH_BITS == 64
467 %define RTR0PTR_RES resq
468%else
469 %define RTR0PTR_RES resd
470%endif
471
472;; @def RTR0PTR_PRE
473; The memory operand prefix used for a pointer in the ring-0 host context.
474%if R0_ARCH_BITS == 64
475 %define RTR0PTR_PRE qword
476%else
477 %define RTR0PTR_PRE dword
478%endif
479
480;; @def RTR0PTR_CB
481; The size in bytes of a pointer in the ring-0 host context.
482%if R0_ARCH_BITS == 64
483 %define RTR0PTR_CB 8
484%else
485 %define RTR0PTR_CB 4
486%endif
487
488
489
490;; @def RTR3PTR_DEF
491; The pesudo-instruction used to declare an initialized pointer variable in the ring-3 host context.
492%if R3_ARCH_BITS == 64
493 %define RTR3PTR_DEF dq
494%else
495 %define RTR3PTR_DEF dd
496%endif
497
498;; @def RTR3PTR_RES
499; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
500; variable of the ring-3 host context.
501%if R3_ARCH_BITS == 64
502 %define RTR3PTR_RES resq
503%else
504 %define RTR3PTR_RES resd
505%endif
506
507;; @def RTR3PTR_PRE
508; The memory operand prefix used for a pointer in the ring-3 host context.
509%if R3_ARCH_BITS == 64
510 %define RTR3PTR_PRE qword
511%else
512 %define RTR3PTR_PRE dword
513%endif
514
515;; @def RTR3PTR_CB
516; The size in bytes of a pointer in the ring-3 host context.
517%if R3_ARCH_BITS == 64
518 %define RTR3PTR_CB 8
519%else
520 %define RTR3PTR_CB 4
521%endif
522
523
524
525;; @def RTGCPTR_DEF
526; The pesudo-instruction used to declare an initialized pointer variable in the guest context.
527%if GC_ARCH_BITS == 64
528 %define RTGCPTR_DEF dq
529%else
530 %define RTGCPTR_DEF dd
531%endif
532
533;; @def RTGCPTR_RES
534; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
535; variable of the guest context.
536%if GC_ARCH_BITS == 64
537 %define RTGCPTR_RES resq
538%else
539 %define RTGCPTR_RES resd
540%endif
541
542%define RTGCPTR32_RES resd
543%define RTGCPTR64_RES resq
544
545;; @def RTGCPTR_PRE
546; The memory operand prefix used for a pointer in the guest context.
547%if GC_ARCH_BITS == 64
548 %define RTGCPTR_PRE qword
549%else
550 %define RTGCPTR_PRE dword
551%endif
552
553;; @def RTGCPTR_CB
554; The size in bytes of a pointer in the guest context.
555%if GC_ARCH_BITS == 64
556 %define RTGCPTR_CB 8
557%else
558 %define RTGCPTR_CB 4
559%endif
560
561
562;; @def RTRCPTR_DEF
563; The pesudo-instruction used to declare an initialized pointer variable in the raw mode context.
564%define RTRCPTR_DEF dd
565
566;; @def RTRCPTR_RES
567; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
568; variable of the raw mode context.
569%define RTRCPTR_RES resd
570
571;; @def RTRCPTR_PRE
572; The memory operand prefix used for a pointer in the raw mode context.
573%define RTRCPTR_PRE dword
574
575;; @def RTRCPTR_CB
576; The size in bytes of a pointer in the raw mode context.
577%define RTRCPTR_CB 4
578
579
580;; @def RT_CCPTR_DEF
581; The pesudo-instruction used to declare an initialized pointer variable in the current context.
582
583;; @def RT_CCPTR_RES
584; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
585; variable of the current context.
586
587;; @def RT_CCPTR_PRE
588; The memory operand prefix used for a pointer in the current context.
589
590;; @def RT_CCPTR_CB
591; The size in bytes of a pointer in the current context.
592
593%ifdef IN_RC
594 %define RTCCPTR_DEF RTRCPTR_DEF
595 %define RTCCPTR_RES RTRCPTR_RES
596 %define RTCCPTR_PRE RTRCPTR_PRE
597 %define RTCCPTR_CB RTRCPTR_CB
598%else
599 %ifdef IN_RING0
600 %define RTCCPTR_DEF RTR0PTR_DEF
601 %define RTCCPTR_RES RTR0PTR_RES
602 %define RTCCPTR_PRE RTR0PTR_PRE
603 %define RTCCPTR_CB RTR0PTR_CB
604 %else
605 %define RTCCPTR_DEF RTR3PTR_DEF
606 %define RTCCPTR_RES RTR3PTR_RES
607 %define RTCCPTR_PRE RTR3PTR_PRE
608 %define RTCCPTR_CB RTR3PTR_CB
609 %endif
610%endif
611
612
613
614;; @def RTHCPHYS_DEF
615; The pesudo-instruction used to declare an initialized host physical address.
616%define RTHCPHYS_DEF dq
617
618;; @def RTHCPTR_RES
619; The pesudo-instruction used to declare (=reserve space for) an uninitialized
620; host physical address variable
621%define RTHCPHYS_RES resq
622
623;; @def RTHCPTR_PRE
624; The memory operand prefix used for a host physical address.
625%define RTHCPHYS_PRE qword
626
627;; @def RTHCPHYS_CB
628; The size in bytes of a host physical address.
629%define RTHCPHYS_CB 8
630
631
632
633;; @def RTGCPHYS_DEF
634; The pesudo-instruction used to declare an initialized guest physical address.
635%define RTGCPHYS_DEF dq
636
637;; @def RTGCPHYS_RES
638; The pesudo-instruction used to declare (=reserve space for) an uninitialized
639; guest physical address variable
640%define RTGCPHYS_RES resq
641
642;; @def RTGCPTR_PRE
643; The memory operand prefix used for a guest physical address.
644%define RTGCPHYS_PRE qword
645
646;; @def RTGCPHYS_CB
647; The size in bytes of a guest physical address.
648%define RTGCPHYS_CB 8
649
650
651
652;;
653; The size of the long double C/C++ type.
654; On 32-bit Darwin this is 16 bytes, on L4, Linux, OS/2 and Windows
655; it's 12 bytes.
656; @todo figure out what 64-bit Windows does (I don't recall right now).
657%ifdef RT_ARCH_X86
658 %ifdef RT_OS_DARWIN
659 %define RTLRD_CB 16
660 %else
661 %define RTLRD_CB 12
662 %endif
663%else
664 %define RTLRD_CB 16
665%endif
666
667
668
669;; @def ASM_CALL64_GCC
670; Indicates that we're using the GCC 64-bit calling convention.
671; @see @ref sec_vboxrem_amd64_compare (in VBoxREMWrapper.cpp) for an ABI description.
672
673;; @def ASM_CALL64_MSC
674; Indicates that we're using the Microsoft 64-bit calling convention (fastcall on steroids).
675; @see @ref sec_vboxrem_amd64_compare (in VBoxREMWrapper.cpp) for an ABI description.
676
677; Note: On X86 we're using cdecl unconditionally. There is not yet any common
678; calling convention on AMD64, that's why we need to support two different ones.)
679
680%ifdef RT_ARCH_AMD64
681 %ifndef ASM_CALL64_GCC
682 %ifndef ASM_CALL64_MSC
683 ; define it based on the object format.
684 %ifdef ASM_FORMAT_PE
685 %define ASM_CALL64_MSC
686 %else
687 %define ASM_CALL64_GCC
688 %endif
689 %endif
690 %else
691 ; sanity check.
692 %ifdef ASM_CALL64_MSC
693 %error "Only one of the ASM_CALL64_* defines should be defined!"
694 %endif
695 %endif
696%endif
697
698
699;; @def RT_NOCRT
700; Symbol name wrapper for the No-CRT bits.
701;
702; In order to coexist in the same process as other CRTs, we need to
703; decorate the symbols such that they don't conflict the ones in the
704; other CRTs. The result of such conflicts / duplicate symbols can
705; confuse the dynamic loader on unix like systems.
706;
707; @remark Always feed the name to this macro first and then pass the result
708; on to the next *NAME* macro.
709;
710%ifndef RT_WITHOUT_NOCRT_WRAPPERS
711 %define RT_NOCRT(name) nocrt_ %+ name
712%else
713 %define RT_NOCRT(name) name
714%endif
715
716;; @def RT_NOCRT_BEGINPROC
717; Starts a NOCRT procedure, taking care of name wrapping and aliasing.
718;
719; Aliasing (weak ones, if supported) will be created when RT_WITH_NOCRT_ALIASES
720; is defined and RT_WITHOUT_NOCRT_WRAPPERS isn't.
721;
722%macro RT_NOCRT_BEGINPROC 1
723%ifdef RT_WITH_NOCRT_ALIASES
724BEGINPROC RT_NOCRT(%1)
725%ifdef ASM_FORMAT_ELF
726global NAME(%1)
727weak NAME(%1)
728NAME(%1):
729%else
730GLOBALNAME %1
731%endif
732%else ; !RT_WITH_NOCRT_ALIASES
733BEGINPROC RT_NOCRT(%1)
734%endif ; !RT_WITH_NOCRT_ALIASES
735%endmacro ; RT_NOCRT_BEGINPROC
736
737%ifdef RT_WITH_NOCRT_ALIASES
738 %ifdef RT_WITHOUT_NOCRT_WRAPPERS
739 %error "RT_WITH_NOCRT_ALIASES and RT_WITHOUT_NOCRT_WRAPPERS doesn't mix."
740 %endif
741%endif
742
743
744
745;; @def xCB
746; The stack unit size / The register unit size.
747
748;; @def xSP
749; The stack pointer register (RSP or ESP).
750
751;; @def xBP
752; The base pointer register (RBP or ESP).
753
754;; @def xAX
755; RAX or EAX depending on context.
756
757;; @def xBX
758; RBX or EBX depending on context.
759
760;; @def xCX
761; RCX or ECX depending on context.
762
763;; @def xDX
764; RDX or EDX depending on context.
765
766;; @def xDI
767; RDI or EDI depending on context.
768
769;; @def xSI
770; RSI or ESI depending on context.
771
772;; @def xWrtRIP
773; 'wrt rip' for AMD64 targets, nothing for x86 ones.
774
775%ifdef RT_ARCH_AMD64
776 %define xCB 8
777 %define xSP rsp
778 %define xBP rbp
779 %define xAX rax
780 %define xBX rbx
781 %define xCX rcx
782 %define xDX rdx
783 %define xDI rdi
784 %define xSI rsi
785 %define xWrtRIP wrt rip
786%else
787 %define xCB 4
788 %define xSP esp
789 %define xBP ebp
790 %define xAX eax
791 %define xBX ebx
792 %define xCX ecx
793 %define xDX edx
794 %define xDI edi
795 %define xSI esi
796 %define xWrtRIP
797%endif
798
799
800;
801; Some simple compile time assertions.
802;
803; Note! Requires new kBuild to work.
804;
805
806;;
807; Structure size assertion macro.
808%define AssertCompileSize(a_Type, a_Size) AssertCompileSizeML a_Type, a_Size
809%macro AssertCompileSizeML 2,
810 %ifndef KBUILD_GENERATING_MAKEFILE_DEPENDENCIES
811 %assign AssertVar_cbActual %1 %+ _size
812 %assign AssertVar_cbExpected %2
813 %if AssertVar_cbActual != AssertVar_cbExpected
814 %error %1 is AssertVar_cbActual bytes instead of AssertVar_cbExpected
815 %endif
816 %endif
817%endmacro
818
819;;
820; Structure memember offset assertion macro.
821%define AssertCompileMemberOffset(a_Type, a_Member, a_off) AssertCompileMemberOffsetML a_Type, a_Member, a_off
822%macro AssertCompileMemberOffsetML 3,
823 %ifndef KBUILD_GENERATING_MAKEFILE_DEPENDENCIES
824 %assign AssertVar_offActual %1 %+ . %+ %2
825 %assign AssertVar_offExpected %3
826 %if AssertVar_offActual != AssertVar_offExpected
827 %error %1 %+ . %+ %2 is at AssertVar_offActual instead of AssertVar_offExpected
828 %endif
829 %endif
830%endmacro
831
832%endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette