• 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 #ifndef EPID_MEMBER_TINY_STDLIB_TINY_STDLIB_H_
20 #define EPID_MEMBER_TINY_STDLIB_TINY_STDLIB_H_
21 
22 #include <stddef.h>
23 
24 /// Fill block of memory
25 /*!
26  * Sets the first num bytes of the block of memory pointed by ptr
27  * to the specified value (interpreted as an unsigned char)
28  *
29  * \param ptr Pointer to the block of memory to fill.
30  * \param value Value to be set. The value is passed as an int,
31  *        but the function fills the block of memory using the
32  *        unsigned char conversion of this value.
33  * \param num Number of bytes to be set to the value. size_t is
34  *        an unsigned integral type.
35  * \result ptr is returned.
36  */
37 void* memset(void* ptr, int value, size_t num);
38 
39 /// Compare two blocks of memory
40 /*!
41  * Compares the first num bytes of the block of memory pointed by
42  * ptr1 to the first num bytes pointed by ptr2, returning zero if
43  * they all match or a value different from zero representing which
44  * is greater if they do not.
45  *
46  * Notice that, unlike strcmp, the function does not stop comparing
47  * after finding a null character.
48  *
49  * \param ptr1 Pointer to block of memory.
50  * \param ptr2 Pointer to block of memory.
51  * \param num Number of bytes to compare.
52  * \result an integral value indicating the relationship between the
53  *         content of the memory blocks:
54  * \retval <0 the first byte that does not match in both memory
55  *            blocks has a lower value in ptr1 than in ptr2 (if
56  *            evaluated as unsigned char values)
57  * \retval 0 the contents of both memory blocks are equal
58  * \retval >0 the first byte that does not match in both memory blocks
59  *            has a greater value in ptr1 than in ptr2 (if evaluated
60  *            as unsigned char values)
61  */
62 int memcmp(const void* ptr1, const void* ptr2, size_t num);
63 
64 #endif  // EPID_MEMBER_TINY_STDLIB_TINY_STDLIB_H_
65