]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Include/EfiStdArg.h
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Include / EfiStdArg.h
1 /*++
2
3 Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 EfiStdArg.h
15
16 Abstract:
17
18 Support for variable length argument lists using the ANSI standard.
19
20 Since we are using the ANSI standard we used the standard nameing and
21 did not folow the coding convention
22
23 VA_LIST - typedef for argument list.
24 VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use.
25 VA_END (VA_LIST Marker) - Clear Marker
26 VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argumnet from
27 the ... list. You must know the size and pass it in this macro.
28
29 example:
30
31 UINTN
32 ExampleVarArg (
33 IN UINTN NumberOfArgs,
34 ...
35 )
36 {
37 VA_LIST Marker;
38 UINTN Index;
39 UINTN Result;
40
41 //
42 // Initialize the Marker
43 //
44 VA_START (Marker, NumberOfArgs);
45 for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) {
46 //
47 // The ... list is a series of UINTN values, so average them up.
48 //
49 Result += VA_ARG (Marker, UINTN);
50 }
51
52 VA_END (Marker);
53 return Result
54 }
55
56 --*/
57
58 #ifndef _EFISTDARG_H_
59 #define _EFISTDARG_H_
60
61 #define _EFI_INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))
62
63 #if defined(__CC_ARM)
64 //
65 // RVCT ARM variable argument list support.
66 //
67
68 ///
69 /// Variable used to traverse the list of arguments. This type can vary by
70 /// implementation and could be an array or structure.
71 ///
72 #ifdef __APCS_ADSABI
73 typedef int *va_list[1];
74 #define VA_LIST va_list
75 #else
76 typedef struct __va_list { void *__ap; } va_list;
77 #define VA_LIST va_list
78 #endif
79
80 #define VA_START(Marker, Parameter) __va_start(Marker, Parameter)
81
82 #define VA_ARG(Marker, TYPE) __va_arg(Marker, TYPE)
83
84 #define VA_END(Marker) ((void)0)
85
86 #define VA_COPY(Dest, Start) __va_copy (Dest, Start)
87
88 #elif defined(__GNUC__)
89 //
90 // Use GCC built-in macros for variable argument lists.
91 //
92
93 ///
94 /// Variable used to traverse the list of arguments. This type can vary by
95 /// implementation and could be an array or structure.
96 ///
97 typedef __builtin_va_list VA_LIST;
98
99 #define VA_START(Marker, Parameter) __builtin_va_start (Marker, Parameter)
100
101 #define VA_ARG(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE)))
102
103 #define VA_END(Marker) __builtin_va_end (Marker)
104
105 #define VA_COPY(Dest, Start) __builtin_va_copy (Dest, Start)
106
107 #else
108
109 //
110 // Also support coding convention rules for var arg macros
111 //
112 #ifndef VA_START
113
114 typedef CHAR8 *VA_LIST;
115 #define VA_START(ap, v) (ap = (VA_LIST) & (v) + _EFI_INT_SIZE_OF (v))
116 #define VA_ARG(ap, t) (*(t *) ((ap += _EFI_INT_SIZE_OF (t)) - _EFI_INT_SIZE_OF (t)))
117 #define VA_END(ap) (ap = (VA_LIST) 0)
118 #define VA_COPY(dest, src) ((void)((dest) = (src)))
119
120 #endif
121
122
123 #endif
124
125 #endif