mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-28 05:20:28 +00:00
Add some more builtins to chibicc
https://justine.lol/cosmopolitan/documentation.html should now contain a lot of functions that had been missing previously due to not having them
This commit is contained in:
parent
ab38f0823d
commit
f1dfa4bdfa
17 changed files with 417 additions and 201 deletions
6
third_party/chibicc/test/msabi_test.c
vendored
Normal file
6
third_party/chibicc/test/msabi_test.c
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include "third_party/chibicc/test/test.h"
|
||||
|
||||
int (*__attribute__((__ms_abi__)) NtFoo)(int x, int y);
|
||||
|
||||
int main() {
|
||||
}
|
26
third_party/chibicc/test/spinlock_test.c
vendored
Normal file
26
third_party/chibicc/test/spinlock_test.c
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "third_party/chibicc/test/test.h"
|
||||
|
||||
#define SPINLOCK(lock) \
|
||||
do { \
|
||||
for (;;) { \
|
||||
typeof(*(lock)) x; \
|
||||
__atomic_load(lock, &x, __ATOMIC_RELAXED); \
|
||||
if (!x && !__sync_lock_test_and_set(lock, 1)) { \
|
||||
break; \
|
||||
} else { \
|
||||
__builtin_ia32_pause(); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SPUNLOCK(lock) __sync_lock_release(lock)
|
||||
|
||||
_Alignas(64) char lock;
|
||||
|
||||
main() {
|
||||
ASSERT(0, lock);
|
||||
SPINLOCK(&lock);
|
||||
ASSERT(1, lock);
|
||||
SPUNLOCK(&lock);
|
||||
ASSERT(0, lock);
|
||||
}
|
40
third_party/chibicc/test/vector_test.c
vendored
40
third_party/chibicc/test/vector_test.c
vendored
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/chibicc/test/test.h"
|
||||
|
||||
typedef char byte16 __attribute__((__vector_size__(16)));
|
||||
typedef float float4 __attribute__((__vector_size__(16)));
|
||||
typedef float float4a1 __attribute__((__vector_size__(16), __aligned__(1)));
|
||||
typedef float float4a16 __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
|
@ -39,18 +40,33 @@ int main(void) {
|
|||
ASSERT(1, _Alignof(double2a1));
|
||||
ASSERT(16, _Alignof(double2a16));
|
||||
|
||||
float4 v1;
|
||||
float4 v2;
|
||||
float x[4] = {1, 2, 3, 4};
|
||||
float y[4] = {1, 1, 1, 1};
|
||||
memcpy(&v1, x, 16);
|
||||
memcpy(&v2, y, 16);
|
||||
v1 = v1 + v2;
|
||||
memcpy(x, &v1, 16);
|
||||
ASSERT(2, x[0]);
|
||||
/* ASSERT(3, x[1]); */
|
||||
/* ASSERT(4, x[2]); */
|
||||
/* ASSERT(5, x[3]); */
|
||||
{
|
||||
float4 v1;
|
||||
float4 v2;
|
||||
float x[4] = {1, 2, 3, 4};
|
||||
float y[4] = {1, 1, 1, 1};
|
||||
memcpy(&v1, x, 16);
|
||||
memcpy(&v2, y, 16);
|
||||
v1 = v1 + v2;
|
||||
memcpy(x, &v1, 16);
|
||||
ASSERT(2, x[0]);
|
||||
// TODO(jart): fix me
|
||||
/* ASSERT(3, x[1]); */
|
||||
/* ASSERT(4, x[2]); */
|
||||
/* ASSERT(5, x[3]); */
|
||||
}
|
||||
|
||||
{
|
||||
byte16 v;
|
||||
float x1[4] = {1, 2, 3, 4};
|
||||
float x2[4];
|
||||
memcpy(&v, x1, 16);
|
||||
__builtin_ia32_movntdq(x1, &v);
|
||||
memcpy(x2, &v, 16);
|
||||
ASSERT(1, x2[0]);
|
||||
// TODO(jart): fix me
|
||||
/* ASSERT(2, x[1]); */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue