forked from xamidev/pepperOS
Function comments (v1)
This commit is contained in:
@@ -16,6 +16,19 @@
|
||||
// We use the "restrict" keyword on pointers so that the compiler knows it can
|
||||
// do more optimization on them (and as it's a much used function, it's good to
|
||||
// be able to do that)
|
||||
|
||||
/*
|
||||
* memcpy - Copy memory from one place to another
|
||||
* @dest: pointer to the destination region
|
||||
* @src: pointer to the source region
|
||||
* @n: amount of bytes to copy
|
||||
*
|
||||
* This function copies n bytes of memory from
|
||||
* src to dest.
|
||||
*
|
||||
* Return:
|
||||
* <dest> - Pointer to destination region
|
||||
*/
|
||||
void* memcpy(void* restrict dest, const void* restrict src, size_t n)
|
||||
{
|
||||
uint8_t* restrict pdest = (uint8_t* restrict)dest;
|
||||
@@ -28,6 +41,18 @@ void* memcpy(void* restrict dest, const void* restrict src, size_t n)
|
||||
return dest;
|
||||
}
|
||||
|
||||
/*
|
||||
* memset - Sets a memory region to given byte
|
||||
* @s: pointer to memory region
|
||||
* @c: byte to be written
|
||||
* @n: amount of bytes to write
|
||||
*
|
||||
* This function writes n times the byte c
|
||||
* to the memory region pointed to by s.
|
||||
*
|
||||
* Return:
|
||||
* <s> - Pointer to memory region
|
||||
*/
|
||||
void* memset(void* s, int c, size_t n)
|
||||
{
|
||||
uint8_t* p = (uint8_t*)s;
|
||||
@@ -39,6 +64,18 @@ void* memset(void* s, int c, size_t n)
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* memmove - Move memory from one place to another
|
||||
* @dest: pointer to the destination region
|
||||
* @src: pointer to the source region
|
||||
* @n: amount of bytes to move
|
||||
*
|
||||
* This function moves n bytes of memory from
|
||||
* src to dest.
|
||||
*
|
||||
* Return:
|
||||
* <dest> - Pointer to destination region
|
||||
*/
|
||||
void* memmove(void *dest, const void* src, size_t n)
|
||||
{
|
||||
uint8_t* pdest = (uint8_t*)dest;
|
||||
@@ -56,6 +93,20 @@ void* memmove(void *dest, const void* src, size_t n)
|
||||
return dest;
|
||||
}
|
||||
|
||||
/*
|
||||
* memcmp - Compare two memory regions
|
||||
* @s1: pointer to the first region
|
||||
* @s2: pointer to the second region
|
||||
* @n: amount of bytes to compare
|
||||
*
|
||||
* This function compares n bytes of memory
|
||||
* bewteen regions pointed to by s1 and s2.
|
||||
*
|
||||
* Return:
|
||||
* %0 - if s1 and s2 are equal
|
||||
* %-1 - if s1 is smaller than s2
|
||||
* %1 - if s1 is greater than s2
|
||||
*/
|
||||
int memcmp(const void* s1, const void* s2, size_t n)
|
||||
{
|
||||
const uint8_t* p1 = (const uint8_t*)s1;
|
||||
|
||||
Reference in New Issue
Block a user