Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/ml-nlffi-lib/internals/c-int.sml
ViewVC logotype

Diff of /sml/trunk/src/ml-nlffi-lib/internals/c-int.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1014, Tue Jan 15 16:32:43 2002 UTC revision 1015, Tue Jan 15 21:46:00 2002 UTC
# Line 11  Line 11 
11   * renaming it because they result in saner printing behavior. *)   * renaming it because they result in saner printing behavior. *)
12  structure C :> C_INT = struct  structure C :> C_INT = struct
13    
14        exception OutOfMemory = CMemory.OutOfMemory
15    
16      fun bug m = raise Fail ("impossible: " ^ m)      fun bug m = raise Fail ("impossible: " ^ m)
17    
18      type addr = CMemory.addr      type addr = CMemory.addr
# Line 440  Line 442 
442      end      end
443    
444      fun new' s = CMemory.alloc s      fun new' s = CMemory.alloc s
445      fun new t = Option.map (fn a => (a, t)) (new' (T.sizeof t))      fun new t = (new' (T.sizeof t), t)
446    
447      val discard' = CMemory.free      val discard' = CMemory.free
448      fun discard x = discard' (p_strip_type x)      fun discard x = discard' (p_strip_type x)
449    
450      fun alloc' s i = CMemory.alloc (s * i)      fun alloc' s i = CMemory.alloc (s * i)
451      fun alloc t i = Option.map (fn p => (p, t)) (alloc' (T.sizeof t) i)      fun alloc t i = (alloc' (T.sizeof t) i, t)
452    
453      val free' = CMemory.free      val free' = CMemory.free
454      fun free x = free' (p_strip_type x)      fun free x = free' (p_strip_type x)
# Line 456  Line 458 
458      fun call' (FPTR mkf) (a, x) = Unsafe.cast mkf a x      fun call' (FPTR mkf) (a, x) = Unsafe.cast mkf a x
459        | call' _ _ = bug "call' (non-function-pointer-type)"        | call' _ _ = bug "call' (non-function-pointer-type)"
460    
461        structure U = struct
462            fun fcast (f : 'a fptr') : 'b fptr' = f
463            fun p2i (a : voidptr) : ulong = CMemory.p2i a
464            fun i2p (a : ulong) : voidptr = CMemory.i2p a
465        end
466    
467      (* ------------- internal stuff ------------- *)      (* ------------- internal stuff ------------- *)
468    
469      fun mk_obj (t: objt, a: addr) = (a, t)      fun mk_obj (t: objt, a: addr) = (a, t)

Legend:
Removed from v.1014  
changed lines
  Added in v.1015

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0