home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / src / linux-headers-2.6.28-15 / arch / m68knommu / include / asm / string.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-12-24  |  3.2 KB  |  127 lines

  1. #ifndef _M68KNOMMU_STRING_H_
  2. #define _M68KNOMMU_STRING_H_
  3.  
  4. #ifdef __KERNEL__ /* only set these up for kernel code */
  5.  
  6. #include <asm/setup.h>
  7. #include <asm/page.h>
  8.  
  9. #define __HAVE_ARCH_STRCPY
  10. static inline char * strcpy(char * dest,const char *src)
  11. {
  12.   char *xdest = dest;
  13.  
  14.   __asm__ __volatile__
  15.        ("1:\tmoveb %1@+,%0@+\n\t"
  16.         "jne 1b"
  17.     : "=a" (dest), "=a" (src)
  18.         : "0" (dest), "1" (src) : "memory");
  19.   return xdest;
  20. }
  21.  
  22. #define __HAVE_ARCH_STRNCPY
  23. static inline char * strncpy(char *dest, const char *src, size_t n)
  24. {
  25.   char *xdest = dest;
  26.  
  27.   if (n == 0)
  28.     return xdest;
  29.  
  30.   __asm__ __volatile__
  31.        ("1:\tmoveb %1@+,%0@+\n\t"
  32.     "jeq 2f\n\t"
  33.         "subql #1,%2\n\t"
  34.         "jne 1b\n\t"
  35.         "2:"
  36.         : "=a" (dest), "=a" (src), "=d" (n)
  37.         : "0" (dest), "1" (src), "2" (n)
  38.         : "memory");
  39.   return xdest;
  40. }
  41.  
  42.  
  43. #ifndef CONFIG_COLDFIRE
  44.  
  45. #define __HAVE_ARCH_STRCMP
  46. static inline int strcmp(const char * cs,const char * ct)
  47. {
  48.   char __res;
  49.  
  50.   __asm__
  51.        ("1:\tmoveb %0@+,%2\n\t" /* get *cs */
  52.         "cmpb %1@+,%2\n\t"      /* compare a byte */
  53.         "jne  2f\n\t"           /* not equal, break out */
  54.         "tstb %2\n\t"           /* at end of cs? */
  55.         "jne  1b\n\t"           /* no, keep going */
  56.         "jra  3f\n\t"        /* strings are equal */
  57.         "2:\tsubb %1@-,%2\n\t"  /* *cs - *ct */
  58.         "3:"
  59.         : "=a" (cs), "=a" (ct), "=d" (__res)
  60.         : "0" (cs), "1" (ct));
  61.  
  62.   return __res;
  63. }
  64.  
  65. #define __HAVE_ARCH_STRNCMP
  66. static inline int strncmp(const char * cs,const char * ct,size_t count)
  67. {
  68.   char __res;
  69.  
  70.   if (!count)
  71.     return 0;
  72.   __asm__
  73.        ("1:\tmovb %0@+,%3\n\t"          /* get *cs */
  74.         "cmpb   %1@+,%3\n\t"            /* compare a byte */
  75.         "jne    3f\n\t"                 /* not equal, break out */
  76.         "tstb   %3\n\t"                 /* at end of cs? */
  77.         "jeq    4f\n\t"                 /* yes, all done */
  78.         "subql  #1,%2\n\t"              /* no, adjust count */
  79.         "jne    1b\n\t"                 /* more to do, keep going */
  80.         "2:\tmoveq #0,%3\n\t"           /* strings are equal */
  81.         "jra    4f\n\t"
  82.         "3:\tsubb %1@-,%3\n\t"          /* *cs - *ct */
  83.         "4:"
  84.         : "=a" (cs), "=a" (ct), "=d" (count), "=d" (__res)
  85.         : "0" (cs), "1" (ct), "2" (count));
  86.   return __res;
  87. }
  88.  
  89. #endif /* CONFIG_COLDFIRE */
  90.  
  91. #define __HAVE_ARCH_MEMSET
  92. extern void * memset(void * s, int c, size_t count);
  93.  
  94. #define __HAVE_ARCH_MEMCPY
  95. extern void * memcpy(void *d, const void *s, size_t count);
  96.  
  97. #else /* KERNEL */
  98.  
  99. /*
  100.  *    let user libraries deal with these,
  101.  *    IMHO the kernel has no place defining these functions for user apps
  102.  */
  103.  
  104. #define __HAVE_ARCH_STRCPY 1
  105. #define __HAVE_ARCH_STRNCPY 1
  106. #define __HAVE_ARCH_STRCAT 1
  107. #define __HAVE_ARCH_STRNCAT 1
  108. #define __HAVE_ARCH_STRCMP 1
  109. #define __HAVE_ARCH_STRNCMP 1
  110. #define __HAVE_ARCH_STRNICMP 1
  111. #define __HAVE_ARCH_STRCHR 1
  112. #define __HAVE_ARCH_STRRCHR 1
  113. #define __HAVE_ARCH_STRSTR 1
  114. #define __HAVE_ARCH_STRLEN 1
  115. #define __HAVE_ARCH_STRNLEN 1
  116. #define __HAVE_ARCH_MEMSET 1
  117. #define __HAVE_ARCH_MEMCPY 1
  118. #define __HAVE_ARCH_MEMMOVE 1
  119. #define __HAVE_ARCH_MEMSCAN 1
  120. #define __HAVE_ARCH_MEMCMP 1
  121. #define __HAVE_ARCH_MEMCHR 1
  122. #define __HAVE_ARCH_STRTOK 1
  123.  
  124. #endif /* KERNEL */
  125.  
  126. #endif /* _M68K_STRING_H_ */
  127.