quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

commit 615afa1621741a48977b244c2fefea9a91150be3
parent f01e01026405973e6eca581d76e580e0c913f60c
Author: Florian Dold <florian@dold.me>
Date:   Wed, 21 Dec 2022 14:38:33 +0100

checkprogs

Diffstat:
Asubprojects/libsodium/checkprogs/amd64_asm.c | 17+++++++++++++++++
Asubprojects/libsodium/checkprogs/avx_asm.c | 11+++++++++++
Asubprojects/libsodium/checkprogs/cpuid.c | 7+++++++
Asubprojects/libsodium/checkprogs/inline_asm.c | 5+++++
Asubprojects/libsodium/checkprogs/mmx.c | 6++++++
Asubprojects/libsodium/checkprogs/rdrand.c | 6++++++
Asubprojects/libsodium/checkprogs/ti_mode.c | 28++++++++++++++++++++++++++++
Asubprojects/libsodium/checkprogs/xgetbv.c | 5+++++
8 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/subprojects/libsodium/checkprogs/amd64_asm.c b/subprojects/libsodium/checkprogs/amd64_asm.c @@ -0,0 +1,17 @@ +void main() { +#if defined(__amd64) || defined(__amd64__) || defined(__x86_64__) +# if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || defined(_WIN32) || defined(_WIN64) +# error Windows x86_64 calling conventions are not supported yet +# endif +/* neat */ +#else +# error !x86_64 +#endif +unsigned char i = 0, o = 0, t; +__asm__ __volatile__ ("pxor %%xmm12, %%xmm6 \n" + "movb (%[i]), %[t] \n" + "addb %[t], (%[o]) \n" + : [t] "=&r"(t) + : [o] "D"(&o), [i] "S"(&i) + : "memory", "flags", "cc"); +} diff --git a/subprojects/libsodium/checkprogs/avx_asm.c b/subprojects/libsodium/checkprogs/avx_asm.c @@ -0,0 +1,11 @@ +void main() { +#if defined(__amd64) || defined(__amd64__) || defined(__x86_64__) +# if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || defined(_WIN32) || defined(_WIN64) +# error Windows x86_64 calling conventions are not supported yet +# endif +/* neat */ +#else +# error !x86_64 +#endif +__asm__ __volatile__ ("vpunpcklqdq %xmm0,%xmm13,%xmm0"); +} diff --git a/subprojects/libsodium/checkprogs/cpuid.c b/subprojects/libsodium/checkprogs/cpuid.c @@ -0,0 +1,7 @@ + int main() { + unsigned int cpu_info[4]; + __asm__ __volatile__ ("xchgl %%ebx, %k1; cpuid; xchgl %%ebx, %k1" : + "=a" (cpu_info[0]), "=&r" (cpu_info[1]), + "=c" (cpu_info[2]), "=d" (cpu_info[3]) : + "0" (0U), "2" (0U)); +} diff --git a/subprojects/libsodium/checkprogs/inline_asm.c b/subprojects/libsodium/checkprogs/inline_asm.c @@ -0,0 +1,5 @@ +int main(int argc, char **argv) { + int a = 42; + int *pnt = &a; + __asm__ __volatile__ ("" : : "r"(pnt) : "memory"); +} diff --git a/subprojects/libsodium/checkprogs/mmx.c b/subprojects/libsodium/checkprogs/mmx.c @@ -0,0 +1,6 @@ +#pragma GCC target("mmx") +#include <mmintrin.h> + +void main() { + _mm_setzero_si64(); +} diff --git a/subprojects/libsodium/checkprogs/rdrand.c b/subprojects/libsodium/checkprogs/rdrand.c @@ -0,0 +1,6 @@ +#pragma GCC target("rdrnd") +#include <immintrin.h> + +void main() { + unsigned long long x; _rdrand64_step(&x); +} diff --git a/subprojects/libsodium/checkprogs/ti_mode.c b/subprojects/libsodium/checkprogs/ti_mode.c @@ -0,0 +1,28 @@ +#if !defined(__clang__) && !defined(__GNUC__) && !defined(__SIZEOF_INT128__) +# error mode(TI) is a gcc extension, and __int128 is not available +#endif +#if defined(__clang__) && !defined(__x86_64__) && !defined(__aarch64__) +# error clang does not properly handle the 128-bit type on 32-bit systems +#endif +#ifndef NATIVE_LITTLE_ENDIAN +# error libsodium currently expects a little endian CPU for the 128-bit type +#endif +#ifdef __EMSCRIPTEN__ +# error emscripten currently doesn't support some operations on integers larger than 64 bits +#endif +#include <stddef.h> +#include <stdint.h> +#if defined(__SIZEOF_INT128__) +typedef unsigned __int128 uint128_t; +#else +typedef unsigned uint128_t __attribute__((mode(TI))); +#endif +void fcontract(uint128_t *t) { + *t += 0x8000000000000 - 1; + *t *= *t; + *t >>= 84; +} + +int main(int argc, char **argv) { + (void) fcontract; +} diff --git a/subprojects/libsodium/checkprogs/xgetbv.c b/subprojects/libsodium/checkprogs/xgetbv.c @@ -0,0 +1,5 @@ +#include <intrin.h> + +void main() { + (void) _xgetbv(0); +}