[CCC DEV] convert.module and friends question

Matt Jadud jadudm at gmail.com
Mon Jun 28 22:55:02 BST 2010


On Mon, Jun 28, 2010 at 2:23 PM, Matt Jadud <jadudm at gmail.com> wrote:
> I've poked a bit at this approach, but am not yet certain how best to
> ascertain how the REAL32 crosses the occam/C barrier.

In case Adam or anyone else can see what I'm missing:

---
occam-side:
---
#PRAGMA EXTERNAL "PROC C.tvmspecial.1.sprintf (VAL INT16 a, b) = 0"
INLINE PROC sprintf (VAL INT16 a, b)
  C.tvmspecial.1.sprintf (a, b)
:


PROC main ()
  REAL32 pi:
  SEQ
    pi := 3.1419
    VAL [2]INT16 pass.me RETYPES pi:
    sprintf(pass.me[0], pass.me[1])
:

---
C-side:
---
int ffi_sprintf (ECTX ectx, WORD args[]) {
  // int is a 16-bit type
  // long int is a 32-bit type
  int lo = (int) args[0];
  int hi = (int) args[1];

  long int nlo = lo;
  long int nhi = hi;
  float n;
  n = (float) (nlo & (nhi << 16));

  printf("size [%d] lo[%d], hi[%d], n [%f] \n", sizeof(float), lo, hi, n);

  return SFFI_OK;
}




More information about the developers mailing list