Commit Graph
100 Commits
Author SHA1 Message Date
Augustin Cavalier 29393e16ae graphics/s3: Fixes for 64-bit.
Untested as I don't have this hardware, but relatively straightforward.

Part of #20112.
2026-06-08 12:11:18 -04:00
Augustin Cavalier 658cb74bed kernel/x86: Initialize CR0 in the kernel more than the bootloader.
The bootloader is now only responsible for setting up Protected Mode
and Paging. It otherwise preserves the existing CR0, and leaves setup
to the kernel.

The kernel now sets CR0 for each CPU in preboot_init_percpu().
Some redundant sets are removed from x86_init_fpu, which now
panic()s in the case where we don't have a FPU, and avoids
unnecessary prints.

This fixes a massive oversight where CR0 was never reset on x86
systems booted using the EFI loader, except on the boot CPU! That
meant that NUMERIC_ERROR and possibly even WRITE_PROTECT were
simply not set on non-boot CPUs, unless the EFI BIOS had set them up
already. (On the BIOS loader, smp_start_kernel() ran on all CPUs.)

Fixes NVMM initialization on non-boot CPUs on Intel hardware.
2026-06-04 18:18:28 -04:00
Augustin Cavalier de79d42abb nvmm: Use dummy kernel & current process maps to avoid allocations.
Removes a bunch of #ifdef __HAIKU__ and avoids unnecessary overhead.
2026-06-04 12:35:08 -04:00
Augustin Cavalier 6f1500d726 kernel/arm64: Add missing "memory" attribute to barrier functions. 2026-06-04 11:16:31 -04:00
Augustin Cavalier d2fdc62fd6 kernel/debug: Check gKernelStartup before printing "CPUs not trapped".
They won't be trapped during kernel startup.
2026-06-04 11:14:34 -04:00
Augustin Cavalier 9b6a529847 kernel/vm: Make VM internal methods C++-only.
They shouldn't be needed from C.

Also add a declaration for VMAddressSpace. This should fix the
RISC-V build.
2026-06-04 11:13:53 -04:00
Augustin Cavalier dd14b451e9 build: Add NVMM, but commented out, to image definitions.
At present, it can boot TinyCore Linux to a GUI, but a Haiku
image reaches the rocket before crashing with an NVMM error,
when tested under nested virtualization in VMware. (It seems
my Intel device is a few generations too old and doesn't have
all required features, so I wasn't able to test there.) So,
some more work is still required, it seems.
2026-06-03 23:12:43 -04:00
Augustin Cavalier fbed0c1424 nvmm & kernel: Implement proper TLB flushing for the nested paging. 2026-06-03 23:12:43 -04:00
Augustin Cavalier 827af4d89a nvmm: Make use of cpu_ent::reschedule_disabled.
This allows the removal of the hacks in VMX support (admittedly
I did not test this, but the equivalent setup works on AMD.)
2026-06-03 23:12:36 -04:00
Augustin Cavalier 08037f3107 kernel/scheduler: Add a mechanism to block reschedules.
This will be used by NVMM, which wants interrupts enabled
but not to be actually preempted until it is safe to do so.
2026-06-03 23:04:56 -04:00
Augustin Cavalier be817ba080 nvmm & kernel: Implement necessary functions/classes for AMD support. 2026-06-03 23:04:56 -04:00
Augustin Cavalier 099de13932 nvmm: Implement necessary functions and classes for Haiku.
Intel VMX only.

Co-authored-by: Augustin Cavalier <[email protected]>
2026-06-03 23:04:56 -04:00
Augustin Cavalier 6e43f9a34a bsd/sys/cdefs.h: Additions for NVMM. 2026-06-03 23:04:55 -04:00
Augustin Cavalier aa731510c1 kernel/vm: Changes to prepare for NVMM.
* VMUserAddressSpace & VMTranslationMap64Bit will need to be inherited from.

 * vm_soft_fault & vm_unmap_address_range will need to be invoked directly.

 * map_backing_store will need to be invoked directly. The whole concept
   of "backing stores" is long merged into VMCache anyway, so at the
   same time, just rename the method to "vm_map_cache".

Methods added to the internal vm_priv.h; they should not be needed
except in special circumstances.
2026-06-03 23:04:55 -04:00
Augustin Cavalier 0088ac13b0 app_server: Refactors to screen configuration management.
* Drop screen_configuration::is_current. This just caused significant
   confusion and problems, because values could get out of sync between
   the Stored and Current screen configuration storage.

 * Try to match by monitor_info always, not just ID.

 * Add the current vs. stored Configurations distinction to VirtualScreen.
   This will populate the CurrentScreenConfiguration object during
   initial configuration of screens.

Fixes app_server not properly reverting to the original resolution after
apps that change the resolution quitting, which was seen in #20042.

Change-Id: I61c9ee4c5b7e755cbb207170d2eddb1d31fd0ea8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11024
Reviewed-by: waddlesplash <[email protected]>
2026-05-28 01:22:15 +00:00
Augustin Cavalier 914768faa8 kernel/timer: Reinstate lazy timer resetting.
This reverts dbc6b2061e.

Hopefully after the various fixes to APIC timer setup, the
problems that this was causing will be gone. (The users who
reported issues with it did so only on the forums and never
opened tickets, it seems.)
2026-05-21 15:12:00 -04:00
Augustin Cavalier 5dfc0663d5 kernel/x86: Avoid using any initial values in APIC timer registers.
We should just be zeroing any unknown bits, not trying to preserve them.
If the BIOS or other mechanisms left the timer in some other mode
besides "one-shot" like we need, then we might incorrectly preserve
those bits.

This also has the advantage of avoiding config reads in set_hardware_timer.
2026-05-21 15:01:17 -04:00
Augustin Cavalier faa27a36dd kernel/thread: Print pinned_to_cpu when dumping thread information.
May help with diagnosing #20100.
2026-05-21 14:06:12 -04:00
Augustin Cavalier 51bbd3778c kernel/smp: Drop the "last caller" spinlock debug system.
Even on a single-core software-emulation QEMU VM, we acquire more
than 10k spinlocks per second (sometimes even over 100k.) That makes
sense, as every syscall entry, mutex acquisition (even uncontended,
for KDEBUG kernels), etc. acquires a spinlock. So, reasonably, this
list will always be too small to detect much of anything at this point.

If we need a similar debugging facility, we should store addresses
or thread IDs in the lock structure. That will require a more significant
refactor to locking code, however, and it doesn't seem necessary at this
time, so I haven't implemented that (yet).
2026-05-21 13:41:52 -04:00
Augustin Cavalier 282c6a34f6 Package Kit: Fix memory leak in BRequest. 2026-05-21 12:58:53 -04:00
Augustin Cavalier 8c25999955 BTabView: Allow SetEnabled to work even if there is no view.
Amends 0a2766d6b0.
2026-05-21 12:58:35 -04:00
Augustin Cavalier f5842905e3 kernel/UserTimer: Major overhaul of the locking design.
* Get rid of the global sUserTimerLock. This was added in 2013
   to prepare for the removal of the global scheduler lock, which
   is what all these routines previously used. The locking design
   was never redesigned since then to accomodate for the changes,
   it appears.

 * Make CPU timers always locked by time_lock, and the system-time
   timers locked by a local lock.

 * Make fScheduled load-bearing as to whether the timer is presently
   in the team/thread lists or not.

 * Don't re-fetch the team/thread every wait cycle. This allows us
   to avoid a lock/unlock dance that would otherwise complicate
   the scheduling logic significantly.

Tested using the old version of the Open POSIX Testsuite (which
indeed caught some bugs in earlier versions of this patch.) All
12 timer_create tests still pass, including the ones that depend on
timers firing within the right timeframe.

Fixes #20090.

Change-Id: I54dd9a49e72f51711baa0fbf18e5c35a7fafec8f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11007
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-05-21 16:54:52 +00:00
Augustin Cavalier 6eec6769f2 kernel: Update comments and add some asserts around the user timers.
Change-Id: I8c5e8faaf9c9a3eb86c1faed29beee4ab2958b3c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11006
Reviewed-by: waddlesplash <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-05-21 16:54:52 +00:00
Augustin Cavalier 57a5a0ff6c kernel/debug: Enter KDL even if some CPUs can't be trapped in it.
Otherwise the system just hangs, which isn't good.

Turns #20090 from a hang into a KDL, as one CPU is stuck in a loop
with interrupts disabled.
2026-05-19 15:25:02 -04:00
Augustin Cavalier ced8a80543 kernel/vm: vm_page_requeue() must be called with the page in ACCESS state.
Should hopefully fix #20103.
2026-05-19 14:55:14 -04:00
Augustin Cavalier 41b45506fc kernel: Add missing NULL check in LegacyDevice::Control.
Fixes #20091.
2026-05-19 13:32:10 -04:00
Augustin Cavalier ff1c6abba8 build_cross_tools (GCC2): Use -std=gnu89 for GCC 13 also.
It shouldn't hurt, and may fix the build in more environments.
2026-05-19 13:15:41 -04:00
Augustin Cavalier c6024e1bff kernel/thread: Assert that thread->pinned_to_cpu does not become negative.
May help with diagnosing #20100.
2026-05-18 11:45:33 -04:00
Augustin Cavalier 286eb01997 stdint.h: Declare SIZE_MAX using __SIZE_MAX__ if available.
Fixes the size_t part of #20079.
2026-05-11 14:36:10 -04:00
Augustin Cavalier 8b38e91f46 headers: Declare address and 64-bit limits using hexadecimal.
No functional change intended.
2026-05-11 14:32:27 -04:00
Augustin Cavalier fd09d924e6 headers: Drop nonstandard null.h and size_t.h.
They're holdovers from R5. <stddef.h> should just be included instead,
and ssize_t declared directly in sys/types.h.
2026-05-11 14:17:55 -04:00
Augustin Cavalier 60d0411454 headers: Move version constants to config/HaikuVersion.h.
They have been in BeBuild.h since BeOS days, but as this file
is included everywhere in the base system headers, it causes
a bunch of unnecessary POSIX namespace pollution. So, instead,
put them in a config header, and include it from SupportDefs.h,
which should only ever be included by Be/Haiku API headers.
2026-05-11 14:08:18 -04:00
Augustin Cavalier 414c41e7bf OS.h: Drop some unnecessary comments.
The first wasn't quite accurate, and the second seems to have been
copied from the R5 header.
2026-05-11 14:03:23 -04:00
Augustin Cavalier 56be32b772 Drop direct includes of size_t.h.
It's a non-standard header we inherited from BeOS. According to the
POSIX specification, size_t should be declared from including stddef.h
and/or sys/types.h, and ssize_t from sys/types.h.
2026-05-11 13:26:44 -04:00
Augustin Cavalier 29fcc40483 system: Move thread_creation_attributes.priority lower to avoid padding.
Note that this breaks syscall ABI.

Change-Id: I353049d67f5611fae87fe9e6193a64d51330c846
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5479
Reviewed-by: waddlesplash <[email protected]>
2026-05-11 17:24:24 +00:00
Augustin Cavalier e7cc89a038 kernel/x86: Use multibyte NOP constants in altcodepatch.
Follows up on a suggestion from the commits mailing list.
2026-05-04 15:27:11 -04:00
Augustin Cavalier facff75dd4 kernel/x86_64: Use VZEROALL to clear XMM/YMM/etc. registers when available.
It comes with AVX, so enable it if we've enabled AVX.

This also adjusts altcodepatch_replace to explicitly set NOPs
for the remainder of the patch area.

Change-Id: Ia07549851d86836ff5428635b580c751b4e5b2a3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10867
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-05-04 00:03:54 +00:00
Augustin Cavalier 009b56e781 kernel/x86_64: Move the stub functions to a stubs.S.
No functional change intended.

Change-Id: I5b52ec9cb401c9c2591ac87fe94c53edfbb7a3fa
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10866
Reviewed-by: waddlesplash <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-05-04 00:03:54 +00:00
Augustin Cavalier ce845a52d4 freebsd_network: Set transfer type in usbd_transfer_setup.
This is necessary for the UE_BULK_INTR case.
2026-04-29 00:01:36 -04:00
Augustin Cavalier 35441396e7 zydwifi1211: Import (if_zyd from FreeBSD 15.)
Requested by a user on Discord. Untested, I don't have this hardware.
2026-04-28 14:10:08 -04:00
Augustin Cavalier b4f627e58b freebsd_network: Add UE_BULK_INTR.
Needed by if_zyd.
2026-04-28 14:08:33 -04:00
Augustin Cavalier a0452d3ac1 SoftwareUpdater: Implement automatic cleanup of admin directory.
Enabled by default, but can be disabled via a new settings window
option (which is saved and remembered across runs.)

Change-Id: Ifd49cd734dcf5e4a5e5b3625d23bc2778fa1fa55
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10850
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-04-28 06:57:18 +00:00
Augustin Cavalier 2964316995 kernel/smp: Make another variable static. 2026-04-27 16:31:55 -04:00
Augustin Cavalier 4dd45837e9 Package Kit & pkgman: Split cleanup operations into a "cleanup" command.
And only inform that some can be deleted at the end of install/uninstall.

As discussed in https://review.haiku-os.org/c/haiku/+/10711.
2026-04-27 16:29:33 -04:00
Augustin Cavalier 3a9a7e2188 libroot/riscv64: Fix TODO about using std::atomic for TLS.
As the comment noted, the same is done on x86_64 already.
2026-04-27 15:15:03 -04:00
Augustin Cavalier 747a839b95 kernel/smp: Move the per-CPU SMP message mailbox into cpu_ent.
Putting all the per-CPU messages in one array means they'll all
be on the same cache lines. The cpu_ent structure is cache-line-aligned,
so this means they'll be on separate cache lines.
2026-04-27 15:14:14 -04:00
Augustin Cavalier 99a4c6e757 network: Handle B_SELECT_DISCONNECTED in socket notifications.
TCPEndpoint::_NotifyReader() calls notify(READ, _AvailableData()),
which after a close will be negative, so this will set DISCONNECTED
in that case.

Drop the unnecessary duplication from TCPEndpoint::_HandleReset:
the net_socket layer sends READ|WRITE notifications in this case.

Fixes #19969.

Change-Id: I0e10c0280f3c84276b486b0375000153a117246d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10581
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-04-25 17:42:44 +00:00
Augustin Cavalier 6aa675a630 ltrace: Place stubs in exectable memory and improve efficiency.
* Implement the TODO about needing to place stubs in executable
   memory. This fixes basic ltrace operations.

 * Place traces behind a TRACE ifdef.

 * Get rid of the "patched table" and find the PatchEntry
   using fixed offsets, to improve efficiency.

 * Add a "bool trace" to PatchEntry. This paves the way for
   tracing only specific methods.

Using LD_PRELOAD_ADDONS=...ltrace_stub.so, trace entries are now
printed on x86_64. However, it seems that the trace stub is clobbering
something, as BWindows don't work correctly when traced.
2026-04-24 18:12:30 -04:00
Augustin Cavalier 28d23a2bbe bootloader: Increase kernel_args chunk size.
On a 64-bit nightly, it appears we're already using 16 out of the 20
slots for kernel_args ranges. On a 32-bit bootstrap build with symbols
enabled, we exhaust them (due to the network drivers that the bootstrap
build adds to the boot set).

The kernel_args are later freed by the kernel, so this shouldn't "leak"
any memory unnecessarily. With this size, we only need one chunk with
symbol loading disabled.
2026-04-24 12:53:45 -04:00
Augustin Cavalier 1c2f998214 bootloader: Avoid allocating the logo image in kernel_args space.
We never send it to the kernel but always free it. The kernel_args
allocator is very simple and can't handle frees besides the most recent
data, so this avoids "leaking" some kernel_args memory (it should all
be freed by the kernel later, though, so that only matters for
the bootloader itself.)
2026-04-24 12:48:48 -04:00
Augustin Cavalier c01840a306 Bump bootstrap package versions. 2026-04-23 16:55:49 -04:00
Augustin Cavalier cb72e7dc57 kernel/vm: Drop VMPageQueue::fName.
Nothing uses it (not even DEBUG_PAGE_QUEUE, it appears),
and it will need to be managed a different way for the
multiple ModifiedPageQueues, if we really do need it.
2026-04-23 16:38:13 -04:00
Augustin Cavalier 76e076b03b launch_daemon: Rework _GetSourceFileEnvironment logic.
Use strchrnul instead of strchr, and increment at the end of the loop.
This avoids needing to call _ParseExportVariable in two separate places.

The invocation of line.Append(chunk, bytesRead) was also incorrect,
as bytesRead would be past the end of chunk if chunk had been
incremented. But this wasn't really a problem because BString
does strnlen() on the passed arguments.

Inspired by a change seen in a fork of the Haiku repository on
GitHub.
2026-04-23 16:34:04 -04:00
Augustin Cavalier cb6c752887 HaikuPorts/arm64: Update with the newly rebootstrapped packages.
After this, a "stock" @minimum-mmc build can boot to the desktop
in QEMU without needing to do a local bootstrap!
2026-04-23 16:19:22 -04:00
Augustin Cavalier 2b1c4326ec MMCImage: Delete the temporary partition file after building.
AnybootImage does the same. Reduces confusion because the files
have quite similar names (we should probably fix that...)
2026-04-23 16:17:41 -04:00
Augustin Cavalier da093f807e Always include framebuffer and virtio_gpu in the build.
The virtio_gpu driver is included the "Haiku" package file,
so it logically makes sense to do the same for its accelerant.
2026-04-23 16:16:50 -04:00
Augustin Cavalier d32e4e0e00 3rdparty/unbootstrap.sh: Add _bootstrap to the package versions.
This makes it clear that the package was made by the bootstrap
process.

Also compress the packages with zlib, so that zstd isn't needed.
2026-04-23 15:54:03 -04:00
Augustin Cavalier 70d41befc2 HaikuBootstrap: Disable virtio_block, same as for the regular build. 2026-04-23 15:53:19 -04:00
Augustin Cavalier 920adf674e libroot/glibc: Fix the build for x86_64. 2026-04-15 23:50:23 -04:00
Augustin Cavalier c8a62a308c libroot/glibc: Properly split long double files and import 128-bit ones.
Also drop the long-double files from architectures where long-double
support is (currently) disabled in glibc config.h.

Should fix #19589 and other long-double related problems on
RISC-V and ARM64.

Change-Id: Ia33ce2791d812eb143b719fb61e69dbf8b70ce79
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10815
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Sam Roberts <[email protected]>
2026-04-15 19:13:54 +00:00
Augustin Cavalier a8fd01eb8e kernel/vm: Notify removed pages as not busy on removal.
We don't need to wait for them to be freed, as they're not
accessible once removed.
2026-04-14 13:40:07 -04:00
Augustin Cavalier 157e34f264 Tracker: Skip watch_node(B_STOP_WATCHING) if we aren't watching individual nodes.
Avoids unnecessary syscalls and saves time.
2026-04-13 18:59:59 -04:00
Augustin Cavalier 3dcdbf569c media: Delay starting the mixer until an output connects to the mixer.
Otherwise we just spends lots of CPU time sending silence.
This also paves the way for stopping the output when all
outputs disconnect, but that's not implemented just yet.

Since this forces a wait inside the mixer for the destination
to actually start, it may help with problems like #19074.
At least in testing, without that block, I got similar symptoms
and crashes, due to the initial 0 value being used to compute
the performance times, and winding up with very incorrect times.

Note that this changes the MultiAudioNode to not really start its
timesource when it gets a TIMESOURCE_START message. Instead it waits
until it gets a regular B_START (via StartNode) message to do that.

Change-Id: I1716e347537c88dcc76163a515e7fbb8c5ccdecb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10643
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-04-13 19:27:55 +00:00
Augustin Cavalier ad37e9a395 BWindow: Use a SplayTree to store shortcuts.
This makes for much faster lookups, and avoids the need
to allocate an array.

sizeof(BWindow) is unchanged (on x86_64, 504; on x86, 376)
so this should not break ABI/API.

Quick benchmark in Tracker:
501 lookups, before: ~488 usec
501 lookups, after: ~284 usec

Change-Id: Ica2c728f0c5957380add53e14a826a4aade52df0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10720
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-04-13 19:24:34 +00:00
Augustin Cavalier fd2113c61a Tracker: Restore handling of B_DELETE key in KeyDown.
If the shortcut is not available (due to the menus not being active),
then this will make sure we handle the key regardless. If the shortcut
is active, then it'll get eaten by BWindow, and we won't get here.

Change-Id: Id6c3ae590f596481f9dfb720aa088238ccc6413c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10718
Haiku-Format: Haiku-format Bot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: John Scipione <[email protected]>
2026-04-13 19:24:15 +00:00
Augustin Cavalier 64d96af568 MIME Sniffer: Use memmem() to speed up matching.
This is now a POSIX method which was widely supported even before
its addition to POSIX, so using it here (including on the build
platform) should be OK.

This takes mimeset -F of the whole src/ hierarchy from around 2.8
seconds to around 2.1 (user time goes from ~1.2s to ~0.6s.) It seems
I/O is a lot of the remainder now.

Also drop the TODO comment; we don't want partial matching like that,
as the sniffing rules would not expect it.

All tests still pass.

Change-Id: Ibb190f6f9f5e73ed027e052ef665b177d3fd6f86
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10688
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-04-10 08:28:40 +00:00
Augustin Cavalier 14ea42a871 MIME Sniffer: Use memcmp instead of the mask setup where possible.
Another slight optimization. The time doesn't seem to decrease much,
but this paves the way for a much more optimized scan.

Change-Id: I0fb65544524fbc9606fd84ef521b706bd9dc4d02
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10687
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2026-04-10 08:28:40 +00:00
Augustin Cavalier 3becbc68c4 MIME Sniffer: Propagate case-insensitivity down to patterns.
This will allow them to perform some more upfront optimizations.

Note that this change includes a slight compatibility breakage with
BeOS R5: it applies an "-i" flag in a disjunction to all patterns in
the disjunction, not just all patterns following the "-i" (I checked.)

However, as far as I can see, this feature of R5 was undocumented
(sniff rules are described in the "Release Notes" section of the Be Book
only, and "-i" isn't discussed there), and the only pattern on R5 that
appears to use them at all was the "text/html" pattern. The behavior to
apply case-insensitivity to all patterns seems unexpected, so I think
it should be OK to break compatibility in this slight way.

Change-Id: I0556d53e602bc68ae14ac21c9e226403061043a0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10686
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-04-10 08:28:40 +00:00
Augustin Cavalier 46af16aa69 MIME Sniffer: Make RPattern a subclass of Pattern.
Avoids some unnecessary allocations.

Change-Id: I0435ed7a814a45739a03a62ba84a315d61bf23e3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10685
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Kacper Kasper <[email protected]>
2026-04-10 08:28:40 +00:00
Augustin Cavalier bc415d41f1 BFS: Send live-query rename/move notifications along with node monitor.
Otherwise, we send them out before the file is actually renamed,
and so we could send notifications with stale name values in them
(in the case of B_ENTRY_CREATED and B_ENTRY_REMOVED), or before
the file's name actually changed as visible in stat(). This way,
we send the notification only after updating the entries.
2026-04-09 15:21:46 -04:00
Augustin Cavalier da1768c354 StringForSize: Preinitialize the BNumberFormats.
I noticed when profiling the system with ActivityMonitor running
that most of ActivityMonitor's time was spent initializing these
for the Memory view. So, instead, cache the formatters to avoid
needing to reinitialize them so often.
2026-04-09 14:26:24 -04:00
Augustin Cavalier 816181bc95 fs_shell: Adjust to work with the new libroot_build errno setup.
I rebuilt fs_shell after the previous commit before pushing,
but it didn't fail then. I guess Jam failed to do an incremental
rebuild properly...
2026-04-09 14:14:00 -04:00
Augustin Cavalier 744616c074 libroot_build: Rework errno assignment.
With the old code, if the currentErrno hadn't changed, but was in
fact re-assigned more recently than the local errno was, then we
would wind up incorrectly return the local value instead of the
system value. This was the cause of the build mimeset not working
properly when run in recursive mode on Haiku.

So, instead, create a wrapper struct to make assignment of the
local errno always pass through to the system one, so they never
get out of sync in the first place.
2026-04-09 14:09:52 -04:00
Augustin Cavalier 95c8251d75 kernel tests: Fix TARGET_CC check.
$(architecture) isn't declared in this file.
2026-04-09 14:01:27 -04:00
Augustin Cavalier d693dd96fc Better handling for use of newer GCCs to build GCC2.
* Move the logic to build_cross_tools, as some scripts use this
   directly.

 * Use gnu89 standard instead of disabling specific warnings.

 * Reduce optimization level used to compile GCC, to try and stave
   off possible bugs.

 * Explain why 32-bit is used for GCC 2. (With some hacks,
   GCC 2 compiled in 64-bit mode can be used to build an image
   that does get to the desktop, though.)

Tested with GCC 14.2.
2026-04-08 00:29:33 -04:00
Augustin Cavalier 0cb8b2e3f6 MIME Sniffer: Include changes to appease GCC 2. 2026-04-07 23:38:30 -04:00
Augustin Cavalier 70bb9d9f1b MIME Sniffer: Pass the buffer all the way down and don't reallocate.
This avoids an allocation, copy, and deallocation every single
test of every single pattern, which was unbelievably inefficent
and one of the worst performance hits to the MIME sniffer.

Before this change, "mimeset -F src/" in the Haiku repository
took 20-40+ seconds. After this, it takes around 3 seconds.

All tests still pass (and indeed the tests caught some bugs in
the initial version of this change.)
2026-04-07 17:57:19 -04:00
Augustin Cavalier 18f8bc9d2d MIME Sniffer: De-indent Pattern::Sniff.
No functional change intended.
2026-04-07 17:57:19 -04:00
Augustin Cavalier 35df817840 MIME Sniffer: Apply haiku-format and new-style copyright headers.
Some changes done manually where it made sense.
2026-04-07 17:57:19 -04:00
Augustin Cavalier 2a001adfd1 MIME Sniffer: Move helper routines to the top of the file and make static. 2026-04-07 17:57:19 -04:00
Augustin Cavalier acaa509bf8 MIME Sniffer: Remove some dead code. 2026-04-07 17:57:19 -04:00
Augustin Cavalier 2168280fac Storage Kit: Streamline CharStream and make it use BString. 2026-04-07 17:57:19 -04:00
Augustin Cavalier 104eaabf01 Storage Kit: Move most MIME sniffer headers into src/.
There's no reason to keep these in the private headers directory
that I can see.
2026-04-07 17:57:19 -04:00
Augustin Cavalier 645c71a9a9 Devices: Fix typo. 2026-04-07 13:57:58 -04:00
Augustin Cavalier bc501624e2 configure: HDS now needs Python 3.10+.
3.9 is end-of-life as of 2025/10 anyway.
2026-04-07 13:51:33 -04:00
Augustin Cavalier 248735d5a2 kernel/vm: Split the page writer into its own file and queue subclass.
This paves the way for there being more than one modified queue,
e.g. for each KDiskDevice.
2026-04-06 22:23:26 -04:00
Augustin Cavalier 62b8be7e22 kernel/vm: DaemonCondition is really just a basic binary semaphore.
So split it off into its own file. This will make it easier to
split the page writer off into a separate file.
2026-04-06 22:23:26 -04:00
Augustin Cavalier f091a24ee2 AreaKeeper: Move to kernel/util.
This seems more consistent with how the directories are laid out.
2026-04-06 22:23:26 -04:00
Augustin Cavalier 2448a77520 kernel/vm: Move a number of init-related methods to a new vm_init.cpp.
This gets around 450 lines of code out of vm.cpp.

No behavioral change intended.
2026-04-06 22:23:26 -04:00
Augustin Cavalier 6e55e6942f pthread: PTHREAD_RECURSIVE_MUTEX_INITIALIZER is non-POSIX.
So add the _NP suffix like glibc does.

Pointed out by sortie.
2026-03-30 20:44:36 -04:00
Augustin Cavalier cc9cae1908 BString: memrchr is nonstandard and not available on macOS.
We use BString in the build platform, so we need it to work
everywhere. Add a fallback for non-Haiku targets (though glibc and
others do have memrchr and so could keep this, if we added some
more logic here.)
2026-03-30 19:21:33 -04:00
Augustin Cavalier d6c0df2394 kernel/guarded_heap: allocate_meta may fail with certain flags set.
May fix #20014.
2026-03-30 18:33:23 -04:00
Augustin Cavalier 75b91674e9 BString: Use memchr and memrchr to optimize two Find routines.
All BString tests are still passing.
2026-03-30 18:30:32 -04:00
Augustin Cavalier 53b69c0037 driver_settings: Use strchrnul to skip comments.
More optimized than just the simple loop.
2026-03-30 18:21:49 -04:00
Augustin Cavalier 40205ec46a kernel/cache: Add test for #18390 and related issues.
Change-Id: I873df21c54d4df4ea85904eabd186a36e55e13d9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10629
Reviewed-by: waddlesplash <[email protected]>
2026-03-30 22:11:53 +00:00
Augustin Cavalier 28e6329e8e kernel/vm: Add assert to VMCache::MarkPageUnbusy.
Change-Id: Iec29bdfa5f0a25d9f255c6eee1937bc7c9cc4c3a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10628
Reviewed-by: waddlesplash <[email protected]>
2026-03-30 22:11:53 +00:00
Augustin Cavalier 5554f0b829 kernel/vm: Fix a TODO about page I/O leaving pages in ACCESS state.
It turns out PAGE_ACCESS assertions could be tripped in other cases,
e.g. when resizing a cache while pages were being read in. So,
properly unset ACCESS (and just leave 'busy' set) in the places
where pages are read in, and re-enable the check.

Change-Id: I22ac5c8cb432c87613bb85e82703a0c1aeb55d86
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10627
Reviewed-by: waddlesplash <[email protected]>
2026-03-30 22:11:53 +00:00
Augustin Cavalier 05772630b8 kernel/file_cache: Recheck size in the do_cache_io loop.
Since we unlock the cache at various points in this loop,
we need to periodically recheck the size here, as otherwise
we might try to insert pages past the end.

This amends 4f8eaff87f. Re-tested
using the case described in that commit.

Change-Id: Id65e309f986a9b7f3e701d2b99c4f318a4eefbd3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10626
Reviewed-by: waddlesplash <[email protected]>
2026-03-30 22:11:53 +00:00
Augustin Cavalier b37e0a513d kernel/vm: Clear busy_io along with the other page flags.
Change-Id: I796e6d01678e46eda9815c1c290b56975b6dbdfe
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10625
Reviewed-by: waddlesplash <[email protected]>
2026-03-30 22:11:53 +00:00
Augustin Cavalier 5eaf967479 kernel/cache: Use vm_page::busy_io in the file_cache.
This allows the VMCache to remove these pages pending the I/O
completion.

Combined with the following commits, confirmed to fix #18390.

Change-Id: I9630a00d70a9d6ac5b36e6de70475a6032390806
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10591
Reviewed-by: waddlesplash <[email protected]>
2026-03-30 22:11:53 +00:00