]> git.saurik.com Git - wxWidgets.git/blobdiff - src/tiff/libtiff/tif_swab.c
Support Unicode module names in wxDynamicLibrary::MSWGetModuleHandle().
[wxWidgets.git] / src / tiff / libtiff / tif_swab.c
index aad43df97c7ca97135d32c3486c597caf1e3c395..9af87a4d4b39ff675dc15be4c38be546c2c0a4d7 100644 (file)
@@ -37,7 +37,7 @@ TIFFSwabShort(uint16* wp)
 {
        register unsigned char* cp = (unsigned char*) wp;
        unsigned char t;
-
+       assert(sizeof(uint16)==2);
        t = cp[1]; cp[1] = cp[0]; cp[0] = t;
 }
 #endif
@@ -48,19 +48,33 @@ TIFFSwabLong(uint32* lp)
 {
        register unsigned char* cp = (unsigned char*) lp;
        unsigned char t;
-
+       assert(sizeof(uint32)==4);
        t = cp[3]; cp[3] = cp[0]; cp[0] = t;
        t = cp[2]; cp[2] = cp[1]; cp[1] = t;
 }
 #endif
 
+#ifndef TIFFSwabLong8
+void
+TIFFSwabLong8(uint64* lp)
+{
+       register unsigned char* cp = (unsigned char*) lp;
+       unsigned char t;
+       assert(sizeof(uint64)==8);
+       t = cp[7]; cp[7] = cp[0]; cp[0] = t;
+       t = cp[6]; cp[6] = cp[1]; cp[1] = t;
+       t = cp[5]; cp[5] = cp[2]; cp[2] = t;
+       t = cp[4]; cp[4] = cp[3]; cp[3] = t;
+}
+#endif
+
 #ifndef TIFFSwabArrayOfShort
 void
-TIFFSwabArrayOfShort(uint16* wp, register unsigned long n)
+TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n)
 {
        register unsigned char* cp;
        register unsigned char t;
-
+       assert(sizeof(uint16)==2);
        /* XXX unroll loop some */
        while (n-- > 0) {
                cp = (unsigned char*) wp;
@@ -72,7 +86,7 @@ TIFFSwabArrayOfShort(uint16* wp, register unsigned long n)
 
 #ifndef TIFFSwabArrayOfTriples
 void
-TIFFSwabArrayOfTriples(uint8* tp, unsigned long n)
+TIFFSwabArrayOfTriples(register uint8* tp, tmsize_t n)
 {
        unsigned char* cp;
        unsigned char t;
@@ -88,11 +102,11 @@ TIFFSwabArrayOfTriples(uint8* tp, unsigned long n)
 
 #ifndef TIFFSwabArrayOfLong
 void
-TIFFSwabArrayOfLong(register uint32* lp, register unsigned long n)
+TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n)
 {
        register unsigned char *cp;
        register unsigned char t;
-
+       assert(sizeof(uint32)==4);
        /* XXX unroll loop some */
        while (n-- > 0) {
                cp = (unsigned char *)lp;
@@ -103,30 +117,84 @@ TIFFSwabArrayOfLong(register uint32* lp, register unsigned long n)
 }
 #endif
 
+#ifndef TIFFSwabArrayOfLong8
+void
+TIFFSwabArrayOfLong8(register uint64* lp, tmsize_t n)
+{
+       register unsigned char *cp;
+       register unsigned char t;
+       assert(sizeof(uint64)==8);
+       /* XXX unroll loop some */
+       while (n-- > 0) {
+               cp = (unsigned char *)lp;
+               t = cp[7]; cp[7] = cp[0]; cp[0] = t;
+               t = cp[6]; cp[6] = cp[1]; cp[1] = t;
+               t = cp[5]; cp[5] = cp[2]; cp[2] = t;
+               t = cp[4]; cp[4] = cp[3]; cp[3] = t;
+               lp++;
+       }
+}
+#endif
+
+#ifndef TIFFSwabFloat
+void
+TIFFSwabFloat(float* fp)
+{
+       register unsigned char* cp = (unsigned char*) fp;
+       unsigned char t;
+       assert(sizeof(float)==4);
+       t = cp[3]; cp[3] = cp[0]; cp[0] = t;
+       t = cp[2]; cp[2] = cp[1]; cp[1] = t;
+}
+#endif
+
+#ifndef TIFFSwabArrayOfFloat
+void
+TIFFSwabArrayOfFloat(register float* fp, tmsize_t n)
+{
+       register unsigned char *cp;
+       register unsigned char t;
+       assert(sizeof(float)==4);
+       /* XXX unroll loop some */
+       while (n-- > 0) {
+               cp = (unsigned char *)fp;
+               t = cp[3]; cp[3] = cp[0]; cp[0] = t;
+               t = cp[2]; cp[2] = cp[1]; cp[1] = t;
+               fp++;
+       }
+}
+#endif
+
 #ifndef TIFFSwabDouble
 void
 TIFFSwabDouble(double *dp)
 {
-        register uint32* lp = (uint32*) dp;
-        uint32 t;
-
-       TIFFSwabArrayOfLong(lp, 2);
-       t = lp[0]; lp[0] = lp[1]; lp[1] = t;
+       register unsigned char* cp = (unsigned char*) dp;
+       unsigned char t;
+       assert(sizeof(double)==8);
+       t = cp[7]; cp[7] = cp[0]; cp[0] = t;
+       t = cp[6]; cp[6] = cp[1]; cp[1] = t;
+       t = cp[5]; cp[5] = cp[2]; cp[2] = t;
+       t = cp[4]; cp[4] = cp[3]; cp[3] = t;
 }
 #endif
 
 #ifndef TIFFSwabArrayOfDouble
 void
-TIFFSwabArrayOfDouble(double* dp, register unsigned long n)
+TIFFSwabArrayOfDouble(double* dp, tmsize_t n)
 {
-       register uint32* lp = (uint32*) dp;
-        register uint32 t;
-
-       TIFFSwabArrayOfLong(lp, n + n);
-        while (n-- > 0) {
-               t = lp[0]; lp[0] = lp[1]; lp[1] = t;
-                lp += 2;
-        }
+       register unsigned char *cp;
+       register unsigned char t;
+       assert(sizeof(double)==8);
+       /* XXX unroll loop some */
+       while (n-- > 0) {
+               cp = (unsigned char *)dp;
+               t = cp[7]; cp[7] = cp[0]; cp[0] = t;
+               t = cp[6]; cp[6] = cp[1]; cp[1] = t;
+               t = cp[5]; cp[5] = cp[2]; cp[2] = t;
+               t = cp[4]; cp[4] = cp[3]; cp[3] = t;
+               dp++;
+       }
 }
 #endif
 
@@ -215,7 +283,7 @@ TIFFGetBitRevTable(int reversed)
 }
 
 void
-TIFFReverseBits(register unsigned char* cp, register unsigned long n)
+TIFFReverseBits(uint8* cp, tmsize_t n)  
 {
        for (; n > 8; n -= 8) {
                cp[0] = TIFFBitRevTable[cp[0]];
@@ -233,3 +301,10 @@ TIFFReverseBits(register unsigned char* cp, register unsigned long n)
 }
 
 /* vim: set ts=8 sts=8 sw=8 noet: */
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 8
+ * fill-column: 78
+ * End:
+ */