summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC
AgeCommit message (Collapse)Author
2021-10-03LibC: Manually count stored bytes in mbstate_tTim Schumacher
This is probably a bit faster than constantly having to look through all stored bytes. It also helps when we are trying to store actual null bytes.
2021-10-03LibC: Remove the mbstate_reset helperTim Schumacher
A zero-initialized mbstate_t struct has to be a valid initial state, so we can just zero-initialize it whenever we need to reset. Having a helper function for resetting the struct might imply that you can add additional setup operations afterwards, which is not the case.
2021-10-03LibC: Stub out swprintfTim Schumacher
2021-10-03LibC: Stub out wcstoldTim Schumacher
2021-10-03LibC: Stub out wcstodTim Schumacher
2021-10-03LibC: Stub out wcstofTim Schumacher
2021-10-03LibC: Stub out wcstoullTim Schumacher
2021-10-03LibC: Stub out wcstoulTim Schumacher
2021-10-03LibC: Implement wmemmoveTim Schumacher
2021-10-03LibC: Implement wmemsetTim Schumacher
2021-10-03LibC: Implement wmemcpyTim Schumacher
2021-10-03LibC: Implement wmemchrTim Schumacher
2021-10-03LibC: Implement wcsstrTim Schumacher
2021-10-03LibC: Implement wcspbrkTim Schumacher
2021-09-26LibC+LibELF: Add definitions for extra dtagsRodrigo Tobar
These are found in some libraries, and LibELF doesn't know how to handle them, not even their name. Adding these definitions should at least help readelf display information correctly, but more work is needed to actually implement them.
2021-09-23LibC: Add getpriority() and setpriority() stubsJelle Raaijmakers
Expected behavior left as a FIXME is outlined here: https://pubs.opengroup.org/onlinepubs/7908799/xsh/getpriority.html
2021-09-23LibC: Add chroot() stubJelle Raaijmakers
Expected behavior left as a FIXME is described here: https://pubs.opengroup.org/onlinepubs/7908799/xsh/chroot.html It is marked as LEGACY but still used in projects such as PHP.
2021-09-20LibC+DynamicLoader: Store the auxiliary vector address at startupItamar
Previously, getauxval() got the address of the auxiliary vector by traversing to the end of the `environ` pointer. The assumption that the auxiliary vector comes after the environment array is true at program startup, however the environment array may be re-allocated and change its address during runtime which would cause getauxval() to work with an incorrect auxiliary vector address. To fix this, we now get the address of the auxiliary vector once in __libc_init and store it in a libc-internal pointer which is then used by getauxval(). Fixes #10087.
2021-09-20LibC: Spec compliant IN6_IS_ADDR_V4MAPPEDKenneth Myhra
An IPv4 mapped IPv6 address consist of 80 "0" bits, followed by 16 "1" bits, followed by the 32-bit IPv4 address. Example of IPv4 mapped IPv6 address: IPv4 address: 169.219.13.133 IPv6 address: 0000:0000:0000:0000:FFFF:A9DB:0D85 Simplified : ::FFFF:A9DB:0D85
2021-09-20AK+LibC: Remove SERENITY_LIBC_BUILD guard around `<initializer_list>`Andrew Kaster
This was required before commit 5f724b6ca1aae3a5a8c7189069649e8a9347cca2 when we were building LibC before libstdc++ headers were available in the sysroot. However as noted in that commit, we never actually needed to be building LibC before libstdc++, so we can go ahead and remove this ancient hack.
2021-09-19LibC: Declare IN6_IS_ADDR_V4MAPPED correctlyKenneth Myhra
When using the IN6_IS_ADDR_V4MAPPED macro in Serenity's LibC it would fail when compiling with the error message: 'invalid type argument of '->''. This patch corrects the macro so that e.g. GLib port can compile again.
2021-09-18LibC: Implement most langinfo values mentioned in POSIXTim Schumacher
2021-09-18LibC: Primitively implement wcscollTim Schumacher
At the moment, sorting like LC_COLLATE=C would do is better than nothing.
2021-09-18LibC: Don't format strings when asserting with an unstable heapJean-Baptiste Boric
If we hit an assertion while the heap isn't in a stable state, we can't rely on dynamic memory allocation because the malloc mutex is already held and the heap is most likely corrupted. Instead, we need to bail out fast before we make the situation even worse.
2021-09-17LibC: Implement towctransTim Schumacher
2021-09-17LibC: Implement iswctypeTim Schumacher
2021-09-17LibC: Implement wctransTim Schumacher
2021-09-17LibC: Implement wctypeTim Schumacher
2021-09-17LibC: Change wctrans_t to be a long instead of int*Tim Schumacher
The POSIX manpage just says that wctrans_t should be "a scalar type that can hold values which represent locale-specific character mappings", and doing switch statements with ints is much more pleasant than with pointers.
2021-09-16Kernel+LibC: Pack SC_stat_params struct tighterBrian Gianforcaro
Flagged by pvs-studio, ordering the members from largest to smallest allows us to save a few bytes in the size of the struct.
2021-09-16Kernel+LibC: Pack SC_mount_params struct tighterBrian Gianforcaro
Flagged by pvs-studio, ordering the members from largest to smallest allows us to save a few bytes in the size of the struct.
2021-09-16Kernel+LibC: Pack SC_setsockopt_params struct tighterBrian Gianforcaro
Flagged by pvs-studio, ordering the members from largest to smallest allows us to save a few bytes in the size of the struct.
2021-09-16Kernel+LibC: Pack SC_accept4_params struct tighterBrian Gianforcaro
Flagged by pvs-studio, ordering the members from largest to smallest allows us to save a few bytes in the size of the struct.
2021-09-16Kernel+LibC: Pack SC_inode_watcher_add_watch_params struct betterBrian Gianforcaro
Flagged by pvs-studio, ordering the members from largest to smallest allows us to save a few bytes in the size of the struct.
2021-09-16LibC: Implement mbsinit and mbrtowcTim Schumacher
2021-09-16LibC: Implement btowc()Tim Schumacher
2021-09-16LibC: Stub out a bunch of wchar functionsTim Schumacher
2021-09-16LibC: Define ptrdiff_t limitsTim Schumacher
2021-09-16LibC: Provide a dummy mbstate_t in wchar.hTim Schumacher
POSIX just says that mbstate_t should be an "object type other than an array type" that can hold the conversion state for converting between (multi-byte) characters and wide characters. Since no other information regarding the contents is given, this apparently means that we should add whatever we need once we start implementing that conversion.
2021-09-16LibC: Implement CODESET for langinfoTim Schumacher
2021-09-15Meta: Switch to a SuperBuild that splits host and target buildsAndrew Kaster
Replace the old logic where we would start with a host build, and swap all the CMake compiler and target variables underneath it to trick CMake into building for Serenity after we configured and built the Lagom code generators. The SuperBuild creates two ExternalProjects, one for Lagom and one for Serenity. The Serenity project depends on the install stage for the Lagom build. The SuperBuild also generates a CMakeToolchain file for the Serenity build to use that replaces the old toolchain file that was only used for Ports. To ensure that code generators are rebuilt when core libraries such as AK and LibCore are modified, developers will need to direct their manual `ninja` invocations to the SuperBuild's binary directory instead of the Serenity binary directory. This commit includes warning coalescing and option style cleanup for the affected CMakeLists in the Kernel, top level, and runtime support libraries. A large part of the cleanup is replacing USE_CLANG_TOOLCHAIN with the proper CMAKE_CXX_COMPILER_ID variable, which will no longer be confused by a host clang compiler.
2021-09-13LibC: Upgrade memmove() to memcpy() when possibleAndreas Kling
We were missing out on opportunities to use memcpy() instead of memmove() when the source and destination don't overlap.
2021-09-13LibC: Implement explicit_bzero with AK::secure_zeroBrian Gianforcaro
2021-09-12Kernel+Userland: Introduce a new way to reboot and poweroff the machineLiav A
This change removes the halt and reboot syscalls, and create a new mechanism to change the power state of the machine. Instead of how power state was changed until now, put a SysFS node as writable only for the superuser, that with a defined value, can result in either reboot or poweroff. In the future, a power group can be assigned to this node (which will be the GroupID responsible for power management). This opens an opportunity to permit to shutdown/reboot without superuser permissions, so in the future, a userspace daemon can take control of this node to perform power management operations without superuser permissions, if we enforce different UserID/GroupID on that node.
2021-09-12Kernel+LibC: Implement fsyncTheFightingCatfish
2021-09-11AK: Replace the mutable String::replace API with an immutable versionIdan Horowitz
This removes the awkward String::replace API which was the only String API which mutated the String and replaces it with a new immutable version that returns a new String with the replacements applied. This also fixes a couple of UAFs that were caused by the use of this API. As an optimization an equivalent StringView::replace API was also added to remove an unnecessary String allocations in the format of: `String { view }.replace(...);`
2021-09-11Kernel+Userland: Remove loadable kernel modulessLiav A
These interfaces are broken for about 9 months, maybe longer than that. At this point, this is just a dead code nobody tests or tries to use, so let's remove it instead of keeping a stale code just for the sake of keeping it and hoping someone will fix it. To better justify this, I read that OpenBSD removed loadable kernel modules in 5.7 release (2014), mainly for the same reason we do - nobody used it so they had no good reason to maintain it. Still, OpenBSD had LKMs being effectively working, which is not the current state in our project for a long time. An arguably better approach to minimize the Kernel image size is to allow dropping drivers and features while compiling a new image.
2021-09-10AK+Everywhere: Reduce the number of template parameters of IntrusiveListAli Mohammad Pur
This makes the user-facing type only take the node member pointer, and lets the compiler figure out the other needed types from that.
2021-09-10LibC: Define RLIM_NLIMITS constantRodrigo Tobar
This is required by programs that want to either iterate over all resources, or check that a resource identifier is valid before passing it down.
2021-09-09LibC: Make remove() propagate non-EISDIR unlink() errorsAndreas Kling
Regressed in 16105091ba5cb8e9d81eabcb499e70b1907ffc08.