chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] C_SIZEOF_FLONUM not really correct


From: Daniel B. Faken
Subject: [Chicken-users] C_SIZEOF_FLONUM not really correct
Date: Thu, 28 Jul 2005 17:00:07 -0400 (EDT)

Hi,

  In chicken.h we find
#define C_SIZEOF_FLONUM           3

  But (whereas this may have been right in the past), in runtime.c:C_flonum():
#ifndef C_SIXTY_FOUR
  /* Align double on 8-byte boundary: */
  if(aligned8(p)) ++p;
#endif

..which is not included in the size of '3', and which means you'll 
allocate too few bytes with C_alloc() unless your flonums happen to always 
be aligned (or you're using a 64bit arch)...
  I discovered that one of my fns was taking 6 more slots than it should 
have, because, due to the size being 3, consecutive flonums are never 
8-byte aligned, and so always take up an extra byte..

  This may also be the answer to some of the ##sys#call-host/FFI 
problems I was having (I haven't done a comprehensive test yet).

  Now that I've changed my fn to use 6*(1+C_SIZEOF_FLONUM), I 
haven't had any more problems.

cheers,
Daniel






reply via email to

[Prev in Thread] Current Thread [Next in Thread]