summaryrefslogtreecommitdiffstats
path: root/c/src/exec
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-04-27 16:10:16 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-04-27 16:10:16 +0000
commitb0aba4c46b14204f7de6471512136de7003877c4 (patch)
treec3128754275e49fb155f41a327d5938385395cb8 /c/src/exec
parentFixed spelling errors. (diff)
downloadrtems-b0aba4c46b14204f7de6471512136de7003877c4.tar.bz2
Added swap of unsigned16
Diffstat (limited to 'c/src/exec')
-rw-r--r--c/src/exec/score/cpu/a29k/cpu.h6
-rw-r--r--c/src/exec/score/cpu/hppa1.1/cpu.h3
-rw-r--r--c/src/exec/score/cpu/i386/i386.h21
-rw-r--r--c/src/exec/score/cpu/i960/i960.h3
-rw-r--r--c/src/exec/score/cpu/m68k/m68k.h12
-rw-r--r--c/src/exec/score/cpu/mips64orion/cpu.h3
-rw-r--r--c/src/exec/score/cpu/no_cpu/cpu.h3
-rw-r--r--c/src/exec/score/cpu/powerpc/cpu.h3
-rw-r--r--c/src/exec/score/cpu/sh/sh.h12
-rw-r--r--c/src/exec/score/cpu/sparc/cpu.h3
-rw-r--r--c/src/exec/score/cpu/unix/cpu.h3
11 files changed, 69 insertions, 3 deletions
diff --git a/c/src/exec/score/cpu/a29k/cpu.h b/c/src/exec/score/cpu/a29k/cpu.h
index 326abaab5c..bf7f5230b9 100644
--- a/c/src/exec/score/cpu/a29k/cpu.h
+++ b/c/src/exec/score/cpu/a29k/cpu.h
@@ -961,7 +961,11 @@ void _CPU_Context_restore_fp(
*/
#define CPU_swap_u32( value ) \
- ((value&0xff) << 24) | (((value >> 8)&0xff) << 16) | (((value >> 16)&0xff) << 8) | ((value>>24)&0xff)
+ ((value&0xff) << 24) | (((value >> 8)&0xff) << 16) | \
+ (((value >> 16)&0xff) << 8) | ((value>>24)&0xff)
+
+#define CPU_swap_u16( value ) \
+ (((value&0xff) << 8) | ((value >> 8)&0xff))
#ifdef __cplusplus
}
diff --git a/c/src/exec/score/cpu/hppa1.1/cpu.h b/c/src/exec/score/cpu/hppa1.1/cpu.h
index 3df9215730..91dbdc8cad 100644
--- a/c/src/exec/score/cpu/hppa1.1/cpu.h
+++ b/c/src/exec/score/cpu/hppa1.1/cpu.h
@@ -599,6 +599,9 @@ CPU_swap_u32(unsigned32 value)
return( swapped );
}
+#define CPU_swap_u16( value ) \
+ (((value&0xff) << 8) | ((value >> 8)&0xff))
+
#endif /* ! ASM */
#ifdef __cplusplus
diff --git a/c/src/exec/score/cpu/i386/i386.h b/c/src/exec/score/cpu/i386/i386.h
index 7f35a68ace..91c5294221 100644
--- a/c/src/exec/score/cpu/i386/i386.h
+++ b/c/src/exec/score/cpu/i386/i386.h
@@ -165,10 +165,26 @@ static inline unsigned int i386_swap_U32(
unsigned int value
)
{
+ unsigned long lout;
+
asm volatile( "rorw $8,%%ax;"
"rorl $16,%0;"
- "rorw $8,%%ax" : "=a" (value) : "0" (value) );
- return( value );
+ "rorw $8,%%ax" : "=a" (lout) : "0" (value) );
+/* this should be better for i486dx and above */
+/*
+ __asm__ volatile( "bswap %0" : "=r" (lout) : "0" (lin));
+*/
+ return( lout );
+}
+
+static inline unsigned int i386_swap_U16(
+ unsigned int value
+)
+{
+ unsigned short sout;
+
+ __asm__ volatile( "rorw $8,%0" : "=r" (sout) : "0" (value));
+ return (sout);
}
/*
@@ -439,6 +455,7 @@ void i386_Install_idt(
#define get_gs() i386_get_gs()
#define CPU_swap_u32( _value ) i386_swap_U32( _value )
+#define CPU_swap_u16( _value ) i386_swap_U16( _value )
/* i80x86 I/O instructions */
diff --git a/c/src/exec/score/cpu/i960/i960.h b/c/src/exec/score/cpu/i960/i960.h
index 5f67f72fb6..78260a5a57 100644
--- a/c/src/exec/score/cpu/i960/i960.h
+++ b/c/src/exec/score/cpu/i960/i960.h
@@ -255,6 +255,9 @@ static inline unsigned int CPU_swap_u32(
return( swapped );
}
+#define CPU_swap_u16( value ) \
+ (((value&0xff) << 8) | ((value >> 8)&0xff))
+
#ifdef __cplusplus
}
#endif
diff --git a/c/src/exec/score/cpu/m68k/m68k.h b/c/src/exec/score/cpu/m68k/m68k.h
index 1336b581d1..a6d24562d2 100644
--- a/c/src/exec/score/cpu/m68k/m68k.h
+++ b/c/src/exec/score/cpu/m68k/m68k.h
@@ -243,6 +243,17 @@ static inline unsigned int m68k_swap_u32(
return( swapped );
}
+static inline unsigned int m68k_swap_u16(
+ unsigned int value
+)
+{
+ unsigned short swapped = value;
+
+ asm volatile( "rorw #8,%0" : "=d" (swapped) : "0" (swapped) );
+
+ return( swapped );
+}
+
/* XXX this is only valid for some m68k family members and should be fixed */
#define m68k_enable_caching() \
@@ -252,6 +263,7 @@ static inline unsigned int m68k_swap_u32(
}
#define CPU_swap_u32( value ) m68k_swap_u32( value )
+#define CPU_swap_u16( value ) m68k_swap_u16( value )
#endif /* !ASM */
diff --git a/c/src/exec/score/cpu/mips64orion/cpu.h b/c/src/exec/score/cpu/mips64orion/cpu.h
index 7868c88ddd..75809b3384 100644
--- a/c/src/exec/score/cpu/mips64orion/cpu.h
+++ b/c/src/exec/score/cpu/mips64orion/cpu.h
@@ -941,6 +941,9 @@ static inline unsigned int CPU_swap_u32(
return( swapped );
}
+#define CPU_swap_u16( value ) \
+ (((value&0xff) << 8) | ((value >> 8)&0xff))
+
/*
* Miscellaneous prototypes
*
diff --git a/c/src/exec/score/cpu/no_cpu/cpu.h b/c/src/exec/score/cpu/no_cpu/cpu.h
index 36e5681709..0373e43fc7 100644
--- a/c/src/exec/score/cpu/no_cpu/cpu.h
+++ b/c/src/exec/score/cpu/no_cpu/cpu.h
@@ -859,6 +859,9 @@ static inline unsigned int CPU_swap_u32(
return( swapped );
}
+#define CPU_swap_u16( value ) \
+ (((value&0xff) << 8) | ((value >> 8)&0xff))
+
#ifdef __cplusplus
}
#endif
diff --git a/c/src/exec/score/cpu/powerpc/cpu.h b/c/src/exec/score/cpu/powerpc/cpu.h
index d2353bacf5..5360b21770 100644
--- a/c/src/exec/score/cpu/powerpc/cpu.h
+++ b/c/src/exec/score/cpu/powerpc/cpu.h
@@ -1091,6 +1091,9 @@ static inline unsigned int CPU_swap_u32(
return( swapped );
}
+#define CPU_swap_u16( value ) \
+ (((value&0xff) << 8) | ((value >> 8)&0xff))
+
#ifdef __cplusplus
}
#endif
diff --git a/c/src/exec/score/cpu/sh/sh.h b/c/src/exec/score/cpu/sh/sh.h
index 1561732c33..b6491128ed 100644
--- a/c/src/exec/score/cpu/sh/sh.h
+++ b/c/src/exec/score/cpu/sh/sh.h
@@ -134,7 +134,19 @@ static inline unsigned int sh_swap_u32(
return( swapped );
}
+static inline unsigned int sh_swap_u32(
+ unsigned int value
+)
+{
+ register unsigned int swapped ;
+
+ asm volatile ( "swap.b %1,%0 : "=r" (swapped) : "r" (value) );
+
+ return( swapped );
+}
+
#define CPU_swap_u32( value ) sh_swap_u32( value )
+#define CPU_swap_u16( value ) sh_swap_u16( value )
/*
* Simple spin delay in microsecond units for device drivers.
diff --git a/c/src/exec/score/cpu/sparc/cpu.h b/c/src/exec/score/cpu/sparc/cpu.h
index 9d96e05838..21b24a0ba7 100644
--- a/c/src/exec/score/cpu/sparc/cpu.h
+++ b/c/src/exec/score/cpu/sparc/cpu.h
@@ -994,6 +994,9 @@ static inline unsigned int CPU_swap_u32(
return( swapped );
}
+#define CPU_swap_u16( value ) \
+ (((value&0xff) << 8) | ((value >> 8)&0xff))
+
#endif ASM
#ifdef __cplusplus
diff --git a/c/src/exec/score/cpu/unix/cpu.h b/c/src/exec/score/cpu/unix/cpu.h
index 13558267a0..1667438f92 100644
--- a/c/src/exec/score/cpu/unix/cpu.h
+++ b/c/src/exec/score/cpu/unix/cpu.h
@@ -991,6 +991,9 @@ static inline unsigned int CPU_swap_u32(
return( swapped );
}
+#define CPU_swap_u16( value ) \
+ (((value&0xff) << 8) | ((value >> 8)&0xff))
+
/*
* Special Purpose Routines to hide the use of UNIX system calls.
*/