From c3f9d4939af90eb8e30119601c86c05bde6c7345 Mon Sep 17 00:00:00 2001 From: wdenk Date: Sun, 14 Mar 2004 00:59:59 +0000 Subject: * Patch by Yuli Barcohen, 4 Mar 2004: Fix problems with GCC 3.3.x which changed handling of global variables explicitly initialized to zero (now in .bss instead of .data as before). * Patch by Leon Kukovec, 02 Mar 2004: add strswab() to fix IDE LBA capacity, firmware and model numbers on little endian machines * Patch by Masami Komiya, 02 Mar 2004: - Remove get_ticks() from NFS code - Add verification of RPC transaction ID * Patch by Pierre Aubert, 02 Mar 2004: cleanup for IDE and USB drivers for MPC5200 --- lib_generic/string.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib_generic/string.c') diff --git a/lib_generic/string.c b/lib_generic/string.c index d06a64501..5ba8d7cb5 100644 --- a/lib_generic/string.c +++ b/lib_generic/string.c @@ -364,6 +364,33 @@ char * strsep(char **s, const char *ct) } #endif +#ifndef __HAVE_ARCH_STRSWAB +/** + * strswab - swap adjacent even and odd bytes in %NUL-terminated string + * s: address of the string + * + * returns the address of the swapped string or NULL on error. If + * string length is odd, last byte is untouched. + */ +char *strswab(const char *s) +{ + char *p; + + if ((NULL == s) || ('\0' == *s)) { + return (NULL); + } + + for (p = ((char *)s + 1); '\0' != *p; p += 2) { + char tmp; + tmp = *(p-1); + *(p-1) = *p; + *p = tmp; + } + + return (char *) s; +} +#endif + #ifndef __HAVE_ARCH_MEMSET /** * memset - Fill a region of memory with the given value -- cgit v1.2.3