|
Last change
on this file since 3587 was 3574, checked in by bird, 18 years ago |
|
Generic kHlpString.h implementation.
|
-
Property svn:eol-style
set to
native
-
Property svn:keywords
set to
Id
|
|
File size:
1.7 KB
|
| Line | |
|---|
| 1 | /* $Id: kHlpMemSet.c 3574 2007-09-02 19:30:58Z bird $ */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * kHlpString - kHlpMemSet.
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /*
|
|---|
| 7 | * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
|---|
| 8 | *
|
|---|
| 9 | * This file is part of kStuff.
|
|---|
| 10 | *
|
|---|
| 11 | * kStuff is free software; you can redistribute it and/or
|
|---|
| 12 | * modify it under the terms of the GNU Lesser General Public
|
|---|
| 13 | * License as published by the Free Software Foundation; either
|
|---|
| 14 | * version 2.1 of the License, or (at your option) any later version.
|
|---|
| 15 | *
|
|---|
| 16 | * kStuff is distributed in the hope that it will be useful,
|
|---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 19 | * Lesser General Public License for more details.
|
|---|
| 20 | *
|
|---|
| 21 | * You should have received a copy of the GNU Lesser General Public
|
|---|
| 22 | * License along with kStuff; if not, write to the Free Software
|
|---|
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|---|
| 24 | *
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | /*******************************************************************************
|
|---|
| 28 | * Header Files *
|
|---|
| 29 | *******************************************************************************/
|
|---|
| 30 | #include <k/kHlpString.h>
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | KHLP_DECL(void *) kHlpMemSet(void *pv1, int ch, KSIZE cb)
|
|---|
| 34 | {
|
|---|
| 35 | union
|
|---|
| 36 | {
|
|---|
| 37 | void *pv;
|
|---|
| 38 | KU8 *pb;
|
|---|
| 39 | KUPTR *pu;
|
|---|
| 40 | } u1;
|
|---|
| 41 |
|
|---|
| 42 | u1.pv = pv1;
|
|---|
| 43 |
|
|---|
| 44 | if (cb >= 32)
|
|---|
| 45 | {
|
|---|
| 46 | KUPTR u = ch & 0xff;
|
|---|
| 47 | #if K_ARCH_BITS > 8
|
|---|
| 48 | u |= u << 8;
|
|---|
| 49 | #endif
|
|---|
| 50 | #if K_ARCH_BITS > 16
|
|---|
| 51 | u |= u << 16;
|
|---|
| 52 | #endif
|
|---|
| 53 | #if K_ARCH_BITS > 32
|
|---|
| 54 | u |= u << 32;
|
|---|
| 55 | #endif
|
|---|
| 56 | #if K_ARCH_BITS > 64
|
|---|
| 57 | u |= u << 64;
|
|---|
| 58 | #endif
|
|---|
| 59 |
|
|---|
| 60 | while (cb > sizeof(KUPTR))
|
|---|
| 61 | {
|
|---|
| 62 | cb -= sizeof(KUPTR);
|
|---|
| 63 | *u1.pu++ = u;
|
|---|
| 64 | }
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | while (cb-- > 0)
|
|---|
| 68 | *u1.pb++ = ch;
|
|---|
| 69 |
|
|---|
| 70 | return pv1;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.