Re: pointer -> integer function
Kostirya <[email protected]> Wed, 28 Sep 2016 17:53:11 +0300
| Newsgroups | gmane.comp.lang.ml.mlton.user |
|---|---|
| Message-ID | <CAG+QnTc=dA-y27r7PJ+-dn+1B7ROgftD7L3WEx5rAvccy29osA@mail.gmail.com> |
Thank you! 2016-09-28 17:28 GMT+03:00 Matthew Fluet <[email protected]>: > You can use the stable, but undocumented, `c-types.mlb` library > (https://github.com/MLton/mlton/blob/master/basis-library/c-types.mlb), > which provides a collection of structures that correspond to > target-dependent C types: > > mtf@uller tmp]$ cat z.mlb > $(SML_LIB)/basis/basis.mlb > $(SML_LIB)/basis/mlton.mlb > $(SML_LIB)/basis/c-types.mlb > z.sml > > [mtf@uller tmp]$ cat z.sml > fun ptrToInt (p: MLton.Pointer.t) : LargeInt.int = > C_Size.toLargeInt (C_Pointer.toWord p) > > Of course, for your application, you might simply use the operations > of `structure C_Size : WORD`. > > On Wed, Sep 28, 2016 at 9:20 AM, Kostirya <[email protected]> wrote: > > Hello.I need help again... > > > > I want to get integer from pointer. > > I use (Word.toLargeInt o Primitive.MLton.Pointer.toWord) for 32bit > > I use (Word64.toLargeInt o Primitive.MLton.Pointer.toWord) for 64bit > > > > There are difficulties due to the fact that type function depends on > 32bit > > or 64bit. > > > > How to write universal function? > > > > Like this: > > > > val p2i = > > if sizeofPointer = 0w8 > > then Word64.toLargeInt o Primitive.MLton.Pointer.toWord > > else Word.toLargeInt o Primitive.MLton.Pointer.toWord > > > > > > Nick. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "MLton-user" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to [email protected]. > > > > ------------------------------------------------------------ > ------------------ > > > > _______________________________________________ > > MLton-user mailing list > > [email protected]; [email protected] > > https://lists.sourceforge.net/lists/listinfo/mlton-user > > > > -- > You received this message because you are subscribed to the Google Groups > "MLton-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > > > ------------------------------------------------------------ > ------------------ > _______________________________________________ > MLton-user mailing list > [email protected]; [email protected] > https://lists.sourceforge.net/lists/listinfo/mlton-user > -- You received this message because you are subscribed to the Google Groups "MLton-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. ------------------------------------------------------------------------------ _______________________________________________ MLton-user mailing list [email protected]; [email protected] https://lists.sourceforge.net/lists/listinfo/mlton-user