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

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

Version: ~ [ linux-5.8 ] ~ [ linux-5.7.12 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.55 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.136 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.191 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.232 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.232 ] ~ [ 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 /*
  2  * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
  3  * Copyright (C) 2008-2009 PetaLogix
  4  * Copyright (C) 2007 John Williams
  5  *
  6  * Reasonably optimised generic C-code for memset on Microblaze
  7  * This is generic C code to do efficient, alignment-aware memcpy.
  8  *
  9  * It is based on demo code originally Copyright 2001 by Intel Corp, taken from
 10  * http://www.embedded.com/showArticle.jhtml?articleID=19205567
 11  *
 12  * Attempts were made, unsuccessfully, to contact the original
 13  * author of this code (Michael Morrow, Intel).  Below is the original
 14  * copyright notice.
 15  *
 16  * This software has been developed by Intel Corporation.
 17  * Intel specifically disclaims all warranties, express or
 18  * implied, and all liability, including consequential and
 19  * other indirect damages, for the use of this program, including
 20  * liability for infringement of any proprietary rights,
 21  * and including the warranties of merchantability and fitness
 22  * for a particular purpose. Intel does not assume any
 23  * responsibility for and errors which may appear in this program
 24  * not any responsibility to update it.
 25  */
 26 
 27 #include <linux/export.h>
 28 #include <linux/types.h>
 29 #include <linux/stddef.h>
 30 #include <linux/compiler.h>
 31 #include <linux/string.h>
 32 
 33 #ifdef __HAVE_ARCH_MEMSET
 34 #ifndef CONFIG_OPT_LIB_FUNCTION
 35 void *memset(void *v_src, int c, __kernel_size_t n)
 36 {
 37         char *src = v_src;
 38 
 39         /* Truncate c to 8 bits */
 40         c = (c & 0xFF);
 41 
 42         /* Simple, byte oriented memset or the rest of count. */
 43         while (n--)
 44                 *src++ = c;
 45 
 46         return v_src;
 47 }
 48 #else /* CONFIG_OPT_LIB_FUNCTION */
 49 void *memset(void *v_src, int c, __kernel_size_t n)
 50 {
 51         char *src = v_src;
 52         uint32_t *i_src;
 53         uint32_t w32 = 0;
 54 
 55         /* Truncate c to 8 bits */
 56         c = (c & 0xFF);
 57 
 58         if (unlikely(c)) {
 59                 /* Make a repeating word out of it */
 60                 w32 = c;
 61                 w32 |= w32 << 8;
 62                 w32 |= w32 << 16;
 63         }
 64 
 65         if (likely(n >= 4)) {
 66                 /* Align the destination to a word boundary */
 67                 /* This is done in an endian independent manner */
 68                 switch ((unsigned) src & 3) {
 69                 case 1:
 70                         *src++ = c;
 71                         --n;
 72                 case 2:
 73                         *src++ = c;
 74                         --n;
 75                 case 3:
 76                         *src++ = c;
 77                         --n;
 78                 }
 79 
 80                 i_src  = (void *)src;
 81 
 82                 /* Do as many full-word copies as we can */
 83                 for (; n >= 4; n -= 4)
 84                         *i_src++ = w32;
 85 
 86                 src  = (void *)i_src;
 87         }
 88 
 89         /* Simple, byte oriented memset or the rest of count. */
 90         while (n--)
 91                 *src++ = c;
 92 
 93         return v_src;
 94 }
 95 #endif /* CONFIG_OPT_LIB_FUNCTION */
 96 EXPORT_SYMBOL(memset);
 97 #endif /* __HAVE_ARCH_MEMSET */
 98 

~ [ 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