]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h
0bdb7be52952379f506c9a2f8f0ed684abcd9ae3
[mirror_edk2.git] / MdeModulePkg / Universal / RegularExpressionDxe / OnigurumaUefiPort.h
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
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 #define xmemmove(Dest,Src,Length) CopyMem(Dest,Src,Length)
50 #define xmemcpy(Dest,Src,Length) CopyMem(Dest,Src,Length)
51 #define xmemset(Buffer,Value,Length) SetMem(Buffer,Length,Value)
52
53 #define va_init_list(a,b) VA_START(a,b)
54 #define va_list VA_LIST
55 #define va_arg(a,b) VA_ARG(a,b)
56 #define va_end(a) VA_END(a)
57 #define va_start VA_START
58
59 #define FILE VOID
60 #define stdout NULL
61 #define fprintf(...)
62 #define fputs(a,b)
63 #define vsnprintf (int)AsciiVSPrint
64 #define _vsnprintf vsnprintf
65 #define xsnprintf sprintf_s
66 #define xvsnprintf vsnprintf
67 #define alloca malloc
68
69 #define setlocale(a,b)
70 #define LC_ALL 0
71
72 #define UCHAR_MAX 255
73 #define MAX_STRING_SIZE 0x1000
74 #define strlen_s(String,MaxSize) AsciiStrnLenS (String, MaxSize)
75 #define xstrncpy(Dest, Src, MaxSize) strcat_s(Dest,MaxSize,Src)
76 #define xstrcat(Dest,Src,MaxSize) strcat(Dest,Src,MaxSize)
77 #define strcat(Dest,Src,MaxSize) strcat_s(Dest,MaxSize,Src)
78 #define strcat_s(Dest,MaxSize,Src) AsciiStrCatS (Dest, MaxSize, Src)
79 #define strncpy_s(Dest,MaxSize,Src,Length) AsciiStrnCpyS (Dest, MaxSize, Src, Length)
80 #define strcmp OnigStrCmp
81
82 int OnigStrCmp (const char* Str1, const char* Str2);
83
84 int EFIAPI sprintf_s (char *str, size_t sizeOfBuffer, char const *fmt, ...);
85 int strlen(const char* str);
86 void* malloc(size_t size);
87 void* realloc(void *ptr, size_t size);
88 void* memcpy (void *dest, const void *src, unsigned int count);
89 void* memset (void *dest, char ch, unsigned int count);
90 void free(void *ptr);
91
92 #define exit(n) ASSERT(FALSE);
93
94 #endif // !ONIGURUMA_UEFI_PORT_H