SWILIB API (ELKA)    
Loading...
Searching...
No Matches
libc.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef __IN_SWILIB__
4#include "base.h"
5#endif
6
7#include <stdarg.h>
8
10
32#ifdef SWILIB_LIBC
33
34#ifndef __JMPBUF_DECL
35#define __JMPBUF_DECL
36typedef int jmp_buf[11];
37#endif
38
50__swi_begin(0x014)
51void *malloc(size_t size)
52__swi_end(0x014, malloc, (size));
53
61__swi_begin(0x092)
62void *calloc(size_t count, size_t size)
63__swi_end(0x092, calloc, (count, size));
64
73__swi_begin(0x0BA)
74void *realloc(void *ptr, size_t size)
75__swi_end(0x0BA, realloc, (ptr, size));
76
81__swi_begin(0x015)
82void free(void *ptr)
83__swi_end(0x015, free, (ptr));
84
85#endif /* SWILIB_LIBC */
86
87/* ----------------------------------------- */
88
93__swi_begin(0x015)
94void mfree(void *ptr)
95__swi_end(0x015, mfree, (ptr));
96
101__swi_begin(0x8014)
102void *malloc_adr(void)
103__swi_end(0x8014, malloc_adr, ());
104
109__swi_begin(0x8015)
110void *mfree_adr(void)
111__swi_end(0x8015, mfree_adr, ());
112
117__swi_begin(0x80BA)
118void *realloc_adr(void)
119__swi_end(0x80BA, realloc_adr, ());
120
121/* ----------------------------------------- */
122
123#ifdef SWILIB_LIBC
124
141__swi_begin(0x11C)
142int memcmp(const void *ptr1, const void *ptr2, size_t num)
143__swi_end(0x11C, memcmp, (ptr1, ptr2, num));
144
152__swi_begin(0x03B)
153void *memchr(const void *str, int c, size_t num)
154__swi_end(0x03B, memchr, (str, c, num));
155
156#endif /* SWILIB_LIBC */
157
158/* ----------------------------------------- */
159
165__swi_begin(0x11D)
166void zeromem(void *ptr, int num)
167__swi_end(0x11D, zeromem, (ptr, num));
168
169/* ----------------------------------------- */
170
171#ifdef SWILIB_LIBC
172
177__swi_begin(0x11D)
178void bzero(void *ptr, int num)
179__swi_end(0x11D, bzero, (ptr, num));
180
188__swi_begin(0x0BB)
189void *memset(void *ptr, int val, size_t num)
190__swi_end(0x0BB, memset, (ptr, val, num));
191
199__swi_begin(0x11E)
200void *memcpy(void *destination, const void *source, size_t num)
201__swi_end(0x11E, memcpy, (destination, source, num));
202
210__swi_begin(0x132)
211void *memmove(void *destination, const void *source, size_t num)
212__swi_end(0x132, memmove, (destination, source, num));
213
230__swi_returns_twice_end(0x162, setjmp, (env));
231
238void longjmp(jmp_buf env, int val)
239__swi_noreturn_end(0x229, longjmp, (env, val));
240
252__swi_begin(0x206)
253void srand(uint32_t seed)
254__swi_end(0x206, srand, (seed));
255
260__swi_begin(0x07E)
261int rand(void)
262__swi_end(0x07E, rand, ());
263
282__swi_format(printf, 3, 4)
283int snprintf(char *s, size_t n, const char *format, ...)
284__swi_variadic_end(0x11B, snprintf, s, n, format);
285
295__swi_format(printf, 2, 3)
296int sprintf(char *s, const char *format, ...)
297__swi_variadic_end(0x016, sprintf, s, format);
298
306__swi_begin(0x3FE)
307__swi_format(printf, 2, 0)
308int vsprintf(char *s, const char *format, va_list args)
309__swi_end(0x3FE, vsprintf, (s, format, args));
310
320__swi_begin(0x3FF)
321__swi_format(printf, 3, 0)
322int vsnprintf(char *s, size_t n, const char *format, va_list args)
323__swi_end(0x3FF, vsnprintf, (s, n, format, args));
324
334__swi_format(scanf, 2, 3)
335int sscanf(const char *s, const char *format, ...)
336__swi_variadic_end(0x1F5, sscanf, s, format);
337
351__swi_begin(0x018)
352char *strchr(const char *str, int character)
353__swi_end(0x018, strchr, (str, character));
354
363__swi_begin(0x019)
364int strcmp(const char *str1, const char *str2)
365__swi_end(0x019, strcmp, (str1, str2));
366
375__swi_begin(0x085)
376int strcasecmp(const char *str1, const char *str2)
377__swi_end(0x085, strcasecmp, (str1, str2));
378
379#endif /* SWILIB_LIBC */
380
381/* ----------------------------------------- */
382
391__swi_begin(0x085)
392int strcmpi(const char *str1, const char *str2)
393__swi_end(0x085, strcmpi, (str1, str2));
394
395/* ----------------------------------------- */
396
397#ifdef SWILIB_LIBC
398
404__swi_begin(0x01B)
405size_t strlen(const char *str)
406__swi_end(0x01B, strlen, (str));
407
415__swi_begin(0x113)
416size_t strcspn(const char *str1, const char *str2)
417__swi_end(0x113, strcspn, (str1, str2));
418
425__swi_begin(0x017)
426char *strcat(char *destination, const char *source)
427__swi_end(0x017, strcat, (destination, source));
428
436__swi_begin(0x114)
437char *strncat(char *destination, const char *source, size_t num)
438__swi_end(0x114, strncat, (destination, source, num));
439
447__swi_begin(0x115)
448int strncmp(const char *str1, const char *str2, size_t num)
449__swi_end(0x115, strncmp, (str1, str2, num));
450
457__swi_begin(0x01A)
458char *strcpy(char *destination, const char *source)
459__swi_end(0x01A, strcpy, (destination, source));
460
468__swi_begin(0x116)
469char *strncpy(char *destination, const char *source, size_t num)
470__swi_end(0x116, strncpy, (destination, source, num));
471
478__swi_begin(0x117)
479char *strrchr(const char *str, int character)
480__swi_end(0x117, strrchr, (str, character));
481
488__swi_begin(0x118)
489char *strstr(const char *str1, const char *str2)
490__swi_end(0x118, strstr, (str1, str2));
491
501__swi_begin(0x119)
502long int strtol(const char *str, char **endptr, int base)
503__swi_end(0x119, strtol, (str, endptr, base));
504
515__swi_begin(0x11A)
516unsigned long strtoul(const char *str, char **endptr, int base)
517__swi_end(0x11A, strtoul, (str, endptr, base));
518
533__swi_begin(0x3AA)
534void qsort(void *first, size_t nitems, size_t size, int (*comparator)(const void *, const void *))
535__swi_end(0x3AA, qsort, (first, nitems, size, comparator));
536
546__swi_begin(0x3AB)
547void *bsearch(const void *key, const void *first, size_t nitems, size_t size, int (*comparator)(const void *, const void *))
548__swi_end(0x3AB, bsearch, (key, first, nitems, size, comparator));
549
565__swi_begin(0x2F2)
566int setenv(const char *name, const char *value, int replace)
567__swi_end(0x2F2, setenv, (name, value, replace));
568
575__swi_begin(0x2F3)
576int unsetenv(const char *name)
577__swi_end(0x2F3, unsetenv, (name));
578
585__swi_begin(0x2F4)
586char *getenv(const char *name)
587__swi_end(0x2F4, getenv, (name));
588
594__swi_begin(0x2F5)
595int clearenv(void)
596__swi_end(0x2F5, clearenv, ());
597
611__swi_begin(0x2EF)
612int dlopen(const char *name)
613__swi_end(0x2EF, dlopen, (name));
614
622__swi_begin(0x2F0)
623void *dlsym(int handle, const char *name)
624__swi_end(0x2F0, dlsym, (handle, name));
625
632__swi_begin(0x2F1)
633int dlclose(int handle)
634__swi_end(0x2F1, dlclose, (handle));
635
641__swi_begin(0x2F7)
642const char *dlerror(void)
643__swi_end(0x2F7, dlerror, ());
644
647#endif /* SWILIB_LIBC */
648
650
#define __swi_returns_twice_begin(number)
Definition doxygen.h:37
#define __swi_variadic_begin(number)
Definition doxygen.h:40
#define __swilib_begin
Definition doxygen.h:29
#define __swi_returns_twice_end(number, func, call)
Definition doxygen.h:38
#define __swi_end(number, func, call)
Definition doxygen.h:33
#define __swi_variadic_end(number, func,...)
Definition doxygen.h:41
#define __swi_noreturn_end(number, func, call)
Definition doxygen.h:36
#define __swi_format(type,...)
Definition doxygen.h:45
#define __swi_begin(number)
Definition doxygen.h:32
#define __swi_noreturn_begin(number)
Definition doxygen.h:35
#define __swilib_end
Definition doxygen.h:30
size_t strlen(const char *str)
Get string length.
void longjmp(jmp_buf env, int val)
Long jump.
void * memset(void *ptr, int val, size_t num)
Fill block of memory with zero.
int setjmp(jmp_buf env)
Save calling environment for long jump.
char * strncpy(char *destination, const char *source, size_t num)
Copy characters from string.
int unsetenv(const char *name)
Remove environment variable.
int snprintf(char *s, size_t n, const char *format,...)
Write formatted output to sized buffer.
int memcmp(const void *ptr1, const void *ptr2, size_t num)
Compare two blocks of memory.
char * strncat(char *destination, const char *source, size_t num)
Append characters from string.
void * dlsym(int handle, const char *name)
Get a pointer to the symbol from the previously loaded dynamic object.
int vsnprintf(char *s, size_t n, const char *format, va_list args)
Write formatted output to a sized buffer using a variable argument list.
unsigned long strtoul(const char *str, char **endptr, int base)
Convert string to unsigned long integer.
size_t strcspn(const char *str1, const char *str2)
Get span until character in string.
void * bsearch(const void *key, const void *first, size_t nitems, size_t size, int(*comparator)(const void *, const void *))
Searchign in array.
long int strtol(const char *str, char **endptr, int base)
Convert string to long integer.
void zeromem(void *ptr, int num)
Fill block of memory with zero.
void bzero(void *ptr, int num)
Fill block of memory with zero.
int strcmpi(const char *str1, const char *str2)
Compare two strings without case sensitivity.
int jmp_buf[11]
Definition libc.h:36
int dlclose(int handle)
Close previously loaded dynamic object.
char * strrchr(const char *str, int character)
Locate last occurrence of character in string.
void qsort(void *first, size_t nitems, size_t size, int(*comparator)(const void *, const void *))
Sorting array.
int strncmp(const char *str1, const char *str2, size_t num)
Compare characters of two strings.
int strcmp(const char *str1, const char *str2)
Compare two strings.
int setenv(const char *name, const char *value, int replace)
Set a value for the environment variable.
void * memcpy(void *destination, const void *source, size_t num)
Copy block of memory.
char * strcat(char *destination, const char *source)
Concatenate strings.
int strcasecmp(const char *str1, const char *str2)
Compare two strings without case sensitivity.
char * strchr(const char *str, int character)
Locate first occurrence of character in string.
void * memchr(const void *str, int c, size_t num)
Locate character in block of memory.
void * malloc_adr(void)
Pointer to the function malloc().
void * malloc(size_t size)
Allocate memory block.
int sprintf(char *s, const char *format,...)
Write formatted output to buffer.
void * mfree_adr(void)
Pointer to the function free().
char * strstr(const char *str1, const char *str2)
Locate substring.
char * getenv(const char *name)
Get value for the environment variable.
int sscanf(const char *s, const char *format,...)
Read formatted data from string.
void * memmove(void *destination, const void *source, size_t num)
Move block of memory.
void * realloc(void *ptr, size_t size)
Reallocate memory block.
int dlopen(const char *name)
Load the dynamic shared object (.so).
void * calloc(size_t count, size_t size)
Allocate and zero-initialize array.
void mfree(void *ptr)
Free previously allocated memory.
int rand(void)
Generate random number.
int clearenv(void)
Remove all environment variables.
char * strcpy(char *destination, const char *source)
Copy string.
void srand(uint32_t seed)
Initialize random number generator.
void free(void *ptr)
Deallocate memory block.
int vsprintf(char *s, const char *format, va_list args)
Write formatted output to buffer using a variable argument list.
const char * dlerror(void)
Get a string representation of the last error in _dlopen.
void * realloc_adr(void)
Pointer to the function realloc().
#define const
Definition zconf.h:115