These are for guarded ports. While I believe we don't currently deliver port guard violation exceptions, there are certain updated programs (like `notifyd`) that need to be able to create and destroy Mach ports using `mach_port_{construct,destruct}`. This commit therefore adds some of the necessary plumbing (which is enough to satisfy `notifyd`) and leaves it up to a future commit to add proper support for guarded ports and port guard violation exceptions.
The main goal of this commit is to make it more easy to add or update any architecture we want to support (such as ARM64). Any changes we want to make would be done in the architectures.cmake file.
The secondary goal of this commit is to encourage a more architecture generic nomenclature. We shouldn't use i368/x86_64 unless we are dealing with code that is specific to those architectures.
First, libpthread now expects `workq_kernreturn` not to return when called with `WQOPS_THREAD_RETURN`. We have to resume the thread and give it a special value for `nkevents` that tells it to kill itself.
Next, Apple has reworked the priority system into a "Quality of Service" (QoS) system. Unfortunately, since we're building libdispatch with a few different settings than Apple's configuration, it seems that they've forgotten to correctly set QoS in some cases, so we have to it for them so that libdispatch doesn't blow up.
Finally, `WQOPS_SETUP_DISPATCH` has been stubbed so libdispatch thinks everything is fine. In the future, we might want to do something with the values it passes in, but for now we have nothing to do with them.
I was accidentally clobbering the `stack_addr` arg which is actually the `flags` arg for workqueues.
Also, use `stack_addr` from `args` instead of `rdi` (which is the dthread pointer) because the user could have allocated a custom stack and libpthread passes that in.
Finally, workqueues have a separate flag to indicate that the TSD base has been set.
This fix allows the child to actually return correctly.
It was present in an older commit but it got removed in a commit from a few months ago, in what looks like an accidental change (not sure how this code was still working, though).
I don't know why Apple felt the need to move those functions out, but we need to implement `strncmp` for ourselves because we use it before libplatform is initialized
MDItem's current code is just a bunch of stubs. However, BackupCore's current code is technically implemented (Darling doesn't do backups, so it just tells users that everything is excluded from backups).
Note that I didn't verify the values of each and every MDItem constant, but those kinds of constants usually follow a pattern, and in this case, the pattern seemed to be that their string content is just a copy of their variable names. (I could probably have used a macro to do it, but *shrug*, my editor made it easy).