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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 836 - (view) (download) (as text)

1 : blume 828 (*
2 :     * A "private" extension to the encoding of C types in SML.
3 :     * The routines here are for use by code that will be automatically
4 :     * generated from corresponding C files. User code is not supposed
5 :     * to access them because they are unsafe. (As if subverting the C
6 :     * type system were such a big deal...)
7 :     *
8 :     * (C) 2001, Lucent Technologies, Bell Laboratories
9 :     *
10 :     * author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
11 :     *)
12 :     signature C_INT = sig
13 :    
14 :     include C
15 :    
16 :     type addr = CMemory.addr
17 :    
18 :     (* make struct or union size from its size given as a word;
19 :     * needs explicit type constraint *)
20 :     val mk_su_size : word -> 's S.size
21 :    
22 :     (* make struct or union RTI given its corresponding size *)
23 :     val mk_su_typ : 's su S.size -> 's T.su_typ
24 :    
25 :     (* make function pointer type give the ML function that
26 :     * implements the calling protocol *)
27 :     val mk_fptr_typ : (addr -> 'a -> 'b) -> ('a -> 'b) T.fptr_typ
28 :    
29 :     (* mk_obj makes writable objects; if they are declared const, then
30 :     * function ro should be applied *)
31 :     val mk_obj : ('t, 'f) T.typ -> addr -> ('t, 'f, rw) obj
32 :    
33 :     (* make a void* from an address *)
34 :     val mk_voidptr : addr -> voidptr
35 :    
36 :     (* given its type, make a function pointer from an address *)
37 :     val mk_fptr : 'f T.fptr_typ -> addr -> 'f fptr
38 :    
39 :     (* making normal and const-declared struct- or union-fields
40 :     * given the field's type and its offset *)
41 :     val mk_rw_field : ('m, 'f) T.typ -> int ->
42 :     ('s, 'c) su_obj -> ('m, 'f, 'c) obj
43 :     val mk_ro_field : ('m, 'f) T.typ -> int ->
44 :     ('s, 'c) su_obj -> ('m, 'f, ro) obj
45 :    
46 :     (* light version *)
47 :     (* NOTE: We do not pass RTI to the light version (which would
48 :     * internally throw it away anyway). This means that we
49 :     * will need an explicit type constraint. *)
50 :     val mk_field' : int -> ('s, 'ac) su_obj' -> ('m, 'f, 'rc) obj'
51 :    
52 :     (* making normal signed bitfields *)
53 :     val mk_rw_sbf : int * word * word -> (* offset * bits * shift *)
54 :     ('s, 'c) su_obj -> 'c sbf
55 :     val mk_ro_sbf : int * word * word -> (* offset * bits * shift *)
56 :     ('s, 'c) su_obj -> ro sbf
57 :    
58 :     (* light versions *)
59 :     val mk_rw_sbf' : int * word * word -> (* offset * bits * shift *)
60 :     ('s, 'c) su_obj' -> 'c sbf
61 :     val mk_ro_sbf' : int * word * word -> (* offset * bits * shift *)
62 :     ('s, 'c) su_obj' -> ro sbf
63 :    
64 :     (* making normal unsigned bitfields *)
65 :     val mk_rw_ubf : int * word * word -> (* offset * bits * shift *)
66 :     ('s, 'c) su_obj -> 'c ubf
67 :     val mk_ro_ubf : int * word * word -> (* offset * bits * shift *)
68 :     ('s, 'c) su_obj -> ro ubf
69 :    
70 :     (* light versions *)
71 :     val mk_rw_ubf' : int * word * word -> (* offset * bits * shift *)
72 :     ('s, 'c) su_obj' -> 'c ubf
73 :     val mk_ro_ubf' : int * word * word -> (* offset * bits * shift *)
74 :     ('s, 'c) su_obj' -> ro ubf
75 :    
76 :     (* reveal address behind void*; this is used to
77 :     * implement the function-call protocol for functions that have
78 :     * pointer arguments *)
79 :     val reveal : voidptr -> addr
80 :     val freveal : 'f fptr' -> addr
81 :    
82 :     val vcast : addr -> voidptr
83 :     val pcast : addr -> ('t, 'f, 'c) ptr'
84 :     val fcast : addr -> 'f fptr'
85 :    
86 :     (* unsafe low-level array subscript that does not require RTI *)
87 :     val unsafe_sub : int -> (* element size *)
88 : blume 836 (('t, 'n) arr, 'f, 'c) obj' * int ->
89 : blume 828 ('t, 'f, 'n) obj'
90 :     end

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