From nobody@FreeBSD.org  Mon Jun 18 00:39:31 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 47B5F1065670
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2012 00:39:31 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 336F68FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2012 00:39:31 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q5I0dU29022003
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2012 00:39:30 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q5I0dUY7022002;
	Mon, 18 Jun 2012 00:39:30 GMT
	(envelope-from nobody)
Message-Id: <201206180039.q5I0dUY7022002@red.freebsd.org>
Date: Mon, 18 Jun 2012 00:39:30 GMT
From: Eric McCorkle <eric@shadowsun.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Bad sizeof(uint64_t) with -m32 compiler flag
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169187
>Category:       kern
>Synopsis:       Bad sizeof(uint64_t) with -m32 compiler flag
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 18 00:40:11 UTC 2012
>Closed-Date:    
>Last-Modified:  Mon Jun 18 15:48:49 UTC 2012
>Originator:     Eric McCorkle
>Release:        9.0, also appears on 10.0
>Organization:
>Environment:
FreeBSD atom-edge 9.0-STABLE FreeBSD 9.0-STABLE #118 r236960M: Wed Jun 13 08:44:31 EDT 2012    root@atom-edge:/usr/obj/usr/src/sys/CUSTOM  amd64
>Description:
When compiling programs on an amd64 machine with the -m32 compiler flag, uint64_t variables are incorrectly sized, resulting in sizeof(uint64_t) == 4.  Presumably this affects int64_t as well, and any types that are typedef'ed to one of these.
>How-To-Repeat:
Compile the following program:

#include <stdio.h>
#include <stdlib.h>

int main() { printf("%d\n", sizeof(uint64_t)); return 0; }

with the following command:

gcc -m32 -o test test.c

The output will be "4" as opposed to "8" like it should be.
>Fix:
The file <machine/_types.h> defines __uint64_t as unsigned long on amd64 platforms.  When compiling with -m32, however, the compiler makes unsigned long a 32-bit integer, which seems to be the root of the problem.

A simple fix is to detect when sizeof(unsigned long) == 4, and define __uint64_t as unsigned long long instead.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->freebsd-bugs 
Responsible-Changed-By: remko 
Responsible-Changed-When: Mon Jun 18 12:07:34 UTC 2012 
Responsible-Changed-Why:  
This is not i386 specific. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169187 
>Unformatted:
