Blame view

build3/liba/src/aeabi-rt/llsl.c 760 Bytes
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
  /* See the "Run-time ABI for the ARM Architecture", Section 4.2 */
  #include <assert.h>
  
  typedef unsigned int uint32_t;
  
  long long __aeabi_llsl(long long value, int shift) {
    uint32_t low = (uint32_t)value << shift;
    /* "Shift behavior is undefined if the right operand is negative, or greater
     * than or equal to the length in bits of the promoted left operand" according
     * to C++ spec. However, arm compiler fill the vacated bits with 0 */
    assert(shift < 32 || low == 0);
    uint32_t high = ((uint32_t)(value >> 32) << shift);
    // Same comment
    assert(shift < 32 || high == 0);
    if (shift < 32) {
      high |= ((uint32_t)value >> (32 - shift));
    } else {
      high |= ((uint32_t)value << (shift - 32));
    }
    return ((long long)high << 32) | low;
  }