string.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:3k
- /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (c) 1994, 1995, 1996, 1997, 1998, 2001 Ralf Baechle
- * Copyright (c) 2001 MIPS Technologies, Inc.
- */
- #ifndef __ASM_STRING_H
- #define __ASM_STRING_H
- #include <linux/config.h>
- #define __HAVE_ARCH_STRCPY
- extern __inline__ char *strcpy(char *__dest, __const__ char *__src)
- {
- char *__xdest = __dest;
- __asm__ __volatile__(
- ".settnoreordernt"
- ".settnoatn"
- "1:tlbut$1,(%1)nt"
- "addiut%1,1nt"
- "sbt$1,(%0)nt"
- "bnezt$1,1bnt"
- "addiut%0,1nt"
- ".settatnt"
- ".settreorder"
- : "=r" (__dest), "=r" (__src)
- : "0" (__dest), "1" (__src)
- : "$1","memory");
- return __xdest;
- }
- #define __HAVE_ARCH_STRNCPY
- extern __inline__ char *strncpy(char *__dest, __const__ char *__src, size_t __n)
- {
- char *__xdest = __dest;
- if (__n == 0)
- return __xdest;
- __asm__ __volatile__(
- ".settnoreordernt"
- ".settnoatn"
- "1:tlbut$1,(%1)nt"
- "subut%2,1nt"
- "sbt$1,(%0)nt"
- "beqzt$1,2fnt"
- "addiut%0,1nt"
- "bnezt%2,1bnt"
- "addiut%1,1n"
- "2:nt"
- ".settatnt"
- ".settreorder"
- : "=r" (__dest), "=r" (__src), "=r" (__n)
- : "0" (__dest), "1" (__src), "2" (__n)
- : "$1","memory");
- return __dest;
- }
- #define __HAVE_ARCH_STRCMP
- extern __inline__ int strcmp(__const__ char *__cs, __const__ char *__ct)
- {
- int __res;
- __asm__ __volatile__(
- ".settnoreordernt"
- ".settnoatnt"
- "lbut%2,(%0)n"
- "1:tlbut$1,(%1)nt"
- "addiut%0,1nt"
- "bnet$1,%2,2fnt"
- "addiut%1,1nt"
- "bnezt%2,1bnt"
- "lbut%2,(%0)nt"
- #if defined(CONFIG_CPU_R3000)
- "nopnt"
- #endif
- "movet%2,$1n"
- "2:tsubut%2,$1n"
- "3:t.settatnt"
- ".settreorder"
- : "=r" (__cs), "=r" (__ct), "=r" (__res)
- : "0" (__cs), "1" (__ct)
- : "$1");
- return __res;
- }
- #define __HAVE_ARCH_STRNCMP
- extern __inline__ int
- strncmp(__const__ char *__cs, __const__ char *__ct, size_t __count)
- {
- int __res;
- __asm__ __volatile__(
- ".settnoreordernt"
- ".settnoatn"
- "1:tlbut%3,(%0)nt"
- "beqzt%2,2fnt"
- "lbut$1,(%1)nt"
- "subut%2,1nt"
- "bnet$1,%3,3fnt"
- "addiut%0,1nt"
- "bnezt%3,1bnt"
- "addiut%1,1n"
- "2:nt"
- #if defined(CONFIG_CPU_R3000)
- "nopnt"
- #endif
- "movet%3,$1n"
- "3:tsubut%3,$1nt"
- ".settatnt"
- ".settreorder"
- : "=r" (__cs), "=r" (__ct), "=r" (__count), "=r" (__res)
- : "0" (__cs), "1" (__ct), "2" (__count)
- : "$1");
- 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);
- /* Don't build bcopy at all ... */
- #define __HAVE_ARCH_BCOPY
- #define __HAVE_ARCH_MEMSCAN
- extern __inline__ void *memscan(void *__addr, int __c, size_t __size)
- {
- char *__end = (char *)__addr + __size;
- __asm__(".settpushnt"
- ".settnoatnt"
- ".settreordernt"
- "1:tbeqt%0,%1,2fnt"
- "addiut%0,1nt"
- "lbt$1,-1(%0)nt"
- "bnet$1,%z4,1bn"
- "2:t.settpop"
- : "=r" (__addr), "=r" (__end)
- : "0" (__addr), "1" (__end), "Jr" (__c)
- : "$1");
- return __addr;
- }
- #endif /* __ASM_STRING_H */