Serenity Operating System
1/*
2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#pragma once
28
29#include <stddef.h>
30#include <sys/cdefs.h>
31#include <sys/types.h>
32
33__attribute__((warn_unused_result)) int __generate_unique_filename(char* pattern);
34
35__BEGIN_DECLS
36
37#define EXIT_SUCCESS 0
38#define EXIT_FAILURE 1
39#define MB_CUR_MAX 1
40
41__attribute__((malloc)) __attribute__((alloc_size(1))) void* malloc(size_t);
42__attribute__((malloc)) __attribute__((alloc_size(1, 2))) void* calloc(size_t nmemb, size_t);
43size_t malloc_size(void*);
44void free(void*);
45void* realloc(void* ptr, size_t);
46char* getenv(const char* name);
47int putenv(char*);
48int unsetenv(const char*);
49int setenv(const char* name, const char* value, int overwrite);
50int atoi(const char*);
51long atol(const char*);
52long long atoll(const char*);
53double strtod(const char*, char** endptr);
54long double strtold(const char*, char** endptr);
55float strtof(const char*, char** endptr);
56long strtol(const char*, char** endptr, int base);
57long long strtoll(const char*, char** endptr, int base);
58unsigned long long strtoull(const char*, char** endptr, int base);
59unsigned long strtoul(const char*, char** endptr, int base);
60void qsort(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
61void qsort_r(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*, void*), void* arg);
62int atexit(void (*function)());
63__attribute__((noreturn)) void exit(int status);
64__attribute__((noreturn)) void abort();
65char* ptsname(int fd);
66int ptsname_r(int fd, char* buffer, size_t);
67int abs(int);
68long labs(long);
69double atof(const char*);
70int system(const char* command);
71char* mktemp(char*);
72int mkstemp(char*);
73char* mkdtemp(char*);
74void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
75size_t mbstowcs(wchar_t*, const char*, size_t);
76size_t mbtowc(wchar_t*, const char*, size_t);
77int wctomb(char*, wchar_t);
78size_t wcstombs(char*, const wchar_t*, size_t);
79char* realpath(const char* pathname, char* buffer);
80
81#define RAND_MAX 32767
82int rand();
83void srand(unsigned seed);
84
85long int random();
86void srandom(unsigned seed);
87
88uint32_t arc4random(void);
89void arc4random_buf(void*, size_t);
90uint32_t arc4random_uniform(uint32_t);
91
92typedef struct {
93 int quot;
94 int rem;
95} div_t;
96div_t div(int, int);
97typedef struct {
98 long quot;
99 long rem;
100} ldiv_t;
101ldiv_t ldiv(long, long);
102
103int posix_openpt(int flags);
104int grantpt(int fd);
105int unlockpt(int fd);
106
107__END_DECLS