Make improvements

- This change fixes a bug that allowed unbuffered printf() output (to
  streams like stderr) to be truncated. This regression was introduced
  some time between now and the last release.

- POSIX specifies all functions as thread safe by default. This change
  works towards cleaning up our use of the @threadsafe / @threadunsafe
  documentation annotations to reflect that. The goal is (1) to use
  @threadunsafe to document functions which POSIX say needn't be thread
  safe, and (2) use @threadsafe to document functions that we chose to
  implement as thread safe even though POSIX didn't mandate it.

- Tidy up the clock_gettime() implementation. We're now trying out a
  cleaner approach to system call support that aims to maintain the
  Linux errno convention as long as possible. This also fixes bugs that
  existed previously, where the vDSO errno wasn't being translated
  properly. The gettimeofday() system call is now a wrapper for
  clock_gettime(), which reduces bloat in apps that use both.

- The recently-introduced improvements to the execute bit on Windows has
  had bugs fixed. access(X_OK) on a directory on Windows now succeeds.
  fstat() will now perform the MZ/#! ReadFile() operation correctly.

- Windows.h is no longer included in libc/isystem/, because it confused
  PCRE's build system into thinking Cosmopolitan is a WIN32 platform.
  Cosmo's Windows.h polyfill was never even really that good, since it
  only defines a subset of the subset of WIN32 APIs that Cosmo defines.

- The setlongerjmp() / longerjmp() APIs are removed. While they're nice
  APIs that are superior to the standardized setjmp / longjmp functions,
  they weren't superior enough to not be dead code in the monorepo. If
  you use these APIs, please file an issue and they'll be restored.

- The .com appending magic has now been removed from APE Loader.
This commit is contained in:
Justine Tunney 2023-10-02 19:25:19 -07:00
parent b99512ac58
commit ff77f2a6af
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
226 changed files with 708 additions and 2657 deletions

View file

@ -88,7 +88,6 @@ static void runcontext(struct Gadget *call, ucontext_t *link) {
* which if null will result in pthread_exit() being called
* @param argc is effectively ignored (see notes above)
* @see setcontext(), getcontext(), swapcontext()
* @threadsafe
*/
void makecontext(ucontext_t *uc, void func(), int argc, ...) {
va_list va;

View file

@ -335,7 +335,6 @@ static const char *DescribeHandle(char buf[12], errno_t err, pthread_t *th) {
* @raise EPERM if scheduling policy was requested and user account
* isn't authorized to use it
* @returnserrno
* @threadsafe
*/
errno_t pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg) {

View file

@ -62,7 +62,6 @@ static errno_t pthread_detach_impl(struct PosixThread *pt) {
* @return 0 on success, or errno with error
* @raise EINVAL if `thread` isn't joinable
* @returnserrno
* @threadsafe
*/
errno_t pthread_detach(pthread_t thread) {
struct PosixThread *pt = (struct PosixThread *)thread;

View file

@ -94,7 +94,6 @@ void _pthread_unkey(struct CosmoTib *tib) {
* destructors is also undefined.
*
* @param rc is reported later to pthread_join()
* @threadsafe
* @noreturn
*/
wontreturn void pthread_exit(void *rc) {

View file

@ -35,7 +35,6 @@
* @raise ECANCELED if calling thread was cancelled in masked mode
* @cancellationpoint
* @returnserrno
* @threadsafe
*/
errno_t pthread_join(pthread_t thread, void **value_ptr) {
return pthread_timedjoin_np(thread, value_ptr, 0);

View file

@ -99,7 +99,6 @@ static errno_t _pthread_wait(atomic_int *ctid, struct timespec *abstime) {
* @raise EBUSY if `abstime` deadline elapsed
* @cancellationpoint
* @returnserrno
* @threadsafe
*/
errno_t pthread_timedjoin_np(pthread_t thread, void **value_ptr,
struct timespec *abstime) {

View file

@ -35,7 +35,6 @@
* @raise ECANCELED if calling thread was cancelled in masked mode
* @cancellationpoint
* @returnserrno
* @threadsafe
*/
errno_t pthread_tryjoin_np(pthread_t thread, void **value_ptr) {
return pthread_timedjoin_np(thread, value_ptr, &timespec_zero);

View file

@ -165,7 +165,6 @@ static struct Semaphore *sem_open_get(const sem_t *sem,
* @raise ENFILE if system-wide file limit has been reached
* @raise ENOMEM if we require more vespene gas
* @raise EINTR if signal handler was called
* @threadsafe
*/
sem_t *sem_open(const char *name, int oflag, ...) {
sem_t *sem;

View file

@ -3,9 +3,8 @@
#define TLS_ALIGNMENT 64
#define TIB_FLAG_TIME_CRITICAL 1
#define TIB_FLAG_VFORKED 2
#define TIB_FLAG_WINCRASHING 4
#define TIB_FLAG_VFORKED 1
#define TIB_FLAG_WINCRASHING 2
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_