pkgsrc-Users archive

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

Re: Portable replacement for __WORDSIZE define?



On Fri, Dec 30, 2022 at 06:32:39PM +0100, Alexander Schreiber wrote:
> The __WORDSIZE issue shows up in libglusterfs/src/glusterfs/dict.h:
> 
>  322  /* POSIX-compliant systems requires the 'time_t' to be a signed integer. */
>  323  #if __WORDSIZE == 64
>  324  #define dict_get_time(dict, key, val) dict_get_int64((dict), (key), (val))
>  325  #define dict_set_time(dict, key, val) dict_set_int64((dict), (key), (val))
>  326  #elif __WORDSIZE == 32
>  327  #define dict_get_time(dict, key, val)                   \
>  328      dict_get_int32((dict), (key), ((int32_t *)(val)))
>  329  #define dict_set_time(dict, key, val)                   \
>  330      dict_set_int32((dict), (key), ((int32_t)(val)))
>  331  #else
>  332  #error "unknown word size"
>  333  #endif /* WORDSIZE check */

It looks like they're specifically trying to determine the type of
time_t here.  There's going to be no assurance that __WORDSIZE and
sizeof(time_t)*NBBY are identical everywhere though.

	Jonathan


Home | Main Index | Thread Index | Old Index