Skip to content

Commit 8bfd56b

Browse files
committed
Rename _bsr/_bsf to bsr/bsf
Now that these functions are behind _COSMO_SOURCE there's no reason for having the ugly underscore anymore. To use these functions, you need to pass -mcosmo to cosmocc.
1 parent a6baba1 commit 8bfd56b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+110
-93
lines changed

dsp/scale/gyarados.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ void *Gyarados(long dyw, long dxw, int dst[dyw][dxw], long syw, long sxw,
202202
CHECK_LE(sxn, sxw);
203203
CHECK_LE(dyn, dyw);
204204
CHECK_LE(dxn, dxw);
205-
CHECK_LT(_bsrl(syn) + _bsrl(sxn), 32);
206-
CHECK_LT(_bsrl(dyn) + _bsrl(dxn), 32);
205+
CHECK_LT(bsrl(syn) + bsrl(sxn), 32);
206+
CHECK_LT(bsrl(dyn) + bsrl(dxn), 32);
207207
CHECK_LE(dyw, 0x7fff);
208208
CHECK_LE(dxw, 0x7fff);
209209
CHECK_LE(syw, 0x7fff);

libc/calls/fstat-nt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static textwindows long GetSizeOfReparsePoint(int64_t fh) {
7171
}
7272
}
7373
if (x >= 0200) {
74-
z += _bsrl(tpenc(x)) >> 3;
74+
z += bsrl(tpenc(x)) >> 3;
7575
}
7676
++z;
7777
}

libc/calls/pledge-linux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ static privileged char *FixCpy(char p[17], uint64_t x, int k) {
10401040
}
10411041

10421042
static privileged char *HexCpy(char p[17], uint64_t x) {
1043-
return FixCpy(p, x, ROUNDUP(x ? _bsrl(x) + 1 : 1, 4));
1043+
return FixCpy(p, x, ROUNDUP(x ? bsrl(x) + 1 : 1, 4));
10441044
}
10451045

10461046
static privileged int GetPid(void) {

libc/calls/sig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static textwindows int __sig_getter(atomic_ulong *sigs, sigset_t masked) {
9797
for (;;) {
9898
pending = atomic_load_explicit(sigs, memory_order_acquire);
9999
if ((deliverable = pending & ~masked)) {
100-
sig = _bsfl(deliverable) + 1;
100+
sig = bsfl(deliverable) + 1;
101101
bit = 1ull << (sig - 1);
102102
if (atomic_fetch_and_explicit(sigs, ~bit, memory_order_acq_rel) & bit) {
103103
return sig;

libc/fmt/formatbinary64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ char *FormatBinary64(char p[hasatleast 67], uint64_t x, char z) {
4545
*p++ = '0';
4646
*p++ = 'b';
4747
}
48-
i = PickGoodWidth(_bsrl(x));
48+
i = PickGoodWidth(bsrl(x));
4949
do {
5050
b = 1;
5151
b <<= i;

libc/fmt/itoa64radix16.greg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
#include "libc/macros.internal.h"
2323

2424
size_t uint64toarray_radix16(uint64_t x, char b[hasatleast 17]) {
25-
return uint64toarray_fixed16(x, b, ROUNDUP(x ? _bsrl(x) + 1 : 1, 4));
25+
return uint64toarray_fixed16(x, b, ROUNDUP(x ? bsrl(x) + 1 : 1, 4));
2626
}

libc/integral/cxx.inc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
#if 1
1919
template <bool _P, typename _T, typename _U>
2020
struct __cxx_choose_expr {
21-
__cxx_choose_expr(_T _a, _U _b) : _value(_a) {}
21+
__cxx_choose_expr(_T _a, _U _b) : _value(_a) {
22+
}
2223
const _T _value;
2324
};
2425
template <typename _T, typename _U>
2526
struct __cxx_choose_expr<false, _T, _U> {
26-
__cxx_choose_expr(_T _a, _U _b) : _value(_b) {}
27+
__cxx_choose_expr(_T _a, _U _b) : _value(_b) {
28+
}
2729
const _U _value;
2830
};
2931
#define __builtin_choose_expr(X, A, B) \
@@ -32,3 +34,8 @@ struct __cxx_choose_expr<false, _T, _U> {
3234
#define __builtin_choose_expr(X, A, B) ((X) ? (A) : (B))
3335
#endif
3436
#endif
37+
38+
#ifdef __aarch64__
39+
/* todo jart whyyyy */
40+
#define _Float16 __fp16
41+
#endif

libc/intrin/bsf.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Returns position of first bit set.
2323
*
2424
* ctz(𝑥) 31^clz(𝑥) clz(𝑥)
25-
* uint32 𝑥 _bsf(𝑥) tzcnt(𝑥) ffs(𝑥) _bsr(𝑥) lzcnt(𝑥)
25+
* uint32 𝑥 bsf(𝑥) tzcnt(𝑥) ffs(𝑥) bsr(𝑥) lzcnt(𝑥)
2626
* 0x00000000 wut 32 0 wut 32
2727
* 0x00000001 0 0 1 0 31
2828
* 0x80000001 0 0 1 31 0
@@ -35,7 +35,7 @@
3535
* @param 𝑥 is a 64-bit integer
3636
* @return number in range 0..63 or undefined if 𝑥 is 0
3737
*/
38-
int(_bsfl)(long x) {
38+
int(bsfl)(long x) {
3939
unsigned l, r;
4040
x &= -x;
4141
l = x | x >> 32;
@@ -52,7 +52,7 @@ int(_bsfl)(long x) {
5252
* Returns position of first bit set.
5353
*
5454
* ctz(𝑥) 31^clz(𝑥) clz(𝑥)
55-
* uint32 𝑥 _bsf(𝑥) tzcnt(𝑥) ffs(𝑥) _bsr(𝑥) lzcnt(𝑥)
55+
* uint32 𝑥 bsf(𝑥) tzcnt(𝑥) ffs(𝑥) bsr(𝑥) lzcnt(𝑥)
5656
* 0x00000000 wut 32 0 wut 32
5757
* 0x00000001 0 0 1 0 31
5858
* 0x80000001 0 0 1 31 0
@@ -65,8 +65,8 @@ int(_bsfl)(long x) {
6565
* @param x is a 32-bit integer
6666
* @return number in range 0..31 or undefined if 𝑥 is 0
6767
*/
68-
int(_bsf)(int x) {
69-
return _bsf((unsigned)x);
68+
int(bsf)(int x) {
69+
return bsf((unsigned)x);
7070
}
7171

72-
__weak_reference(_bsfl, _bsfll);
72+
__weak_reference(bsfl, bsfll);

libc/intrin/bsf.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
#ifdef _COSMO_SOURCE
12
#ifndef COSMOPOLITAN_LIBC_NEXGEN32E_BSF_H_
23
#define COSMOPOLITAN_LIBC_NEXGEN32E_BSF_H_
34
COSMOPOLITAN_C_START_
45

5-
libcesque int _bsf(int) pureconst;
6-
libcesque int _bsfl(long) pureconst;
7-
libcesque int _bsfll(long long) pureconst;
6+
libcesque int bsf(int) pureconst;
7+
libcesque int bsfl(long) pureconst;
8+
libcesque int bsfll(long long) pureconst;
89

910
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
10-
#define _bsf(x) __builtin_ctz(x)
11-
#define _bsfl(x) __builtin_ctzl(x)
12-
#define _bsfll(x) __builtin_ctzll(x)
11+
#define bsf(x) __builtin_ctz(x)
12+
#define bsfl(x) __builtin_ctzl(x)
13+
#define bsfll(x) __builtin_ctzll(x)
1314
#endif
1415

1516
COSMOPOLITAN_C_END_
1617
#endif /* COSMOPOLITAN_LIBC_NEXGEN32E_BSF_H_ */
18+
#endif /* _COSMO_SOURCE */

libc/intrin/bsr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Returns binary logarithm of 𝑥.
2424
*
2525
* ctz(𝑥) 31^clz(𝑥) clz(𝑥)
26-
* uint32 𝑥 _bsf(𝑥) tzcnt(𝑥) ffs(𝑥) _bsr(𝑥) lzcnt(𝑥)
26+
* uint32 𝑥 bsf(𝑥) tzcnt(𝑥) ffs(𝑥) bsr(𝑥) lzcnt(𝑥)
2727
* 0x00000000 wut 32 0 wut 32
2828
* 0x00000001 0 0 1 0 31
2929
* 0x80000001 0 0 1 31 0
@@ -36,7 +36,7 @@
3636
* @param x is a 32-bit integer
3737
* @return number in range 0..31 or undefined if 𝑥 is 0
3838
*/
39-
int(_bsr)(int x) {
39+
int(bsr)(int x) {
4040
int r = 0;
4141
if(x & 0xFFFF0000u) { x >>= 16; r |= 16; }
4242
if(x & 0xFF00) { x >>= 8; r |= 8; }

0 commit comments

Comments
 (0)