libc icon indicating copy to clipboard operation
libc copied to clipboard

Apple: Add additional `pthread` APIs

Open nathaniel-bennett opened this issue 1 year ago • 4 comments

Resolves #1618

It seems like #1618 has already been mostly resolved; this PR simply adds some of the few pthread APIs that are still missing.

nathaniel-bennett avatar Aug 17 '24 08:08 nathaniel-bennett

r? @JohnTitor

rustbot has assigned @JohnTitor. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rustbot avatar Aug 17 '24 08:08 rustbot

r? @tgross35

nathaniel-bennett avatar Aug 31 '24 15:08 nathaniel-bennett

Sources for future reference:

  • Type pthread_once_t is defined as _opaque_pthread_once_t here https://github.com/apple-oss-distributions/libpthread/blob/d8c4e3c212553d3e0f5d76bb7d45a8acd61302dc/include/sys/_pthread/_pthread_types.h#L88-L91.
  • Opaque padding __PTHREAD_ONCE_SIZE__ is defined to 4/8 here https://github.com/apple-oss-distributions/libpthread/blob/d8c4e3c212553d3e0f5d76bb7d45a8acd61302dc/include/sys/_pthread/_pthread_types.h#L42-L52
  • Constants are defined here https://github.com/apple-oss-distributions/libpthread/blob/d8c4e3c212553d3e0f5d76bb7d45a8acd61302dc/include/pthread/pthread.h#L138
  • _PTHREAD_ONCE_SIG_init is defined here https://github.com/apple-oss-distributions/libpthread/blob/d8c4e3c212553d3e0f5d76bb7d45a8acd61302dc/include/pthread/pthread_impl.h#L48C33-L48C43
  • pthread_once https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/pthread_once.3.html
  • The remaining functions are here, some already exist or are in unix/mod.rs https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/pthread_attr_getinheritsched.3.html

One fix above, then could you define __PTHREAD_ONCE_SIZE__ and make use of it in __opaque (rather than literals) like the definition? We already have e.g. __PTHREAD_RWLOCKATTR_SIZE__ defined, just unfortunately don't use them consistently.

tgross35 avatar Sep 01 '24 06:09 tgross35

@rustbot label -S-waiting-on-author S-waiting-on-review

nathaniel-bennett avatar Sep 06 '24 20:09 nathaniel-bennett