95 __asm__ (
"\n" :
"=g" ( ret ) :
"0" ( &
a ) );
118 #define check_divmod( dividend, divisor, OP ) ( { \ 121 void *check = NULL; \ 124 __asm__ ( "\n" : "=g" ( count ) : "0" ( count ) ); \ 131 assert ( check == stack_check() ); \ 133 check = stack_check(); \ 139 __asm__ ( "\n" : "=g" ( dividend ), "=g" ( divisor ) \ 140 : "0" ( dividend ), "1" ( divisor ) ); \ 141 result = ( dividend OP divisor ); \ 142 __asm__ ( "\n" : "=g" ( result ) : "0" ( result ) ); \ 144 } while ( --count ); \ 216 #define ffsl_ok( value, lsb ) ffsl_okx ( value, lsb, __FILE__, __LINE__ ) 235 #define ffsll_ok( value, lsb ) ffsll_okx ( value, lsb, __FILE__, __LINE__ ) 254 #define flsl_ok( value, msb ) flsl_okx ( value, msb, __FILE__, __LINE__ ) 273 #define flsll_ok( value, msb ) flsll_okx ( value, msb, __FILE__, __LINE__ ) 287 const char *file,
unsigned int line ) {
290 okx ( ( ( divisor * quotient ) + remainder ) == dividend, file, line );
293 okx (
u64div_var ( dividend, divisor ) == quotient, file, line );
296 okx (
u64mod_var ( dividend, divisor ) == remainder, file, line );
298 #define u64divmod_ok( dividend, divisor, quotient, remainder ) \ 299 u64divmod_okx ( dividend, divisor, quotient, remainder, \ 314 const char *file,
unsigned int line ) {
317 okx ( ( ( divisor * quotient ) + remainder ) == dividend, file, line );
320 okx (
s64div_var ( dividend, divisor ) == quotient, file, line );
323 okx (
s64mod_var ( dividend, divisor ) == remainder, file, line );
325 #define s64divmod_ok( dividend, divisor, quotient, remainder ) \ 326 s64divmod_okx ( dividend, divisor, quotient, remainder, \ 349 ffsll_ok ( 0x8000000000000000ULL, 64 );
358 flsl_ok ( -1U, ( 8 *
sizeof (
int ) ) );
359 flsl_ok ( -1UL, ( 8 *
sizeof (
long ) ) );
365 flsll_ok ( -1U, ( 8 *
sizeof (
int ) ) );
366 flsll_ok ( -1UL, ( 8 *
sizeof (
long ) ) );
367 flsll_ok ( -1ULL, ( 8 *
sizeof (
long long ) ) );
379 0x2eef6ab4ULL, 0x0e12f089ULL );
381 0x2eef6ab4ULL, 0x0e12f089ULL );
382 u64divmod_ok ( 0xc09e00dcb9e34b54ULL, 0x35968185cdc744f3ULL,
383 3, 0x1fda7c4b508d7c7bULL );
384 s64divmod_ok ( -0x3f61ff23461cb4acLL, 0x35968185cdc744f3ULL,
385 -1LL, -0x9cb7d9d78556fb9LL );
395 ok (
isqrt ( 0xa53df2adUL ) == 52652 );
396 ok (
isqrt ( 0x123793c6UL ) == 17482 );
397 ok (
isqrt ( -1UL ) == ( -1UL >> ( 8 *
sizeof (
unsigned long ) / 2 )));
#define s64divmod_ok(dividend, divisor, quotient, remainder)
#define ffsl(x)
Find first (i.e.
#define ffsl_ok(value, lsb)
unsigned long isqrt(unsigned long value)
Find integer square root.
unsigned long long uint64_t
Self-test infrastructure.
const char * name
Test set name.
static void ffsl_okx(long value, int lsb, const char *file, unsigned int line)
Report a ffsl() test result.
#define flsll(x)
Find last (i.e.
int ffsll_var(long long value)
Force a call to the non-constant implementation of ffsll()
int64_t s64div_var(int64_t dividend, int64_t divisor)
Force a use of runtime 64-bit signed integer division.
#define u64divmod_ok(dividend, divisor, quotient, remainder)
uint64_t u64div_var(uint64_t dividend, uint64_t divisor)
Force a use of runtime 64-bit unsigned integer division.
struct self_test math_test __self_test
Mathematical self-tests.
#define okx(success, file, line)
Report test result.
#define ffsll(x)
Find first (i.e.
#define ffsll_ok(value, lsb)
static void math_test_exec(void)
Perform mathematical self-tests.
pseudo_bit_t value[0x00020]
static void u64divmod_okx(uint64_t dividend, uint64_t divisor, uint64_t quotient, uint64_t remainder, const char *file, unsigned int line)
Report a 64-bit unsigned integer division test result.
static void ffsll_okx(long long value, int lsb, const char *file, unsigned int line)
Report a ffsll() test result.
static void * stack_check(void)
Check current stack pointer.
static void s64divmod_okx(int64_t dividend, int64_t divisor, int64_t quotient, int64_t remainder, const char *file, unsigned int line)
Report a 64-bit signed integer division test result.
int64_t s64mod_var(int64_t dividend, int64_t divisor)
Force a use of runtime 64-bit unsigned integer modulus.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
uint64_t u64mod_var(uint64_t dividend, uint64_t divisor)
Force a use of runtime 64-bit unsigned integer modulus.
#define flsll_ok(value, msb)
static void flsl_okx(long value, int msb, const char *file, unsigned int line)
Report a flsl() test result.
int flsll_var(long long value)
Force a call to the non-constant implementation of flsll()
static void flsll_okx(long long value, int msb, const char *file, unsigned int line)
Report a flsll() test result.
#define check_divmod(dividend, divisor, OP)
Check division/modulus operation.
int ffsl_var(long value)
Force a call to the non-constant implementation of ffsl()
#define flsl(x)
Find last (i.e.
int flsl_var(long value)
Force a call to the non-constant implementation of flsl()
#define flsl_ok(value, msb)