Skip to content

Commit 3de6632

Browse files
committed
Graduate some clock_gettime() constants to #define
- CLOCK_THREAD_CPUTIME_ID - CLOCK_PROCESS_CPUTIME_ID Cosmo now supports the above constants universally across supported OSes therefore it's now safe to let programs detect their presence w/ #ifdefs
1 parent c83ec5f commit 3de6632

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

ape/specification.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ arises in the fact that our Linux-flavored GCC and Clang toolchains
402402
producing TLS instructions that use the %fs convention.
403403

404404
To solve these challenges, the `cosmocc` compiler will rewrite binary
405-
objects after they've been compiled by GCC, so that `%gs` register is
406-
used, rather than `%fs`. Morphing x86-64 binaries after they've been
405+
objects after they've been compiled by GCC, so that the `%gs` register
406+
is used, rather than `%fs`. Morphing x86-64 binaries after they've been
407407
compiled is normally difficult, due to the complexity of the machine
408408
instruction language. However GCC provides `-mno-tls-direct-seg-refs`
409409
which greatly reduces the complexity of this task. This flag forgoes

libc/runtime/weakfree.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* Thunks free() if it's linked, otherwise do nothing.
2525
*/
2626
void _weakfree(void *p) {
27-
if (_weaken(free)) {
27+
if (_weaken(free))
2828
_weaken(free)(p);
29-
}
3029
}

libc/sysv/consts/clock.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ extern const int CLOCK_UPTIME_PRECISE;
2424

2525
COSMOPOLITAN_C_END_
2626

27-
#define CLOCK_REALTIME 0
28-
#define CLOCK_MONOTONIC CLOCK_MONOTONIC
27+
#define CLOCK_REALTIME 0
28+
#define CLOCK_MONOTONIC CLOCK_MONOTONIC
29+
#define CLOCK_PROCESS_CPUTIME_ID CLOCK_PROCESS_CPUTIME_ID
30+
#define CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID
2931

3032
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_CLOCK_H_ */

libc/thread/pthread_create.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void _pthread_decimate(bool annihilation_only) {
118118
if (status != kPosixThreadZombie)
119119
break; // zombies only exist at the end of the linked list
120120
if (atomic_load_explicit(&pt->tib->tib_tid, memory_order_acquire))
121-
continue; // undead thread should that'll stop existing soon
121+
continue; // undead thread that should stop existing soon
122122
dll_remove(&_pthread_list, e);
123123
dll_make_first(&list, e);
124124
}

0 commit comments

Comments
 (0)