]> code.delx.au - gnu-emacs/blobdiff - src/sound.c
Use hardware support for byteswapping on glibc x86 etc.
[gnu-emacs] / src / sound.c
index 27e06b8ababeadac1ce1a946d8c1fd59a55c187c..f8c6b483056270996d38f5ee38232835da3f8db3 100644 (file)
@@ -55,6 +55,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 /* BEGIN: Non Windows Includes */
 #ifndef WINDOWSNT
 
+#include <byteswap.h>
+
 #include <sys/ioctl.h>
 
 /* FreeBSD has machine/soundcard.h.  Voxware sound driver docs mention
@@ -461,8 +463,7 @@ static u_int32_t
 le2hl (u_int32_t value)
 {
 #ifdef WORDS_BIGENDIAN
-  unsigned char *p = (unsigned char *) &value;
-  value = p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24);
+  value = bswap_32 (value);
 #endif
   return value;
 }
@@ -475,8 +476,7 @@ static u_int16_t
 le2hs (u_int16_t value)
 {
 #ifdef WORDS_BIGENDIAN
-  unsigned char *p = (unsigned char *) &value;
-  value = p[0] + (p[1] << 8);
+  value = bswap_16 (value);
 #endif
   return value;
 }
@@ -489,30 +489,11 @@ static u_int32_t
 be2hl (u_int32_t value)
 {
 #ifndef WORDS_BIGENDIAN
-  unsigned char *p = (unsigned char *) &value;
-  value = p[3] + (p[2] << 8) + (p[1] << 16) + (p[0] << 24);
+  value = bswap_32 (value);
 #endif
   return value;
 }
 
-
-#if 0 /* Currently not used.  */
-
-/* Convert 16-bit value VALUE which is in big-endian byte-order
-   to host byte-order.  */
-
-static u_int16_t
-be2hs (u_int16_t value)
-{
-#ifndef WORDS_BIGENDIAN
-  unsigned char *p = (unsigned char *) &value;
-  value = p[1] + (p[0] << 8);
-#endif
-  return value;
-}
-
-#endif /* 0 */
-
 /***********************************************************************
                          RIFF-WAVE (*.wav)
  ***********************************************************************/