This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Eliminate the implementations of [hv]to[vh][ls] for mixed-endian systems.
authorNicholas Clark <nick@ccl4.org>
Tue, 7 May 2013 16:25:53 +0000 (18:25 +0200)
committerNicholas Clark <nick@ccl4.org>
Mon, 20 May 2013 19:19:44 +0000 (21:19 +0200)
As pp_pack.c has had mixed-endian support removed, there is little point in
keeping code in perl.h and util.c only needed for architectures that cannot
be built.

perl.h
util.c

diff --git a/perl.h b/perl.h
index 3636147..87e7f0f 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -3408,8 +3408,7 @@ my_swap16(const U16 x) {
 #  define vtohs(x)      ((x)&0xFFFF)
 #  define htovl(x)      vtohl(x)
 #  define htovs(x)      vtohs(x)
-#else
-# if BYTEORDER == 0x4321 || BYTEORDER == 0x87654321
+#elif BYTEORDER == 0x4321 || BYTEORDER == 0x87654321
 #  define vtohl(x)     ((((x)&0xFF)<<24)       \
                        +(((x)>>24)&0xFF)       \
                        +(((x)&0x0000FF00)<<8)  \
@@ -3417,14 +3416,11 @@ my_swap16(const U16 x) {
 #  define vtohs(x)     ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
 #  define htovl(x)     vtohl(x)
 #  define htovs(x)     vtohs(x)
-# endif
-       /* otherwise default to functions in util.c */
-#ifndef htovs
-short htovs(short n);
-short vtohs(short n);
-long htovl(long n);
-long vtohl(long n);
-#endif
+#else
+#  error "Unsupported byteorder"
+/* If you have need for current perl on PDP-11 or similar, and can help test
+   that blead keeps working on a mixed-endian system, then see
+   pod/perlhack.pod for how to submit patches to things working again.  */
 #endif
 
 /* *MAX Plus 1. A floating point value.
diff --git a/util.c b/util.c
index e1bbed3..66793a3 100644 (file)
--- a/util.c
+++ b/util.c
@@ -2160,99 +2160,6 @@ vsprintf(char *dest, const char *pat, void *args)
 
 #endif /* HAS_VPRINTF */
 
-/*
- * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
- * If these functions are defined,
- * the BYTEORDER is neither 0x1234 nor 0x4321.
- * However, this is not assumed.
- * -DWS
- */
-
-#define HTOLE(name,type)                                       \
-       type                                                    \
-       name (type n)                                           \
-       {                                                       \
-           union {                                             \
-               type value;                                     \
-               char c[sizeof(type)];                           \
-           } u;                                                \
-           U32 i;                                              \
-           U32 s = 0;                                          \
-           for (i = 0; i < sizeof(u.c); i++, s += 8) {         \
-               u.c[i] = (n >> s) & 0xFF;                       \
-           }                                                   \
-           return u.value;                                     \
-       }
-
-#define LETOH(name,type)                                       \
-       type                                                    \
-       name (type n)                                           \
-       {                                                       \
-           union {                                             \
-               type value;                                     \
-               char c[sizeof(type)];                           \
-           } u;                                                \
-           U32 i;                                              \
-           U32 s = 0;                                          \
-           u.value = n;                                        \
-           n = 0;                                              \
-           for (i = 0; i < sizeof(u.c); i++, s += 8) {         \
-               n |= ((type)(u.c[i] & 0xFF)) << s;              \
-           }                                                   \
-           return n;                                           \
-       }
-
-/*
- * Big-endian byte order functions.
- */
-
-#define HTOBE(name,type)                                       \
-       type                                                    \
-       name (type n)                                           \
-       {                                                       \
-           union {                                             \
-               type value;                                     \
-               char c[sizeof(type)];                           \
-           } u;                                                \
-           U32 i;                                              \
-           U32 s = 8*(sizeof(u.c)-1);                          \
-           for (i = 0; i < sizeof(u.c); i++, s -= 8) {         \
-               u.c[i] = (n >> s) & 0xFF;                       \
-           }                                                   \
-           return u.value;                                     \
-       }
-
-#define BETOH(name,type)                                       \
-       type                                                    \
-       name (type n)                                           \
-       {                                                       \
-           union {                                             \
-               type value;                                     \
-               char c[sizeof(type)];                           \
-           } u;                                                \
-           U32 i;                                              \
-           U32 s = 8*(sizeof(u.c)-1);                          \
-           u.value = n;                                        \
-           n = 0;                                              \
-           for (i = 0; i < sizeof(u.c); i++, s -= 8) {         \
-               n |= ((type)(u.c[i] & 0xFF)) << s;              \
-           }                                                   \
-           return n;                                           \
-       }
-
-#if !defined(htovs)
-HTOLE(htovs,short)
-#endif
-#if !defined(htovl)
-HTOLE(htovl,long)
-#endif
-#if !defined(vtohs)
-LETOH(vtohs,short)
-#endif
-#if !defined(vtohl)
-LETOH(vtohl,long)
-#endif
-
 PerlIO *
 Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args)
 {