My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
libc_sos.c File Reference
#include "libc_sos.h"
#include "sw_types.h"
#include "sw_buddy.h"
#include "fat32.h"
#include "sw_mem_functions.h"
#include "sw_string_functions.h"
#include "sw_debug.h"
#include "otz_api.h"
#include "sw_syscall.h"

Macros

#define MIN(x, y)   ((y) ^ (((x) ^ (y)) & -((x) < (y))))
 

Functions

void * memmove (void *dest, const void *src, u32 count)
 
void * memset (void *dest, u32 c, u32 count)
 copies the character c to the first n characters of the string pointed to dest More...
 
void * memcpy (void *dst, const void *src, u32 count)
 copies count characters from memory area src to dest More...
 
void * malloc (u32 size)
 allocates the requested size of memory and returns a pointer to it More...
 
void * realloc (void *ptr, u32 size)
 Resizes the memory block pointed to by ptr to size that was previously allocated by malloc or calloc. More...
 
void * calloc (u32 num_elements, u32 element_size)
 allocates the requested memory and returns a pointer to it and sets the memory to zero More...
 
void free (void *ptr)
 Deallocates the memory previously allocated. More...
 
int strncmp (const char *s1, const char *s2, u32 n)
 compares the first n characters of string s1 and string s2 More...
 
u32 atoi (const char *ptr)
 converts the string argument pointed to ptr to integer More...
 
u32 strlen (const char *ptr)
 computes and returns the length of the string pointed to ptr More...
 
char * strcpy (char *ptr1, const char *ptr2)
 copies the string pointed to by ptr2 to ptr1 More...
 
int strcmp (const char *ptr1, const char *ptr2)
 compares the string pointed to by ptr1 to the string pointed to by ptr2 More...
 
char * strcat (char *ptr1, const char *ptr2)
 appends the string pointed to by ptr2 to the end of string pointed to by dest More...
 
s32int pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attribute)
 initializes the mutex parameters More...
 
s32int pthread_mutex_destroy (pthread_mutex_t *mutex)
 This function is called to destroy the mutex once it is used If it is under lock it returns an error code init param is reinitialized to zero. More...
 
s32int pthread_mutex_lock (pthread_mutex_t *mutex)
 This function is called to lock the specified mutex. More...
 
s32int pthread_mutex_unlock (pthread_mutex_t *mutex)
 This function is called to unlock a mutex. More...
 
s32int pthread_mutex_trylock (pthread_mutex_t *mutex)
 Same as sw_mutex_lock but it does not block the calling function It returns an error code if the mutex is already locked. More...
 
s32int sem_init (sem_t *sem, s32int shared, u32 value)
 Semaphore initialization Following successful call, other semaphore operations can be performed until semaphore is destroyed. More...
 
s32int sem_wait (sem_t *sem)
 Locks the semaphore referenced by sem It will return to the calling thread only after locking the semaphore or if the call is interrupted by a signal. More...
 
s32int sem_post (sem_t *sem)
 unlocks the semaphore referenced by sem by performing a unlock operation on that semaphore More...
 
s32int sem_destroy (sem_t *sem)
 Destroys the semaphore indicated by sem. More...
 
s32int sem_getvalue (sem_t *sem, s32int *value)
 This function is called to get the semaphore value. More...
 
void sleep (u32 seconds)
 suspends action for a specified interval of time More...
 
void usleep (u32 seconds)
 suspends action for micro second intervals More...
 
int truncate (const char *tr_path, long tr_lth)
 truncate - function cause the regular file named by path to be truncated to a size of precisely length bytes More...
 
int rename (const char *old_name, const char *new_name)
 rename - Changes the name of the file or directory specified by oldname to newname More...
 

Macro Definition Documentation

#define MIN (   x,
 
)    ((y) ^ (((x) ^ (y)) & -((x) < (y))))

Function Documentation

u32 atoi ( const char *  ptr)

converts the string argument pointed to ptr to integer

Parameters
ptr
Returns
void* calloc ( u32  num_elements,
u32  element_size 
)

allocates the requested memory and returns a pointer to it and sets the memory to zero

Parameters
num_elements
element_size
Returns
void free ( void *  ptr)

Deallocates the memory previously allocated.

Parameters
ptr
void* malloc ( u32  size)

allocates the requested size of memory and returns a pointer to it

Parameters
size
Returns
void* memcpy ( void *  dst,
const void *  src,
u32  count 
)

copies count characters from memory area src to dest

Parameters
dst
src
count
Returns
void* memmove ( void *  dest,
const void *  src,
u32  count 
)
void* memset ( void *  dest,
u32  c,
u32  count 
)

copies the character c to the first n characters of the string pointed to dest

Parameters
dest
c
count
Returns
s32int pthread_mutex_destroy ( pthread_mutex_t mutex)

This function is called to destroy the mutex once it is used If it is under lock it returns an error code init param is reinitialized to zero.

Parameters
mutex
Returns
s32int pthread_mutex_init ( pthread_mutex_t mutex,
const pthread_mutexattr_t attribute 
)

initializes the mutex parameters

Parameters
mutex
attribute
Returns
s32int pthread_mutex_lock ( pthread_mutex_t mutex)

This function is called to lock the specified mutex.

Parameters
mutex
Returns
s32int pthread_mutex_trylock ( pthread_mutex_t mutex)

Same as sw_mutex_lock but it does not block the calling function It returns an error code if the mutex is already locked.

Parameters
mutex
Returns
s32int pthread_mutex_unlock ( pthread_mutex_t mutex)

This function is called to unlock a mutex.

Parameters
mutex
Returns
void* realloc ( void *  ptr,
u32  size 
)

Resizes the memory block pointed to by ptr to size that was previously allocated by malloc or calloc.

Parameters
ptr
size
Returns
int rename ( const char *  old_name,
const char *  new_name 
)

rename - Changes the name of the file or directory specified by oldname to newname

Parameters
old_name-string containing the name of an existing file to be renamed
new_name-string containing the new name for the file
Returns
- If the file is successfully renamed, a zero value is returned. On failure, a nonzero value is returned
s32int sem_destroy ( sem_t sem)

Destroys the semaphore indicated by sem.

Parameters
sem
Returns
s32int sem_getvalue ( sem_t sem,
s32int *  value 
)

This function is called to get the semaphore value.

Parameters
sem
value
Returns
s32int sem_init ( sem_t sem,
s32int  shared,
u32  value 
)

Semaphore initialization Following successful call, other semaphore operations can be performed until semaphore is destroyed.

Parameters
sem
shared
value
Returns
s32int sem_post ( sem_t sem)

unlocks the semaphore referenced by sem by performing a unlock operation on that semaphore

Parameters
sem
Returns
s32int sem_wait ( sem_t sem)

Locks the semaphore referenced by sem It will return to the calling thread only after locking the semaphore or if the call is interrupted by a signal.

Parameters
sem
Returns
void sleep ( u32  seconds)

suspends action for a specified interval of time

Parameters
seconds
Returns
char* strcat ( char *  ptr1,
const char *  ptr2 
)

appends the string pointed to by ptr2 to the end of string pointed to by dest

Parameters
ptr1
ptr2
Returns
int strcmp ( const char *  ptr1,
const char *  ptr2 
)

compares the string pointed to by ptr1 to the string pointed to by ptr2

Parameters
ptr1
ptr2
Returns
char* strcpy ( char *  ptr1,
const char *  ptr2 
)

copies the string pointed to by ptr2 to ptr1

Parameters
ptr1
ptr2
Returns
u32 strlen ( const char *  ptr)

computes and returns the length of the string pointed to ptr

Parameters
ptr
Returns
int strncmp ( const char *  s1,
const char *  s2,
u32  n 
)

compares the first n characters of string s1 and string s2

Parameters
s1
s2
n
Returns
equal to zero if s1 equals s2 less than zero if s1 is less than s2 greater than zero if s1 greater than s2
int truncate ( const char *  tr_path,
long  tr_lth 
)

truncate - function cause the regular file named by path to be truncated to a size of precisely length bytes

Parameters
tr_path- truncates the file whose name is specified in filename
tr_lth- The desired truncate size of the file in bytes
Returns
- If the file contents is successfully truncated, a zero value is returned.On failure, non-Zero is returned
void usleep ( u32  seconds)

suspends action for micro second intervals

Parameters
seconds
Returns