~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/m68k/lib/memset.c

Version: ~ [ linux-5.9 ] ~ [ linux-5.8.14 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.70 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.150 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.200 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.238 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.238 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <linux/types.h>
  2 
  3 void * memset(void * s, int c, size_t count)
  4 {
  5   void *xs = s;
  6   size_t temp, temp1;
  7 
  8   if (!count)
  9     return xs;
 10   c &= 0xff;
 11   c |= c << 8;
 12   c |= c << 16;
 13   if ((long) s & 1)
 14     {
 15       char *cs = s;
 16       *cs++ = c;
 17       s = cs;
 18       count--;
 19     }
 20   if (count > 2 && (long) s & 2)
 21     {
 22       short *ss = s;
 23       *ss++ = c;
 24       s = ss;
 25       count -= 2;
 26     }
 27   temp = count >> 2;
 28   if (temp)
 29     {
 30       long *ls = s;
 31 
 32       __asm__ __volatile__("movel %1,%2\n\t"
 33                            "andw  #7,%2\n\t"
 34                            "lsrl  #3,%1\n\t"
 35                            "negw  %2\n\t"
 36                            "jmp   %%pc@(2f,%2:w:2)\n\t"
 37                            "1:\t"
 38                            "movel %3,%0@+\n\t"
 39                            "movel %3,%0@+\n\t"
 40                            "movel %3,%0@+\n\t"
 41                            "movel %3,%0@+\n\t"
 42                            "movel %3,%0@+\n\t"
 43                            "movel %3,%0@+\n\t"
 44                            "movel %3,%0@+\n\t"
 45                            "movel %3,%0@+\n\t"
 46                            "2:\t"
 47                            "dbra  %1,1b\n\t"
 48                            "clrw  %1\n\t"
 49                            "subql #1,%1\n\t"
 50                            "jpl   1b\n\t"
 51                            : "=a" (ls), "=d" (temp), "=&d" (temp1)
 52                            : "d" (c), "" (ls), "1" (temp)
 53                            );
 54       s = ls;
 55     }
 56   if (count & 2)
 57     {
 58       short *ss = s;
 59       *ss++ = c;
 60       s = ss;
 61     }
 62   if (count & 1)
 63     {
 64       char *cs = s;
 65       *cs = c;
 66     }
 67   return xs;
 68 }
 69 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp