]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2004, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | EfiStdArg.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Support for variable length argument lists using the ANSI standard.\r | |
19 | \r | |
20 | Since we are using the ANSI standard we used the standard nameing and\r | |
21 | did not folow the coding convention\r | |
22 | \r | |
23 | VA_LIST - typedef for argument list.\r | |
24 | VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use.\r | |
25 | VA_END (VA_LIST Marker) - Clear Marker\r | |
26 | VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argumnet from\r | |
27 | the ... list. You must know the size and pass it in this macro.\r | |
28 | \r | |
29 | example:\r | |
30 | \r | |
31 | UINTN\r | |
32 | ExampleVarArg (\r | |
33 | IN UINTN NumberOfArgs,\r | |
34 | ...\r | |
35 | )\r | |
36 | {\r | |
37 | VA_LIST Marker;\r | |
38 | UINTN Index;\r | |
39 | UINTN Result;\r | |
40 | \r | |
41 | //\r | |
42 | // Initialize the Marker\r | |
43 | //\r | |
44 | VA_START (Marker, NumberOfArgs);\r | |
45 | for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) {\r | |
46 | //\r | |
47 | // The ... list is a series of UINTN values, so average them up.\r | |
48 | //\r | |
49 | Result += VA_ARG (Marker, UINTN);\r | |
50 | }\r | |
51 | \r | |
52 | VA_END (Marker);\r | |
53 | return Result\r | |
54 | }\r | |
55 | \r | |
56 | --*/\r | |
57 | \r | |
58 | #ifndef _EFISTDARG_H_\r | |
59 | #define _EFISTDARG_H_\r | |
60 | \r | |
61 | #define _EFI_INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))\r | |
62 | \r | |
63 | //\r | |
64 | // Also support coding convention rules for var arg macros\r | |
65 | //\r | |
66 | #ifndef VA_START\r | |
67 | \r | |
68 | typedef CHAR8 *VA_LIST;\r | |
69 | #define VA_START(ap, v) (ap = (VA_LIST) & (v) + _EFI_INT_SIZE_OF (v))\r | |
70 | #define VA_ARG(ap, t) (*(t *) ((ap += _EFI_INT_SIZE_OF (t)) - _EFI_INT_SIZE_OF (t)))\r | |
71 | #define VA_END(ap) (ap = (VA_LIST) 0)\r | |
72 | \r | |
73 | #endif\r | |
74 | \r | |
75 | #endif\r |