@@ -99,32 +99,127 @@ pub unsafe fn move_val_init<T>(dst: &mut T, src: T) {
99
99
intrinsics:: move_val_init ( dst, src)
100
100
}
101
101
102
+ /// Convert an i16 to little endian from the target's endianness.
103
+ ///
104
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
102
105
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn to_le16 ( x : i16 ) -> i16 { x }
106
+
107
+ /// Convert an i16 to little endian from the target's endianness.
108
+ ///
109
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
103
110
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn to_le16 ( x : i16 ) -> i16 { unsafe { bswap16 ( x) } }
111
+
112
+ /// Convert an i32 to little endian from the target's endianness.
113
+ ///
114
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
104
115
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn to_le32 ( x : i32 ) -> i32 { x }
116
+
117
+ /// Convert an i32 to little endian from the target's endianness.
118
+ ///
119
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
105
120
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn to_le32 ( x : i32 ) -> i32 { unsafe { bswap32 ( x) } }
121
+
122
+ /// Convert an i64 to little endian from the target's endianness.
123
+ ///
124
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
106
125
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn to_le64 ( x : i64 ) -> i64 { x }
126
+
127
+ /// Convert an i64 to little endian from the target's endianness.
128
+ ///
129
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
107
130
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn to_le64 ( x : i64 ) -> i64 { unsafe { bswap64 ( x) } }
108
131
132
+
133
+ /// Convert an i16 to big endian from the target's endianness.
134
+ ///
135
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
109
136
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn to_be16 ( x : i16 ) -> i16 { unsafe { bswap16 ( x) } }
137
+
138
+ /// Convert an i16 to big endian from the target's endianness.
139
+ ///
140
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
110
141
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn to_be16 ( x : i16 ) -> i16 { x }
142
+
143
+ /// Convert an i32 to big endian from the target's endianness.
144
+ ///
145
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
111
146
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn to_be32 ( x : i32 ) -> i32 { unsafe { bswap32 ( x) } }
147
+
148
+ /// Convert an i32 to big endian from the target's endianness.
149
+ ///
150
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
112
151
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn to_be32 ( x : i32 ) -> i32 { x }
152
+
153
+ /// Convert an i64 to big endian from the target's endianness.
154
+ ///
155
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
113
156
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn to_be64 ( x : i64 ) -> i64 { unsafe { bswap64 ( x) } }
157
+
158
+ /// Convert an i64 to big endian from the target's endianness.
159
+ ///
160
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
114
161
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn to_be64 ( x : i64 ) -> i64 { x }
115
162
163
+
164
+ /// Convert an i16 from little endian to the target's endianness.
165
+ ///
166
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
116
167
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn from_le16 ( x : i16 ) -> i16 { x }
168
+
169
+ /// Convert an i16 from little endian to the target's endianness.
170
+ ///
171
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
117
172
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn from_le16 ( x : i16 ) -> i16 { unsafe { bswap16 ( x) } }
173
+
174
+ /// Convert an i32 from little endian to the target's endianness.
175
+ ///
176
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
118
177
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn from_le32 ( x : i32 ) -> i32 { x }
178
+
179
+ /// Convert an i32 from little endian to the target's endianness.
180
+ ///
181
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
119
182
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn from_le32 ( x : i32 ) -> i32 { unsafe { bswap32 ( x) } }
183
+
184
+ /// Convert an i64 from little endian to the target's endianness.
185
+ ///
186
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
120
187
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn from_le64 ( x : i64 ) -> i64 { x }
188
+
189
+ /// Convert an i64 from little endian to the target's endianness.
190
+ ///
191
+ /// On little endian, this is a no-op. On big endian, the bytes are swapped.
121
192
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn from_le64 ( x : i64 ) -> i64 { unsafe { bswap64 ( x) } }
122
193
194
+
195
+ /// Convert an i16 from big endian to the target's endianness.
196
+ ///
197
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
123
198
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn from_be16 ( x : i16 ) -> i16 { unsafe { bswap16 ( x) } }
199
+
200
+ /// Convert an i16 from big endian to the target's endianness.
201
+ ///
202
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
124
203
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn from_be16 ( x : i16 ) -> i16 { x }
204
+
205
+ /// Convert an i32 from big endian to the target's endianness.
206
+ ///
207
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
125
208
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn from_be32 ( x : i32 ) -> i32 { unsafe { bswap32 ( x) } }
209
+
210
+ /// Convert an i32 from big endian to the target's endianness.
211
+ ///
212
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
126
213
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn from_be32 ( x : i32 ) -> i32 { x }
214
+
215
+ /// Convert an i64 from big endian to the target's endianness.
216
+ ///
217
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
127
218
#[ cfg( target_endian = "little" ) ] #[ inline] pub fn from_be64 ( x : i64 ) -> i64 { unsafe { bswap64 ( x) } }
219
+
220
+ /// Convert an i64 from big endian to the target's endianness.
221
+ ///
222
+ /// On big endian, this is a no-op. On little endian, the bytes are swapped.
128
223
#[ cfg( target_endian = "big" ) ] #[ inline] pub fn from_be64 ( x : i64 ) -> i64 { x }
129
224
130
225
0 commit comments