mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-15 01:23:49 +01:00
78 lines
1.8 KiB
C
78 lines
1.8 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2022 Otto-von-Guericke-Universität Magdeburg
|
|
* SPDX-License-Identifier: LGPL-2.1-only
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
/**
|
|
* @addtogroup cpu_atmega_common
|
|
*
|
|
* This is header file provides `strings.h` that is missing in AVR libc for
|
|
* compatibility.
|
|
*
|
|
* @{
|
|
*
|
|
* @file
|
|
* @brief strings.h
|
|
*
|
|
* @author Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
|
*/
|
|
|
|
#include <string.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* @brief Same as `memset(dest, 0, n_bytes)`, use `memset()` instead
|
|
*
|
|
* @param[in,out] dest Memory to clear
|
|
* @param[in] n_bytes Size of memory to clear in bytes
|
|
*/
|
|
static inline void bzero(void *dest, size_t n_bytes)
|
|
{
|
|
memset(dest, 0, n_bytes);
|
|
}
|
|
|
|
/**
|
|
* @brief Same as `memcmp()`, use `memcmp` instead
|
|
*
|
|
* @param[in] s1 first memory chunk to compare
|
|
* @param[in] s2 second memory chunk to compare
|
|
* @param[in] n number of bytes to compare
|
|
*
|
|
* @retval `0` The first @p n bytes of @p s1 and @p s2 are equal
|
|
* @retval `!=0` The first @p n bytes of @p s1 and @p s2 differ in at least
|
|
* one bit
|
|
*/
|
|
static inline int bcmp(const void *s1, const void *s2, size_t n)
|
|
{
|
|
return memcmp(s1, s2, n);
|
|
}
|
|
|
|
/**
|
|
* @brief Same as `memmove()`, use `memmove()` or `memcpy()` instead
|
|
*
|
|
* @param[in] src memory to copy from
|
|
* @param[out] dest memory to copy to
|
|
* @param[in] n number of bytes to copy
|
|
*
|
|
* @details @p src and @p dest may overlap
|
|
*
|
|
* @note It is preferred to use the standardize function `memcpy()` for
|
|
* non-overlapping memory regions and `memmove()` for overlapping
|
|
* memory regions instead of this obsolete function.
|
|
*/
|
|
static inline void bcopy(const void *src, void *dest, size_t n)
|
|
{
|
|
memmove(dest, src, n);
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
/** @} */
|