Embedded Artistry Framework
Embedded Systems C++ Framework
Macros | Functions | Variables
strlen.c File Reference
#include <limits.h>
#include <string.h>
Include dependency graph for strlen.c:

Macros

#define LONGPTR_MASK   (sizeof(long) - 1)
 
#define testbyte(x)
 

Functions

size_t strlen (const char *str)
 Returns the length of the given null-terminated byte string. More...
 

Variables

static const unsigned long mask01 = 0x0101010101010101
 
static const unsigned long mask80 = 0x8080808080808080
 

Macro Definition Documentation

◆ LONGPTR_MASK

#define LONGPTR_MASK   (sizeof(long) - 1)

◆ testbyte

#define testbyte (   x)
Value:
do \
{ \
if(p[x] == '\0') \
return ((uintptr_t)p - (uintptr_t)str + x); \
} while(0)
unsigned long uintptr_t
Definition: _uintptr_t.h:4
static void * p[ALLOCATION_TEST_COUNT]
Definition: malloc_freelist.c:21

Function Documentation

◆ strlen()

size_t strlen ( const char *  str)

Returns the length of the given null-terminated byte string.

Returns the length of the given null-terminated byte string, that is, the number of characters in a character array whose first element is pointed to by str up to and not including the first null character.

The behavior is undefined if str is not a pointer to a null-terminated byte string.

Parameters
strpointer to the null-terminated byte string to be examined
Returns
The length of the null-terminated byte string str.

References LONGPTR_MASK, mask01, mask80, p, and testbyte.

Referenced by __strchrnul(), char_test(), embvm::basicDisplay::printString(), strcat(), strcat_test(), strcpy(), strdup(), strdup_test(), strerror_r(), strlen_test(), strncat(), strndup_test(), strnstr(), strrchr(), strxfrm(), and TEST_CASE().

Here is the caller graph for this function:

Variable Documentation

◆ mask01

const unsigned long mask01 = 0x0101010101010101
static

Referenced by strlen().

◆ mask80

const unsigned long mask80 = 0x8080808080808080
static

Referenced by strlen().