patacongo commented on issue #740:
URL: https://github.com/apache/incubator-nuttx/issues/740#issuecomment-672929712


   >  but can we assume that `sizeof(FAR void *)` is always equals to 
`sizeof(uintptr_t)` and `>= sizeof(uint32_t)`?
   
   No. that is a false assumption.  sizeof(uintptr) can be less than 
sizeof(uint32_t)..  On most 8-bit machines, sizeof(uintptr_t) is or should be 2 
bytes.  On ez80 it is either 2 or 3 bytes depending on mode.  For ez80, you can 
see:
   
   In include/stdint.h:
   
       /* Integer types capable of holding object pointers
        * As a general rule, the size of size_t should be the same as the size 
of
        * uintptr_t: 32-bits on a machine with 32-bit addressing but 64-bits on 
a
        * machine with 64-bit addressing.
        */
       
       typedef _ssize_t            intptr_t;
       typedef _size_t             uintptr_t;
   
   And in arch/z80/include/ez80/types.h:
   
       /* These are the sizes of the standard integer types.  NOTE that these 
type
        * names have a leading underscore character.  This file will be included
        * (indirectly) by include/stdint.h and typedef'ed to the final name 
without
        * the underscore character.  This roundabout way of doings things allows
        * the stdint.h to be removed from the include/ directory in the event 
that
        * the user prefers to use the definitions provided by their toolchain 
header
        * files
        *
        * These are the sizes of the types supported by the ZiLOG compiler:
        *
        *   int    - 24-bits
        *   short  - 16-bits
        *   long   - 32-bits
        *   char   - 8-bits
        *   float  - 32-bits
        */
       ...
       /* A pointer is 2 or 3 bytes, depending upon if the ez80 is in z80
        * compatibility mode or not
        *
        *   Z80 mode - 16 bits
        *   ADL mode - 24 bits
        */
       ...
       #elif defined(CONFIG_EZ80_Z80MODE)
       typedef signed short       _ssize_t;
       typedef unsigned short     _size_t;
      #else
       typedef signed int         _ssize_t;
      typedef unsigned int       _size_t;
      #endif
   
   For AVR, the size of a pointer is different on the I-space bus and on the 
D-space bus.  As I recall, sizeof(FAR void *) is usualy 16-bits but might be as 
much as 24-bits).
   
   In fact sizeof(uinptr_t) < sizeof(uint32_t) is very common among the support 
architecures.  You must not use FAR void * as a container for arbitrary values. 
 You will break MANY architectures and we cannot permit you to do that.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to