Luna/libc/include/stdlib.h

106 lines
2.7 KiB
C
Raw Normal View History

/* stdlib.h: General utilities header. */
#ifndef _STDLIB_H
#define _STDLIB_H
#include <bits/attrs.h>
#include <stddef.h>
/* The result of a division operation on two integers. */
typedef struct
{
int quot;
int rem;
} div_t;
/* The result of a division operation on two long integers. */
typedef struct
{
long quot;
long rem;
} ldiv_t;
/* The result of a division operation on two long long integers. */
typedef struct
{
long long quot;
long long rem;
} lldiv_t;
#ifdef __cplusplus
extern "C"
{
#endif
/* Returns the absolute value of v. */
int abs(int v);
/* Returns the absolute value of v. */
long labs(long v);
/* Returns the absolute value of v. */
long long llabs(long long v);
/* Returns the result of dividing num by den, including the remainder. */
div_t div(int num, int den);
/* Returns the result of dividing num by den, including the remainder. */
ldiv_t ldiv(long, long);
/* Returns the result of dividing num by den, including the remainder. */
lldiv_t lldiv(long long, long long);
void* malloc(size_t);
void* calloc(size_t, size_t);
void* realloc(void*, size_t);
void free(void*);
/* Aborts the program without performing any normal cleanup. */
__noreturn void abort();
/* Registers a handler to be run at normal program termination. */
int atexit(void (*func)(void));
/* Parses a decimal integer from the provided string. */
int atoi(const char* s);
/* Parses a decimal integer from the provided string. */
long atol(const char* s);
/* Parses a decimal integer from the provided string. */
long long atoll(const char* s);
double atof(const char*);
double strtod(const char*, char**);
/* Parses an integer of the specified base from the string str, storing the first non-number character in endptr if
* nonnull. */
long strtol(const char* str, char** endptr, int base);
/* Parses an unsigned integer of the specified base from the string str, storing the first non-number character in
* endptr if nonnull. */
unsigned long strtoul(const char* str, char** endptr, int base);
int rand();
void srand(int);
/* Exits the program normally, performing any registered cleanup actions. */
__noreturn void exit(int);
/* Exits the program abnormally, without performing any registered cleanup actions. */
__noreturn void _Exit(int);
int system(const char*);
char* getenv(const char*);
void qsort(void*, size_t, size_t, int (*)(const void*, const void*));
void* bsearch(const void*, const void*, size_t, size_t, int (*)(const void*, const void*));
#ifdef __cplusplus
}
#endif
#endif