pkgsrc-Users archive

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

Re: How to patch for: #include <bits/wordsize.h>





On 9/13/25 11:13 PM, Mansour Moufid wrote:

On Sep 13, 2025, at 13:16, Mayuresh <mayuresh%acm.org@localhost> wrote:

On Sat, Sep 13, 2025 at 10:45:52AM -0500, Jonathan A. Kollasch wrote:
For a better answer we'd need to see what's in the #if and any #else.

It chooses between read_uint32 vs read_uint64 ( and write_uint32 vs
write_uint64 ).

wordsize.h is part of glibc, it defines the macro __WORDSIZE to either 32 or 64.

https://fossies.org/linux/glibc/sysdeps/x86/bits/wordsize.h

It's usually safe to do this (with the exception of x32 (ILP32) and maybe others):

     #if defined(__GLIBC__)
     #include <bits/wordsize.h>
     #endif
     #if !defined(__WORDSIZE)
     #define __WORDSIZE (sizeof (void *) * 8)
     #endif

From the usage in glibc itself, the easiest option would be to compare LONG_MAX to 2147483647 to use if __WORDSIZE is 32.

Joerg


Home | Main Index | Thread Index | Old Index