~ubuntu-branches/ubuntu/trusty/ocamlnet/trusty

« back to all changes in this revision

Viewing changes to src/netsys/mem.ml

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu
  • Date: 2011-09-02 14:12:33 UTC
  • mfrom: (18.2.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110902141233-zbj0ygxb92u6gy4z
Tags: 3.4-1
* New upstream release
  - add a new NetcgiRequire directive to ease dependency management
    (Closes: #637147)
  - remove patches that were applied upstream:
    + Added-missing-shebang-lines-in-example-shell-scripts
    + Try-also-ocamlc-for-POSIX-threads

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(* Testing *)
 
2
 
 
3
#use "topfind";;
 
4
#require "netsys";;
 
5
open Netsys_mem;;
 
6
open Printf;;
 
7
let m = alloc_memory_pages 1;;
 
8
let () = value_area m;;
 
9
let ba = Bigarray.Array1.create Bigarray.int Bigarray.c_layout 5;; 
 
10
 
 
11
for k = 0 to 4 do
 
12
  ba.{ k } <- 4 + k
 
13
done;;
 
14
 
 
15
let dump (m : Netsys_mem.memory) =
 
16
  let n = Bigarray.Array1.dim m in
 
17
  let w = n/8 in
 
18
  for k = 0 to w-1 do
 
19
    let v = ref 0L in
 
20
    for j = 7 downto 0 do
 
21
      let c = m.{ 8*k+j } in
 
22
      v := Int64.logor (Int64.shift_left !v 8) (Int64.of_int (Char.code c))
 
23
    done;
 
24
    printf "%d: %016Lx\n" k !v
 
25
  done
 
26
;;