VirtualBox

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

Last change on this file since 47147 was 47034, checked in by vboxsync, 12 years ago

iprt/asmdefs.mac: Added AssertCompileSize and AssertCompileMemberOffset.

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