Commit Graph
100 Commits
Author SHA1 Message Date
Augustin Cavalier a706a92d65 hda: Fix build with DEBUG enabled.
We need the kernel debug macros defined so that hmulti_audio doesn't
try to use the userland ones.
2024-09-17 18:50:09 -04:00
Augustin Cavalier 89235ee967 DebugAnalyzer: Fix build after SinglyLinkedList API change. 2024-09-17 17:54:06 -04:00
Augustin Cavalier 99d2d975a4 BCollator: Avoid more crashes when the ICUCollator fails to initialize. 2024-09-17 17:51:53 -04:00
Augustin Cavalier 5a8a2b5066 package_repo: Add -f argument to "list" mode to print filenames.
This way, users of package_repo don't have to reassemble the
canonical filenames themselves.
2024-09-17 10:53:21 -04:00
Augustin Cavalier 8728f4797f libroot: Move malloc implementations to their own subdirectory.
No functional change intended.
2024-09-16 16:12:01 -04:00
Augustin Cavalier f6313044f1 kernel/vm: Add "unimplemented" messages in VMTranslationMap::Debug methods.
This way, when certain KDL commands don't work on architectures that
don't implement these methods, it won't be a mystery as to why.
2024-09-16 16:00:01 -04:00
Augustin Cavalier d29c0e6ee5 libroot: Fix shared unnamed semaphore acquisition with timeouts.
We set flags above the timeout check, so we need to use |= and
not lose the SHARED flag we already set.

Fixes some testcases in the POSIX testsuite, and the shared
semaphore code in Gecko/Firefox.
2024-09-16 15:38:29 -04:00
Augustin Cavalier 2eb83002c5 strace: Add FlagsTypeHandler for the mutex option flags.
So that MUTEX_SHARED etc. are displayed in strace output.
Also fix indentation, and the name of the "toFlags" parameter
in syscall definitions.
2024-09-16 15:36:12 -04:00
Augustin Cavalier e1d0a30ed4 bin: Link launch_roster against libshared. 2024-09-16 14:48:54 -04:00
Augustin Cavalier 532c5e75d3 TextTable: Ignore ANSI escape codes when counting text width.
Otherwise the launch_roster table will be misaligned.
2024-09-16 14:39:31 -04:00
Augustin Cavalier 33ce9b1b5c runtime_loader: Remove -fno-builtin from compiler options.
Except on kernel_cpp.cpp. We don't use it for most of libroot, so
we don't need it for most of runtime_loader either. The two preceding
changes were all that's necessary to fix things with builtins enabled.

Very slight performance improvement (the "run 1000 shells" benchmark
seems to decrease by about 0.4 seconds out of 16.5 or so.)
2024-09-16 13:23:46 -04:00
Augustin Cavalier 6a519848d8 runtime_loader: Add cast in ELF TLS to appease GCC.
Otherwise when builtins are enabled, we get class-memaccess warnings.
2024-09-16 13:19:47 -04:00
Augustin Cavalier 6863cd3038 runtime_loader: Add calloc() to heap implementation.
Taken from the bootloader's version, which this heap is based on.
2024-09-16 13:18:57 -04:00
Augustin Cavalier fbf5967e67 packagefs: Restore accidentally removed rw_lock initializations.
Incorrect rebase from the change that removes these from Node.
2024-09-11 15:23:40 -04:00
Augustin Cavalier 088e0628c2 packagefs: Acquire some more write locks to fix assertion failures. 2024-09-11 15:20:35 -04:00
Augustin Cavalier dfb09e12b1 packagefs: Set and unset node parents in Directory rather than Node::Init.
This way we can ASSERT() that the node doesn't belong to some other
directory.
2024-09-11 15:20:35 -04:00
Augustin Cavalier cb29c48dfa packagefs: Add more write-locked assertions.
Also fix a memory leak on failure in mount().
2024-09-11 15:20:35 -04:00
Augustin Cavalier 57bc041d4b packagefs: Add CountReferences method to InlineReferenceable. 2024-09-11 15:20:35 -04:00
Augustin Cavalier a5dbc9f81c HaikuPorts: Synchronize. 2024-09-10 23:21:22 -04:00
Augustin Cavalier 70b84c8aa2 kernel/locks: Assert that rwlocks have no readers on destruction.
Previously only whether there were active waiters was checked.
2024-09-10 23:02:18 -04:00
Augustin Cavalier 2d07400f07 nvme_disk: Unlock the ReadLocker before notifying the IORequest.
SetStatusAndNotify might call us back for more I/O, and we don't
need (or want) to hold a read-lock for that. It will be acquired
anew if necessary.
2024-09-10 18:13:32 -04:00
Augustin Cavalier 13a5c7f91f kernel/lock: Remove ASSERT_UNLOCKED_RW_LOCK from _rw_lock_read_lock.
It's valid to read-lock the same rwlock twice, of course.

(Only affects KDEBUG_RW_LOCK_DEBUG builds, the assertions do
nothing on any other.)
2024-09-10 18:12:20 -04:00
Augustin Cavalier dd45194d37 kernel/lock: Adjust KDEBUG_RW_LOCK_DEBUG logic in _rw_lock_read_unlock.
We need to always decrement the count by 1 even if we own the lock.
Seems to fix some intermittent hangs with KDEBUG_RW_LOCK_DEBUG.
2024-09-10 17:24:57 -04:00
Augustin Cavalier 1705e9761a kernel/x86: Don't disable the CPUID/MSR TSC frequency read on hypervisor.
It was disabled when adding the hypervisor CPUID leaf reading to
the bootloader, but that's not really necessary. This way, if
a hypervisor does not provide that CPUID leaf but does provide
the value in the standard CPUID or MSR, we will still read it
correctly anyway.
2024-09-10 17:07:10 -04:00
Augustin Cavalier 1e13801271 kernel/locks: Add another assertion to _rw_lock_unset_read_locked.
This method is only used when KDEBUG_RW_LOCK_DEBUG is enabled,
which it isn't by default (even when KDEBUG is.)
2024-09-10 17:05:12 -04:00
Augustin Cavalier 0d931e6321 registrar: Use BMessage::MakeEmpty().
Shouldn't be a functional change, but more idiomatic.
2024-09-10 17:04:21 -04:00
Augustin Cavalier f7c5998eb0 kernelland_emu: Include <debug.h> and set defines before <lock.h>. 2024-09-10 17:04:02 -04:00
Augustin Cavalier f5f11192a1 kernel/slab: Add some more information to slab_object KDL command. 2024-09-10 17:03:43 -04:00
Augustin Cavalier bfc4b17442 kernelland_emu: Fix build following kernel mutex ABI changes. 2024-09-10 16:13:25 -04:00
Augustin Cavalier 65f942aada WebPositive: Add missed conversion from BString to HashString. 2024-09-10 15:48:16 -04:00
Augustin Cavalier ab4fc43458 EntryCache: Cache the entry's hash value.
EntryCacheEntry was padded out to 40 bytes, so this doesn't increase
its size (on 64-bit platforms).

Also increase entriesSize to actually be a power of 2.

This saves us a string comparison when the hashes don't match.
It saved around ~1400 such string comparisons during a boot, and then
rebuilding HaikuDepot, it saved around ~10,000 (both numbers after
factoring in the hashes that compared equal but the directory
values differed, as we skip the string comparisons in that case too.)

Time to compile HaikuDepot seems slightly improved, on average.
2024-09-10 14:07:37 -04:00
Augustin Cavalier 1af0198a7d EntryCache: Unify hash computation logic and use uint32 for it.
Some methods returned uint32 and others returned size_t. We always
set only the lower 32 bits of the value, so just use uint32 everywhere.
2024-09-10 13:43:18 -04:00
Augustin Cavalier b8a2c90991 EntryCache: Use memcpy to copy the strings.
We already use strlen() once, we might as well cache that result
and then use memcpy() instead of strcpy().
2024-09-10 12:40:00 -04:00
Augustin Cavalier f3a9981f9f kernel/vm: Add dangling-reference assertions to AddressSpace{Read,Write}Locker.
Inspired by a change from jpelczar.
2024-09-10 12:35:41 -04:00
Augustin Cavalier b4798ac6a7 kernel: Add assertions to ensure vm_page_reservation is destroyed with a count of 0.
Inspired by some of jpelczar's changes.
2024-09-10 12:13:38 -04:00
Augustin Cavalier 5f8fe75449 freebsd_network: Don't include <vm/vm_page.h> in bus_dma.cpp.
The BSD headers prevent using ASSERT definitions in it if we do,
and one will be added in the next commit. Just declare the one
method we need from it instead.
2024-09-10 12:11:57 -04:00
Augustin Cavalier fcae3b6674 kernel/thread: Unset user_data only after unblocking the thread.
This amends 352548d0a3.

If the thread was migrated to another CPU after it was blocked with a
timeout and then was unblocked without needing the timeout, this handler
could possibly race with the thread waking up on the other CPU, resulting
in the other thread thinking it doesn't need to cancel the timer when
the timer is still in the process of running.

May fix #18983.
2024-09-10 11:17:38 -04:00
Augustin Cavalier d8e26ab4d1 HaikuDepot: Switch to using BString::HashValue. 2024-09-09 23:36:39 -04:00
Augustin Cavalier cfdc362817 pthread_barrier: Actually unlock the barrier lock.
If we just unblock all threads without actually releasing the lock,
then in the case where all threads have performed the atomic_add
but none have actually started waiting, we'll deadlock forever.

Fixes Mesa deadlocking when using our pthread barriers (at present
it's been using its own.)
2024-09-09 23:08:00 -04:00
Augustin Cavalier 151f01c21d Debugger: Remove unused includes.
Missed in prior change.
2024-09-09 22:35:29 -04:00
Augustin Cavalier f4e0ce8d61 kernel/lock: Fix ABI compatibility between KDEBUG and non-KDEBUG builds.
This breaks kernel ABI on KDEBUG builds (but not non-KDEBUG builds),
but it does so in order to resolve a long-standing incompatibility
between them: until now, any kernel add-ons built against one which
made use of these lock facilities could not be run on the other;
instead you would get hangs and/or crashes.

After this change, kernel add-ons built with a KDEBUG configuration
should work on a non-KDEBUG kernel, while add-ons built with a
non-KDEBUG configuration will fail to load on a KDEBUG kernel
with unresolved symbols, preventing incorrect and broken operation.
2024-09-09 22:35:05 -04:00
Augustin Cavalier cf5249749d libbsd: Use timespec_to_bigtime for time conversions in kqueue.
The FreeBSD manpage indicates that it will fail with EINVAL if
an invalid timespec is passed.
2024-09-09 17:33:04 -04:00
Augustin Cavalier 6a2d53e723 Debugger: Use BString::HashValue().
Previously BString::HashValue() had an identical hash to the one
in StringUtils::HashValue(), but now it uses hashdjb2, so this
means Debugger will now use that also.

Tested basic Debugger functionality, seems to still work.

Change-Id: Ia341daa56249967a494df46e6e0a69a74c8b5fe2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8266
Reviewed-by: Rene Gollent <[email protected]>
2024-09-09 18:13:29 +00:00
Augustin Cavalier c07586a343 kernel/low_resource_manager: Add wait entry before releasing the semaphore.
Otherwise the low_resource thread's run may complete before we
even start waiting, which makes things much slower as we then
have to wait all the way to the timeout.
2024-09-09 13:44:18 -04:00
Augustin Cavalier 54113084a4 kernel/locks: Add another assertion to _mutex_unlock.
We should only get an error return code in this method when the mutex
was destroyed, in which case waiter.thread should be NULL.

Also do some minor code cleanups.

May help with diagnosing #18983.
2024-09-09 13:42:26 -04:00
Augustin Cavalier 67c0b8f2d1 BString, HashString: Replace string hashes with hashdjb2. 2024-09-09 13:39:29 -04:00
Augustin Cavalier e9254dd79c Package Kit, WebPositive: Standardize string hashes.
Use either HashString or BString::HashValue (both of which currently
use the "modified hashpjw".)
2024-09-09 13:39:28 -04:00
Augustin Cavalier 0d71a44091 mixer: Also delay starting the mixer until the realTime is recent.
If it's more than a second in the past, continue delaying.
May help with #19074 and/or #18981.
2024-09-08 15:22:06 -04:00
Augustin Cavalier 2897b2cc97 Tracker: Rename HashString to not conflict with the HashString class.
Right now, nothing includes both, but when WebPositive is switched to
use <HashString.h> instead of its own HashKeyString, it will.
2024-09-08 15:01:26 -04:00
Augustin Cavalier 1389907570 ramfs: Switch to hash_hash_string.
Remove the now-unused string_hash from String.h.
2024-09-08 15:00:27 -04:00
Augustin Cavalier 006c901891 StringHash: Replace with hashdjb2().
packagefs StringPool on my system had about 380 colliding string hashes
with the old hash_hash_string (out of ~98,000 strings). With this, it has
only 4, and they're all very odd strings (example: "p16c5x.inc" and
"p16c76.inc" collide.)

(This affects more than packagefs, though; other parts of the kernel
also make use of this routine, including the EntryCache.)

Change-Id: I3cf48a28c5c1a1fb5a457cfaf4fff80029ae146c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8243
Reviewed-by: Adrien Destugues <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2024-09-07 19:34:21 +00:00
Augustin Cavalier c0bf008a31 Tracker: Reduce kDirentBufferSize to 2 * B_PAGE_SIZE.
The kernel will never return more than this, so there's no reason
to bother with allocating a larger buffer.
2024-09-07 12:52:15 -04:00
Augustin Cavalier 86fbc36f66 kernel/fd: Reduce kMaxReadDirBufferSize to 2 pages at most.
Standard kernel malloc() only uses the block allocator for allocations
up to size 8192, and anything past that has to do a raw allocation,
which is much slower than going through the object_cache.

libroot's readdir() uses a buffer of size 4096, but BDirectory
invokes the syscall directly and allows using arbitrary buffer sizes.
Tracker's AddPosesTask uses CachedEntryIterator which invokes the
syscall with 10 KB buffers, which thus hits this path.

Reducing the buffer size shouldn't be a problem, as applications should
continue calling GetNextDirents() until it returns 0. In case there
are buggy applications, we can simply change GetNextDirents to
call the syscall multiple times if it needs to. Tracker still seems
to behave OK, at least.
2024-09-07 12:50:53 -04:00
Augustin Cavalier 788da26bbc kernel: Let user_debugger take care of tracking syscall runtime.
If we just use the kernel entry time, then the pre-syscall tracing
routine (with a debugger message send) will be counted in the syscall's
runtime.

Makes the output of timing in strace and strace -c much more accurate,
however it won't include the "syscall overhead" (time spent in the
syscall entry routines, etc.) But we already can't account for time
spent in the userland-to-kernel transition, so that should probably
be measured some other way if knowing it is desired.

In fact, on architectures which used the generic syscall dispatcher
(e.g. RISC-V), this is the behavior that already existed. So this just
makes x86 consistent with them.

Change-Id: I8cef6111e478ab49b0584e15575172eea77a8760
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8240
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2024-09-07 15:31:15 +00:00
Augustin Cavalier 2358db9297 BCollator: Don't crash in SetStrength() if the ICUCollator failed to initialize. 2024-09-07 11:30:27 -04:00
Augustin Cavalier 2c61e38afb packagefs: Include hash table size in StringPool overhead. 2024-09-07 11:29:54 -04:00
Augustin Cavalier cdb5f73822 packagefs: Add a Compare() method to StringKey.
Returns an int which is -1, 0, or 1, much like strcmp(). Implemented
as part of the work for using an AVLTree to store nodes, which won't
be merged, but this may be useful in the future anyway.
2024-09-07 11:29:33 -04:00
Augustin Cavalier 6d1f6cad34 Package Kit: Allocate attribute handlers with BumpAllocator.
On my development VM, there were over 300,000 calls to malloc()
from EntryAttributeHandler::HandleAttribute() alone, which had
the most out of any AttributeHandler, but the others were still
significant (over another 10,000 at least.) On systems with more
packages and more attributes, there would be of course more calls
to malloc().

Since the Handlers are allocated and freed in a "stack"-like
configuration, we can use a simple "bump" allocation strategy
with the AttributeHandlerContext to avoid calling malloc() at all.
In my testing, the most memory that was used appeared to be around
2 KB or so (and the smallest was 216 bytes), so a single slab
should suffice for this.

AttributeHandlerContext seems to be created/destroyed around 530 times
during the boot process on my test machine; allocating and freeing the
allocator's slab page that many times should be negligible (allocations
that large still go through the block allocator.)

Performance-wise, the total time we spend with AttributeHandlerContext
objects "alive" goes from around ~172ms to ~156ms. So, not as much an
improvement as one might hope, but that just goes to show that our
kernel malloc() is pretty efficient. And this change will also keep
short-lived objects off the heap during a period when we are allocating
many long-lived objects, anyway.

Change-Id: I810888434aad788511f2af30143335009b34ee78
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8230
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2024-09-06 19:15:42 +00:00
Augustin Cavalier 3be79a33b0 kernel/util: Introduce BumpAllocator.
A basic bump allocator that can handle arbitrary amounts of allocations,
so long as all are allocated and freed in a "stack"-like manner.

(Actually it could be extended to support non-stack-like operation,
but that would require more logic that isn't needed at the moment.)

Change-Id: I47077146ea282600130778d312f7d86bd8c032e0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8238
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Michael Lotz <[email protected]>
2024-09-06 19:15:42 +00:00
Augustin Cavalier ace43da6f9 kernel/thread: Account for current run in fill_thread_info's CPU time handling.
Otherwise, if the thread is currently running, its runtime won't
be included in the returned statistics.
2024-09-06 14:22:40 -04:00
Augustin Cavalier 4e392e7f44 AboutSystem Credits: Move a number of people from Current to Past maintainers.
Anyone I've moved, I didn't see any signs of code contributions
or reviews, tickets, or forum posts in the last year and a half
at least. They may still be around and reachable, but I don't think
that suffices to be a "Haiku maintainer".

I've also moved Alexander up in the list of maintainers; the "Past"
list doesn't seem to count "von" for the alphabetical sort.
There was also one mis-sort in the past list which I've fixed.

Change-Id: If6763372be6a23b24bc0f781243e198d1734a849
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8239
Reviewed-by: waddlesplash <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2024-09-06 15:14:01 +00:00
Augustin Cavalier 65f80c14fc packagefs: Declare more classes as "final". 2024-09-06 00:32:07 -04:00
Augustin Cavalier 41b4817e4c packagefs: Break out the inline Referenceable from PackageNode and use it for Node.
We unfortunately have to define its methods in the .cpp and not fully
inline them, because otherwise GCC chokes in some places thinking
that the class can be NULL (where it can't be) and thus generating
overrun -Werrors.

This reduces the size of Node and all subclasses (like UnpackingLeafNode)
by 8 bytes. (Not 16 as with PackageNode, as it doesn't eliminate a
virtual table pointer.)
2024-09-06 00:10:49 -04:00
Augustin Cavalier 76985513d6 packagefs: Use an inline reference count in PackageNode.
BReferenceable has a vtable, so it's aligned on sizeof(void*) and thus
has 4 bytes of padding on 64-bit systems. We also had 4 bytes of padding,
and so if we just inline an int32 and add Acquire/Release methods,
then we save 16 bytes (again on 64-bit systems) of object size.

Since this isn't so obvious, add an inline comment explaining the
situation.

This makes sizeof(PackageFile) go from 112 to 96 bytes, and so on.
2024-09-05 23:06:24 -04:00
Augustin Cavalier 837d9b4776 packagefs: Store PackageNode modified time in bigtime_t, not timespec.
We don't really need nanosecond resolution here, microseconds will do.
We can thus fit the value into bigtime_t and use the standard converters.

Reduces the size of PackageNode by another 8 bytes on 64-bit,
saving another ~2.5 MB of memory (or so) on my test VM.

Change-Id: I1232aa8aa22fbf84a6a70af0129183f297961f03
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8237
Reviewed-by: waddlesplash <[email protected]>
2024-09-06 02:36:02 +00:00
Augustin Cavalier 90eb65c956 mbuf: Rename "page size chunks" cache.
To better align KDL "slabs" output.
2024-09-05 22:25:37 -04:00
Augustin Cavalier 5331db0abd packagefs: PackageNode UID/GID are never actually set.
Perhaps in the future they will be, but for now we don't need
to waste 8 bytes per package node in storing them.
2024-09-05 15:22:32 -04:00
Augustin Cavalier 20d9f6e408 packagefs: Use ClassCache for PackageSymlink too.
We already do it for PackageFile and PackageDirectory, so this
only makes sense.
2024-09-05 14:53:28 -04:00
Augustin Cavalier 0f90b34722 BFS: Terminology cleanup in BlockAllocator.
* Rename NumBlocks to NumBitmapBlocks, as this is the number
   of blocks in the block bitmap, not on the filesystem.

 * Rename AllocationGroup::Block(index) to Chunk(index), as it refers
   to a "chunk" of 32 bits within the bitmap block. This gives us
   one less usage of the term "block" in this file.

 * Remove superfluous comment.

No functional change intended.

Change-Id: If736387fcd9963a4a74bb0dde12ede81da5502f3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8185
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Axel Dörfler <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2024-09-05 15:14:19 +00:00
Augustin Cavalier f060b7ece8 packagefs: Use [] instead of [1] in StringData definition.
This lets the compiler skip adding padding, saving us 8
(or 7, depending on how you look at it) bytes per StringData
(on x86_64, that is.)
2024-09-04 18:53:57 -04:00
Augustin Cavalier e3f2b2d790 packagefs: Print the hash table size in the StringPool overhead. 2024-09-04 18:52:49 -04:00
Augustin Cavalier 8e33a0dacf packagefs: Use SinglyLinkedList for PackageNodeAttribute.
We never actually remove these (except on destruction) and only
iterate over them sequentially, so just use a singly linked list.

Combined with previous changes, this reduces the size of NodeAttributes
from 64 to 48 bytes (on x86_64).
2024-09-04 14:21:58 -04:00
Augustin Cavalier df44e515de SinglyLinkedList: The sole Iterator is really ConstIterator.
It behaves the same way as DoublyLinkedList's ConstIterator,
so let's name it the same way for consistency.
2024-09-04 14:15:20 -04:00
Augustin Cavalier 3e6902c3f4 SinglyLinkedList: Rename Size to Count.
So that it has the same naming as DoublyLinkedList.
No functional change. It seems there aren't any users
of this API in the default build at the moment.
2024-09-04 14:04:46 -04:00
Augustin Cavalier d6dd251e6c packagefs: Remove some last remnants of V1 support.
* PackageData::fVersion is (for now) static const, until such time
   as there's a HPKGv3.

 * Remove locking from DataAccessor as it was only needed for V1.
2024-09-04 14:03:07 -04:00
Augustin Cavalier e5f569eedd packagefs: Don't bother with depots for most of the object caches.
We want them for the heap buffers, but the rest will generally only
be used when other packagefs locks are acquired (during mounting
or unmounting of packages), so the depots are just a waste.
2024-09-04 13:50:09 -04:00
Augustin Cavalier d4d360a0d7 ACPI: Reword the new comment in AcpiOsMapMemory for clarity's sake. 2024-09-04 13:21:28 -04:00
Augustin Cavalier 3dc487fe1c kernel/fs: Ignore FD in fd_and_path_to_dir_vnode if an absolute path was specified.
This is the same thing fd_and_path_to_vnode does.
2024-09-04 13:16:56 -04:00
Augustin Cavalier 2301efc9d9 pthread: Make rwlocks keep waiting on EINTR.
As specified by POSIX.

Fixes #16708.
2024-09-03 16:17:06 -04:00
Augustin Cavalier 4812636028 pthread: Return EINVAL for pthread_detach() if the thread is already detached.
Fixes #16706.
2024-09-03 15:55:44 -04:00
Augustin Cavalier 797b4eef8b pthread: pthread_cancel() on non-existent thread should return ESRCH.
As per POSIX. Fixes #16705.
2024-09-03 15:51:10 -04:00
Augustin Cavalier 95a871b37d libroot: Handle invalid timeouts being passed to unnamed_sem_timedwait.
According to the POSIX specification:

> The sem_timedwait() function shall fail if:
> [EINVAL]
> 	The process or thread would have blocked, and the abstime
>	parameter specified a nanoseconds field value less than zero
>	or greater than or equal to 1000 million.

Fixes #16693, #16694.
2024-09-03 15:38:19 -04:00
Augustin Cavalier 74181c7e1f libroot: _SC_SEM_NSEMS_MAX is functionally unlimited.
Haiku's Be-style semaphores have a global limit, but the
POSIX-style semaphores do not. Functionally there will be a limit
as to how many can be waited on at a time, but one will probably
hit thread limits before that happens.

This matches what FreeBSD does: specifies 256 for _POSIX_SEM_NSEMS_MAX
but then returns -1 for the sysconf value.

Fixes #16692.
2024-09-03 14:57:54 -04:00
Augustin Cavalier 8260adb68d gnulib-test-mbrtowc: Add test for the change in previous commit. 2024-09-03 14:35:47 -04:00
Augustin Cavalier 0559911493 ICUCtypeData: Fix conversion of surrogate pairs.
If a multibyte Unicode character is specified to MultibyteToWchar
one byte at a time, then resetting the state will lose the data
for the second character. We thus shouldn't re-read but instead
keep the existing character and just read the second one.

Fixes #19035.
2024-09-03 14:34:30 -04:00
Augustin Cavalier c686c2216c ICUTimeConversion: Also override to "GMT" in Gmtime().
Otherwise, when the current locale timezone is one that has
an offset to GMT of 0, we would wind up with its name in tm_zone
and not "GMT".

Follows up to #19047.
2024-09-03 14:02:46 -04:00
Augustin Cavalier 5b4d5ef897 ICUTimeConversion: Handle GMT properly in _FillTmValues.
We can be called with a timezone that isn't the same as the one
set in the current locale, in particular from gmtime(). We thus need
to handle this case properly by checking that the gmtoff is really
the timezone in the locale, or if it's GMT, to just use a static
string for the tm_zone instead.

Fixes #19047.
2024-09-03 12:51:59 -04:00
Augustin Cavalier 6b468e5635 libroot: Replace fpurge implementation with upstream glibc's.
This doesn't seem to fix #19039 however.
2024-09-03 12:02:18 -04:00
Augustin Cavalier 0ab7cc6d60 BFile: Use AT_FDCWD instead of -1. 2024-09-03 12:01:21 -04:00
Augustin Cavalier a6de998330 runtime_loader: Use AT_FDCWD instead of -1. 2024-09-03 12:01:00 -04:00
Augustin Cavalier 136442cb5d kernel/fs: Accept only AT_FDCWD and -1 for negative FDs in path_to_vnode.
-1 was our previous value for AT_FDCWD, so we should retain support
for it here for the moment. All other negative values will now result
in an error.

Part of #19048.
2024-09-03 11:51:31 -04:00
Augustin Cavalier 9854d38a3f BEntry: Use AT_FDCWD instead of hardcoding -1. 2024-09-03 11:49:37 -04:00
Augustin Cavalier b93d9fcf70 libroot: Clean up and unify link/linkat.
* Move Haiku -> POSIX error mapping to linkat.

 * Implement link in terms of linkat.
2024-09-03 11:20:51 -04:00
Augustin Cavalier 004833215d libroot: Return EBADF if a negative FD is specified to fdopendir.
And do some minor code cleanups.

Fixes #19060.
2024-09-03 11:20:07 -04:00
Augustin Cavalier 55e8238c72 libroot: Use AT_FDCWD rather than hardcoding -1 in many places.
AT_FDCWD is now -100, not -1, though the kernel accepts any negative
value at the moment.
2024-09-03 11:19:02 -04:00
Augustin Cavalier 90ae97dbac libroot: Remove another obsolete comment. 2024-09-03 11:16:54 -04:00
Augustin Cavalier f27384b845 usb_audio: Reduce log spam.
Fixes #19037.

Change-Id: I1c0a0b39a5d725b95dff5f2d9dd7d61568030146
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8188
Reviewed-by: waddlesplash <[email protected]>
2024-09-02 22:33:40 +00:00
Augustin Cavalier a062b2146e IORequest: Fix computation of parent-relative transfer offsets.
The local transferEndOffset should be relative to the parent (us),
not to the underlying filesystem. We thus need to subtract our
own offset from the operation's offset.

This fixes a regression from be8080575a.
Errors transferring data should now be properly reported in more cases.
2024-09-02 17:57:32 -04:00
Augustin Cavalier 544336415d BFS: Give endian macros parentheses.
Some things that call these macros put expressions in them; to avoid
operator precedence problems we should put them in parens.

Change-Id: I57335ffb190c484778c4bc8075d5ca3597f1e7e5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8184
Reviewed-by: waddlesplash <[email protected]>
2024-09-02 20:19:06 +00:00
Augustin Cavalier 0ef833e5e8 build: Only add haiku_source to package repository if HAIKU_INCLUDE_SOURCES is set.
This way, we won't build the source package unnecessarily for
nightly images when it isn't included in the build.
2024-09-02 15:59:58 -04:00