@@ -237,43 +237,64 @@ module Swap = struct
237237 ((caml_bigstring_get_16 x off) lsl (Sys. int_size - 16 )) asr (Sys. int_size - 16 )
238238end
239239
240- let set_int16_le, set_int16_be =
241- if Sys. big_endian
242- then Swap. caml_bigstring_set_16, caml_bigstring_set_16
243- else caml_bigstring_set_16 , Swap. caml_bigstring_set_16
244-
245- let set_int32_le, set_int32_be =
246- if Sys. big_endian
247- then Swap. caml_bigstring_set_32, caml_bigstring_set_32
248- else caml_bigstring_set_32 , Swap. caml_bigstring_set_32
249-
250- let set_int64_le, set_int64_be =
251- if Sys. big_endian
252- then Swap. caml_bigstring_set_64, caml_bigstring_set_64
253- else caml_bigstring_set_64 , Swap. caml_bigstring_set_64
254-
255- let get_int16_le, get_int16_be =
256- if Sys. big_endian
257- then Swap. caml_bigstring_get_16, caml_bigstring_get_16
258- else caml_bigstring_get_16 , Swap. caml_bigstring_get_16
240+ let set_int16_le b i x =
241+ if Sys. big_endian then Swap. caml_bigstring_set_16 b i x
242+ else caml_bigstring_set_16 b i x
243+
244+ let set_int16_be b i x =
245+ if not Sys. big_endian then Swap. caml_bigstring_set_16 b i x
246+ else caml_bigstring_set_16 b i x
247+
248+ let set_int32_le b i x =
249+ if Sys. big_endian then Swap. caml_bigstring_set_32 b i x
250+ else caml_bigstring_set_32 b i x
251+
252+ let set_int32_be b i x =
253+ if not Sys. big_endian then Swap. caml_bigstring_set_32 b i x
254+ else caml_bigstring_set_32 b i x
255+
256+ let set_int64_le b i x =
257+ if Sys. big_endian then Swap. caml_bigstring_set_64 b i x
258+ else caml_bigstring_set_64 b i x
259+
260+ let set_int64_be b i x =
261+ if not Sys. big_endian then Swap. caml_bigstring_set_64 b i x
262+ else caml_bigstring_set_64 b i x
263+
264+ let get_int16_le b i =
265+ if Sys. big_endian then Swap. caml_bigstring_get_16 b i
266+ else caml_bigstring_get_16 b i
267+
268+ let get_int16_be b i =
269+ if not Sys. big_endian then Swap. caml_bigstring_get_16 b i
270+ else caml_bigstring_get_16 b i
259271
260272let get_int16_sign_extended_noswap x off =
261273 ((caml_bigstring_get_16 x off) lsl (Sys. int_size - 16 )) asr (Sys. int_size - 16 )
262274
263- let get_int16_sign_extended_le, get_int16_sign_extended_be =
264- if Sys. big_endian
265- then Swap. get_int16_sign_extended , get_int16_sign_extended_noswap
266- else get_int16_sign_extended_noswap, Swap. get_int16_sign_extended
275+ let get_int16_sign_extended_le b i =
276+ if Sys. big_endian then Swap. get_int16_sign_extended b i
277+ else get_int16_sign_extended_noswap b i
278+
279+ let get_int16_sign_extended_be b i =
280+ if not Sys. big_endian then Swap. get_int16_sign_extended b i
281+ else get_int16_sign_extended_noswap b i
267282
268- let get_int32_le, get_int32_be =
269- if Sys. big_endian
270- then Swap. caml_bigstring_get_32, caml_bigstring_get_32
271- else caml_bigstring_get_32 , Swap. caml_bigstring_get_32
283+ let get_int32_le b i =
284+ if Sys. big_endian then Swap. caml_bigstring_get_32 b i
285+ else caml_bigstring_get_32 b i
272286
273- let get_int64_le, get_int64_be =
274- if Sys. big_endian
275- then Swap. caml_bigstring_get_64, caml_bigstring_get_64
276- else caml_bigstring_get_64 , Swap. caml_bigstring_get_64
287+ let get_int32_be b i =
288+ if not Sys. big_endian then Swap. caml_bigstring_get_32 b i
289+ else caml_bigstring_get_32 b i
290+
291+ let get_int64_le b i =
292+ if Sys. big_endian then Swap. caml_bigstring_get_64 b i
293+ else caml_bigstring_get_64 b i
294+
295+ let get_int64_be b i =
296+ if not Sys. big_endian then Swap. caml_bigstring_get_64 b i
297+ else caml_bigstring_get_64 b i
277298
278299(* Unsafe operations *)
279300
@@ -309,38 +330,56 @@ module USwap = struct
309330 bswap_int64 (caml_bigstring_unsafe_get_64 bs off)
310331end
311332
312- let unsafe_set_int16_le, unsafe_set_int16_be =
313- if Sys. big_endian
314- then USwap. caml_bigstring_unsafe_set_16, caml_bigstring_unsafe_set_16
315- else caml_bigstring_unsafe_set_16 , USwap. caml_bigstring_unsafe_set_16
333+ let unsafe_set_int16_le b i x =
334+ if Sys. big_endian then USwap. caml_bigstring_unsafe_set_16 b i x
335+ else caml_bigstring_unsafe_set_16 b i x
336+
337+ let unsafe_set_int16_be b i x =
338+ if not Sys. big_endian then USwap. caml_bigstring_unsafe_set_16 b i x
339+ else caml_bigstring_unsafe_set_16 b i x
340+
341+ let unsafe_set_int32_le b i x =
342+ if Sys. big_endian then USwap. caml_bigstring_unsafe_set_32 b i x
343+ else caml_bigstring_unsafe_set_32 b i x
316344
317- let unsafe_set_int32_le, unsafe_set_int32_be =
318- if Sys. big_endian
319- then USwap. caml_bigstring_unsafe_set_32, caml_bigstring_unsafe_set_32
320- else caml_bigstring_unsafe_set_32 , USwap. caml_bigstring_unsafe_set_32
345+ let unsafe_set_int32_be b i x =
346+ if not Sys. big_endian then USwap. caml_bigstring_unsafe_set_32 b i x
347+ else caml_bigstring_unsafe_set_32 b i x
321348
322- let unsafe_set_int64_le, unsafe_set_int64_be =
323- if Sys. big_endian
324- then USwap. caml_bigstring_unsafe_set_64, caml_bigstring_unsafe_set_64
325- else caml_bigstring_unsafe_set_64 , USwap. caml_bigstring_unsafe_set_64
349+ let unsafe_set_int64_le b i x =
350+ if Sys. big_endian then USwap. caml_bigstring_unsafe_set_64 b i x
351+ else caml_bigstring_unsafe_set_64 b i x
326352
327- let unsafe_get_int16_le, unsafe_get_int16_be =
328- if Sys. big_endian
329- then USwap. caml_bigstring_unsafe_get_16, caml_bigstring_unsafe_get_16
330- else caml_bigstring_unsafe_get_16 , USwap. caml_bigstring_unsafe_get_16
353+ let unsafe_set_int64_be b i x =
354+ if not Sys. big_endian then USwap. caml_bigstring_unsafe_set_64 b i x
355+ else caml_bigstring_unsafe_set_64 b i x
356+
357+ let unsafe_get_int16_le b i =
358+ if Sys. big_endian then USwap. caml_bigstring_unsafe_get_16 b i
359+ else caml_bigstring_unsafe_get_16 b i
360+
361+ let unsafe_get_int16_be b i =
362+ if not Sys. big_endian then USwap. caml_bigstring_unsafe_get_16 b i
363+ else caml_bigstring_unsafe_get_16 b i
331364
332365let unsafe_get_int16_sign_extended_le x off =
333366 ((unsafe_get_int16_le x off) lsl (Sys. int_size - 16 )) asr (Sys. int_size - 16 )
334367
335368let unsafe_get_int16_sign_extended_be x off =
336369 ((unsafe_get_int16_be x off ) lsl (Sys. int_size - 16 )) asr (Sys. int_size - 16 )
337370
338- let unsafe_get_int32_le, unsafe_get_int32_be =
339- if Sys. big_endian
340- then USwap. caml_bigstring_unsafe_get_32, caml_bigstring_unsafe_get_32
341- else caml_bigstring_unsafe_get_32 , USwap. caml_bigstring_unsafe_get_32
371+ let unsafe_get_int32_le b i =
372+ if Sys. big_endian then USwap. caml_bigstring_unsafe_get_32 b i
373+ else caml_bigstring_unsafe_get_32 b i
374+
375+ let unsafe_get_int32_be b i =
376+ if not Sys. big_endian then USwap. caml_bigstring_unsafe_get_32 b i
377+ else caml_bigstring_unsafe_get_32 b i
378+
379+ let unsafe_get_int64_le b i =
380+ if Sys. big_endian then USwap. caml_bigstring_unsafe_get_64 b i
381+ else caml_bigstring_unsafe_get_64 b i
342382
343- let unsafe_get_int64_le, unsafe_get_int64_be =
344- if Sys. big_endian
345- then USwap. caml_bigstring_unsafe_get_64, caml_bigstring_unsafe_get_64
346- else caml_bigstring_unsafe_get_64 , USwap. caml_bigstring_unsafe_get_64
383+ let unsafe_get_int64_be b i =
384+ if not Sys. big_endian then USwap. caml_bigstring_unsafe_get_64 b i
385+ else caml_bigstring_unsafe_get_64 b i
0 commit comments