|
ginnOS
The reference: libc, the libraries and the kernel
|
This file contains the declarations of general utility functions. More...
Go to the source code of this file.
Data Structures | |
| struct | div_t |
| struct | ldiv_t |
Macros | |
| #define | RAND_MAX 0x7fffffff |
| #define | EXIT_SUCCESS 0 |
| #define | EXIT_FAILURE 1 |
| #define | MB_CUR_MAX ((size_t)4) |
Functions | |
| void * | malloc (size_t size) |
| allocate memory. | |
| void * | calloc (size_t nmemb, size_t size) |
| allocate zero-initialized memory. | |
| void * | realloc (void *ptr, size_t size) |
| resize a previously allocated block. | |
| void | free (void *ptr) |
| free a previously allocated block. | |
| int | atoi (const char *s) |
| convert a string to an integer. | |
| double | strtod (const char *str, char **end) |
| a floating-point number at the start of str, after spaces: an optional sign, then decimal digits with an optional point and exponent (1.5e3), hexadecimal digits with "0x" and an optional "p" exponent (0x1.8p1), "inf", "infinity" or "nan". | |
| float | strtof (const char *str, char **end) |
| long double | strtold (const char *str, char **end) |
| double | atof (const char *str) |
| strtod(str, NULL). | |
| int | system (const char *command) |
| run a command with "/bin/sh -c" and wait for it. | |
| int | mkstemp (char *template) |
| make and open a new file with a name no other file has. | |
| char * | getenv (const char *name) |
| look up an environment variable. | |
| int | atexit (void(*function)(void)) |
| register a function for exit() to call. | |
| long | atol (const char *s) |
| long long | atoll (const char *s) |
| long | strtol (const char *s, char **end, int base) |
| unsigned long | strtoul (const char *s, char **end, int base) |
| long long | strtoll (const char *s, char **end, int base) |
| unsigned long long | strtoull (const char *s, char **end, int base) |
| int | abs (int value) |
| long | labs (long value) |
| long long | llabs (long long value) |
| div_t | div (int numerator, int denominator) |
| ldiv_t | ldiv (long numerator, long denominator) |
| int | rand (void) |
| void | srand (unsigned int seed) |
| uint32_t | arc4random (void) |
| random numbers good for keys, from the kernel's generator (sys/random.h). | |
| void | arc4random_buf (void *buf, size_t length) |
| uint32_t | arc4random_uniform (uint32_t bound) |
| a random number below bound, each one equally likely | |
| void | qsort (void *base, size_t count, size_t size, int(*compare)(const void *, const void *)) |
| sort count elements of size bytes (heap sort: not stable). | |
| void * | bsearch (const void *key, const void *base, size_t count, size_t size, int(*compare)(const void *, const void *)) |
| find key in a sorted array. | |
| int | setenv (const char *name, const char *value, int overwrite) |
| int | unsetenv (const char *name) |
| int | putenv (char *entry) |
| int | posix_openpt (int flags) |
| pseudo-terminals (the master side, /dev/ptmx). | |
| int | grantpt (int fd) |
| int | unlockpt (int fd) |
| char * | ptsname (int fd) |
| int | ptsname_r (int fd, char *buf, size_t size) |
| void | abort (void) __attribute__((noreturn)) |
| end the process with SIGABRT. | |
| void | exit (int status) __attribute__((noreturn)) |
| run the atexit handlers, write out buffered stdio output, then end the process with an exit code. | |
| void | _Exit (int status) __attribute__((noreturn)) |
| end the process at once: no atexit functions, no stream flush (C99) | |
| int | mblen (const char *s, size_t n) |
| the bytes of the character at s (at most n), 0 for "\0", or -1 | |
| int | mbtowc (wchar_t *wc, const char *s, size_t n) |
| the character at s (at most n bytes) into *wc: its bytes, 0 or -1 | |
| int | wctomb (char *s, wchar_t wc) |
| wc as UTF-8 at s: the bytes, or -1 | |
| char * | realpath (const char *restrict path, char *restrict resolved) |
| the absolute path of path, with no "." or ".." and no double slashes, into resolved (PATH_MAX bytes), or into new memory when resolved is NULL. | |
| char * | mkdtemp (char *template) |
| make a new folder (0700) named template with its six X's replaced | |
Variables | |
| char ** | environ |
| the environment: a NULL-terminated array of "KEY=VALUE" strings. | |
This file contains the declarations of general utility functions.
| #define RAND_MAX 0x7fffffff |
| #define EXIT_SUCCESS 0 |
| #define EXIT_FAILURE 1 |
| #define MB_CUR_MAX ((size_t)4) |
| void * malloc | ( | size_t | size | ) |
allocate memory.
| size | number of bytes to allocate. |
allocate zero-initialized memory.
| nmemb | number of elements. |
| size | size of each element in bytes. |
| void * realloc | ( | void * | ptr, |
| size_t | size ) |
resize a previously allocated block.
| ptr | pointer returned by malloc/calloc/realloc, or NULL. |
| size | new size in bytes. if 0, the block is freed and NULL is returned. |
| void free | ( | void * | ptr | ) |
free a previously allocated block.
| ptr | pointer returned by malloc/calloc/realloc, or NULL (no-op). |
| int atoi | ( | const char * | s | ) |
convert a string to an integer.
| s | null-terminated string. |
| double strtod | ( | const char * | str, |
| char ** | end ) |
a floating-point number at the start of str, after spaces: an optional sign, then decimal digits with an optional point and exponent (1.5e3), hexadecimal digits with "0x" and an optional "p" exponent (0x1.8p1), "inf", "infinity" or "nan".
the result is rounded correctly.
| end | receives the first character after the number (may be NULL). |
| float strtof | ( | const char * | str, |
| char ** | end ) |
| long double strtold | ( | const char * | str, |
| char ** | end ) |
| double atof | ( | const char * | str | ) |
strtod(str, NULL).
| int system | ( | const char * | command | ) |
run a command with "/bin/sh -c" and wait for it.
| command | the command line, or NULL to ask whether there is a shell. |
| int mkstemp | ( | char * | template | ) |
make and open a new file with a name no other file has.
the last six characters of template must be "XXXXXX"; they are changed to the name that was used.
| char * getenv | ( | const char * | name | ) |
look up an environment variable.
| name | the variable name (without '='). |
| int atexit | ( | void(* | function )(void) | ) |
| long atol | ( | const char * | s | ) |
| long long atoll | ( | const char * | s | ) |
| long strtol | ( | const char * | s, |
| char ** | end, | ||
| int | base ) |
| unsigned long strtoul | ( | const char * | s, |
| char ** | end, | ||
| int | base ) |
| long long strtoll | ( | const char * | s, |
| char ** | end, | ||
| int | base ) |
| unsigned long long strtoull | ( | const char * | s, |
| char ** | end, | ||
| int | base ) |
| int abs | ( | int | value | ) |
| long labs | ( | long | value | ) |
| long long llabs | ( | long long | value | ) |
| div_t div | ( | int | numerator, |
| int | denominator ) |
| ldiv_t ldiv | ( | long | numerator, |
| long | denominator ) |
| int rand | ( | void | ) |
| void srand | ( | unsigned int | seed | ) |
| uint32_t arc4random | ( | void | ) |
random numbers good for keys, from the kernel's generator (sys/random.h).
they cannot fail.
| void arc4random_buf | ( | void * | buf, |
| size_t | length ) |
sort count elements of size bytes (heap sort: not stable).
| void * bsearch | ( | const void * | key, |
| const void * | base, | ||
| size_t | count, | ||
| size_t | size, | ||
| int(* | compare )(const void *, const void *) ) |
find key in a sorted array.
| int setenv | ( | const char * | name, |
| const char * | value, | ||
| int | overwrite ) |
| int unsetenv | ( | const char * | name | ) |
| int putenv | ( | char * | entry | ) |
| int posix_openpt | ( | int | flags | ) |
pseudo-terminals (the master side, /dev/ptmx).
posix_openpt opens a new master; unlockpt lets the slave be opened; ptsname gives the slave's path (in a static buffer). grantpt does nothing: the slaves are open to all. see also <pty.h>.
| int grantpt | ( | int | fd | ) |
| int unlockpt | ( | int | fd | ) |
| char * ptsname | ( | int | fd | ) |
| int ptsname_r | ( | int | fd, |
| char * | buf, | ||
| size_t | size ) |
| void abort | ( | void | ) |
end the process with SIGABRT.
| void exit | ( | int | status | ) |
run the atexit handlers, write out buffered stdio output, then end the process with an exit code.
| status | exit code. |
| void _Exit | ( | int | status | ) |
end the process at once: no atexit functions, no stream flush (C99)
| int mblen | ( | const char * | s, |
| size_t | n ) |
the bytes of the character at s (at most n), 0 for "\0", or -1
the character at s (at most n bytes) into *wc: its bytes, 0 or -1
| int wctomb | ( | char * | s, |
| wchar_t | wc ) |
wc as UTF-8 at s: the bytes, or -1
| char * realpath | ( | const char *restrict | path, |
| char *restrict | resolved ) |
the absolute path of path, with no "." or ".." and no double slashes, into resolved (PATH_MAX bytes), or into new memory when resolved is NULL.
the file must exist. (ginnOS has no symbolic links yet.)
| char * mkdtemp | ( | char * | template | ) |
make a new folder (0700) named template with its six X's replaced
|
extern |
the environment: a NULL-terminated array of "KEY=VALUE" strings.