summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC
AgeCommit message (Collapse)Author
2021-06-11Libc: Silence debug spam from `strerror`Jelle Raaijmakers
Particularly noticeable in ports like openssl, which like to map the entire error message set from 0 through 128 on startup.
2021-06-11LibC: Let `strerror_r` fail if `errnum` < 0Jelle Raaijmakers
2021-06-10LibC: Use EX_IOERR instead of EX_IOEREgor Ananyin
2021-06-09LibC: Add stub implementation for sigsuspendThiago Henrique Hupner
Currently, ZSH tries to call this function and it always asserts, so adding a stub to allow ZSH at least open.
2021-06-09LibC: Make tgetnum() return -1 if capability is not availableThiago Henrique Hupner
2021-06-08LibC+AK: Remove our custom macros from <assert.h>Gunnar Beutner
Other software might not expect these to be defined and behave differently if they _are_ defined, e.g. scummvm which checks if the TODO macro is defined and fails to build if it is.
2021-06-06LibC+LibELF: Implement dladdr()Gunnar Beutner
This implements the dladdr() function which lets the caller look up the symbol name, symbol address as well as library name and library base address for an arbitrary address.
2021-06-05LibC: Let setlocale() pretend that setting the locale succeededGunnar Beutner
By returning nullptr we're telling the caller that setlocale() failed. Some programs expect setlocale() to succeed so let's pretend that it did.
2021-06-04LibC: Define `MSG_OOB`Jelle Raaijmakers
2021-06-04LibC: Implement `execle()`Jelle Raaijmakers
2021-06-04LibC: Implement `mblen()`Jelle Raaijmakers
2021-06-04LibC: Add POSIX timer constantsJelle Raaijmakers
2021-06-03LibC: Switch ChunkedBlock to IntrusiveList from InlineLinkedListBrian Gianforcaro
2021-06-02LibC: Use memory_order_acquire instead of memory_order_acq_relGunnar Beutner
Acquire ordering should be sufficient for pthread_mutex_lock and pthread_mutex_trylock.
2021-06-02LibC: Fix race condition in pthread_mutex_unlock()Gunnar Beutner
This ensures the store to mutex->lock doesn't get re-ordered before the store to mutex->owner which could otherwise result in a locked owner-less mutex if another thread tries to acquire the lock at the same time.
2021-06-02LibC: Remove reinterpret_cast in pthread_mutex_{try,}lockGunnar Beutner
2021-05-31LibC: Replace fprintf(stderr) with warnln()Linus Groh
2021-05-30LibC: Don't clear errno on successTim Schumacher
POSIX (`errno(3p)`) states that errno should not be set to zero. This helps with applications that don't expect errno to get updated unless an intermediate syscall also fails.
2021-05-30LibC: Allow empty spwd members when writing shadow entries via putspentbrapru
Previously there was no way to output an empty value into the shadow file entries when the spwd members were disabled. This would cause new user entries to the shadow file to be cluttered with disabled values. This commit checks if the spwd member value is diabled (-1) and will output as appropriate.
2021-05-30LibC: Add stubs for wctype and iswctypeTim Schumacher
2021-05-30LibC: Stub out btowcTim Schumacher
wint_t is also not supposed to be defined by sys/types.h, but should be defined in wchar.h instead. Since we require it for our definition of btowc, let's move it to the correct place.
2021-05-30LibC: Implement __fpurgeTim Schumacher
2021-05-30LibC: Implement getprogname and setprognameTim Schumacher
2021-05-30LibC: Implement __freading and __fwritingTim Schumacher
These functions are used by gnulib (and therefore many GNU utilities) to provide access to internal details of the stdio FILE structure.
2021-05-30AK+Userland: Use akaster@serenityos.org for my copyright headersAndrew Kaster
2021-05-30LibC: openpty error handling updateDavid Carlier
2021-05-29LibC: Don't leak memory for realloc(p, 0)Gunnar Beutner
Previously we'd leak memory when the user called realloc(p, 0). Instead this call should behave as if the user had called free(p).
2021-05-27Userland: Treat inet_pton returning 0 as an errorTim Schumacher
The POSIX man-page states that inet_pton returns 0 if the input is not a valid IPv4 dotted-decimal string or a valid IPv6 address string. This is also how it is implemented in SerenityOS. This means that we should treat a return value of 0 as an error to avoid using an invalid address (or 0.0.0.0).
2021-05-27LibC: Use u32 in arc4random instead of char[4]Andrew Kaster
There's no alignment requirements on a char[4] buffer, so this was causing unaligned reads that were caught by UBSAN.
2021-05-27Userland: Port UBSAN implementation to userspaceAndrew Kaster
Take Kernel/UBSanitizer.cpp and make a copy in LibSanitizer. We can use LibSanitizer to hold other sanitizers as people implement them :^). To enable UBSAN for LibC, DynamicLoader, and other low level system libraries, LibUBSanitizer is built as a serenity_libc, and has a static version for LibCStatic to use. The approach is the same as that taken in Note that this means now UBSAN is enabled for code generators, Lagom, Kernel, and Userspace with -DENABLE_UNDEFINED_SANTIZER=ON. In userspace however, UBSAN is not deadly (yet). Co-authored-by: ForLoveOfCats <ForLoveOfCats@vivaldi.net>
2021-05-25LibC: Implement strerror_r()Gunnar Beutner
This implements the XSI-compliant version of strerror_r() - as opposed to the GNU-specific variant. The function explicitly saves errno so as to not accidentally change it with one of the calls to other functions.
2021-05-25LibC: Add definition for PRIxPTRGunnar Beutner
2021-05-23LibC: Use \010 for erasing instead of \0177Daniel Bertalan
We ignore \0177 in the terminal -- as the ANSI standard dictates. Fixes #7415
2021-05-23LibC+UE: Keep more unused chunked blocks aroundGunnar Beutner
Previously each malloc size class would keep around a limited number of unused blocks which were marked with MADV_SET_VOLATILE which could then be reinitialized when additional blocks were needed. This changes malloc() so that it also keeps around a number of blocks without marking them with MADV_SET_VOLATILE. I termed these "hot" blocks whereas blocks which were marked as MADV_SET_VOLATILE are called "cold" blocks because they're more expensive to reinitialize. In the worst case this could increase memory usage per process by 1MB when a program requests a bunch of memory and frees all of it. Also, in order to make more efficient use of these unused blocks they're now shared between size classes.
2021-05-22Userland: Rename LibThread => LibThreadingAndreas Kling
Also rename the "LibThread" namespace to "Threading"
2021-05-21Revert "Userland: static vs non-static constexpr variables"Linus Groh
This reverts commit 800ea8ea969835297dc7e7da345a45b9dc5e751a. Booting the system no longer worked after these changes.
2021-05-21Userland: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-19Kernel: Generate page fault events from the kernel profilerBrian Gianforcaro
Hook the kernel page fault handler and capture page fault events when the fault has a current thread attached in TLS. We capture the eip and ebp so we can unwind the stack and locate which pieces of code are generating the most page faults. Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-19Kernel: Add support for profiling kmalloc()/kfree()Gunnar Beutner
2021-05-19Kernel+LibC: Add support for filtering profiling eventsGunnar Beutner
This adds the -t command-line argument for the profile tool. Using this argument you can filter which event types you want in your profile.
2021-05-19Kernel: Track performance events for context switchesGunnar Beutner
2021-05-19LibC: Add functions for the new statvfs syscallsJustin
This commit adds the statvfs() and fstatvfs() functions into LibC.
2021-05-18Revert "LibC: Simplify malloc size classes"Andreas Kling
This reverts commit f91bcb8895cd6b76b2977ad0632fef521ba2f1d1.
2021-05-18LibC: Use ptsname_r() instead of ptsname() in openpty() (#7231)Gunnar Beutner
This improves thread-safety because ptsname() is using a global buffer that is shared between threads.
2021-05-18LibC: Remove static from function local constexpr variableLenny Maiorani
Problem: - Function local `constexpr` variables do not need to be `static`. This consumes memory which is unnecessary and can prevent some optimizations. Solution: - Remove `static` keyword.
2021-05-18LibC: Simplify malloc size classesLenny Maiorani
Problem: - `size_classes` is a C-style array which makes it difficult to use in algorithms. - `all_of` algorithm is re-written for the specific implementation. Solution: - Change `size_classes` to be an `Array`. - Directly use the generic `all_of` algorithm instead of reimplementing.
2021-05-17Kernel+Userspace: Implement the accept4() system callGunnar Beutner
Unlike accept() the new accept4() system call lets the caller specify flags for the newly accepted socket file descriptor, such as SOCK_CLOEXEC and SOCK_NONBLOCK.
2021-05-17Kernel+LibC: Support more `termios` settings in TTYDaniel Bertalan
This commit adds support for the various ECHO* lflags and fixes some POSIX conformance issues around newline handling. Also included are error messages when setting not implemented settings.
2021-05-16AK+Userland: Fix some compiler warnings and make variables const-refGunnar Beutner
This fixes a few compiler warnings and makes some variables const-ref in preparation for the next commit which changes how ByteBuffer works.
2021-05-16LibC+Kernel: Add sys/ttydefaults.hDaniel Bertalan
This non-POSIX header is used in Linux/BSD systems for storing the default termios settings. This lets us setup new TTYs' `m_termios.c_cc` in a nicer way than using a magic string.