]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / RegularExpressionDxe / OnigurumaUefiPort.h
1 /** @file
2
3 Module to rewrite stdlib references within Oniguruma
4
5 (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP<BR>
6 Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9 **/
10 #ifndef ONIGURUMA_UEFI_PORT_H
11 #define ONIGURUMA_UEFI_PORT_H
12
13 #include <Library/MemoryAllocationLib.h>
14 #include <Library/PrintLib.h>
15 #include <Library/BaseMemoryLib.h>
16 #include <Library/BaseLib.h>
17 #include <Library/DebugLib.h>
18
19
20 #define ONIG_NO_STANDARD_C_HEADERS
21 #define ONIG_NO_PRINT
22 #define P_(args) args
23
24 #define INT_MAX 0x7FFFFFFF
25 #define LONG_MAX 0x7FFFFFFF
26 #define UINT_MAX 0xFFFFFFFF
27 #define ULONG_MAX 0xFFFFFFFF
28
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 #ifdef MDE_CPU_IA32
41 #define SIZEOF_VOIDP 4
42 #endif
43
44 #ifdef MDE_CPU_X64
45 #define SIZEOF_VOIDP 8
46 #endif
47
48 #define calloc(n,s) AllocateZeroPool((n)*(s))
49
50 #define free(p) \
51 do { \
52 VOID *EvalOnce; \
53 \
54 EvalOnce = (p); \
55 if (EvalOnce != NULL) { \
56 FreePool (EvalOnce); \
57 } \
58 } while (FALSE)
59
60 #define xmemmove(Dest,Src,Length) CopyMem(Dest,Src,Length)
61 #define xmemcpy(Dest,Src,Length) CopyMem(Dest,Src,Length)
62 #define xmemset(Buffer,Value,Length) SetMem(Buffer,Length,Value)
63
64 #define va_init_list(a,b) VA_START(a,b)
65 #define va_list VA_LIST
66 #define va_arg(a,b) VA_ARG(a,b)
67 #define va_end(a) VA_END(a)
68 #define va_start VA_START
69
70 #define FILE VOID
71 #define stdout NULL
72 #define fprintf(...)
73 #define fputs(a,b)
74 #define vsnprintf (int)AsciiVSPrint
75 #define _vsnprintf vsnprintf
76 #define xsnprintf sprintf_s
77 #define xvsnprintf vsnprintf
78 #define alloca malloc
79
80 #define setlocale(a,b)
81 #define LC_ALL 0
82
83 #define UCHAR_MAX 255
84 #define MAX_STRING_SIZE 0x1000
85 #define strlen_s(String,MaxSize) AsciiStrnLenS (String, MaxSize)
86 #define xstrncpy(Dest, Src, MaxSize) strcat_s(Dest,MaxSize,Src)
87 #define xstrcat(Dest,Src,MaxSize) strcat(Dest,Src,MaxSize)
88 #define strcat(Dest,Src,MaxSize) strcat_s(Dest,MaxSize,Src)
89 #define strcat_s(Dest,MaxSize,Src) AsciiStrCatS (Dest, MaxSize, Src)
90 #define strncpy_s(Dest,MaxSize,Src,Length) AsciiStrnCpyS (Dest, MaxSize, Src, Length)
91 #define strcmp OnigStrCmp
92
93 int OnigStrCmp (const char* Str1, const char* Str2);
94
95 int EFIAPI sprintf_s (char *str, size_t sizeOfBuffer, char const *fmt, ...);
96 int strlen(const char* str);
97 void* malloc(size_t size);
98 void* realloc(void *ptr, size_t size);
99 void* memcpy (void *dest, const void *src, unsigned int count);
100 void* memset (void *dest, char ch, unsigned int count);
101
102 #define exit(n) ASSERT(FALSE);
103
104 #endif // !ONIGURUMA_UEFI_PORT_H