* Makefile.am (nat_source_files): Remove
[official-gcc.git] / libf2c / libF77 / qbitbits.c
blobf72858e7a3397bbcb72469c96394a6763925d980
1 #include "f2c.h"
3 #ifndef LONGBITS
4 #define LONGBITS 32
5 #endif
7 #ifndef LONG8BITS
8 #define LONG8BITS (2*LONGBITS)
9 #endif
11 integer
12 qbit_bits (longint a, integer b, integer len)
14 /* Assume 2's complement arithmetic */
16 ulongint x, y;
18 x = (ulongint) a;
19 y = (ulongint) - 1L;
20 x >>= b;
21 y <<= len;
22 return (longint) (x & y);
25 longint
26 qbit_cshift (longint a, integer b, integer len)
28 ulongint x, y, z;
30 x = (ulongint) a;
31 if (len <= 0)
33 if (len == 0)
34 return 0;
35 goto full_len;
37 if (len >= LONG8BITS)
39 full_len:
40 if (b >= 0)
42 b %= LONG8BITS;
43 return (longint) (x << b | x >> (LONG8BITS - b));
45 b = -b;
46 b %= LONG8BITS;
47 return (longint) (x << (LONG8BITS - b) | x >> b);
49 y = z = (unsigned long) -1;
50 y <<= len;
51 z &= ~y;
52 y &= x;
53 x &= z;
54 if (b >= 0)
56 b %= len;
57 return (longint) (y | (z & (x << b | x >> (len - b))));
59 b = -b;
60 b %= len;
61 return (longint) (y | (z & (x >> b | x << (len - b))));