* builtins.def: Break out _Complex math functions into their
[official-gcc.git] / libf2c / libF77 / lbitbits.c
blob3b28ae97aba324800a5b1444b78ec566cd3169d9
1 #include "f2c.h"
3 #ifndef LONGBITS
4 #define LONGBITS 32
5 #endif
7 integer
8 lbit_bits (integer a, integer b, integer len)
10 /* Assume 2's complement arithmetic */
12 unsigned long x, y;
14 x = (unsigned long) a;
15 y = (unsigned long) -1L;
16 x >>= b;
17 y <<= len;
18 return (integer) (x & ~y);
21 integer
22 lbit_cshift (integer a, integer b, integer len)
24 unsigned long x, y, z;
26 x = (unsigned long) a;
27 if (len <= 0)
29 if (len == 0)
30 return 0;
31 goto full_len;
33 if (len >= LONGBITS)
35 full_len:
36 if (b >= 0)
38 b %= LONGBITS;
39 return (integer) (x << b | x >> (LONGBITS - b));
41 b = -b;
42 b %= LONGBITS;
43 return (integer) (x << (LONGBITS - b) | x >> b);
45 y = z = (unsigned long) -1;
46 y <<= len;
47 z &= ~y;
48 y &= x;
49 x &= z;
50 if (b >= 0)
52 b %= len;
53 return (integer) (y | (z & (x << b | x >> (len - b))));
55 b = -b;
56 b %= len;
57 return (integer) (y | (z & (x >> b | x << (len - b))));