Rerun clang-format on the repo (#1217)

🚨 clang-format changes output per version!

This is with version 19.0.0. The modifications seem to be fixing the old
version’s errors - mainly involving omitted whitespace around binary ops
and inserted whitespace between goto labels and colons (if followed by a
curly brace.)

Also fixes a few mistakes made by e.g. someone (ahem) forgetting to pass
his ctl/string.h modifications through it.

We should add this to .git-blame-ignore-revs once we have its final hash
on master.
This commit is contained in:
Jōshin 2024-06-15 13:34:48 -07:00 committed by GitHub
parent 8e37ee2598
commit 89fc95fefd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 139 additions and 122 deletions

View file

@ -4,7 +4,7 @@ COSMOPOLITAN_C_START_
#define BPF_MAXINSNS 4096
#define BPF_CLASS(code) ((code)&0x07)
#define BPF_CLASS(code) ((code) & 0x07)
#define BPF_LD 0x00 /* load into accumulator */
#define BPF_LDX 0x01 /* load into index register */
#define BPF_ST 0x02 /* store from immediate */
@ -14,13 +14,13 @@ COSMOPOLITAN_C_START_
#define BPF_RET 0x06
#define BPF_MISC 0x07
#define BPF_SIZE(code) ((code)&0x18)
#define BPF_SIZE(code) ((code) & 0x18)
#define BPF_W 0x00 /* 32-bit */
#define BPF_H 0x08 /* 16-bit */
#define BPF_B 0x10 /* 8-bit */
#define BPF_DW 0x18 /* 64-bit (eBPF only) */
#define BPF_MODE(code) ((code)&0xe0)
#define BPF_MODE(code) ((code) & 0xe0)
#define BPF_IMM 0x00 /* 64-bit immediate */
#define BPF_ABS 0x20
#define BPF_IND 0x40
@ -28,7 +28,7 @@ COSMOPOLITAN_C_START_
#define BPF_LEN 0x80
#define BPF_MSH 0xa0
#define BPF_OP(code) ((code)&0xf0)
#define BPF_OP(code) ((code) & 0xf0)
#define BPF_ADD 0x00
#define BPF_SUB 0x10
#define BPF_MUL 0x20
@ -41,7 +41,7 @@ COSMOPOLITAN_C_START_
#define BPF_MOD 0x90
#define BPF_XOR 0xa0
#define BPF_SRC(code) ((code)&0x08)
#define BPF_SRC(code) ((code) & 0x08)
#define BPF_JA 0x00
#define BPF_JEQ 0x10
#define BPF_JGT 0x20
@ -442,7 +442,7 @@ COSMOPOLITAN_C_START_
#define BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP (1U << 2)
#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10)
#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col)&0x3ff)
#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)
#define BTF_F_COMPACT (1ULL << 0)
#define BTF_F_NONAME (1ULL << 1)

View file

@ -17,9 +17,9 @@ struct sock_fprog {
const struct sock_filter *filter;
};
#define BPF_RVAL(code) ((code)&0x18)
#define BPF_RVAL(code) ((code) & 0x18)
#define BPF_A 0x10
#define BPF_MISCOP(code) ((code)&0xf8)
#define BPF_MISCOP(code) ((code) & 0xf8)
#define BPF_TAX 0x00
#define BPF_TXA 0x80

View file

@ -24,7 +24,7 @@
#include "libc/intrin/strace.internal.h"
#include "libc/runtime/runtime.h"
#define IsPeek(request) (IsLinux() && (request)-1u < 3)
#define IsPeek(request) (IsLinux() && (request) - 1u < 3)
/**
* Traces process.

View file

@ -2,7 +2,7 @@
#define COSMOPOLITAN_LIBC_DOS_H_
#define DOS_DATE(YEAR, MONTH_IDX1, DAY_IDX1) \
(((YEAR)-1980) << 9 | (MONTH_IDX1) << 5 | (DAY_IDX1))
(((YEAR) - 1980) << 9 | (MONTH_IDX1) << 5 | (DAY_IDX1))
#define DOS_TIME(HOUR, MINUTE, SECOND) \
((HOUR) << 11 | (MINUTE) << 5 | (SECOND) >> 1)

View file

@ -456,12 +456,12 @@
#define DF_P1_GROUPPERM 0x00000002
#define ELF64_ST_BIND(val) (((unsigned char)(val)) >> 4)
#define ELF64_ST_TYPE(val) ((val)&0xf)
#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type)&0xf))
#define ELF64_ST_VISIBILITY(o) ((o)&0x03)
#define ELF64_ST_TYPE(val) ((val) & 0xf)
#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
#define ELF64_ST_VISIBILITY(o) ((o) & 0x03)
#define ELF64_R_SYM(i) ((i) >> 32)
#define ELF64_R_TYPE(i) ((i)&0xffffffff)
#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
#define ELF64_R_INFO(sym, type) ((((Elf64_Xword)(sym)) << 32) + (type))
#define ELF64_M_SYM(info) ((info) >> 8)

View file

@ -25,7 +25,7 @@
#include "libc/runtime/runtime.h"
#include "libc/runtime/winargs.internal.h"
#define UNSHADOW(x) ((int64_t)(MAX(0, (x)-0x7fff8000)) << 3)
#define UNSHADOW(x) ((int64_t)(MAX(0, (x) - 0x7fff8000)) << 3)
#define FRAME(x) ((int)((x) >> 16))
static const char *GetFrameName(int x) {

View file

@ -22,7 +22,7 @@
*/
#define asint(x) ((union pun){x}).i
#define isnan(x) (((x)&0x7fff) > 0x7c00)
#define isnan(x) (((x) & 0x7fff) > 0x7c00)
union pun {
_Float16 f;

View file

@ -50,19 +50,22 @@ struct magicu __magicu_get(uint32_t d) {
p32 = 2 * p32;
}
if (r + 1 >= d - r) {
if (q >= 0x7FFFFFFF) a = 1;
if (q >= 0x7FFFFFFF)
a = 1;
q = 2 * q + 1; // Update q.
r = 2 * r + 1 - d; // Update r.
} else {
if (q >= 0x80000000) a = 1;
if (q >= 0x80000000)
a = 1;
q = 2 * q;
r = 2 * r + 1;
}
delta = d - 1 - r;
} while (p < 64 && p32 < delta);
magu.M = q + 1; // Magic number and
magu.s = p - 32; // Shift amount to return
if (a) magu.s |= 64; // Sets "add" indicator
magu.M = q + 1; // Magic number and
magu.s = p - 32; // Shift amount to return
if (a)
magu.s |= 64; // Sets "add" indicator
npassert(magu.M || magu.s); // Never returns zero.
return magu;
}

View file

@ -24,8 +24,10 @@ forceinline uint32_t __magicu_div(uint32_t x, struct magicu d) {
* Checks if 𝑑 contains a valid initialized divisor.
*/
static inline bool32 __magicu_valid(struct magicu d) {
if (!d.M && !d.s) return false; /* uninitialized */
if (d.s & ~(64 | 63)) return false; /* corrupted */
if (!d.M && !d.s)
return false; /* uninitialized */
if (d.s & ~(64 | 63))
return false; /* corrupted */
return true;
}

View file

@ -45,7 +45,7 @@
#ifdef __x86_64__
#define INVERT(x) (BANE + PHYSICAL((uintptr_t)(x)))
#define NOPAGE ((uint64_t)-1)
#define NOPAGE ((uint64_t) - 1)
#define APE_STACK_VADDR \
({ \

View file

@ -8,36 +8,36 @@ void palignr(void *, const void *, const void *, unsigned long);
#if !defined(__STRICT_ANSI__) && !defined(__chibicc__) && defined(__x86_64__)
__intrin_xmm_t __palignrs(__intrin_xmm_t, __intrin_xmm_t);
#define palignr(C, B, A, I) \
do { \
if (__builtin_expect(!IsModeDbg() && X86_NEED(SSE) && X86_HAVE(SSSE3), \
1)) { \
__intrin_xmm_t *Xmm0 = (void *)(C); \
const __intrin_xmm_t *Xmm1 = (const __intrin_xmm_t *)(B); \
const __intrin_xmm_t *Xmm2 = (const __intrin_xmm_t *)(A); \
if (__builtin_constant_p(I)) { \
if (!X86_NEED(AVX)) { \
asm("palignr\t%2,%1,%0" \
: "=x"(*Xmm0) \
: "x"(*Xmm2), "i"(I), "0"(*Xmm1)); \
} else { \
asm("vpalignr\t%3,%2,%1,%0" \
: "=x"(*Xmm0) \
: "x"(*Xmm1), "x"(*Xmm2), "i"(I)); \
} \
} else { \
unsigned long Vimm = (I); \
typeof(__palignrs) *Fn; \
if (__builtin_expect(Vimm < 32, 1)) { \
Fn = (typeof(__palignrs) *)((uintptr_t)&__palignrs + Vimm * 8); \
*Xmm0 = Fn(*Xmm1, *Xmm2); \
} else { \
memset(Xmm0, 0, 16); \
} \
} \
} else { \
palignr(C, B, A, I); \
} \
#define palignr(C, B, A, I) \
do { \
if (__builtin_expect(!IsModeDbg() && X86_NEED(SSE) && X86_HAVE(SSSE3), \
1)) { \
__intrin_xmm_t *Xmm0 = (void *)(C); \
const __intrin_xmm_t *Xmm1 = (const __intrin_xmm_t *)(B); \
const __intrin_xmm_t *Xmm2 = (const __intrin_xmm_t *)(A); \
if (__builtin_constant_p(I)) { \
if (!X86_NEED(AVX)) { \
asm("palignr\t%2,%1,%0" \
: "=x"(*Xmm0) \
: "x"(*Xmm2), "i"(I), "0"(*Xmm1)); \
} else { \
asm("vpalignr\t%3,%2,%1,%0" \
: "=x"(*Xmm0) \
: "x"(*Xmm1), "x"(*Xmm2), "i"(I)); \
} \
} else { \
unsigned long Vimm = (I); \
typeof(__palignrs) *Fn; \
if (__builtin_expect(Vimm < 32, 1)) { \
Fn = (typeof(__palignrs) *)((uintptr_t) & __palignrs + Vimm * 8); \
*Xmm0 = Fn(*Xmm1, *Xmm2); \
} else { \
memset(Xmm0, 0, 16); \
} \
} \
} else { \
palignr(C, B, A, I); \
} \
} while (0)
#endif

View file

@ -31,7 +31,7 @@ static __vex size_t __strlen(const char *s) {
m = __builtin_ia32_pmovmskb128(*++p == z);
return (const char *)p + __builtin_ctzl(m) - s;
#else
#define ONES ((word)-1 / 255)
#define ONES ((word) - 1 / 255)
#define BANE (ONES * (255 / 2 + 1))
typedef unsigned long mayalias word;
word w;

View file

@ -25,7 +25,7 @@ COSMOPOLITAN_C_START_
#define CHECK_ALIGNED(BYTES, VAR, ...) \
do { \
if (((uintptr_t)VAR & ((BYTES)-1u))) { \
if (((uintptr_t)VAR & ((BYTES) - 1u))) { \
__check_fail_aligned(BYTES, (uintptr_t)VAR, __FILE__, __LINE__, \
"" __VA_ARGS__); \
__builtin_unreachable(); \
@ -35,7 +35,7 @@ COSMOPOLITAN_C_START_
#define DCHECK_ALIGNED(BYTES, VAR, ...) \
do { \
if (((uintptr_t)VAR & ((BYTES)-1u))) { \
if (((uintptr_t)VAR & ((BYTES) - 1u))) { \
__DCHK_ALIGNED(BYTES, (uintptr_t)VAR, "" __VA_ARGS__); \
__builtin_unreachable(); \
} \

View file

@ -21,8 +21,8 @@
#define TRUE 1
#define FALSE 0
#define IS2POW(X) (!((X) & ((X)-1)))
#define ROUNDUP(X, K) (((X) + (K)-1) & -(K))
#define IS2POW(X) (!((X) & ((X) - 1)))
#define ROUNDUP(X, K) (((X) + (K) - 1) & -(K))
#define ROUNDDOWN(X, K) ((X) & -(K))
#ifndef __ASSEMBLER__
#define ABS(X) ((X) >= 0 ? (X) : -(X))
@ -40,7 +40,7 @@
#define STRINGIFY(A) __STRINGIFY(A)
#define EQUIVALENT(X, Y) (__builtin_constant_p((X) == (Y)) && ((X) == (Y)))
#define TYPE_BIT(type) (sizeof(type) * CHAR_BIT)
#define TYPE_SIGNED(type) (((type)-1) < 0)
#define TYPE_SIGNED(type) (((type) - 1) < 0)
#define TYPE_INTEGRAL(type) (((type)0.5) != 0.5)
#define ARRAYLEN(A) \

View file

@ -25,7 +25,7 @@
// Sort for double-precision floating points. (2009).
#define HIST_SIZE (size_t)2048
#define get_byte_0(v) ((v)&0x7FF)
#define get_byte_0(v) ((v) & 0x7FF)
#define get_byte_1(v) (((v) >> 11) & 0x7FF)
#define get_byte_2_flip_sign(v) (((unsigned)(v) >> 22) ^ 0x200)

View file

@ -25,7 +25,7 @@
// Sort for double-precision floating points. (2009).
#define HIST_SIZE (size_t)2048
#define get_byte_0(v) ((v)&0x7FF)
#define get_byte_0(v) ((v) & 0x7FF)
#define get_byte_1(v) (((v) >> 11) & 0x7FF)
#define get_byte_2(v) (((v) >> 22) & 0x7FF)
#define get_byte_3(v) (((v) >> 33) & 0x7FF)

View file

@ -13,7 +13,7 @@
#define shuffle(R, A, n) \
do { \
autotype(A) Array = (A); \
for (size_t i = (n)-1; i >= 1; --i) { \
for (size_t i = (n) - 1; i >= 1; --i) { \
xchg(&Array[i], &Array[R() % (i + 1)]); \
} \
} while (0)

View file

@ -5,7 +5,7 @@
#include "libc/nexgen32e/x86feature.h"
COSMOPOLITAN_C_START_
#define TSC_AUX_CORE(MSR) ((MSR)&0xfff)
#define TSC_AUX_CORE(MSR) ((MSR) & 0xfff)
#define TSC_AUX_NODE(MSR) (((MSR) >> 12) & 0xfff)
/**

View file

@ -74,10 +74,10 @@ typedef uint32_t NtStatus;
#define NtInformation(s) (NtSeverity(s) == 1)
#define NtWarning(s) (NtSeverity(s) == 2)
#define NtError(s) (NtSeverity(s) == 3)
#define NtCode(s) ((NtStatus)(s)&0xffff)
#define NtCode(s) ((NtStatus)(s) & 0xffff)
#define NtSeverity(s) ((NtStatus)(s) >> 30)
#define NtFacility(s) (((NtStatus)(s) >> 16) & 0xfff)
#define NtFacilityCode(s) ((NtStatus)(s)&0x0FFFFFFF)
#define NtFacilityCode(s) ((NtStatus)(s) & 0x0FFFFFFF)
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_NT_STATUS_H_ */

View file

@ -198,8 +198,8 @@
#define kNtImageScnScaleIndex 0x00000001
#define kNtImageSymUndefined ((uint16_t)0)
#define kNtImageSymAbsolute ((uint16_t)-1)
#define kNtImageSymDebug ((uint16_t)-2)
#define kNtImageSymAbsolute ((uint16_t) - 1)
#define kNtImageSymDebug ((uint16_t) - 2)
#define kNtImageSymSectionMax 0xFEFF
#define kNtImageSymSectionMaxEx __LONG_MAX__
#define kNtImageSymTypeNull 0x0000

View file

@ -68,6 +68,7 @@ char *GetInterpreterExecutableName(char *p, size_t n) {
p[rc] = 0;
return p;
} else if (IsFreebsd() || IsNetbsd()) {
// clang-format off
cmd[0] = 1; // CTL_KERN
cmd[1] = 14; // KERN_PROC
if (IsFreebsd()) { //
@ -76,6 +77,7 @@ char *GetInterpreterExecutableName(char *p, size_t n) {
cmd[2] = 5; // KERN_PROC_PATHNAME
} //
cmd[3] = -1; // current process
// clang-format on
if (sysctl(cmd, ARRAYLEN(cmd), p, &n, 0, 0) != -1) {
errno = e;
return p;

View file

@ -127,7 +127,7 @@ https://github.com/piscisaureus/wepoll");
} while (0)
#define CONTAINOF(ptr, type, member) \
((type *)((uintptr_t)(ptr)-offsetof(type, member)))
((type *)((uintptr_t)(ptr) - offsetof(type, member)))
#define TREE__ROTATE(cis, trans) \
struct TreeNode *p = node; \

View file

@ -13,9 +13,9 @@ typedef struct fd_set {
unsigned long fds_bits[FD_SETSIZE / (sizeof(long) * 8)];
} fd_set;
#define FD_ISSET(FD, SET) (((SET)->fds_bits[(FD) >> 6] >> ((FD)&63)) & 1)
#define FD_SET(FD, SET) ((SET)->fds_bits[(FD) >> 6] |= 1ull << ((FD)&63))
#define FD_CLR(FD, SET) ((SET)->fds_bits[(FD) >> 6] &= ~(1ull << ((FD)&63)))
#define FD_ISSET(FD, SET) (((SET)->fds_bits[(FD) >> 6] >> ((FD) & 63)) & 1)
#define FD_SET(FD, SET) ((SET)->fds_bits[(FD) >> 6] |= 1ull << ((FD) & 63))
#define FD_CLR(FD, SET) ((SET)->fds_bits[(FD) >> 6] &= ~(1ull << ((FD) & 63)))
#define FD_ZERO(SET) bzero((SET)->fds_bits, sizeof((SET)->fds_bits))
#define FD_SIZE(bits) (((bits) + (sizeof(long) * 8) - 1) / sizeof(long))

View file

@ -23,8 +23,8 @@ COSMOPOLITAN_C_START_
#undef roundup
#define roundup(n, d) (howmany(n, d) * (d))
#define powerof2(n) !(((n)-1) & (n))
#define howmany(n, d) (((n) + ((d)-1)) / (d))
#define powerof2(n) !(((n) - 1) & (n))
#define howmany(n, d) (((n) + ((d) - 1)) / (d))
#ifdef MIN
#undef MIN

View file

@ -21,7 +21,7 @@
COSMOPOLITAN_C_START_
#define LC_GLOBAL_LOCALE ((locale_t)-1)
#define LC_GLOBAL_LOCALE ((locale_t) - 1)
struct __locale_map {
const void *map;

View file

@ -5,7 +5,7 @@ COSMOPOLITAN_C_START_
#define SA 0xc2u
#define SB 0xf4u
#define CODEUNIT(c) (0xdfff & (signed char)(c))
#define IS_CODEUNIT(c) ((unsigned)(c)-0xdf80 < 0x80)
#define IS_CODEUNIT(c) ((unsigned)(c) - 0xdf80 < 0x80)
#define R(a, b) ((uint32_t)((a == 0x80 ? 0x40u - b : 0u - a) << 23))
#define FAILSTATE R(0x80, 0x80)
#define OOB(c, b) \

View file

@ -13,14 +13,14 @@ COSMOPOLITAN_C_START_
#define IsLowSurrogate(wc) ((UTF16_MASK & (wc)) == UTF16_CONT)
#define IsUcs2(wc) (((65535 & (wc)) >> 11) != 27)
#define IsUtf16Cont(wc) IsLowSurrogate(wc) /* TODO: DELETE */
#define MergeUtf16(hi, lo) ((((hi)-0xD800) << 10) + ((lo)-0xDC00) + 0x10000)
#define EncodeUtf16(wc) \
(LIKELY((0x0000 <= (wc) && (wc) <= 0xFFFF) || \
(0xE000 <= (wc) && (wc) <= 0xFFFF)) \
? (wc) \
: 0x10000 <= (wc) && (wc) <= 0x10FFFF \
? (((((wc)-0x10000) >> 10) + 0xD800) | \
(unsigned)((((wc)-0x10000) & 1023) + 0xDC00) << 16) \
#define MergeUtf16(hi, lo) ((((hi) - 0xD800) << 10) + ((lo) - 0xDC00) + 0x10000)
#define EncodeUtf16(wc) \
(LIKELY((0x0000 <= (wc) && (wc) <= 0xFFFF) || \
(0xE000 <= (wc) && (wc) <= 0xFFFF)) \
? (wc) \
: 0x10000 <= (wc) && (wc) <= 0x10FFFF \
? (((((wc) - 0x10000) >> 10) + 0xD800) | \
(unsigned)((((wc) - 0x10000) & 1023) + 0xDC00) << 16) \
: 0xFFFD)
COSMOPOLITAN_C_END_

View file

@ -12,10 +12,10 @@
#define IOPRIO_PRIO_CLASS(ioprio) \
(((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK)
#define IOPRIO_PRIO_DATA(ioprio) ((ioprio)&IOPRIO_PRIO_MASK)
#define IOPRIO_PRIO_DATA(ioprio) ((ioprio) & IOPRIO_PRIO_MASK)
#define IOPRIO_PRIO_VALUE(class, data) \
((((class) & IOPRIO_CLASS_MASK) << IOPRIO_CLASS_SHIFT) | \
((data)&IOPRIO_PRIO_MASK))
((data) & IOPRIO_PRIO_MASK))
#define IOPRIO_CLASS_NONE 0
#define IOPRIO_CLASS_RT 1

View file

@ -30,13 +30,13 @@
#define S_IWRITE 0000200 /* just use octal */
#define S_ISTXT 0001000 /* just use octal */
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
#define S_ISCHR(mode) (((mode)&S_IFMT) == S_IFCHR)
#define S_ISBLK(mode) (((mode)&S_IFMT) == S_IFBLK)
#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
#define S_ISFIFO(mode) (((mode)&S_IFMT) == S_IFIFO)
#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK)
#define S_ISSOCK(mode) (((mode)&S_IFMT) == S_IFSOCK)
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
#define S_BLKSIZE 512
#define ALLPERMS (S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO)

View file

@ -44,7 +44,9 @@ COSMOPOLITAN_C_START_
#define PTHREAD_COND_INITIALIZER _PTHREAD_INIT
#define PTHREAD_RWLOCK_INITIALIZER _PTHREAD_INIT
#define PTHREAD_MUTEX_INITIALIZER _PTHREAD_INIT
#define _PTHREAD_INIT {0}
#define _PTHREAD_INIT \
{ 0 }
typedef uintptr_t pthread_t;
typedef int pthread_id_np_t;