]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/Wchar/ConsDecons.c
Standard Libraries for EDK II.
[mirror_edk2.git] / StdLib / LibC / Wchar / ConsDecons.c
1 /** @file
2 Constructor and Deconstructor functions for <wchar.h>.
3
4 Unless explicitly stated otherwise, the functions defined in this file order
5 two wide characters the same way as two integers of the underlying integer
6 type designated by wchar_t.
7
8 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
9 This program and the accompanying materials are licensed and made available under
10 the terms and conditions of the BSD License that accompanies this distribution.
11 The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php.
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 **/
17 #include <Uefi.h>
18 #include <Library/BaseLib.h>
19 #include <Library/BaseMemoryLib.h>
20 #include <Library/MemoryAllocationLib.h>
21
22 #include <LibConfig.h>
23
24 #include <errno.h>
25 #include <wchar.h>
26
27 /* Data initialized by the library constructor */
28 UINT8 *__wchar_bitmap = NULL;
29 UINTN __wchar_bitmap_size;
30 UINTN __wchar_bitmap_64;
31
32 EFI_STATUS
33 EFIAPI
34 __wchar_construct(
35 IN EFI_HANDLE ImageHandle,
36 IN EFI_SYSTEM_TABLE *SystemTable
37 )
38 {
39 if( __wchar_bitmap == NULL) {
40 __wchar_bitmap_size = (WCHAR_MAX + 8) / 8U;
41 __wchar_bitmap = AllocatePool(__wchar_bitmap_size);
42 if( __wchar_bitmap == NULL) {
43 EFIerrno = RETURN_OUT_OF_RESOURCES;
44 errno = ENOMEM;
45 return EFIerrno;
46 }
47 return RETURN_SUCCESS;
48 }
49 return RETURN_ALREADY_STARTED;
50 }
51
52 EFI_STATUS
53 EFIAPI
54 __wchar_deconstruct(
55 IN EFI_HANDLE ImageHandle,
56 IN EFI_SYSTEM_TABLE *SystemTable
57 )
58 {
59 if( __wchar_bitmap != NULL) {
60 FreePool( __wchar_bitmap);
61 __wchar_bitmap = NULL;
62 }
63 return RETURN_SUCCESS;
64 }