FYI.

If anyone wants to provide a uintptr_t-equivalent for parrot, i'll happily 
switch this to use it.

--Josh

------- Forwarded Message

Date:    09 Jun 2002 16:44:35 -0000
From:    [EMAIL PROTECTED]
To:      [EMAIL PROTECTED]
Subject: cvs commit: parrot/include/parrot parrot.h

cvsuser     02/06/09 09:44:35

  Modified:    include/parrot parrot.h
  Log:
  Revisiting the problem we saw before, where tcc won't permit casting between
  function and data pointers.  (this is technically undefined by ANSI C).
  
  However, it is possible to cast between them by first casting to an integer
  of sufficient size.  Defined two macros for converting values betwen
  function and data pointers and inserted them in the right places.
  
  This gets things to build with tcc, and makes us more ANSI-correct.  We
  might be able to remove the check for this in Configure.pl if everything
  uses these macros.  (Though if JIT ever works on tcc, i will be impressed)
  
  Revision  Changes    Path
  1.38      +14 -1     parrot/include/parrot/parrot.h
  
  Index: parrot.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/parrot.h,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -w -r1.37 -r1.38
  --- parrot.h  8 Jun 2002 21:53:20 -0000       1.37
  +++ parrot.h  9 Jun 2002 16:44:35 -0000       1.38
  @@ -1,7 +1,7 @@
   /* parrot.h
    *  Copyright: (When this is determined...it will go here)
    *  CVS Info
  - *     $Id: parrot.h,v 1.37 2002/06/08 21:53:20 grunblatt Exp $
  + *     $Id: parrot.h,v 1.38 2002/06/09 16:44:35 josh Exp $
    *  Overview:
    *     General header file includes for the parrot interpreter
    *  Data Structure and Algorithms:
  @@ -103,6 +103,19 @@
    * function pointers and NULLfunc in place of NULL */
   typedef void (*funcptr_t)(void);
   #define NULLfunc (funcptr_t)0
  +
  +/* define macros for converting between data and function pointers.  As it
  + * turns out, ANSI C does appear to permit you to do this conversion if you
  + * convert the value to an integer (well, a value type large enough to hold
  + * a pointer) in between.  Believe it or not, this even works on TenDRA (tcc
).
  + * 
  + * NOTE!  UINTVAL is incorrect below.  It should be UINTPTR or something lik
e
  + * that. The equivalent of C99's uintptr_t- a non-pointer data type that can
 
  + * hold a pointer.
  + */
  +#define D2FPTR(x) (funcptr_t)(UINTVAL) x
  +#define F2DPTR(x) (void*)(UINTVAL)(funcptr_t) x
  +
   
   /* Provide support for inline keyword where available.  Just make sure to us
e
    * "INLINE" instead and it will DTRT. */
  
  
  

------- End of Forwarded Message



Reply via email to