2 Global data for the program environment.
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.
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.
14 #include <Library/ShellLib.h>
21 #include "Efi/Console.h"
23 /* ################## Type Declarations ################################# */
25 /** The type of an atexit handler function. **/
26 typedef void __xithandler_t(void);
28 /* ################## Global Declarations ############################### */
30 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
31 #endif /* !defined TYPE_BIT */
34 #define TYPE_SIGNED(type) (((type) -1) < 0)
35 #endif /* !defined TYPE_SIGNED */
37 #ifndef INT_STRLEN_MAXIMUM
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.
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 */
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).
55 #define ASCTIME_BUFLEN (3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) + 3 + 2 + 1 + 1)
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.
69 struct __filedes fdarray
[OPEN_MAX
];
70 // Low-level File abstractions for the stdin, stdout, stderr streams
74 __sighandler_t
*sigarray
[SIG_LAST
]; // Pointers to signal handlers
76 void (*cleanup
)(void); // Cleanup Function Pointer
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.
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
89 BOOLEAN aborting
; // Ensures cleanup function only called once when aborting.
92 extern struct __MainData
*gMD
;