This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3] Merge parts of <sys/time.h> from FreeBSD


On 03/20/2015 04:34 AM, Sebastian Huber wrote:

>> I try currently to figure out, why this is not a problem on FreeBSD.
> 
> On FreeBSD the <sys/types.h> defines the following types:
> 
> int8_t
> int16_t
> int32_t
> int64_t
> uint8_t
> uint16_t
> uint32_t
> uint64_t
> intptr_t
> uintptr_t
> 
> These types are defined in <sys/_stdint.h> on FreeBSD.
> 
> On glibc only the following types are available via <sys/types.h>:
> 
> int8_t
> int16_t
> int32_t
> int64_t
> 

POSIX does not require ANY of these types to be defined in
<sys/types.h>; Portable code MUST use #include <stdint.h> [or the
superset <inttypes.h>] to guarantee that they exist.
 http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html#tag_13_67
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html#tag_13_48

That said, POSIX also does not forbid these types from being
additionally defined in <sys/types.h>
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_02
reserves the entire *_t namespace for all headers, which means ANY
header, including sys/types.h, can declare uint8_t without polluting the
namespace).

> I would like to use the FreeBSD approach also for Newlib. Any objections?

Personally, I think that forcing users to include <stdint.h> makes their
code more portable, but practically, I can live with making life easier
for people who don't pay attention to standards when there is no
namespace pollution issue at hand.  Therefore, no objections from me.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]