Home | History | Annotate | Download | only in Oniguruma
      1 /** @file
      2 
      3   Provide intrinsics within Oniguruma
      4 
      5   (C) Copyright 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 
     16 #include <Library/BaseMemoryLib.h>
     17 
     18 //
     19 // From CryptoPkg/IntrinsicLib
     20 //
     21 
     22 /* Copies bytes between buffers */
     23 #pragma function(memcpy)
     24 void * memcpy (void *dest, const void *src, unsigned int count)
     25 {
     26   return CopyMem (dest, src, (UINTN)count);
     27 }
     28 
     29 /* Sets buffers to a specified character */
     30 #pragma function(memset)
     31 void * memset (void *dest, char ch, unsigned int count)
     32 {
     33   //
     34   // NOTE: Here we use one base implementation for memset, instead of the direct
     35   //       optimized SetMem() wrapper. Because the IntrinsicLib has to be built
     36   //       without whole program optimization option, and there will be some
     37   //       potential register usage errors when calling other optimized codes.
     38   //
     39 
     40   //
     41   // Declare the local variables that actually move the data elements as
     42   // volatile to prevent the optimizer from replacing this function with
     43   // the intrinsic memset()
     44   //
     45   volatile UINT8  *Pointer;
     46 
     47   Pointer = (UINT8 *)dest;
     48   while (count-- != 0) {
     49     *(Pointer++) = ch;
     50   }
     51 
     52   return dest;
     53 }
     54