about summary refs log tree commit diff
path: root/lib/util/wordaccess_generic.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util/wordaccess_generic.h')
-rw-r--r--lib/util/wordaccess_generic.h74
1 files changed, 7 insertions, 67 deletions
diff --git a/lib/util/wordaccess_generic.h b/lib/util/wordaccess_generic.h
index 7f27ef74..94cc8124 100644
--- a/lib/util/wordaccess_generic.h
+++ b/lib/util/wordaccess_generic.h
@@ -5,85 +5,25 @@
 
   * Compilers other than GCC
   * GCC before version 3.4
-  * c libraries other than Glibc
   * Specified by the user with WORDACCESS_GENERIC
 =============================================================================*/
 
+#include "intcode.h"
+
 typedef uint32_t wordint;
 typedef unsigned char wordintBytes[sizeof(wordint)];
+
     
 static __inline__ wordint
-bytesToWordint(wordintBytes const bytes) {
-    wordint retval;
-    unsigned int i;
+bytesToWordint(wordintBytes  const bytes) {
 
-    /* Note that 'bytes' is a pointer, due to C array degeneration.
-       That means sizeof(bytes) isn't what you think it is.
-    */
-    
-    for (i = 1, retval = bytes[0]; i < sizeof(wordint); ++i) {
-        retval = (retval << 8) + bytes[i];
-    }
-    return retval;
+    return (wordint)  pm_uintFromBigend32( * (bigend32*) bytes);
 }
 
 
-
 static __inline__ void
 wordintToBytes(wordintBytes * const bytesP,
-               wordint        const wordInt) {
-
-    wordint buffer;
-    int i;
-
-    for (i = sizeof(*bytesP)-1, buffer = wordInt; i >= 0; --i) {
-        (*bytesP)[i] = buffer & 0xFF;
-        buffer >>= 8;
-    }
-}
-    
-static unsigned char const clz8[256]= {
-    8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
-    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
-};
-
-
-
-static __inline__ unsigned int
-clz16(wordint const x) {
-    if (x >> 8  != 0)
-        return clz8[x >> 8];
-    else
-        return clz8[x] + 8;
-}
-
-
-
-static __inline__  unsigned int
-clz32(wordint const x) {
-    if (x >> 16  != 0)
-        return clz16(x >> 16);
-    else
-        return clz16(x) +16;
-}
-
-
+               wordint    const wordInt) {
 
-static __inline__  unsigned int
-wordintClz(wordint const x) {
-    return clz32(x);
+    * (bigend32*) bytesP = pm_bigendFromUint32((uint32_t)wordInt);
 }