XenevaOS
Loading...
Searching...
No Matches
stdlib.h
Go to the documentation of this file.
1
30#ifndef __STDLIB_H__
31#define __STDLIB_H__
32
33#include <_xeneva.h>
34#include <stddef.h>
35#include <_xeprint.h>
36
37#ifdef __cplusplus
39#endif
40
41#include <stdarg.h>
42
43
44#define max(a, b) ((a) > (b) ? (a) : (b))
45#define min(a, b) ((a) < (b) ? (a) : (b))
46#define offsetof(type, field) ((unsigned long) &(((type *)0L)->field))
47
48#define EXIT_FAILURE 1
49#define EXIT_SUCCESS 0
50
51#define RAND_MAX (0x7fffffff)
52
53 XE_LIB int atoi(const char*);
54 XE_LIB long atol(const char*);
55#define atoll(string) ((long long) _str2num(string, 10, 1, NULL))
56
57 XE_LIB double atof(const char*);
58 XE_LIB int abs(int);
59 XE_LIB void* malloc(unsigned int);
60 XE_LIB void free(void* ptr);
61 XE_LIB void* realloc(void* address, unsigned int new_size);
62 XE_LIB void* calloc(unsigned long long num, unsigned long long size);
63 XE_LIB int mblen(const char*, size_t);
64 XE_LIB size_t mbstowcs(wchar_t *, const char*, size_t);
65 XE_LIB int mbtowc(wchar_t*, const char*, size_t);
66 XE_LIB char* mkdtemp(char*);
67 XE_LIB char* mkstemp(char *);
68 XE_LIB int rand(void);
69#define random() rand()
70 XE_LIB size_t wcstombs(char*, const wchar_t *, size_t);
71 XE_LIB int wctomb(char*, wchar_t);
72 XE_LIB void qsort(void* base, size_t num, size_t size, int(*comparator)(const void*, const void*));
73
74 XE_LIB char* sztoa(size_t value, char* str, int base);
75 /*
76 * setenv -- set environment variables
77 * @param name -- Key name
78 * @param value -- value of the variable
79 * @param overwrite -- 0 - append at the last, 1 force-write
80 */
81 XE_LIB int setenv(const char* name, const char* value, int overwrite);
82 XE_LIB char* getenv(const char*);
83 XE_LIB void exit(int errno);
84
85 XE_LIB int vsprintf(char *str, const char *format, va_list ap);
86 XE_LIB long strtol(const char* nptr, char** endptr, int base);
87 XE_LIB unsigned long strtoul(const char* nptr, char** endptr, int base);
88 XE_LIB void itoa_s(int i, unsigned base, char* buf);
90 XE_LIB void abort(void);
91
92
93// Functions are from Visopsys project
94// These are unofficial, Andy-special extensions of the atoi() and atoll()
95// paradigm
96// Visopsys, Copyright (C) 1998-2020 J. Andrew McLaughlin
97#define atou(string) ((unsigned) _str2num(string, 10, 0, NULL))
98#define atoull(string) _str2num(string, 10, 0, NULL)
99#define atoo(string) ((unsigned)_str2num(string, 8, 0, NULL))
100#define atooll(string) _str2num(string, 8, 0, NULL)
101#define dtoa(num, string, round) _dbl2str(num, string, round)
102#define ftoa(num, string) _flt2str(num, string, round)
103#define itoa(num, string) _num2str(num, string, 10, 1)
104#define itouo(num, string) _num2str(num,string, 10, 1)
105#define itoux(num,string) _num2str(num, string, 16,0);
106#define itox(num, string) _num2str(num, string, 16, 1)
107#define lltoa(num, string) _lnum2str(num, string, 10,1)
108#define lltouo(num, string) _lnum2str(num, string, 8, 0)
109#define lltoux(num, string) _lnum2str(num, string, 16,0)
110#define lltox(num, string) _lnum2str(num, string, 16, 1)
111#define xtoi(string) ((int)_str2num(string, 16, 1, NULL))
112#define xtoll(string) ((long long) _str2num(string, 16,1, NULL))
113#define ulltoa(num, string) _lnum2str(num, string, 10, 0)
114#define utoa(num, string) _num2str(num, string, 10, 0)
115
116#ifdef __cplusplus
117}
118#endif
119
120
121#endif
#define XE_LIB
Definition _xeneva.h:55
#define XE_EXTERN
Definition _xeneva.h:50
char * va_list
Definition acmsvcex.h:186
int errno
Definition errno.cpp:33
XE_LIB void PrintOSName()
XE_LIB double atof(const char *)
Definition stdlib.cpp:63
XE_LIB void exit(int errno)
Definition stdlib.cpp:245
XE_LIB void itoa_s(int i, unsigned base, char *buf)
Definition stdlib.cpp:270
XE_LIB size_t wcstombs(char *, const wchar_t *, size_t)
Definition stdlib.cpp:187
XE_LIB char * mkdtemp(char *)
XE_LIB unsigned long strtoul(const char *nptr, char **endptr, int base)
converts a string to an unsigned long
Definition stdlib.cpp:369
XE_LIB long strtol(const char *nptr, char **endptr, int base)
converts a string to a long
Definition stdlib.cpp:282
XE_LIB size_t mbstowcs(wchar_t *, const char *, size_t)
Definition stdlib.cpp:108
XE_LIB char * mkstemp(char *)
XE_LIB char * getenv(const char *)
Definition stdlib.cpp:264
XE_LIB int abs(int)
Definition stdlib.cpp:41
XE_LIB void * realloc(void *address, unsigned int new_size)
Definition _heap.cpp:502
XE_LIB long atol(const char *)
XE_LIB int mblen(const char *, size_t)
Definition stdlib.cpp:84
XE_LIB char * sztoa(size_t value, char *str, int base)
Definition clib.cpp:107
XE_LIB int vsprintf(char *str, const char *format, va_list ap)
Definition stdio.cpp:326
XE_LIB void * calloc(unsigned long long num, unsigned long long size)
Definition _heap.cpp:486
XE_LIB void * malloc(unsigned int)
Definition _heap.cpp:281
XE_LIB int mbtowc(wchar_t *, const char *, size_t)
Definition stdlib.cpp:135
XE_LIB void abort(void)
Definition stdlib.cpp:443
XE_LIB int rand(void)
NOT IMPLEMENTED.
Definition stdio.cpp:132
XE_LIB int wctomb(char *, wchar_t)
Definition stdlib.cpp:168
XE_LIB int atoi(const char *)
Definition stdio.cpp:107
XE_LIB void qsort(void *base, size_t num, size_t size, int(*comparator)(const void *, const void *))
Definition qsort.cpp:80
XE_LIB void free(void *ptr)
Definition _heap.cpp:392
XE_LIB int setenv(const char *name, const char *value, int overwrite)
Definition stdlib.cpp:256