Warning: This file is not a C or C++ file. It does not have highlighting.

1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10/*
11 stdlib.h synopsis
12
13Macros:
14
15 EXIT_FAILURE
16 EXIT_SUCCESS
17 MB_CUR_MAX
18 NULL
19 RAND_MAX
20
21Types:
22
23 size_t
24 div_t
25 ldiv_t
26 lldiv_t // C99
27
28double atof (const char* nptr);
29int atoi (const char* nptr);
30long atol (const char* nptr);
31long long atoll(const char* nptr); // C99
32double strtod (const char* restrict nptr, char** restrict endptr);
33float strtof (const char* restrict nptr, char** restrict endptr); // C99
34long double strtold (const char* restrict nptr, char** restrict endptr); // C99
35long strtol (const char* restrict nptr, char** restrict endptr, int base);
36long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
37unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
38unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
39int rand(void);
40void srand(unsigned int seed);
41void* calloc(size_t nmemb, size_t size);
42void free(void* ptr);
43void* malloc(size_t size);
44void* realloc(void* ptr, size_t size);
45void abort(void);
46int atexit(void (*func)(void));
47void exit(int status);
48void _Exit(int status);
49char* getenv(const char* name);
50int system(const char* string);
51void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
52 int (*compar)(const void *, const void *));
53void qsort(void* base, size_t nmemb, size_t size,
54 int (*compar)(const void *, const void *));
55int abs( int j);
56long abs( long j);
57long long abs(long long j); // C++0X
58long labs( long j);
59long long llabs(long long j); // C99
60div_t div( int numer, int denom);
61ldiv_t div( long numer, long denom);
62lldiv_t div(long long numer, long long denom); // C++0X
63ldiv_t ldiv( long numer, long denom);
64lldiv_t lldiv(long long numer, long long denom); // C99
65int mblen(const char* s, size_t n);
66int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
67int wctomb(char* s, wchar_t wchar);
68size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
69size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
70int at_quick_exit(void (*func)(void)) // C++11
71void quick_exit(int status); // C++11
72void *aligned_alloc(size_t alignment, size_t size); // C11
73
74*/
75
76#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
77# include <__cxx03/stdlib.h>
78#else
79# include <__config>
80
81# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
82# pragma GCC system_header
83# endif
84
85// The inclusion of the system's <stdlib.h> is intentionally done once outside of any include
86// guards because some code expects to be able to include the underlying system header multiple
87// times to get different definitions based on the macros that are set before inclusion.
88# if __has_include_next(<stdlib.h>)
89# include_next <stdlib.h>
90# endif
91
92# if !defined(_LIBCPP_STDLIB_H)
93# define _LIBCPP_STDLIB_H
94
95# ifdef __cplusplus
96extern "C++" {
97// abs
98
99# ifdef abs
100# undef abs
101# endif
102# ifdef labs
103# undef labs
104# endif
105# ifdef llabs
106# undef llabs
107# endif
108
109// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
110# if !defined(_LIBCPP_MSVCRT)
111[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); }
112[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); }
113# endif // !defined(_LIBCPP_MSVCRT)
114
115[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT {
116 return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
117}
118
119[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT {
120 return __builtin_fabs(__lcpp_x);
121}
122
123[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT {
124 return __builtin_fabsl(__lcpp_x);
125}
126
127// div
128
129# ifdef div
130# undef div
131# endif
132# ifdef ldiv
133# undef ldiv
134# endif
135# ifdef lldiv
136# undef lldiv
137# endif
138
139// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
140# if !defined(_LIBCPP_MSVCRT)
141inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); }
142# if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED))
143inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); }
144# endif
145# endif // _LIBCPP_MSVCRT
146} // extern "C++"
147# endif // __cplusplus
148# endif // _LIBCPP_STDLIB_H
149
150#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
151

Warning: This file is not a C or C++ file. It does not have highlighting.

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of libcxx/include/stdlib.h