[PATCH v3] Merge parts of <sys/time.h> from FreeBSD
Eric Blake
eblake@redhat.com
Fri Mar 20 20:12:00 GMT 2015
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20150320/5ed00068/attachment.sig>
More information about the Newlib
mailing list