linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* bug in asm-ppc/div64.h
@ 2003-03-11 11:03 Bastien Nocera
  2003-03-11 11:04 ` Paul Mackerras
  0 siblings, 1 reply; 4+ messages in thread
From: Bastien Nocera @ 2003-03-11 11:03 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 706 bytes --]

Hello,

While chasing a date bug in smbfs with Urban Widmark, it so happened
that we stumbled across a bug in do_div on PPC 32bit, ie. it doesn't
work.

I attached a test case, provided by Urban. do_div is used in quite a few
places like vsprintf, the matrox fb code, etc.

When running on x86:
now: 1047238073
adjusted: 24edd64059e100
/ 10000000: 3df4e80a
1039460362

Check the run on PPC. It's wrong by quite a scale.

Any ideas on how to solve this properly ?

Cheers

--
/Bastien Nocera
http://www.redhat.com

Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away.
                                                Antoine de Saint-Exupery

[-- Attachment #2: smbfs-time.c --]
[-- Type: text/x-c, Size: 550 bytes --]

#include <stdio.h>
#include <time.h>
#include <asm/types.h>
#include <asm/div64.h>

typedef  __u64 u64;

#define NTFS_TIME_OFFSET ((u64)(369*365 + 89) * 24 * 3600 * 10000000)

static time_t
smb_ntutc2unixutc(u64 ntutc)
{
	u64 t = ntutc - NTFS_TIME_OFFSET;
	printf("adjusted: %Lx\n", t);

	do_div(t, 10000000);
	printf("/ 10000000: %Lx\n", t);

	return (time_t)t;
}

int main()
{
    time_t t;

    t = time(NULL);
    printf("now: %ld\n", t);

    t = smb_ntutc2unixutc(0x01c29fb515986100LL);
    printf("%ld\n", t);
}

^ permalink raw reply	[flat|nested] 4+ messages in thread
* bug in asm-ppc/div64.h
@ 2003-03-11 11:05 Bastien Nocera
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien Nocera @ 2003-03-11 11:05 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 885 bytes --]

Hello,

While chasing a date bug in smbfs with Urban Widmark, it so happened
that we stumbled across a bug in do_div on PPC 32bit, ie. it doesn't
work.

I attached a test case, provided by Urban. do_div is used in quite a few
places like vsprintf, the matrox fb code, etc.

When running on x86:
now: 1047238073
adjusted: 24edd64059e100
/ 10000000: 3df4e80a
1039460362

Check the run on PPC. It's wrong by quite a scale.

Any ideas on how to solve this properly ?

Cheers

--
/Bastien Nocera
http://www.redhat.com

Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away.
                                                Antoine de Saint-Exupery
--
/Bastien Nocera
http://hadess.net

#2  0x4205a2cc in printf ("Oh my %s\n", preferred_deity) from
/lib/i686/libc.so.6 printf ("Oh my %s\n", preferred_deity);
Segmentation fault

[-- Attachment #2: smbfs-time.c --]
[-- Type: text/x-c, Size: 550 bytes --]

#include <stdio.h>
#include <time.h>
#include <asm/types.h>
#include <asm/div64.h>

typedef  __u64 u64;

#define NTFS_TIME_OFFSET ((u64)(369*365 + 89) * 24 * 3600 * 10000000)

static time_t
smb_ntutc2unixutc(u64 ntutc)
{
	u64 t = ntutc - NTFS_TIME_OFFSET;
	printf("adjusted: %Lx\n", t);

	do_div(t, 10000000);
	printf("/ 10000000: %Lx\n", t);

	return (time_t)t;
}

int main()
{
    time_t t;

    t = time(NULL);
    printf("now: %ld\n", t);

    t = smb_ntutc2unixutc(0x01c29fb515986100LL);
    printf("%ld\n", t);
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-03-11 11:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-11 11:03 bug in asm-ppc/div64.h Bastien Nocera
2003-03-11 11:04 ` Paul Mackerras
2003-03-11 11:23   ` Bastien Nocera
  -- strict thread matches above, loose matches on Subject: below --
2003-03-11 11:05 Bastien Nocera

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).