]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Include/EfiStdArg.h
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Include / EfiStdArg.h
1 /*++
2
3 Copyright (c) 2004, Intel Corporation
4 All rights reserved. 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 //
64 // Also support coding convention rules for var arg macros
65 //
66 #ifndef VA_START
67
68 typedef CHAR8 *VA_LIST;
69 #define VA_START(ap, v) (ap = (VA_LIST) & (v) + _EFI_INT_SIZE_OF (v))
70 #define VA_ARG(ap, t) (*(t *) ((ap += _EFI_INT_SIZE_OF (t)) - _EFI_INT_SIZE_OF (t)))
71 #define VA_END(ap) (ap = (VA_LIST) 0)
72
73 #endif
74
75 #endif