]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaIntrinsics.c
MdeModulePkg/RegularExpressionDxe: Make oniguruma a submodule in edk2.
[mirror_edk2.git] / MdeModulePkg / Universal / RegularExpressionDxe / OnigurumaIntrinsics.c
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaIntrinsics.c b/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaIntrinsics.c
new file mode 100644 (file)
index 0000000..536c7e0
--- /dev/null
@@ -0,0 +1,48 @@
+/** @file\r
+\r
+  Provide intrinsics within Oniguruma\r
+\r
+  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+//\r
+// From CryptoPkg/IntrinsicLib\r
+//\r
+\r
+/* Copies bytes between buffers */\r
+#pragma function(memcpy)\r
+void * memcpy (void *dest, const void *src, unsigned int count)\r
+{\r
+  return CopyMem (dest, src, (UINTN)count);\r
+}\r
+\r
+/* Sets buffers to a specified character */\r
+#pragma function(memset)\r
+void * memset (void *dest, char ch, unsigned int count)\r
+{\r
+  //\r
+  // NOTE: Here we use one base implementation for memset, instead of the direct\r
+  //       optimized SetMem() wrapper. Because the IntrinsicLib has to be built\r
+  //       without whole program optimization option, and there will be some\r
+  //       potential register usage errors when calling other optimized codes.\r
+  //\r
+\r
+  //\r
+  // Declare the local variables that actually move the data elements as\r
+  // volatile to prevent the optimizer from replacing this function with\r
+  // the intrinsic memset()\r
+  //\r
+  volatile UINT8  *Pointer;\r
+\r
+  Pointer = (UINT8 *)dest;\r
+  while (count-- != 0) {\r
+    *(Pointer++) = ch;\r
+  }\r
+\r
+  return dest;\r
+}\r