Blame view

build1/epsilon-master/liba/test/aeabi.c 2.36 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  #include <quiz.h>
  #include <stdint.h>
  #include <assert.h>
  
  long long __aeabi_llsl(long long value, int shift);
  long long __aeabi_llsr(long long value, int shift);
  
  QUIZ_CASE(liba_llsl) {
    assert(__aeabi_llsl((uint64_t)1, 1) == (uint64_t)0x2);
    assert(__aeabi_llsl((uint64_t)1, 2) == (uint64_t)0x4);
    assert(__aeabi_llsl((uint64_t)1, 10) == (uint64_t)0x400);
    assert(__aeabi_llsl((uint64_t)1, 20) == (uint64_t)0x100000);
    assert(__aeabi_llsl((uint64_t)1, 30) == (uint64_t)0x40000000);
    assert(__aeabi_llsl((uint64_t)1, 31) == (uint64_t)0x80000000);
    assert(__aeabi_llsl((uint64_t)1, 32) == (uint64_t)0x100000000);
    assert(__aeabi_llsl((uint64_t)1, 33) == (uint64_t)0x200000000);
    assert(__aeabi_llsl((uint64_t)1, 40) == (uint64_t)0x10000000000);
    assert(__aeabi_llsl((uint64_t)1, 50) == (uint64_t)0x4000000000000);
    assert(__aeabi_llsl((uint64_t)1, 60) == (uint64_t)0x1000000000000000);
    assert(__aeabi_llsl((uint64_t)1, 61) == (uint64_t)0x2000000000000000);
    assert(__aeabi_llsl((uint64_t)1, 62) == (uint64_t)0x4000000000000000);
    assert(__aeabi_llsl((uint64_t)1, 63) == (uint64_t)0x8000000000000000);
    assert(__aeabi_llsl((uint64_t)1, 64) == (uint64_t)0);
  }
  
  QUIZ_CASE(liba_llsr) {
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 1) == (uint64_t)0x4000000000000000);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 2) == (uint64_t)0x2000000000000000);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 10) == (uint64_t)0x20000000000000);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 20) == (uint64_t)0x80000000000);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 30) == (uint64_t)0x200000000);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 31) == (uint64_t)0x100000000);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 32) == (uint64_t)0x80000000);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 33) == (uint64_t)0x40000000);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 40) == (uint64_t)0x800000);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 50) == (uint64_t)0x2000);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 60) == (uint64_t)0x8);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 61) == (uint64_t)0x4);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 62) == (uint64_t)0x2);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 63) == (uint64_t)0x1);
    assert(__aeabi_llsr((uint64_t)0x8000000000000000, 64) == (uint64_t)0);
  }