Phoenix
Object-oriented orthogonally persistent operating system
Functions
CommonLib.cpp File Reference

Run-time mid-level support functions. More...

#include <sys.h>
Include dependency graph for CommonLib.cpp:

Functions

ASMCALL void * memset (void *dst, u8 value, size_t size)
 Fill block of memory.
ASMCALL void * memcpy (void *dst, const void *src, size_t size)
 Copy block of memory.
ASMCALL void * memmove (void *dst, const void *src, size_t size)
 Move block of memory.
ASMCALL int memcmp (const void *ptr1, const void *ptr2, size_t size)
 Compare two blocks of memory.
ASMCALL void * memchr (void *ptr, int value, size_t size)
 Locate character in block of memory.
ASMCALL int toupper (int c)
 Convert ASCII character to upper case.
ASMCALL int tolower (int c)
 Convert ASCII character to lower case.
ASMCALL bool isalnum (int c)
 Check if ASCII character belongs to alphanumeric class.
ASMCALL bool isalpha (int c)
 Check if ASCII character is alphabetic.
ASMCALL bool iscntrl (int c)
 Check is ASCII character is control character.
ASMCALL bool isdigit (int c)
 Check if ASCII character is digit.
ASMCALL bool isgraph (int c)
 Check if ASCII character is pseudo-graphical character.
ASMCALL bool islower (int c)
 Check if ASCII character is lower case alphabetical character.
ASMCALL bool isprint (int c)
 Check if ASCII character is printable.
ASMCALL bool ispunct (int c)
 Check if ASCII character is punctuation character.
ASMCALL bool isspace (int c)
 Check if ASCII character is space character.
ASMCALL bool isupper (int c)
 Check if ASCII character is upper case alphabetical character.
ASMCALL bool isxdigit (int c)
 Check if ASCII character is hexadecimal digit.
ASMCALL bool isascii (int c)
 Check if ASCII character belongs to low part half of ASCII table.
int sscanf (const char *str, const char *fmt,...)
 Parse string into provided variables.
int vsscanf (const char *str, char const *fmt, va_list ap)
 Parse string into provided variables.

Detailed Description

Run-time mid-level support functions.

This file contains definitions for C run-time support functions.


Function Documentation

ASMCALL bool isalnum ( int  c)

Check if ASCII character belongs to alphanumeric class.

ASMCALL bool isalpha ( int  c)

Check if ASCII character is alphabetic.

ASMCALL bool isascii ( int  c)

Check if ASCII character belongs to low part half of ASCII table.

ASMCALL bool iscntrl ( int  c)

Check is ASCII character is control character.

ASMCALL bool isdigit ( int  c)

Check if ASCII character is digit.

ASMCALL bool isgraph ( int  c)

Check if ASCII character is pseudo-graphical character.

ASMCALL bool islower ( int  c)

Check if ASCII character is lower case alphabetical character.

ASMCALL bool isprint ( int  c)

Check if ASCII character is printable.

ASMCALL bool ispunct ( int  c)

Check if ASCII character is punctuation character.

ASMCALL bool isspace ( int  c)

Check if ASCII character is space character.

ASMCALL bool isupper ( int  c)

Check if ASCII character is upper case alphabetical character.

ASMCALL bool isxdigit ( int  c)

Check if ASCII character is hexadecimal digit.

ASMCALL void* memchr ( void *  ptr,
int  value,
size_t  size 
)

Locate character in block of memory.

Searches within the first size bytes of the block of memory pointed by ptr for the first occurrence of value (interpreted as an unsigned char), and returns a pointer to it.

Parameters:
ptrPointer to the block of memory where the search is performed.
valueValue to be located. The value is passed as an int, but the function performs a byte per byte search using the unsigned char conversion of this value.
sizeNumber of bytes to be analyzed.
Returns:
A pointer to the first occurrence of value in the block of memory pointed by ptr. If the value is not found, the function returns 0.
ASMCALL int memcmp ( const void *  ptr1,
const void *  ptr2,
size_t  size 
)

Compare two blocks of memory.

Compares the first size bytes of the block of memory pointed by ptr1 to the first size bytes pointed by ptr2, returning zero if they all match or a value different from zero representing which is greater if they do not.

Parameters:
ptr1Pointer to block of memory.
ptr2Pointer to block of memory.
sizeNumber of bytes to compare.
Returns:
Returns an integral value indicating the relationship between the content of the memory blocks:
  • A zero value indicates that the contents of both memory blocks are equal.
  • A value greater than zero indicates that the first byte that does not match in both memory blocks has a greater value in ptr1 than in ptr2 as if evaluated as unsigned char values; And a value less than zero indicates the opposite.
ASMCALL void* memcpy ( void *  dst,
const void *  src,
size_t  size 
)

Copy block of memory.

Copies the values of size bytes from the location pointed by src directly to the memory block pointed by dst.

The underlying type of the objects pointed by both the source and destination pointers are irrelevant for this function; The result is a binary copy of the data.
The function does not check for any terminating null character in source - it always copies exactly size bytes.
To avoid overflows, the size of the arrays pointed by both the destination and source parameters, shall be at least size bytes, and should not overlap (for overlapping memory blocks, memmove is a safer approach).
Parameters:
dstPointer to the destination array where the content is to be copied, type-casted to a pointer of type void*.
srcPointer to the source of data to be copied, type-casted to a pointer of type void*.
sizeNumber of bytes to copy.
Returns:
dst is returned.
ASMCALL void* memmove ( void *  dst,
const void *  src,
size_t  size 
)

Move block of memory.

Copies the values of size bytes from the location pointed by src to the memory block pointed by dst. Copying takes place as if an intermediate buffer were used, allowing the destination and source to overlap.

The underlying type of the objects pointed by both the source and destination pointers are irrelevant for this function; The result is a binary copy of the data.
The function does not check for any terminating null character in source - it always copies exactly size bytes.
To avoid overflows, the size of the arrays pointed by both the destination and source parameters, shall be at least size bytes.
Parameters:
dstPointer to the destination array where the content is to be copied, type-casted to a pointer of type void*.
srcPointer to the source of data to be copied, type-casted to a pointer of type const void*.
sizeNumber of bytes to copy.
Returns:
dst is returned.
ASMCALL void* memset ( void *  dst,
u8  value,
size_t  size 
)

Fill block of memory.

Sets the first size bytes of the block of memory pointed by dst to the specified value (interpreted as an unsigned char).

Parameters:
dstPointer to the block of memory to fill.
valueValue to be set. The value is passed as an int, but the function fills the block of memory using the unsigned char conversion of this value.
sizeNumber of bytes to be set to the value.
int sscanf ( const char *  str,
const char *  fmt,
  ... 
)

Parse string into provided variables.

Parameters:
strNull terminated input string.
fmtFormat specifier for input string parsing.
Returns:
Number of variables assigned.
ASMCALL int tolower ( int  c)

Convert ASCII character to lower case.

ASMCALL int toupper ( int  c)

Convert ASCII character to upper case.

int vsscanf ( const char *  str,
char const *  fmt,
va_list  ap 
)

Parse string into provided variables.

Parameters:
strNull terminated input string.
fmtFormat specifier for input string parsing.
apArguments list with pointer to variables to assign values to.
Returns:
Number of variables assigned.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines