Closed Bug 209814 Opened 21 years ago Closed 20 years ago

PR_dtoa blows up when executed on an ARM platform

Categories

(NSPR :: NSPR, defect)

Other
Linux
defect
Not set
major

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: darin.moz, Assigned: darin.moz)

References

Details

Attachments

(1 file, 2 obsolete files)

despite the fact that ARM is a little endian architecture, it stores doubles in
big endian format.  this means that the conversion macros in prdtoa.c (word0 and
word1) need to be defined differently for the ARM platform.
Attached patch v1 patch (obsolete) — Splinter Review
note: this patch is basically ripped from mozilla/js/src/jsnum.h
Comment on attachment 125923 [details] [diff] [review]
v1 patch

>-#ifdef IEEE_8087
>+#ifdef IEEE_8087 && !defined(CPU_IS_ARM)

Instead of this, I think we should say:

#if  defined(IS_LITTLE_ENDIAN) && !defined(CPU_IS_ARM)
#define IEEE_8087
#else
#define IEEE_MC68k
#endif

Also, maybe we should also test for defined(LINUX),
because there are other OS's that run on ARM and
I'm not sure if they also need this fix.
wtc: i originally wrote code like that and it didn't work.  the problem is that
we need to assume IEEE_8087 semantics in all cases except when we try to access
the individual DWORDs stored in a double.  you see, the DWORDS are stored in
reverse order, but are still little endian.  also, i'm pretty sure the same
format is used by WinCE.  i think we should try to follow what spidermonkey
(mozjs) does, which is the patch i wrote.
so, this bug causes NSS initialization to fail on ARM.  NSS appears to be the
only caller of PR_dtoa.

wan-teh: your thoughts on comment #3 ?
Attached patch v1.1 patch (obsolete) — Splinter Review
the previous patch was malformed (i think i must have edited it without
testing).  this is what i meant.
Attachment #125923 - Attachment is obsolete: true
Attachment #136507 - Flags: review?(wchang0222)
-> me
Assignee: wchang0222 → darin
Darin, I believe that something along the line of
this patch should work.

I added a new case for IEEE arithmetic called IEEE_ARM.

For the word0 and word1 macros, IEEE_ARM is treated like
IEEE_MC68k (big endian).

For the Storeinc macro, IEEE_ARM is treated like
IEEE_8087 (little endian).

Please review and test this patch.  Please run the
dtoa.c and strod.c tests in nsprpub/pr/tests.
Thanks.
Comment on attachment 141345 [details] [diff] [review]
wtc's alternate patch

dtoa test passed.  patch looks good to me.

r=darin

thanks wtc!
Attachment #141345 - Flags: review+
Attachment #136507 - Attachment is obsolete: true
Attachment #136507 - Flags: review?(wchang0222)
Comment on attachment 141345 [details] [diff] [review]
wtc's alternate patch

requesting approval to land this patch.  it only affects the ARM build of NSPR.
Attachment #141345 - Flags: approval1.7b?
Comment on attachment 141345 [details] [diff] [review]
wtc's alternate patch

a=brendan@mozilla.org for 1.7b.

/be
Attachment #141345 - Flags: approval1.7b? → approval1.7b+
fixed NSPRPUB_PRE_4_2_CLIENT_BRANCH for mozilla 1.7 beta 
 ... and the NSPR trunk.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Target Milestone: --- → 4.5
Blocks: 215636
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: