Numworks Epsilon  1.4.1
Graphing Calculator Operating System
llsr.c
Go to the documentation of this file.
1 /* See the "Run-time ABI for the ARM Architecture", Section 4.2 */
2 #include <assert.h>
3 
4 typedef unsigned int uint32_t;
5 
6 long long __aeabi_llsr(long long value, int shift) {
7  uint32_t low = ((uint32_t)value >> shift);
8  /* "Shift behavior is undefined if the right operand is negative, or greater
9  * than or equal to the length in bits of the promoted left operand" according
10  * to C++ spec. However, arm compiler fill the vacated bits with 0 */
11  assert(shift < 32 || low == 0);
12  if (shift < 32) {
13  low |= ((uint32_t)(value >> 32) << (32 - shift));
14  } else {
15  low |= ((uint32_t)(value >> 32) >> (shift - 32));
16  }
17  uint32_t high = (uint32_t)(value >> 32) >> shift;
18  // Same comment
19  assert(shift < 32 || high == 0);
20  return ((long long)high << 32) | low;
21 }
#define assert(e)
Definition: assert.h:9
unsigned int uint32_t
Definition: stdint.h:6
unsigned int uint32_t
Definition: llsr.c:4
long long __aeabi_llsr(long long value, int shift)
Definition: llsr.c:6