summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC/stdlib.h
AgeCommit message (Collapse)Author
2022-01-12LibC: Make the address argument of `malloc_size` a pointer to constDaniel Bertalan
We don't mutate the pointed-to memory, so let's be const correct. Fixes building the `mimalloc` library that's optionally used by the mold linker (note that it isn't enabled yet as I haven't tested it).
2022-01-08LibC+LibDl: Declare functions taking no arguments as taking voidDaniel Bertalan
In C++, a function declaration with an empty parameter list means that the function takes no arguments. In C, however, it means that the function takes an unspecified number of parameters. What we did previously was therefore non-conforming. This caused a config check to fail in the curl port, as it was able to redeclare `rand` as taking an int parameter.
2021-12-21LibC: Implement ungetwc()Ali Mohammad Pur
2021-12-18LibC: Move `_abort` next to `abort`Michel Hermier
It should be now the only user of it, and it is more logical to have it in `stdlib.h` than in `assert.h`
2021-12-18LibC: Remove undefined `__generate_unique_filename` declarationMichel Hermier
2021-11-14LibC: Implement _aligned_malloc and _aligned_freeDaniel Bertalan
C++17 introduced aligned versions of `new` and `delete`, which are automatically called by the compiler when allocating over-aligned objects. As with the regular allocator functions, these are generally thin wrappers around LibC. We did not have support for aligned allocations in LibC, so this was not possible. While libstdc++ has a fallback implementation, libc++ does not, so the aligned allocation function was disabled internally. This made building the LLVM port with Clang impossible. Note that while the Microsoft docs say that aligned_malloc and _aligned_free are declared in `malloc.h`, libc++ doesn't #include that file, but instead relies on the definition coming from `stdlib.h`. Therefore, I chose to declare it in that file instead of creating a new LibC header. I chose not to implement the more Unix-y `memalign`, `posix_memalign`, or the C11 `aligned_alloc`, because that would require us to significantly alter the memory allocator's internals. See the comment in malloc.cpp.
2021-10-28LibC+LibELF: Move getauxval and AT_* flags to sys/auxv.hIdan Horowitz
2021-10-23LibC: Use a sensible `MB_CUR_MAX` valueDaniel Bertalan
We always use UTF-8, meaning that a single `wchar_t` might be converted into up to 4 `char`s. This would cause a buffer overflow if something actually relied on this being the right value.
2021-06-04LibC: Implement `mblen()`Jelle Raaijmakers
2021-05-30LibC: Implement getprogname and setprognameTim Schumacher
2021-05-15AK+LibC: Implement malloc_good_size() and use it for Vector/HashTableGunnar Beutner
This implements the macOS API malloc_good_size() which returns the true allocation size for a given requested allocation size. This allows us to make use of all the available memory in a malloc chunk. For example, for a malloc request of 35 bytes our malloc would internally use a chunk of size 64, however the remaining 29 bytes would be unused. Knowing the true allocation size allows us to request more usable memory that would otherwise be wasted and make that available for Vector, HashTable and potentially other callers in the future.
2021-05-09LibC: Implement the _Exit functionGunnar Beutner
libstdc++v3 checks whether this function is available and makes certain functions available in the std namespace if so.
2021-04-29Implemented llabs() in stdlib.h/cpp.Holden Green
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-09LibC: Add imaxdiv and lldivMițca Dumitru
2021-01-31LibC: Don't honor LIBC_* malloc debugging flags in AT_SECURE contextAndreas Kling
Just ignore all these environment flags if the AT_SECURE flag is set in the program's auxiliary vector. This prevents a user from tricking set-uid programs into dumping debug information via environment flags.
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling