]> git.proxmox.com Git - mirror_edk2.git/blob - StdLibPrivateInternalFiles/Include/MainData.h
Correct typo: GCC 5.4 --> GCC 4.5.
[mirror_edk2.git] / StdLibPrivateInternalFiles / Include / MainData.h
1 /** @file
2 Global data for the program environment.
3
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 **/
13 #include <Uefi.h>
14 #include <Library/ShellLib.h>
15
16 #include <limits.h>
17 #include <signal.h>
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <time.h>
21 #include "Efi/Console.h"
22
23 /* ################## Type Declarations ################################# */
24
25 /** The type of an atexit handler function. **/
26 typedef void __xithandler_t(void);
27
28 /* ################## Global Declarations ############################### */
29 #ifndef TYPE_BIT
30 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
31 #endif /* !defined TYPE_BIT */
32
33 #ifndef TYPE_SIGNED
34 #define TYPE_SIGNED(type) (((type) -1) < 0)
35 #endif /* !defined TYPE_SIGNED */
36
37 #ifndef INT_STRLEN_MAXIMUM
38 /*
39 ** 302 / 1000 is log10(2.0) rounded up.
40 ** Subtract one for the sign bit if the type is signed;
41 ** add one for integer division truncation;
42 ** add one more for a minus sign if the type is signed.
43 */
44 #define INT_STRLEN_MAXIMUM(type) \
45 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
46 #endif /* !defined INT_STRLEN_MAXIMUM */
47
48 /*
49 ** Big enough for something such as
50 ** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n
51 ** (two three-character abbreviations, five strings denoting integers,
52 ** three explicit spaces, two explicit colons, a newline,
53 ** and a trailing ASCII nul).
54 */
55 #define ASCTIME_BUFLEN (3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) + 3 + 2 + 1 + 1)
56
57 struct __filedes {
58 EFI_FILE_HANDLE FileHandle;
59 UINT32 State; // In use if non-zero
60 int Oflags; // From the open call
61 int Omode; // From the open call
62 int RefCount; // Reference count of opens
63 int SocProc; // Placeholder: socket owner process or process group.
64 UINT16 MyFD; // Which FD this is.
65 };
66
67 struct __MainData {
68 // File descriptors
69 struct __filedes fdarray[OPEN_MAX];
70 // Low-level File abstractions for the stdin, stdout, stderr streams
71 ConInstance StdIo[3];
72
73 // Signal Handlers
74 __sighandler_t *sigarray[SIG_LAST]; // Pointers to signal handlers
75
76 void (*cleanup)(void); // Cleanup Function Pointer
77
78 __xithandler_t *atexit_handler[ATEXIT_MAX]; // Array of handlers for atexit.
79 clock_t AppStartTime; // Set in Main.c and used for time.h
80 clock_t ClocksPerSecond; // Set in Main.c and used for time.h
81 int num_atexit; ///< Number of registered atexit handlers.
82
83 CHAR16 UString[UNICODE_STRING_MAX];
84 struct tm BDTime; // Broken-down time structure for localtime.
85 EFI_TIME TimeBuffer; // Used by <time.h>mk
86 char ASgetenv[ASCII_STRING_MAX]; // Only modified by getenv
87 char ASasctime[ASCTIME_BUFLEN]; // Only modified by asctime
88
89 BOOLEAN aborting; // Ensures cleanup function only called once when aborting.
90 };
91
92 extern struct __MainData *gMD;