After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 101318 - New asm for endian swap functions
New asm for endian swap functions
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.1.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2002-12-16 00:37 UTC by Manish Singh
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch implementing the above (9.12 KB, patch)
2002-12-16 00:37 UTC, Manish Singh
none Details | Review

Description Manish Singh 2002-12-16 00:37:04 UTC
I've reorged the asm stuff for the endian swap routines. I got rid of the
obsolete #ifdef for G_HAVE_GINT64, synced up the i386 implementations with
glibc 2.3's stuff, brought in ia64 implementations from glibc, and wrote my
own x86_64 implementations.

I've tested these with glib's testglib and type-test, and with gimp. It'd
be nice if it could go into for 2.2.
Comment 1 Manish Singh 2002-12-16 00:37:52 UTC
Created attachment 13013 [details] [review]
patch implementing the above
Comment 2 Owen Taylor 2002-12-16 01:22:47 UTC
+#    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
+#    define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86_64 (val))
+#    define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86_64 (val))

Was wondering why there wasn't a GUINT16_SWAP_LE_BE_X86_64;
presumably a straightforward adaption of the ia32 version should
work, and be a bit faster.

(Of course even the C fallbacks should be running way faster 
than memory bandwidth...)
Comment 3 Owen Taylor 2002-12-16 18:05:45 UTC
After discussing this some with Manish on IRC, it appears
that given a sufficiently good definition of a 16-bit
endian swap, GCC will generate the right code (use a
roll) from the C code for both x86 and x86_64. But the current 
macro isn't good enough.

#define GUINT16_SWAP_LE_BE_CONSTANT(val)  \
     ((guint16)((guint16)(val) >> 8) |    \
      (guint16)((guint16)(val) << 8))

Seems to work better. 
Comment 4 Manish Singh 2002-12-19 00:20:58 UTC
Wed Dec 18 16:19:08 2002  Manish Singh  <yosh@gimp.org>
                                                                     
          
        * glib/gtypes.h: new endian asm for ia64 and x86_64, general
        reorg and clean up. New implementation of
GUINT16_SWAP_LE_BE_CONSTANT()
        that should optimize better. (#101318)