bytevector-u16-native-set! prefers the big end of the egg

Bug #274446 reported by G. Weinholt
2
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Fix Committed
Low
Abdulaziz Ghuloum

Bug Description

bytevector-u16-native-set! apparently uses big-endian, even though amd64 is little-endian. It's the same with the -s16- and -ref functions.

Ikarus Scheme version 0.0.3+ (revision 1613, build 2008-09-25, 64-bit)
Copyright (c) 2006-2008 Abdulaziz Ghuloum

> (let ((x (make-bytevector 2)))
    (bytevector-u16-native-set! x 0 1)
    x)
#vu8(0 1)
> (let ((x (make-bytevector 2)))
    (bytevector-u16-set! x 0 1 (native-endianness))
    x)
#vu8(1 0)
>

Related branches

Revision history for this message
leppie (leppie) wrote :

Same behavior with x86/Cygwin. AFAIK only Mac's use big-endian (not even sure about the Intel Macs) and some other lesser known OS's.

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Fixed in 1625. Sorry for the delay.

Changed in ikarus:
assignee: nobody → aghuloum
importance: Undecided → Low
status: New → Fix Committed
Revision history for this message
G. Weinholt (weinholt) wrote :

There's still a problem here, not sure why I didn't notice it before. bytevector-u32-native-ref uses the wrong endianness:

Ikarus Scheme version 0.0.3+ (revision 1625, build 2008-10-13, 64-bit)
Copyright (c) 2006-2008 Abdulaziz Ghuloum

> (let ((x (make-bytevector 4)))
  (bytevector-u32-native-set! x 0 1)
  (values x (bytevector-u32-native-ref x 0)))
#vu8(1 0 0 0)
16777216 ;should be 1

Revision history for this message
G. Weinholt (weinholt) wrote :

Oh, and bytevector-s32-native-ref has the same problem. At least they're all consistently wrong. :)

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

They *were* all consistently wrong until you brought this up :-)

Changed in ikarus:
status: Fix Committed → Confirmed
Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Fixed in 1643.

Changed in ikarus:
status: Confirmed → Fix Committed
Changed in ikarus:
milestone: none → 0.0.4
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.