diff options
Diffstat (limited to 'funtools/filter/swap_c.h')
-rw-r--r-- | funtools/filter/swap_c.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/funtools/filter/swap_c.h b/funtools/filter/swap_c.h new file mode 100644 index 0000000..f58fe26 --- /dev/null +++ b/funtools/filter/swap_c.h @@ -0,0 +1 @@ +static char *SWAP_C="\n#if __DARWIN_BYTE_ORDER\n#define XBYTE_ORDER __DARWIN_BYTE_ORDER\n#else\n#define XBYTE_ORDER 0\n#endif\n\n#ifndef MYBYTE_ORDER\n#define MYBYTE_ORDER XBYTE_ORDER\n#endif\n\n#ifndef DO_FILTER_SWAP\n#if (XBYTE_ORDER !=0) && (XBYTE_ORDER != MYBYTE_ORDER)\n#define DO_FILTER_SWAP 1\n#endif\n#endif\n\n#if DO_FILTER_SWAP\nchar *_sw2(char *s, int n, char *_swf, int off)\n{\n char c;\n char *t=s;\n size_t i;\n if( !_swf || !_swf[off]++ ){\n for (i=0; i<n; i += 2, s += 2) {\n c = *s;\n *(s) = *(s+1);\n *(s+1) = c;\n }\n }\n return t;\n}\n\nchar *_sw4(char *s, int n, char *_swf, int off)\n{\n char c;\n char *t=s;\n size_t i;\n if( !_swf || !_swf[off]++ ){\n for (i=0; i<n; i += 4, s += 4) {\n c = *s;\n *s = *(s+3);\n *(s+3) = c;\n c = *(s+1);\n *(s+1) = *(s+2);\n *(s+2) = c;\n }\n }\n return t;\n}\n\nchar *_sw8(char *s, int n, char *_swf, int off)\n{\n char c;\n char *t=s;\n size_t i;\n if( !_swf || !_swf[off]++ ){\n for (i=0; i<n; i += 8, s += 8) {\n c = *(s+0);\n *(s+0) = *(s+7);\n *(s+7) = c;\n c = *(s+1);\n *(s+1) = *(s+6);\n *(s+6) = c;\n c = *(s+2);\n *(s+2) = *(s+5);\n *(s+5) = c;\n c = *(s+3);\n *(s+3) = *(s+4);\n *(s+4) = c;\n }\n }\n return t;\n}\n\n#define SW1(a,n,b,i) a\n#define SW2(a,n,b,i) _sw2(a,n,b,i)\n#define SW4(a,n,b,i) _sw4(a,n,b,i)\n#define SW8(a,n,b,i) _sw8(a,n,b,i)\n\n#if defined(FILTER_PTYPE) && (FILTER_PTYPE != c)\n#error \"FILTER_PTYPE environment variable must be 'c' when running with Rosetta\"\n#endif\n\n#else\n\n#define SW1(a,n,b,i) a\n#define SW2(a,n,b,i) a\n#define SW4(a,n,b,i) a\n#define SW8(a,n,b,i) a\n\n#endif\n\n"; |