1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/libc/include/stdlib.h

168 lines
4.6 KiB
C
Raw Normal View History

2012-03-27 10:24:51 -04:00
/*******************************************************************************
2011-08-05 08:25:00 -04:00
2013-03-23 20:39:43 -04:00
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
2011-08-05 08:25:00 -04:00
This file is part of the Sortix C Library.
2011-08-05 08:25:00 -04:00
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
2011-08-05 08:25:00 -04:00
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
2011-08-05 08:25:00 -04:00
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
2011-08-05 08:25:00 -04:00
stdlib.h
Standard library definitions.
2011-08-05 08:25:00 -04:00
2012-03-27 10:24:51 -04:00
*******************************************************************************/
2011-08-05 08:25:00 -04:00
#ifndef _STDLIB_H
#define _STDLIB_H 1
2011-08-05 08:25:00 -04:00
#include <sys/cdefs.h>
#include <sys/__/types.h>
2013-01-14 13:24:37 -05:00
#include <sortix/wait.h>
2011-08-05 08:25:00 -04:00
__BEGIN_DECLS
#define EXIT_SUCCESS (0)
#define EXIT_FAILURE (1)
/* TODO: This random interface is stupid. What should a good value be? */
#define RAND_MAX 32767
/* TODO: This is just a value. It's not a compile time constant! */
#define MB_CUR_MAX 16
2013-03-19 03:59:26 -04:00
typedef struct
{
int quot;
int rem;
} div_t;
typedef struct
{
long quot;
long rem;
} ldiv_t;
typedef struct
{
long long quot;
long long rem;
} lldiv_t;
2011-08-05 08:25:00 -04:00
2013-12-26 19:44:03 -05:00
#ifndef NULL
#define __need_NULL
#include <stddef.h>
#endif
#ifndef __size_t_defined
#define __size_t_defined
#define __need_size_t
#include <stddef.h>
#endif
#ifndef __wchar_t_defined
#define __wchar_t_defined
#define __need_wchar_t
#include <stddef.h>
#endif
2011-08-05 08:25:00 -04:00
void abort(void) __attribute__ ((__noreturn__));
2012-03-27 10:24:51 -04:00
int abs(int value);
2012-05-28 18:05:27 -04:00
int atexit(void (*function)(void));
2013-03-19 17:10:27 -04:00
double atof(const char* value);
2011-11-09 17:48:26 -05:00
int atoi(const char*);
2012-03-05 06:53:58 -05:00
long atol(const char*);
long long atoll(const char*);
void* bsearch(const void*, const void*, size_t, size_t, int (*)(const void*, const void*));
2011-12-23 22:05:38 -05:00
void* calloc(size_t, size_t);
2013-03-19 12:23:41 -04:00
char* canonicalize_file_name(const char* path);
char* canonicalize_file_name_at(int dirfd, const char* path);
int clearenv(void);
2013-03-19 03:59:26 -04:00
div_t div(int, int);
void exit(int) __attribute__ ((__noreturn__));
void _Exit(int status) __attribute__ ((__noreturn__));
2011-08-05 08:25:00 -04:00
void free(void*);
char* getenv(const char*);
2012-03-27 10:24:51 -04:00
long labs(long);
2013-03-19 03:59:26 -04:00
ldiv_t ldiv(long, long);
2012-03-27 10:24:51 -04:00
long long llabs(long long);
2013-03-19 03:59:26 -04:00
lldiv_t lldiv(long long, long long);
2011-08-05 08:25:00 -04:00
void* malloc(size_t);
2013-04-22 04:16:09 -04:00
int mblen(const char*, size_t);
size_t mbstowcs(wchar_t* __restrict, const char* __restrict, size_t);
int mbtowc(wchar_t *__restrict, const char* __restrict, size_t);
2013-09-18 14:07:30 -04:00
int mkstemp(char*);
char* mktemp(char* templ);
2012-05-28 18:05:27 -04:00
int on_exit(void (*function)(int, void*), void* arg);
void qsort(void*, size_t, size_t, int (*)(const void*, const void*));
2014-03-09 11:08:01 -04:00
void qsort_r(void*, size_t, size_t, int (*)(const void*, const void*, void*), void*);
2011-11-10 06:27:31 -05:00
int rand(void);
2012-02-12 18:31:05 -05:00
void* realloc(void*, size_t);
char* realpath(const char* __restrict, char* __restrict);
int setenv(const char*, const char*, int);
2013-03-19 08:48:59 -04:00
void srand(unsigned);
2013-03-23 14:20:44 -04:00
double strtod(const char* __restrict, char** __restrict);
float strtof(const char* __restrict, char** __restrict);
long strtol(const char* __restrict, char** __restrict, int);
2013-03-23 14:20:44 -04:00
long double strtold(const char* __restrict, char** __restrict);
unsigned long strtoul(const char* __restrict, char** __restrict, int);
unsigned long long strtoull(const char* __restrict, char** __restrict, int);
long long strtoll(const char* __restrict, char** __restrict, int);
2013-01-14 13:27:19 -05:00
int system(const char*);
int unsetenv(const char*);
size_t wcstombs(char* __restrict, const wchar_t *__restrict, size_t);
int wctomb(char*, wchar_t);
#if defined(__is_sortix_libc)
struct exit_handler
{
void (*hook)(int, void*);
void* param;
struct exit_handler* next;
};
extern struct exit_handler* __exit_handler_stack;
#endif
2012-09-28 18:53:50 -04:00
/* TODO: These are not implemented in sortix libc yet. */
#if 0
2011-08-05 08:25:00 -04:00
long a64l(const char* s);
double drand48(void);
double erand48(unsigned short [3]);
int getsubopt(char**, char* const *, char**);
int grantpt(int);
char* initstate(unsigned, char*, size_t);
long jrand48(unsigned short [3]);
char* l64a(long);
void lcong48(unsigned short [7]);
long lrand48(void);
char* mkdtemp(char*);
long mrand48(void);
long nrand48(unsigned short[3]);
int posix_memalign(void**, size_t, size_t);
int posix_openpt(int);
char* ptsname(int);
long random(void);
2013-09-22 18:43:42 -04:00
int rand_r(unsigned *);
2011-08-05 08:25:00 -04:00
unsigned short *seed48(unsigned short [3]);
void setkey(const char*);
char* setstate(char*);
void srand48(long);
void srandom(unsigned);
int unlockpt(int);
#endif
__END_DECLS
#endif