summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC
AgeCommit message (Collapse)Author
2022-06-12LibC: Force default visibility for the _ctype_ symbolAndrew Kaster
When ports compile with -fvisibility=hidden, they can end up with unresolved references to _ctype_ without passing -Wl,--allow-shlib-undefined
2022-06-12LibC: Add public and independent ucontext.h headerAndrew Kaster
2022-06-04LibC: Make asctime_r() in time.h POSIX compliantMay
Previously, when the asctime_r() buffer overflowed, we would fail an assertion. This patch modifies asctime_r() to instead set errno and return null.
2022-05-23LibC: Add barebones <complex.h>Peter Elliott
2022-05-21Kernel+LibC: Implement futimens(3)Ariel Don
Implement futimes() in terms of utimensat(). Now, utimensat() strays from POSIX compliance because it also accepts a combination of a file descriptor of a regular file and an empty path. utimensat() then uses this file descriptor instead of the path to update the last access and/or modification time of a file. That being said, its prior behavior remains intact. With the new behavior of utimensat(), `path` must point to a valid string; given a null pointer instead of an empty string, utimensat() sets `errno` to `EFAULT` and returns a failure.
2022-05-21Kernel+LibC+VFS: Implement utimensat(3)Ariel Don
Create POSIX utimensat() library call and corresponding system call to update file access and modification times.
2022-05-21LibC: Add a stub for nice()Simon Danner
2022-05-20LibC: Implement posix_memalign(3) and aligned_alloc(3)Peter Elliott
Some ports linked against posix_memalign, but didn't use it, and others used it if it was Available. So I decided to implement posix_memalign. My implementation adds almost no overhead to regular mallocs. However, if an alignment is specified, it will use the smallest ChunkedBlock, for which aligned chunks exist, and simply use one of the chunks that is aligned. If it cannot use a ChunkedBlock, for size or alignment reasons, it will use a BigAllocationBlock, and return a pointer to the first aligned address past the start of the block. This implementation supports alignments up to 32768, due to the limitations of the BigAllocationBlock technique.
2022-05-12LibC: Add herror() and hstrerror()Michał Lach
2022-05-12LibC: Make h_errno thread-localMichał Lach
2022-05-12LibC+Kernel: Prevent string functions from calling themselvesDaniel Bertalan
Most of the string.h and wchar.h functions are implemented quite naively at the moment, and GCC's pattern recognition pass might realize what we are trying to do, and transform them into libcalls. This is usually a useful optimization, but not when we're implementing the functions themselves :^) Relevant discussion from the GCC Bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725 This prevents the infamous recursive `strlen`. A more proper fix would be writing these functions in assembly. That would likely give a small performance boost as well ;)
2022-05-08LibC: Add missing macro definitions for errno codescircl
2022-05-05Everywhere: Purge all support and usage of framebuffer devicesLiav A
Long live the DisplayConnector object!
2022-05-05Everywhere: Rename FB prefix structure names => GraphicsLiav A
2022-05-05Everywhere: Rename FB prefix name ioctls => GRAPHICSLiav A
2022-05-05DisplaySettings+WindowServer: Add support for display connector devicesLiav A
2022-05-05Kernel/Graphics: Introduce the DisplayConnector classLiav A
The DisplayConnector class is meant to replace the FramebufferDevice class. The advantage of this class over the FramebufferDevice class is: 1. It removes the mmap interface entirely. This interface is unsafe, as multiple processes could try to use it, and when switching to and from text console mode, there's no "good" way to revoke a memory mapping from this interface, let alone when there are multiple processes that call this interface. Therefore, in the DisplayConnector class there's no implementation for this method at all. 2. The class uses a new real-world structure called ModeSetting, which takes into account the fact that real hardware requires more than width, height and pitch settings to mode-set the display resolution. 3. The class assumes all instances should supply some sort of EDID, so it facilitates such mechanism to do so. Even if a given driver does not know what is the actual EDID, it will ask to create default-generic EDID blob. 3. This class shifts the responsibilies of switching between console mode and graphical mode from a GraphicsAdapter to the DisplayConnector class, so when doing the switch, the GraphicsManagement code actually asks each DisplayConnector object to do the switch and doesn't rely on the GraphicsAdapter objects at all.
2022-05-05LibC: Add IN6_IS_ADDR_MULTICASTTim Schumacher
2022-05-03LibC: Hide `posix_memalign` by defaultTim Schumacher
This should keep ports from preferring `posix_memalign` over other implementations of aligned memory.
2022-05-02Meta+Userland: Add ENABLE_USERSPACE_COVERAGE_COLLECTION CMake optionAndrew Kaster
This option sets -fprofile-instr-generate -fcoverage-mapping for Clang builds only on almost all of Userland. Loader and LibTimeZone are exempt. This can be used for generating code coverage reports, or even PGO in the future.
2022-05-01LibC: Implement a faster memset routine for x86-64 in assemblyDaniel Bertalan
This commit addresses the following shortcomings of our current, simple and elegant memset function: - REP STOSB/STOSQ has considerable startup overhead, it's impractical to use for smaller sizes. - Up until very recently, AMD CPUs didn't have support for "Enhanced REP MOVSB/STOSB", so it performed pretty poorly on them. With this commit applied, I could measure a ~5% decrease in `test-js`'s runtime when I used qemu's TCG backend. The implementation is based on the following article from Microsoft: https://msrc-blog.microsoft.com/2021/01/11/building-faster-amd64-memset-routines Two versions of the routine are implemented: one that uses the ERMS extension mentioned above, and one that performs plain SSE stores. The version appropriate for the CPU is selected at load time using an IFUNC.
2022-05-01LibELF: Add support for IFUNCsDaniel Bertalan
IFUNC is a GNU extension to the ELF standard that allows a function to have multiple implementations. A resolver function has to be called at load time to choose the right one to use. The PLT will contain the entry to the resolved function, so branching and more indirect jumps can be avoided at run-time. This mechanism is usually used when a routine can be made faster using CPU features that are available in only some models, and a fallback implementation has to exist for others. We will use this feature to have two separate memset implementations for CPUs with and without ERMS (Enhanced REP MOVSB/STOSB) support.
2022-04-30LibC: Add all the `POSIX_FADV_*` constantsTim Schumacher
2022-04-29LibC: Implement posix_fadvise() (as a harmless no-op)Andreas Kling
2022-04-29LibC: Add more _POSIX_FOO constants to unistd.hAndreas Kling
Let's advertise more of our POSIX capabilities. :^)
2022-04-29LibC: Add MIN, MAX and howmany macros to sys/param.hAndreas Kling
2022-04-29LibC: Actually set the FPU environment instead of its pointerTim Schumacher
2022-04-29Kernel: Support userspace TTY graphics modesettingPeter Elliott
This is a copy of linux's KDSETMODE/KDGETMODE console ioctl(2) interface.
2022-04-26LibC: Don't handle pending exceptions when reading FPU statusTim Schumacher
2022-04-26Kernel: Add FIOCLEX and FIONCLEX ioctlsAndreas Kling
These allow you to turn the close-on-exec flag on/off via ioctl().
2022-04-23LibC: Use correct inttypes.h format strings on Aarch64Daniel Bertalan
Similarly to x86_64, Aarch64 is LP64, so its `uint64_t` type is `unsigned long`. Fixes a bunch of compiler warnings when compiling the LLVM runtime libraries for the aarch64-pc-serenity target.
2022-04-23LibC: Unconditionally include bits/posix1_lim.h from limits.hDaniel Bertalan
No other system seems to put this behind a _USE_POSIX ifdef.
2022-04-23Kernel+LibC+LibCore: Implement the unlinkat(2) syscallsin-ack
2022-04-21LibC: Stub out posix_memalign()Andreas Kling
2022-04-21LibC: Make nameinfo (NI_*) constants bitfield-friendlyAndreas Kling
These are supposed to be used as flags in a bitfield, so let's make them powers of two.
2022-04-21LibC: Implement errno via a __errno_location() functionAndreas Kling
This matches how some other systems implement errno, and makes 3rd party software that expect us to have __errno_location() work.
2022-04-19LibC: Return early in time_to_tm for large time_tLeonardo Duarte
POSIX says that localtime should fail with EOVERFLOW if the result cannot be represented, which is the case for most large (in absolute value) time_t inputs, since they overflow (or underflow) tm_year, which is an int. This patch introduces this functionality. Previously, tm_year just overflowed (or underflowed) silently. Incidentally, this partially fixes #12729 without solving the root problem, which is that time_to_tm is linear in its input to determine the number of years since epoch. This means that the bash port mktime test no longer times-out in 60s, but it still fails (faster) in some other place. Due to underlying issue in the algorithm, the worst case inputs still take a couple of seconds on my machine.
2022-04-15LibC+LibCore: Change a.m./p.m. to AM/PMcflip
2022-04-15LibC+LibCore: Properly format 12-hour formatted hourscflip
This fixes a small formatting issue where midnight and noon would display as 00 when they should display as 12.
2022-04-14LibC: Define correct limits for `long` on `x86_64`Tim Schumacher
2022-04-03LibC: Implement __fseterrTim Schumacher
2022-04-03LibC: Implement __freadptrincTim Schumacher
2022-04-03LibC: Implement __freadaheadTim Schumacher
2022-04-03LibC: Implement __freadptrTim Schumacher
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-29LibC: Implement `getdtablesize()`Jelle Raaijmakers
2022-03-29LibC: Make prctl() a varargs functionTim Schumacher
2022-03-29LibC: Make wchar size definitions available from stdint.hTim Schumacher
POSIX describes WCHAR_MIN and WCHAR_MAX in stdint.h(0P), while wchar.h(0P) only says "as described in stdint.h". As there isn't a trivial path of "may make visible", just move it to a shared header and include it from both files.
2022-03-28LibC: Fix inttypes.h macros for x86-64 and extend themDaniel Bertalan
On x86-64, `int64_t` is defined to be `long` (not `long long`) , so for printing, the "l" format specifier has to be used instead of i686's "ll". A couple of these macros weren't updated when the x86-64 target was added, so using them produced warnings like this: > warning: format specifies type 'long long' but the argument has type > 'int64_t' (aka 'long') [-Wformat] > > "DW_CFA_GNU_negative_offset_extended(%" PRId64 ")\n", offset); > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ This commit changes the macros to be correct for both architectures, and reorders them to be consistent and adds a couple missing ones for the sake of completeness.
2022-03-28LibC: Partially implement __fpendingTim Schumacher