-
Notifications
You must be signed in to change notification settings - Fork 3
/
c-ops.ads
167 lines (124 loc) · 5.96 KB
/
c-ops.ads
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
-- $Source: /home/CVSROOT/c2ada/c-ops.ads,v $
-- $Revision: 1.1.1.1 $ $Date: 1999/02/02 12:01:51 $
with Ada.Unchecked_Conversion;
package C.Ops is
subtype Uchar is C.Unsigned_Char;
subtype Ushort is C.Unsigned_Short;
subtype Uint is C.Unsigned_Int;
subtype Ulong is C.Unsigned_Long;
-- unchecked conversions between signed and unsigned types --------------
function To_Unsigned is new Ada.Unchecked_Conversion (Char, UChar);
function To_Unsigned is new Ada.Unchecked_Conversion (Short, Ushort);
function To_Unsigned is new Ada.Unchecked_Conversion (Int, Uint);
function To_Unsigned is new Ada.Unchecked_Conversion (Long, Ulong);
function To_Signed is new Ada.Unchecked_Conversion (UChar, Char);
function To_Signed is new Ada.Unchecked_Conversion (UShort, Short);
function To_Signed is new Ada.Unchecked_Conversion (UInt, Int);
function To_Signed is new Ada.Unchecked_Conversion (ULong, Long);
-- and, or, xor, not -----------------------------------------------------
function "and" (I1, I2: Uchar) return Uchar renames Interfaces.C."and";
function "and" (I1, I2: Ushort) return Ushort renames Interfaces.C."and";
function "and" (I1, I2: Uint) return Uint renames Interfaces.C."and";
function "and" (I1, I2: Ulong) return Ulong renames Interfaces.C."and";
function "and" (I1, I2: Char) return Char;
pragma Inline("and");
function "and" (I1, I2: Short) return Short;
pragma Inline("and");
function "and" (I1, I2: Int) return Int;
pragma Inline("and");
function "and" (I1, I2: Long) return Long;
pragma Inline("and");
function "or" (I1, I2: Uchar) return Uchar renames Interfaces.C."or";
function "or" (I1, I2: Ushort) return Ushort renames Interfaces.C."or";
function "or" (I1, I2: Uint) return Uint renames Interfaces.C."or";
function "or" (I1, I2: Ulong) return Ulong renames Interfaces.C."or";
function "or" (I1, I2: Char) return Char;
pragma Inline("or");
function "or" (I1, I2: Short) return Short;
pragma Inline("or");
function "or" (I1, I2: Int) return Int;
pragma Inline("or");
function "or" (I1, I2: Long) return Long;
pragma Inline("or");
function "xor" (I1, I2: Uchar) return Uchar renames Interfaces.C."xor";
function "xor" (I1, I2: Ushort) return Ushort renames Interfaces.C."xor";
function "xor" (I1, I2: Uint) return Uint renames Interfaces.C."xor";
function "xor" (I1, I2: Ulong) return Ulong renames Interfaces.C."xor";
function "xor" (I1, I2: Char) return Char;
pragma Inline("xor");
function "xor" (I1, I2: Short) return Short;
pragma Inline("xor");
function "xor" (I1, I2: Int) return Int;
pragma Inline("xor");
function "xor" (I1, I2: Long) return Long;
pragma Inline("xor");
function "not" (I1: Uchar) return Uchar renames Interfaces.C."not";
function "not" (I1: Ushort) return Ushort renames Interfaces.C."not";
function "not" (I1: Uint) return Uint renames Interfaces.C."not";
function "not" (I1: Ulong) return Ulong renames Interfaces.C."not";
function "not" (I1: Char) return Char;
pragma Inline("not");
function "not" (I1: Short) return Short;
pragma Inline("not");
function "not" (I1: Int) return Int;
pragma Inline("not");
function "not" (I1: Long) return Long;
pragma Inline("not");
-- Shift left and right ---------------------------------------------------
function Shift_Left (Value: Uchar; Amount: Natural) return Uchar;
pragma Inline(Shift_Left);
function Shift_Left (Value: Ushort; Amount: Natural) return Ushort;
pragma Inline(Shift_Left);
function Shift_Left (Value: Uint; Amount: Natural) return Uint;
pragma Inline(Shift_Left);
function Shift_Left (Value: Ulong; Amount: Natural) return Ulong;
pragma Inline(Shift_Left);
function Shift_Left (Value: Char; Amount: Natural) return Char;
pragma Inline(Shift_Left);
function Shift_Left (Value: Short; Amount: Natural) return Short;
pragma Inline(Shift_Left);
function Shift_Left (Value: Int; Amount: Natural) return Int;
pragma Inline(Shift_Left);
function Shift_Left (Value: Long; Amount: Natural) return Long;
pragma Inline(Shift_Left);
function Shift_Right (Value: Uchar; Amount: Natural) return Uchar;
pragma Inline(Shift_Right);
function Shift_Right (Value: Ushort; Amount: Natural) return Ushort;
pragma Inline(Shift_Right);
function Shift_Right (Value: Uint; Amount: Natural) return Uint;
pragma Inline(Shift_Right);
function Shift_Right (Value: Ulong; Amount: Natural) return Ulong;
pragma Inline(Shift_Right);
function Shift_Right (Value: Char; Amount: Natural) return Char;
pragma Inline(Shift_Right);
function Shift_Right (Value: Short; Amount: Natural) return Short;
pragma Inline(Shift_Right);
function Shift_Right (Value: Int; Amount: Natural) return Int;
pragma Inline(Shift_Right);
function Shift_Right (Value: Long; Amount: Natural) return Long;
pragma Inline(Shift_Right);
function Shift_Right_Arithmetic (Value: Uchar; Amount: Natural)
return Uchar;
pragma Inline(Shift_Right_Arithmetic);
function Shift_Right_Arithmetic (Value: Ushort; Amount: Natural)
return Ushort;
pragma Inline(Shift_Right_Arithmetic);
function Shift_Right_Arithmetic (Value: Uint; Amount: Natural)
return Uint;
pragma Inline(Shift_Right_Arithmetic);
function Shift_Right_Arithmetic (Value: Ulong; Amount: Natural)
return Ulong;
pragma Inline(Shift_Right_Arithmetic);
function Shift_Right_Arithmetic (Value: Char; Amount: Natural)
return Char;
pragma Inline(Shift_Right_Arithmetic);
function Shift_Right_Arithmetic (Value: Short; Amount: Natural)
return Short;
pragma Inline(Shift_Right_Arithmetic);
function Shift_Right_Arithmetic (Value: Int; Amount: Natural)
return Int;
pragma Inline(Shift_Right_Arithmetic);
function Shift_Right_Arithmetic (Value: Long; Amount: Natural)
return Long;
pragma Inline(Shift_Right_Arithmetic);
end C.Ops;