2021-04-27 18:33:31 +02:00
|
|
|
#ifndef _STDLIB_H_
|
|
|
|
#define _STDLIB_H_
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2022-04-15 11:11:49 +02:00
|
|
|
#define RAND_MAX 65535
|
2021-04-27 18:33:31 +02:00
|
|
|
#ifndef NULL
|
2022-04-15 11:11:49 +02:00
|
|
|
#define NULL ((void*)0)
|
2021-04-27 18:33:31 +02:00
|
|
|
#endif
|
|
|
|
|
2022-04-15 11:11:49 +02:00
|
|
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
|
|
#define max(a, b) ((a) > (b) ? (a) : (b))
|
2021-04-27 18:33:31 +02:00
|
|
|
|
2022-04-15 11:11:49 +02:00
|
|
|
typedef struct {
|
2021-11-02 22:29:04 +01:00
|
|
|
int quot;
|
2022-04-15 11:11:49 +02:00
|
|
|
int rem;
|
2021-11-02 22:29:04 +01:00
|
|
|
} div_t;
|
2021-04-27 18:33:31 +02:00
|
|
|
|
2022-04-15 11:11:49 +02:00
|
|
|
typedef struct {
|
|
|
|
long quot;
|
2021-11-02 22:29:04 +01:00
|
|
|
long rem;
|
|
|
|
} ldiv_t;
|
|
|
|
|
2022-04-15 11:11:49 +02:00
|
|
|
typedef struct {
|
|
|
|
long long quot;
|
|
|
|
long long rem;
|
2021-11-02 22:29:04 +01:00
|
|
|
} lldiv_t;
|
|
|
|
|
2022-04-15 11:11:49 +02:00
|
|
|
static inline div_t div(int num, int den)
|
|
|
|
{
|
|
|
|
return (div_t) { num / den, num % den };
|
2021-11-02 22:29:04 +01:00
|
|
|
}
|
|
|
|
|
2022-04-15 11:11:49 +02:00
|
|
|
static inline ldiv_t ldiv(long num, long den)
|
|
|
|
{
|
|
|
|
return (ldiv_t) { num / den, num % den };
|
2021-11-02 22:29:04 +01:00
|
|
|
}
|
|
|
|
|
2022-04-15 11:11:49 +02:00
|
|
|
static inline lldiv_t lldiv(long long num, long long den)
|
|
|
|
{
|
|
|
|
return (lldiv_t) { num / den, num % den };
|
2021-11-02 22:29:04 +01:00
|
|
|
}
|
2021-04-27 18:33:31 +02:00
|
|
|
|
2022-05-10 20:58:40 +02:00
|
|
|
DLLAPI void* malloc(size_t size);
|
|
|
|
DLLAPI void* calloc(size_t num, size_t size);
|
|
|
|
DLLAPI void* realloc(void* ptr, size_t newsize);
|
|
|
|
DLLAPI void free(void* ptr);
|
2021-04-27 18:33:31 +02:00
|
|
|
|
2022-05-10 20:58:40 +02:00
|
|
|
DLLAPI long int strtol(const char* str, char** endptr, int base);
|
2021-04-27 18:33:31 +02:00
|
|
|
|
2022-05-10 20:58:40 +02:00
|
|
|
DLLAPI void exit(int status);
|
2021-04-27 18:33:31 +02:00
|
|
|
|
2022-05-10 20:58:40 +02:00
|
|
|
DLLAPI void srand(unsigned s);
|
|
|
|
DLLAPI int rand(void);
|
2022-04-15 11:11:49 +02:00
|
|
|
|
2022-05-10 20:58:40 +02:00
|
|
|
DLLAPI void __assert_fail(const char* expr, const char* file, int line, const char* func);
|
|
|
|
DLLAPI void qsort(void* base0, size_t n, size_t size, int (*compar)(const void*, const void*));
|
2021-05-25 02:16:29 +02:00
|
|
|
|
2022-05-10 20:58:40 +02:00
|
|
|
DLLAPI double strtod(const char* s, char** sret);
|
|
|
|
DLLAPI double atof(const char* ascii);
|
2021-07-06 20:18:46 +02:00
|
|
|
|
2022-05-10 20:58:40 +02:00
|
|
|
DLLAPI int atoi(const char* s);
|
|
|
|
DLLAPI long atol(const char*);
|
|
|
|
DLLAPI long long atoll(const char*);
|
|
|
|
DLLAPI void itoa(int n, char* s);
|
2022-04-15 11:11:49 +02:00
|
|
|
|
2022-05-10 20:58:40 +02:00
|
|
|
DLLAPI int abs(int);
|
|
|
|
DLLAPI long labs(long);
|
|
|
|
DLLAPI long long llabs(long long);
|
2021-08-15 22:21:32 +02:00
|
|
|
|
2021-05-25 02:16:29 +02:00
|
|
|
#endif
|