[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to print size_t in LGPLv2+ program
From: |
Eric Blake |
Subject: |
Re: how to print size_t in LGPLv2+ program |
Date: |
Tue, 17 Aug 2010 17:48:04 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.3 Thunderbird/3.1.1 |
On 08/17/2010 05:37 PM, Eric Blake wrote:
> On 08/17/2010 05:35 PM, Bruno Haible wrote:
>>>> What a shame that POSIX omitted an <inttypes.h> PRIu* for size_t.
>>>
>>> You can define it by yourself ...
>>
>> Or use uintptr_t instead of size_t. By the definition of these types,
>> you can be sure that uintptr_t is at least as wide as size_t.
Actually, you aren't even guaranteed that; uintptr_t is optional on
non-XSI systems. But you are correct that uintptr_t is the size of
void*, size_t is the maximum size of an object, and an object must
necessarily fit within a pointer; therefore sizeof(size_t) <=
sizeof(uintptr_t). The <= is important - it is possible to have a
system with 32-bit size_t and 64-bit void* (or, in older days, a 16-bit
size_t and 32-bit void *). In fact, people are already experimenting
with that alternate ABI on x86_64 architectures, with demonstrations of
the speedups possible when object sizes are constrained to 4G while
still allowing more than 4G of memory accessible to a single process.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: detecting uses of "%zu", (continued)
Re: how to print size_t in LGPLv2+ program, Paul Eggert, 2010/08/17
Re: how to print size_t in LGPLv2+ program, Bruno Haible, 2010/08/17
Re: how to print size_t in LGPLv2+ program, Eric Blake, 2010/08/17
Re: how to print size_t in LGPLv2+ program, Bruno Haible, 2010/08/17
Message not available
Message not available
Re: how to print size_t in LGPLv2+ program, Paolo Bonzini, 2010/08/23