1 | /** @file
|
---|
2 |
|
---|
3 | Module to rewrite stdlib references within Oniguruma
|
---|
4 |
|
---|
5 | (C) Copyright 2014-2021 Hewlett Packard Enterprise Development LP<BR>
|
---|
6 | Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
|
---|
7 | Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
---|
8 |
|
---|
9 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
10 | **/
|
---|
11 |
|
---|
12 | #ifndef ONIGURUMA_UEFI_PORT_H
|
---|
13 | #define ONIGURUMA_UEFI_PORT_H
|
---|
14 |
|
---|
15 | #include <Library/MemoryAllocationLib.h>
|
---|
16 | #include <Library/PrintLib.h>
|
---|
17 | #include <Library/BaseMemoryLib.h>
|
---|
18 | #include <Library/BaseLib.h>
|
---|
19 | #include <Library/DebugLib.h>
|
---|
20 |
|
---|
21 | #define ONIG_NO_STANDARD_C_HEADERS
|
---|
22 | #define ONIG_NO_PRINT
|
---|
23 | #define P_(args) args
|
---|
24 |
|
---|
25 | #define INT_MAX 0x7FFFFFFF
|
---|
26 | #define LONG_MAX 0x7FFFFFFF
|
---|
27 | #define UINT_MAX 0xFFFFFFFF
|
---|
28 | #define ULONG_MAX 0xFFFFFFFF
|
---|
29 |
|
---|
30 | #define SIZEOF_LONG 4
|
---|
31 | #define SIZEOF_LONG_LONG 8
|
---|
32 | typedef UINTN size_t;
|
---|
33 | typedef UINT32 uint32_t;
|
---|
34 | typedef INTN intptr_t;
|
---|
35 |
|
---|
36 | #ifndef offsetof
|
---|
37 | #define offsetof OFFSET_OF
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | #if defined (MDE_CPU_IA32) || defined (MDE_CPU_ARM) || defined (MDE_CPU_EBC)
|
---|
41 | #define SIZEOF_VOIDP 4
|
---|
42 | #else
|
---|
43 | #define SIZEOF_VOIDP 8
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | #define calloc(n, s) AllocateZeroPool((n)*(s))
|
---|
47 | #define xmemmove(Dest, Src, Length) CopyMem(Dest,Src,Length)
|
---|
48 | #define xmemcpy(Dest, Src, Length) CopyMem(Dest,Src,Length)
|
---|
49 | #define xmemset(Buffer, Value, Length) SetMem(Buffer,Length,Value)
|
---|
50 |
|
---|
51 | #define va_init_list(a, b) VA_START(a,b)
|
---|
52 | #define va_list VA_LIST
|
---|
53 | #define va_arg(a, b) VA_ARG(a,b)
|
---|
54 | #define va_end(a) VA_END(a)
|
---|
55 | #define va_start VA_START
|
---|
56 |
|
---|
57 | #define FILE VOID
|
---|
58 | #define stdout NULL
|
---|
59 | #define fprintf(...)
|
---|
60 | #define fputs(a, b)
|
---|
61 | #define vsnprintf (int)AsciiVSPrint
|
---|
62 | #define _vsnprintf vsnprintf
|
---|
63 | #define xsnprintf sprintf_s
|
---|
64 | #define xvsnprintf vsnprintf
|
---|
65 | #define alloca malloc
|
---|
66 |
|
---|
67 | #define setlocale(a, b)
|
---|
68 | #define LC_ALL 0
|
---|
69 |
|
---|
70 | #define UCHAR_MAX 255
|
---|
71 | #define MAX_STRING_SIZE 0x1000
|
---|
72 | #define strlen_s(String, MaxSize) AsciiStrnLenS (String, MaxSize)
|
---|
73 | #define xstrncpy(Dest, Src, MaxSize) strcat_s(Dest,MaxSize,Src)
|
---|
74 | #define xstrcat(Dest, Src, MaxSize) strcat(Dest,Src,MaxSize)
|
---|
75 | #define strcat(Dest, Src, MaxSize) strcat_s(Dest,MaxSize,Src)
|
---|
76 | #define strcat_s(Dest, MaxSize, Src) AsciiStrCatS (Dest, MaxSize, Src)
|
---|
77 | #define strncpy_s(Dest, MaxSize, Src, Length) AsciiStrnCpyS (Dest, MaxSize, Src, Length)
|
---|
78 | #define strcmp OnigStrCmp
|
---|
79 |
|
---|
80 | int
|
---|
81 | OnigStrCmp (
|
---|
82 | const char *Str1,
|
---|
83 | const char *Str2
|
---|
84 | );
|
---|
85 |
|
---|
86 | int EFIAPI
|
---|
87 | sprintf_s (
|
---|
88 | char *str,
|
---|
89 | size_t sizeOfBuffer,
|
---|
90 | char const *fmt,
|
---|
91 | ...
|
---|
92 | );
|
---|
93 |
|
---|
94 | int
|
---|
95 | strlen (
|
---|
96 | const char *str
|
---|
97 | );
|
---|
98 |
|
---|
99 | void *
|
---|
100 | malloc (
|
---|
101 | size_t size
|
---|
102 | );
|
---|
103 |
|
---|
104 | void *
|
---|
105 | realloc (
|
---|
106 | void *ptr,
|
---|
107 | size_t size
|
---|
108 | );
|
---|
109 |
|
---|
110 | #if !defined (MDE_CPU_ARM)
|
---|
111 | void *
|
---|
112 | memcpy (
|
---|
113 | void *dest,
|
---|
114 | const void *src,
|
---|
115 | unsigned int count
|
---|
116 | );
|
---|
117 |
|
---|
118 | #endif
|
---|
119 |
|
---|
120 | void *
|
---|
121 | memset (
|
---|
122 | void *dest,
|
---|
123 | int ch,
|
---|
124 | unsigned int count
|
---|
125 | );
|
---|
126 |
|
---|
127 | void
|
---|
128 | free (
|
---|
129 | void *ptr
|
---|
130 | );
|
---|
131 |
|
---|
132 | #define exit(n) ASSERT(FALSE);
|
---|
133 |
|
---|
134 | #endif // !ONIGURUMA_UEFI_PORT_H
|
---|