• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*############################################################################
2   # Copyright 2017 Intel Corporation
3   #
4   # Licensed under the Apache License, Version 2.0 (the "License");
5   # you may not use this file except in compliance with the License.
6   # You may obtain a copy of the License at
7   #
8   #     http://www.apache.org/licenses/LICENSE-2.0
9   #
10   # Unless required by applicable law or agreed to in writing, software
11   # distributed under the License is distributed on an "AS IS" BASIS,
12   # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   # See the License for the specific language governing permissions and
14   # limitations under the License.
15   ############################################################################*/
16 /// Tiny portable implementations of standard library functions
17 /*! \file */
18 
19 #include "epid/member/tiny/stdlib/tiny_stdlib.h"
20 
21 #ifdef SHARED
22 
memset(void * ptr,int value,size_t num)23 void* memset(void* ptr, int value, size_t num) {
24   unsigned char* p = ptr;
25   size_t i = num;
26   while (i != 0) {
27     i -= 1;
28     p[i] = (unsigned char)value;
29   }
30   return ptr;
31 }
32 
memcmp(const void * ptr1,const void * ptr2,size_t num)33 int memcmp(const void* ptr1, const void* ptr2, size_t num) {
34   const unsigned char* p1 = (const unsigned char*)ptr1;
35   const unsigned char* p2 = (const unsigned char*)ptr2;
36   int d = 0;
37   while (num != 0 && d == 0) {
38     d = (*p1 == *p2) ? 0 : ((*p1 < *p2) ? -1 : 1);
39     p1 += 1;
40     p2 += 1;
41     num -= 1;
42   }
43   return d;
44 }
45 
46 #endif  // SHARED
47