1 | /*
|
---|
2 | * Copyright (c) 2001-2004 Jakub Jermar
|
---|
3 | * Copyright (c) 2008 Jiri Svoboda
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * - Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | * - The name of the author may not be used to endorse or promote products
|
---|
16 | * derived from this software without specific prior written permission.
|
---|
17 | *
|
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
28 | */
|
---|
29 |
|
---|
30 | /** @addtogroup kernel_generic
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * @file
|
---|
36 | * @brief Memory string operations.
|
---|
37 | *
|
---|
38 | * This file provides architecture independent functions to manipulate blocks
|
---|
39 | * of memory. These functions are optimized as much as generic functions of
|
---|
40 | * this type can be.
|
---|
41 | */
|
---|
42 |
|
---|
43 | #include <memw.h>
|
---|
44 | #include <typedefs.h>
|
---|
45 |
|
---|
46 | /** Fill block of memory.
|
---|
47 | *
|
---|
48 | * Fill cnt bytes at dst address with the value val.
|
---|
49 | *
|
---|
50 | * @param dst Destination address to fill.
|
---|
51 | * @param cnt Number of bytes to fill.
|
---|
52 | * @param val Value to fill.
|
---|
53 | *
|
---|
54 | */
|
---|
55 | void memsetb(void *dst, size_t cnt, uint8_t val)
|
---|
56 | {
|
---|
57 | memset(dst, val, cnt);
|
---|
58 | }
|
---|
59 |
|
---|
60 | /** Fill block of memory.
|
---|
61 | *
|
---|
62 | * Fill cnt words at dst address with the value val. The filling
|
---|
63 | * is done word-by-word.
|
---|
64 | *
|
---|
65 | * @param dst Destination address to fill.
|
---|
66 | * @param cnt Number of words to fill.
|
---|
67 | * @param val Value to fill.
|
---|
68 | *
|
---|
69 | */
|
---|
70 | void memsetw(void *dst, size_t cnt, uint16_t val)
|
---|
71 | {
|
---|
72 | size_t i;
|
---|
73 | uint16_t *ptr = (uint16_t *) dst;
|
---|
74 |
|
---|
75 | for (i = 0; i < cnt; i++)
|
---|
76 | ptr[i] = val;
|
---|
77 | }
|
---|
78 |
|
---|
79 | /** @}
|
---|
80 | */
|
---|