Bug 186247 - <machine/_types.h> defines int64_t/uint64_t incorrectly
Summary: <machine/_types.h> defines int64_t/uint64_t incorrectly
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-29 17:20 UTC by Ivan Kosarev
Modified: 2014-06-09 15:39 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Kosarev 2014-01-29 17:20:00 UTC
The file:

/usr/include/machine/_types.h

reads:

typedef long __int64_t;
typedef unsigned long __uint64_t;

This causes types int64_t and uint64_t be of width 32 when being compiled in the 32-bit mode.

Fix: 

These definitions:

typedef long __int64_t;
typedef unsigned long __uint64_t;

should be replaced with something like:

#if defined(__LP64__)
typedef long __int64_t;
typedef unsigned long __uint64_t;
#else
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
#endif
How-To-Repeat: $ cat x.c
#include <stdio.h>
#include <stdint.h>

int main(void)
{
    printf("%d\n", sizeof(uint64_t));
    return 0;
}
$ gcc -m32 -B/usr/lib32 x.c
$ ./a.out
4
Comment 1 Ed Maste freebsd_committer freebsd_triage 2014-02-21 19:25:11 UTC
State Changed
From-To: open->patched

amd64 and i386 _types.h merged into x86/_types.h in r232261 
http://svnweb.freebsd.org/base?view=revision&revision=232261
Comment 2 Ed Maste freebsd_committer freebsd_triage 2014-06-09 15:39:35 UTC
Merged to stable/9: http://svnweb.freebsd.org/changeset/base/263505
Will be in FreeBSD 9.3