00001 /* 00002 * Copyright 2005 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 memset.c - replacement for memset(3), using duff's device. 00007 Copyright (C) 1995 - 1998 Michael Riepe <michael@stud.uni-hannover.de> 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Library General Public 00011 License as published by the Free Software Foundation; either 00012 version 2 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Library General Public License for more details. 00018 00019 You should have received a copy of the GNU Library General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 */ 00023 00024 #if HAVE_CONFIG_H 00025 # include <config.h> 00026 #endif /* HAVE_CONFIG_H */ 00027 00028 #ifndef lint 00029 static const char rcsid[] = "@(#) $Id: memset.c,v 1.1.1.1 2005/10/21 19:00:00 marcel Exp $"; 00030 #endif /* lint */ 00031 00032 #include <sys/types.h> 00033 00034 void* 00035 _elf_memset(void *s, int c, size_t n) { 00036 char *t = (char*)s; 00037 00038 if (n) { 00039 switch (n % 8u) { 00040 do { 00041 n -= 8; 00042 default: 00043 case 0: *t++ = (char)c; 00044 case 7: *t++ = (char)c; 00045 case 6: *t++ = (char)c; 00046 case 5: *t++ = (char)c; 00047 case 4: *t++ = (char)c; 00048 case 3: *t++ = (char)c; 00049 case 2: *t++ = (char)c; 00050 case 1: *t++ = (char)c; 00051 } 00052 while (n > 8); 00053 } 00054 } 00055 return s; 00056 }
1.5.6