string.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
- #ifndef __ASM_SH_STRING_H
- #define __ASM_SH_STRING_H
- /*
- * Copyright (C) 1999 Niibe Yutaka
- * But consider these trivial functions to be public domain.
- */
- #define __HAVE_ARCH_STRCPY
- static __inline__ char *strcpy(char *__dest, const char *__src)
- {
- register char *__xdest = __dest;
- unsigned long __dummy;
- __asm__ __volatile__("1:nt"
- "mov.b @%1+, %2nt"
- "mov.b %2, @%0nt"
- "cmp/eq #0, %2nt"
- "bf/s 1bnt"
- " add #1, %0nt"
- : "=r" (__dest), "=r" (__src), "=&z" (__dummy)
- : "0" (__dest), "1" (__src)
- : "memory", "t");
- return __xdest;
- }
- #define __HAVE_ARCH_STRNCPY
- static __inline__ char *strncpy(char *__dest, const char *__src, size_t __n)
- {
- register char *__xdest = __dest;
- unsigned long __dummy;
- if (__n == 0)
- return __xdest;
- __asm__ __volatile__(
- "1:n"
- "mov.b @%1+, %2nt"
- "mov.b %2, @%0nt"
- "cmp/eq #0, %2nt"
- "bt/s 2fnt"
- " cmp/eq %5,%1nt"
- "bf/s 1bnt"
- " add #1, %0n"
- "2:"
- : "=r" (__dest), "=r" (__src), "=&z" (__dummy)
- : "0" (__dest), "1" (__src), "r" (__src+__n)
- : "memory", "t");
- return __xdest;
- }
- #define __HAVE_ARCH_STRCMP
- static __inline__ int strcmp(const char *__cs, const char *__ct)
- {
- register int __res;
- unsigned long __dummy;
- __asm__ __volatile__(
- "mov.b @%1+, %3n"
- "1:nt"
- "mov.b @%0+, %2nt"
- "cmp/eq #0, %3nt"
- "bt 2fnt"
- "cmp/eq %2, %3nt"
- "bt/s 1bnt"
- " mov.b @%1+, %3nt"
- "add #-2, %1nt"
- "mov.b @%1, %3nt"
- "sub %3, %2n"
- "2:"
- : "=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
- : "0" (__cs), "1" (__ct)
- : "t");
- return __res;
- }
- #define __HAVE_ARCH_STRNCMP
- static __inline__ int strncmp(const char *__cs, const char *__ct, size_t __n)
- {
- register int __res;
- unsigned long __dummy;
- if (__n == 0)
- return 0;
- __asm__ __volatile__(
- "mov.b @%1+, %3n"
- "1:nt"
- "mov.b @%0+, %2nt"
- "cmp/eq %6, %0nt"
- "bt/s 2fnt"
- " cmp/eq #0, %3nt"
- "bt/s 3fnt"
- " cmp/eq %3, %2nt"
- "bt/s 1bnt"
- " mov.b @%1+, %3nt"
- "add #-2, %1nt"
- "mov.b @%1, %3n"
- "2:nt"
- "sub %3, %2n"
- "3:"
- :"=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
- : "0" (__cs), "1" (__ct), "r" (__cs+__n)
- : "t");
- return __res;
- }
- #define __HAVE_ARCH_MEMSET
- extern void *memset(void *__s, int __c, size_t __count);
- #define __HAVE_ARCH_MEMCPY
- extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
- #define __HAVE_ARCH_MEMMOVE
- extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
- #define __HAVE_ARCH_MEMCHR
- extern void *memchr(const void *__s, int __c, size_t __n);
- #define __HAVE_ARCH_STRLEN
- extern size_t strlen(const char *);
- /* Don't build bcopy at all ... */
- #define __HAVE_ARCH_BCOPY
- #endif /* __ASM_SH_STRING_H */