Home | History | Annotate | Download | only in Oniguruma
      1 /** @file
      2 
      3   Module to rewrite stdlib references within Oniguruma
      4 
      5   (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP<BR>
      6 
      7   This program and the accompanying materials are licensed and made available
      8   under the terms and conditions of the BSD License that accompanies this
      9   distribution.  The full text of the license may be found at
     10   http://opensource.org/licenses/bsd-license.php.
     11 
     12   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
     13   WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     14 **/
     15 #ifndef ONIGURUMA_UEFI_PORT_H
     16 #define ONIGURUMA_UEFI_PORT_H
     17 
     18 #include <Library/MemoryAllocationLib.h>
     19 #include <Library/PrintLib.h>
     20 #include <Library/BaseMemoryLib.h>
     21 #include <Library/BaseLib.h>
     22 #include <Library/DebugLib.h>
     23 
     24 #undef _WIN32
     25 #define P_(args) args
     26 
     27 #define SIZEOF_LONG sizeof(long)
     28 #define SIZEOF_INT  sizeof(int)
     29 typedef UINTN size_t;
     30 
     31 #define malloc(n) AllocatePool(n)
     32 #define calloc(n,s) AllocateZeroPool((n)*(s))
     33 #define free(p) FreePool(p)
     34 #define realloc(OldPtr,NewSize,OldSize) ReallocatePool(OldSize,NewSize,OldPtr)
     35 #define xmemmove(Dest,Src,Length) CopyMem(Dest,Src,Length)
     36 #define xmemcpy(Dest,Src,Length) CopyMem(Dest,Src,Length)
     37 #define xmemset(Buffer,Value,Length) SetMem(Buffer,Length,Value)
     38 
     39 #define va_init_list(a,b) VA_START(a,b)
     40 #define va_list VA_LIST
     41 #define va_arg(a,b) VA_ARG(a,b)
     42 #define va_end(a) VA_END(a)
     43 
     44 #define FILE VOID
     45 #define stdout NULL
     46 #define fprintf(...)
     47 #define fputs(a,b)
     48 #define vsnprintf (int)AsciiVSPrint
     49 #define _vsnprintf vsnprintf
     50 
     51 #define setlocale(a,b)
     52 #define LC_ALL 0
     53 
     54 #define MAX_STRING_SIZE 0x1000
     55 #define strlen_s(String,MaxSize)            AsciiStrnLenS (String, MaxSize)
     56 #define strcat_s(Dest,MaxSize,Src)          AsciiStrCatS (Dest, MaxSize, Src)
     57 #define strncpy_s(Dest,MaxSize,Src,Length)  AsciiStrnCpyS (Dest, MaxSize, Src, Length)
     58 #define strcmp                              OnigStrCmp
     59 
     60 int OnigStrCmp (char* Str1, char* Str2);
     61 
     62 int sprintf_s (char *str, size_t sizeOfBuffer, char const *fmt, ...);
     63 
     64 #define exit(n) ASSERT(FALSE);
     65 
     66 #endif // !ONIGURUMA_UEFI_PORT_H
     67