diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2013-10-04 00:36:22 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2013-10-04 00:36:22 -0700 |
commit | 4eed3157327f8406921658442a11af7e9d84d603 (patch) | |
tree | e727a3017628ce840707d71998d4f6423a8fbde3 /src/xsettings.c | |
parent | 157fec2e190a84345138a0cc69e35f177c4d4a56 (diff) | |
download | emacs-4eed3157327f8406921658442a11af7e9d84d603.tar.gz |
Use hardware support for byteswapping on glibc x86 etc.
On Fedora 19 x86-64, the new bswap_64 needs 1 instruction,
whereas the old swap64 needed 30.
* admin/merge-gnulib (GNULIB_MODULES): Add byteswap.
* lib/byteswap.in.h, m4/byteswap.m4: New files, copied from Gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* src/fringe.c (init_fringe_bitmap) [WORDS_BIGENDIAN]:
* src/sound.c (le2hl, le2hs, be2hl) [!WINDOWSNT]:
Use byteswap.h's macros to swap bytes.
* src/lisp.h (swap16, swap32, swap64): Remove.
All uses replaced by bswap_16, bswap_32, bswap_64.
Diffstat (limited to 'src/xsettings.c')
-rw-r--r-- | src/xsettings.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/xsettings.c b/src/xsettings.c index 8fe82fec74b..e5a66c4cf0a 100644 --- a/src/xsettings.c +++ b/src/xsettings.c @@ -22,6 +22,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <float.h> #include <limits.h> #include <fcntl.h> + +#include <byteswap.h> + #include "lisp.h" #include "xterm.h" #include "xsettings.h" @@ -405,7 +408,7 @@ parse_settings (unsigned char *prop, if (bytes < 12) return BadLength; memcpy (&n_settings, prop+8, 4); - if (my_bo != that_bo) n_settings = swap32 (n_settings); + if (my_bo != that_bo) n_settings = bswap_32 (n_settings); bytes_parsed = 12; memset (settings, 0, sizeof (*settings)); @@ -427,7 +430,7 @@ parse_settings (unsigned char *prop, memcpy (&nlen, prop+bytes_parsed, 2); bytes_parsed += 2; - if (my_bo != that_bo) nlen = swap16 (nlen); + if (my_bo != that_bo) nlen = bswap_16 (nlen); if (bytes_parsed+nlen > bytes) return BadLength; to_cpy = nlen > 127 ? 127 : nlen; memcpy (name, prop+bytes_parsed, to_cpy); @@ -454,7 +457,7 @@ parse_settings (unsigned char *prop, if (want_this) { memcpy (&ival, prop+bytes_parsed, 4); - if (my_bo != that_bo) ival = swap32 (ival); + if (my_bo != that_bo) ival = bswap_32 (ival); } bytes_parsed += 4; break; @@ -463,7 +466,7 @@ parse_settings (unsigned char *prop, if (bytes_parsed+4 > bytes) return BadLength; memcpy (&vlen, prop+bytes_parsed, 4); bytes_parsed += 4; - if (my_bo != that_bo) vlen = swap32 (vlen); + if (my_bo != that_bo) vlen = bswap_32 (vlen); if (want_this) { to_cpy = vlen > 127 ? 127 : vlen; |