Debian Codegraph @

headers/cstdlib

raw
1 /* Copyright (C) 2015 Povilas Kanapickas <[email protected]>
2
3 This file is part of cppreference-doc
4
5 This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
6 Unported License. To view a copy of this license, visit
7 http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
8 Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
9
10 Permission is granted to copy, distribute and/or modify this document
11 under the terms of the GNU Free Documentation License, Version 1.3 or
12 any later version published by the Free Software Foundation; with no
13 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
14 */
15
16 #ifndef CPPREFERENCE_CSTDLIB_H
17 #define CPPREFERENCE_CSTDLIB_H
18
19 namespace std {
20
21 // math utils
22 int abs(int n);
23 long abs(long n);
24 #if CPPREFERENCE_STDVER>= 2011
25 long long abs(long long n);
26 #endif
27 long labs(long n);
28 #if CPPREFERENCE_STDVER>= 2011
29 long long llabs(long long n);
30 #endif
31
32 struct div_t {
33 int quot;
34 int rem;
35 };
36
37 struct ldiv_t {
38 long quot;
39 long rem;
40 };
41
42 #if CPPREFERENCE_STDVER>= 2011
43 struct lldiv_t {
44 long long quot;
45 long long rem;
46 };
47 #endif
48
49 std::div_t div(int x, int y);
50 std::ldiv_t div(long x, long y);
51 #if CPPREFERENCE_STDVER>= 2011
52 std::lldiv_t div(long long x, long long y);
53 #endif
54 std::ldiv_t ldiv(long x, long y);
55 #if CPPREFERENCE_STDVER>= 2011
56 std::lldiv_t lldiv(long long x, long long y);
57 #endif
58
59 // string conversions
60
61 double atof(const char* nptr);
62 int atoi(const char* nptr);
63 long atol(const char* nptr);
64
65 #if CPPREFERENCE_STDVER>= 2011
66 long long atoll(const char* nptr);
67 #endif
68
69 double strtod(const char* nptr, char** endptr);
70 #if CPPREFERENCE_STDVER>= 2011
71 float strtof(const char* nptr, char** endptr);
72 long double strtold(const char* nptr, char** endptr);
73 #endif
74 long strtol(const char* nptr, char** endptr, int base);
75 #if CPPREFERENCE_STDVER>= 2011
76 long long strtoll(const char* nptr, char** endptr, int base);
77 #endif
78 unsigned long strtoul(const char* nptr, char** endptr, int base);
79 unsigned long long strtoull(const char* nptr, char** endptr, int base);
80
81 // multibyte string operations
82 #define MB_CUR_MAX 0 // actually unspecified
83 int mblen(const char* s, std::size_t n);
84 int mbtowc(wchar_t* pwc, const char* s, std::size_t n);
85 int wctomb(char* s, wchar_t wc);
86 std::size_t mbstowcs(wchar_t* dst, const char* src, std::size_t len);
87 std::size_t wcstombs(char* dst, const wchar_t* src, std::size_t len);
88
89 // random numbers
90 #define RAND_MAX 0 // actually unspecified
91 int rand();
92 void srand(unsigned seed);
93
94 // sorting
95 void qsort(void* ptr, std::size_t count, std::size_t size,
96 int (*comp)(const void*, const void*));
97
98 void* bsearch(const void* key, const void* ptr, std::size_t count,
99 std::size_t size, int (*comp)(const void*, const void*));
100
101 // program support utils
102 void abort();
103 void exit(int exit_code);
104 int atexit(void (*func)());
105
106 #define EXIT_SUCCESS 0 // actually impl-defined
107 #define EXIT_FAILURE 0 // actually impl-defined
108
109 #if CPPREFERENCE_STDVER>= 2011
110 void _Exit(int exit_code);
111 void quick_exit(int exit_code);
112 int at_quick_exit(void (*func)());
113 #endif
114
115 int system(const char* command);
116 char* getenv(const char* env_var);
117
118 // dynamic memory management
119 void* malloc(std::size_t size);
120 void* calloc(std::size_t num, std::size_t size);
121 void* realloc(void* ptr, std::size_t new_size);
122 void free(void* ptr);
123
124 } // namespace std
125
126 #endif // CPPREFERENCE_CSTDLIB_H