[Pkg-ocaml-maint-commits] [SCM] libaio-ocaml packaging branch, upstream, updated. upstream/1.0-12-g7e515d4
Goswin von Brederlow
goswin-v-b at web.de
Wed Mar 21 16:29:18 UTC 2012
The following commit has been merged in the upstream branch:
commit e7dd48012d8bf5179baa408eefd7f594e681f90d
Author: Goswin von Brederlow <goswin-v-b at web.de>
Date: Wed Mar 21 17:21:24 2012 +0100
Imported Upstream version 1.0.1
diff --git a/examples/test.md5sum b/examples/test.md5sum
index db5f8ad..7f5ac43 100644
--- a/examples/test.md5sum
+++ b/examples/test.md5sum
@@ -1,2 +1,2 @@
-ec6c8217ef588bc3be41d82fe2a8027d testfile
+c1fc57167b5ca075c133dcd6f842e9da testfile
326f7113188b3aa074c496928c2f7214 test.out
diff --git a/examples/test.ml b/examples/test.ml
index 18aca1c..19ab7c3 100644
--- a/examples/test.ml
+++ b/examples/test.ml
@@ -1,12 +1,12 @@
let read_done result =
let buffer = Aio.result result in
- let i64 = Aio.Buffer.get_int64 buffer 0 in
- let i32 = Aio.Buffer.get_int32 buffer 8 in
- let i31 = Aio.Buffer.get_int31 buffer 12 in
- let i16 = Aio.Buffer.get_int16 buffer 16 in
- let u16 = Aio.Buffer.get_uint16 buffer 18 in
- let i8 = Aio.Buffer.get_int8 buffer 20 in
- let u8 = Aio.Buffer.get_uint8 buffer 21
+ let i64 = Aio.Buffer.get_net_int64 buffer 0 in
+ let i32 = Aio.Buffer.get_net_int32 buffer 8 in
+ let i31 = Aio.Buffer.get_net_int31 buffer 12 in
+ let i16 = Aio.Buffer.get_net_int16 buffer 16 in
+ let u16 = Aio.Buffer.get_net_uint16 buffer 18 in
+ let i8 = Aio.Buffer.get_net_int8 buffer 20 in
+ let u8 = Aio.Buffer.get_net_uint8 buffer 21
in
Printf.printf " int64 = %Lx\n" i64;
Printf.printf " int32 = %lx\n" i32;
@@ -35,13 +35,13 @@ let _ =
let ctx = Aio.context 32
in
Aio.Buffer.clear buffer;
- Aio.Buffer.set_int64 buffer 0 0x123456789abcdefL;
- Aio.Buffer.set_int32 buffer 8 0x12345678l;
- Aio.Buffer.set_int31 buffer 12 0x12345678;
- Aio.Buffer.set_int16 buffer 16 (-12345);
- Aio.Buffer.set_uint16 buffer 18 12345;
- Aio.Buffer.set_int8 buffer 20 (-23);
- Aio.Buffer.set_uint8 buffer 21 42;
+ Aio.Buffer.set_net_int64 buffer 0 0x123456789abcdefL;
+ Aio.Buffer.set_net_int32 buffer 8 0x12345678l;
+ Aio.Buffer.set_net_int31 buffer 12 0x12345678;
+ Aio.Buffer.set_net_int16 buffer 16 (-12345);
+ Aio.Buffer.set_net_uint16 buffer 18 12345;
+ Aio.Buffer.set_net_int8 buffer 20 (-23);
+ Aio.Buffer.set_net_uint8 buffer 21 42;
Printf.printf "writing\n";
flush_all ();
diff --git a/lib/aio.mli b/lib/aio.mli
index 2952381..e21c41a 100644
--- a/lib/aio.mli
+++ b/lib/aio.mli
@@ -100,6 +100,8 @@ module Buffer : sig
(** convert string to buffer *)
(* Big endian byte order *)
+ val get_be_int8 : t -> int -> int
+ val get_be_uint8 : t -> int -> int
val get_be_int16 : t -> int -> int
val get_be_uint16 : t -> int -> int
val get_be_int31 : t -> int -> int
@@ -107,6 +109,8 @@ module Buffer : sig
val get_be_int64 : t -> int -> int64
(** Access with alignment and range checking *)
+ val unsafe_get_be_int8 : t -> int -> int
+ val unsafe_get_be_uint8 : t -> int -> int
external unsafe_get_be_int16 : t -> int -> int = "caml_aio_buffer_get_be_int16" "noalloc"
external unsafe_get_be_uint16 : t -> int -> int = "caml_aio_buffer_get_be_uint16" "noalloc"
external unsafe_get_be_int31 : t -> int -> int = "caml_aio_buffer_get_be_int31" "noalloc"
@@ -114,6 +118,8 @@ module Buffer : sig
external unsafe_get_be_int64 : t -> int -> int64 = "caml_aio_buffer_get_be_int64"
(** Unsafe access without checks. *)
+ val set_be_int8 : t -> int -> int -> unit
+ val set_be_uint8 : t -> int -> int -> unit
val set_be_int16 : t -> int -> int -> unit
val set_be_uint16 : t -> int -> int -> unit
val set_be_int31 : t -> int -> int -> unit
@@ -121,6 +127,8 @@ module Buffer : sig
val set_be_int64 : t -> int -> int64 -> unit
(** Access with alignment and range checking *)
+ val unsafe_set_be_int8 : t -> int -> int -> unit
+ val unsafe_set_be_uint8 : t -> int -> int -> unit
external unsafe_set_be_int16 : t -> int -> int -> unit = "caml_aio_buffer_set_be_int16" "noalloc"
external unsafe_set_be_uint16 : t -> int -> int -> unit = "caml_aio_buffer_set_be_uint16" "noalloc"
external unsafe_set_be_int31 : t -> int -> int -> unit = "caml_aio_buffer_set_be_int31" "noalloc"
@@ -130,6 +138,8 @@ module Buffer : sig
(* Little endian byte order *)
+ val get_le_int8 : t -> int -> int
+ val get_le_uint8 : t -> int -> int
val get_le_int16 : t -> int -> int
val get_le_uint16 : t -> int -> int
val get_le_int31 : t -> int -> int
@@ -137,6 +147,8 @@ module Buffer : sig
val get_le_int64 : t -> int -> int64
(** Access with alignment and range checking *)
+ val unsafe_get_le_int8 : t -> int -> int
+ val unsafe_get_le_uint8 : t -> int -> int
external unsafe_get_le_int16 : t -> int -> int = "caml_aio_buffer_get_le_int16" "noalloc"
external unsafe_get_le_uint16 : t -> int -> int = "caml_aio_buffer_get_le_uint16" "noalloc"
external unsafe_get_le_int31 : t -> int -> int = "caml_aio_buffer_get_le_int31" "noalloc"
@@ -144,6 +156,8 @@ module Buffer : sig
external unsafe_get_le_int64 : t -> int -> int64 = "caml_aio_buffer_get_le_int64"
(** Unsafe access without checks. *)
+ val set_le_int8 : t -> int -> int -> unit
+ val set_le_uint8 : t -> int -> int -> unit
val set_le_int16 : t -> int -> int -> unit
val set_le_uint16 : t -> int -> int -> unit
val set_le_int31 : t -> int -> int -> unit
@@ -151,6 +165,8 @@ module Buffer : sig
val set_le_int64 : t -> int -> int64 -> unit
(** Access with alignment and range checking *)
+ val unsafe_set_le_int8 : t -> int -> int -> unit
+ val unsafe_set_le_uint8 : t -> int -> int -> unit
external unsafe_set_le_int16 : t -> int -> int -> unit = "caml_aio_buffer_set_le_int16" "noalloc"
external unsafe_set_le_uint16 : t -> int -> int -> unit = "caml_aio_buffer_set_le_uint16" "noalloc"
external unsafe_set_le_int31 : t -> int -> int -> unit = "caml_aio_buffer_set_le_int31" "noalloc"
@@ -159,6 +175,8 @@ module Buffer : sig
(** Unsafe access without checks. *)
(* Network byte order *)
+ val get_net_int8 : t -> int -> int
+ val get_net_uint8 : t -> int -> int
val get_net_int16 : t -> int -> int
val get_net_uint16 : t -> int -> int
val get_net_int31 : t -> int -> int
@@ -166,6 +184,8 @@ module Buffer : sig
val get_net_int64 : t -> int -> int64
(** Access with alignment and range checking *)
+ val unsafe_get_net_int8 : t -> int -> int
+ val unsafe_get_net_uint8 : t -> int -> int
val unsafe_get_net_int16 : t -> int -> int
val unsafe_get_net_uint16 : t -> int -> int
val unsafe_get_net_int31 : t -> int -> int
@@ -173,6 +193,8 @@ module Buffer : sig
val unsafe_get_net_int64 : t -> int -> int64
(** Unsafe access without checks. *)
+ val set_net_int8 : t -> int -> int -> unit
+ val set_net_uint8 : t -> int -> int -> unit
val set_net_int16 : t -> int -> int -> unit
val set_net_uint16 : t -> int -> int -> unit
val set_net_int31 : t -> int -> int -> unit
@@ -180,6 +202,8 @@ module Buffer : sig
val set_net_int64 : t -> int -> int64 -> unit
(** Access with alignment and range checking *)
+ val unsafe_set_net_int8 : t -> int -> int -> unit
+ val unsafe_set_net_uint8 : t -> int -> int -> unit
val unsafe_set_net_int16 : t -> int -> int -> unit
val unsafe_set_net_uint16 : t -> int -> int -> unit
val unsafe_set_net_int31 : t -> int -> int -> unit
diff --git a/lib/aio_buffer.ml b/lib/aio_buffer.ml
index 62194a6..1d0ab74 100644
--- a/lib/aio_buffer.ml
+++ b/lib/aio_buffer.ml
@@ -161,6 +161,10 @@ let set_str str =
(* Big endian byte order *)
+let unsafe_get_be_int8 = unsafe_get_int8
+let unsafe_set_be_int8 = unsafe_set_int8
+let unsafe_get_be_uint8 = unsafe_get_uint8
+let unsafe_set_be_uint8 = unsafe_set_uint8
external unsafe_get_be_int16 : t -> int -> int = "caml_aio_buffer_get_be_int16" "noalloc"
external unsafe_set_be_int16 : t -> int -> int -> unit = "caml_aio_buffer_set_be_int16" "noalloc"
external unsafe_get_be_uint16 : t -> int -> int = "caml_aio_buffer_get_be_uint16" "noalloc"
@@ -172,6 +176,11 @@ external unsafe_set_be_int32 : t -> int -> int32 -> unit = "caml_aio_buffer_set_
external unsafe_get_be_int64 : t -> int -> int64 = "caml_aio_buffer_get_be_int64"
external unsafe_set_be_int64 : t -> int -> int64 -> unit = "caml_aio_buffer_set_be_int64" "noalloc"
+let get_be_int8 = get_int8
+let set_be_int8 = set_int8
+let get_be_uint8 = get_uint8
+let set_be_uint8 = set_uint8
+
let get_be_int16 buf off =
check buf off 2;
unsafe_get_be_int16 buf off
@@ -214,6 +223,10 @@ let set_be_int64 buf off x =
(* Little endian byte order *)
+let unsafe_get_le_int8 = unsafe_get_int8
+let unsafe_set_le_int8 = unsafe_set_int8
+let unsafe_get_le_uint8 = unsafe_get_uint8
+let unsafe_set_le_uint8 = unsafe_set_uint8
external unsafe_get_le_int16 : t -> int -> int = "caml_aio_buffer_get_le_int16" "noalloc"
external unsafe_set_le_int16 : t -> int -> int -> unit = "caml_aio_buffer_set_le_int16" "noalloc"
external unsafe_get_le_uint16 : t -> int -> int = "caml_aio_buffer_get_le_uint16" "noalloc"
@@ -225,6 +238,11 @@ external unsafe_set_le_int32 : t -> int -> int32 -> unit = "caml_aio_buffer_set_
external unsafe_get_le_int64 : t -> int -> int64 = "caml_aio_buffer_get_le_int64"
external unsafe_set_le_int64 : t -> int -> int64 -> unit = "caml_aio_buffer_set_le_int64" "noalloc"
+let get_le_int8 = get_int8
+let set_le_int8 = set_int8
+let get_le_uint8 = get_uint8
+let set_le_uint8 = set_uint8
+
let get_le_int16 buf off =
check buf off 2;
unsafe_get_le_int16 buf off
@@ -267,6 +285,10 @@ let set_le_int64 buf off x =
(* Network byte order is big endian *)
+let unsafe_get_net_int8 = unsafe_get_int8
+let unsafe_set_net_int8 = unsafe_set_int8
+let unsafe_get_net_uint8 = unsafe_get_uint8
+let unsafe_set_net_uint8 = unsafe_set_uint8
let unsafe_get_net_int16 = unsafe_get_be_int16
let unsafe_set_net_int16 = unsafe_set_be_int16
let unsafe_get_net_uint16 = unsafe_get_be_uint16
@@ -277,6 +299,10 @@ let unsafe_get_net_int32 = unsafe_get_be_int32
let unsafe_set_net_int32 = unsafe_set_be_int32
let unsafe_get_net_int64 = unsafe_get_be_int64
let unsafe_set_net_int64 = unsafe_set_be_int64
+let get_net_int8 = get_int8
+let set_net_int8 = set_int8
+let get_net_uint8 = get_uint8
+let set_net_uint8 = set_uint8
let get_net_int16 = get_be_int16
let set_net_int16 = set_be_int16
let get_net_uint16 = get_be_uint16
diff --git a/lib/aio_buffer_stubs.c b/lib/aio_buffer_stubs.c
index 52ad4c2..30caf65 100644
--- a/lib/aio_buffer_stubs.c
+++ b/lib/aio_buffer_stubs.c
@@ -175,7 +175,7 @@ value caml_aio_buf_unsafe_set_substr_stub(value ml_buf, value ml_off, value ml_s
value caml_aio_buffer_get_be_int16(value ml_buf, value ml_off) {
int16_t *buf = (int16_t*)Data_bigarray_val(ml_buf);
size_t off = Int_val(ml_off);
- return Val_int(be16toh(buf[off / 2]));
+ return Val_int((int16_t)be16toh(buf[off / 2]));
}
value caml_aio_buffer_set_be_int16(value ml_buf, value ml_off, value ml_x) {
@@ -203,7 +203,7 @@ value caml_aio_buffer_set_be_uint16(value ml_buf, value ml_off, value ml_x) {
value caml_aio_buffer_get_be_int31(value ml_buf, value ml_off) {
int32_t *buf = (int32_t*)Data_bigarray_val(ml_buf);
size_t off = Int_val(ml_off);
- return Val_int(be32toh(buf[off / 4]));
+ return Val_int((int32_t)be32toh(buf[off / 4]));
}
value caml_aio_buffer_set_be_int31(value ml_buf, value ml_off, value ml_x) {
@@ -219,7 +219,7 @@ CAMLprim value caml_aio_buffer_get_be_int32(value ml_buf, value ml_off) {
CAMLlocal1(ml_res);
int32_t *buf = (int32_t*)Data_bigarray_val(ml_buf);
size_t off = Int_val(ml_off);
- CAMLreturn(caml_copy_int32(be32toh(buf[off / 4])));
+ CAMLreturn(caml_copy_int32((int32_t)be32toh(buf[off / 4])));
}
value caml_aio_buffer_set_be_int32(value ml_buf, value ml_off, value ml_x) {
@@ -235,7 +235,7 @@ CAMLprim value caml_aio_buffer_get_be_int64(value ml_buf, value ml_off) {
CAMLlocal1(ml_res);
int64_t *buf = (int64_t*)Data_bigarray_val(ml_buf);
size_t off = Int_val(ml_off);
- CAMLreturn(caml_copy_int64(be64toh(buf[off / 8])));
+ CAMLreturn(caml_copy_int64((int64_t)be64toh(buf[off / 8])));
}
#include <stdio.h>
value caml_aio_buffer_set_be_int64(value ml_buf, value ml_off, value ml_x) {
@@ -251,7 +251,7 @@ value caml_aio_buffer_set_be_int64(value ml_buf, value ml_off, value ml_x) {
value caml_aio_buffer_get_le_int16(value ml_buf, value ml_off) {
int16_t *buf = (int16_t*)Data_bigarray_val(ml_buf);
size_t off = Int_val(ml_off);
- return Val_int(le16toh(buf[off / 2]));
+ return Val_int((int16_t)le16toh(buf[off / 2]));
}
value caml_aio_buffer_set_le_int16(value ml_buf, value ml_off, value ml_x) {
@@ -279,7 +279,7 @@ value caml_aio_buffer_set_le_uint16(value ml_buf, value ml_off, value ml_x) {
value caml_aio_buffer_get_le_int31(value ml_buf, value ml_off) {
int32_t *buf = (int32_t*)Data_bigarray_val(ml_buf);
size_t off = Int_val(ml_off);
- return Val_int(le32toh(buf[off / 4]));
+ return Val_int((int32_t)le32toh(buf[off / 4]));
}
value caml_aio_buffer_set_le_int31(value ml_buf, value ml_off, value ml_x) {
@@ -295,7 +295,7 @@ CAMLprim value caml_aio_buffer_get_le_int32(value ml_buf, value ml_off) {
CAMLlocal1(ml_res);
int32_t *buf = (int32_t*)Data_bigarray_val(ml_buf);
size_t off = Int_val(ml_off);
- CAMLreturn(caml_copy_int32(le32toh(buf[off / 4])));
+ CAMLreturn(caml_copy_int32((int32_t)le32toh(buf[off / 4])));
}
value caml_aio_buffer_set_le_int32(value ml_buf, value ml_off, value ml_x) {
@@ -311,7 +311,7 @@ CAMLprim value caml_aio_buffer_get_le_int64(value ml_buf, value ml_off) {
CAMLlocal1(ml_res);
int64_t *buf = (int64_t*)Data_bigarray_val(ml_buf);
size_t off = Int_val(ml_off);
- CAMLreturn(caml_copy_int64(le64toh(buf[off / 8])));
+ CAMLreturn(caml_copy_int64((int64_t)le64toh(buf[off / 8])));
}
#include <stdio.h>
value caml_aio_buffer_set_le_int64(value ml_buf, value ml_off, value ml_x) {
--
libaio-ocaml packaging
More information about the Pkg-ocaml-maint-commits
mailing list