]>
Commit | Line | Data |
---|---|---|
ada7c492 A |
1 | /* |
2 | * Copyright (c) 2013 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
24 | #include <platform/string.h> | |
25 | ||
26 | #if !_PLATFORM_OPTIMIZED_MEMSET_PATTERN4 | |
27 | ||
28 | void | |
29 | _platform_memset_pattern4(void *b, const void *pattern4, size_t len) | |
30 | { | |
31 | char * start = (char *)b; | |
32 | char * p = (char *)b; | |
33 | while ((start + len) - p >= 4) { | |
34 | _platform_memmove(p, pattern4, 4); | |
35 | p += 4; | |
36 | } | |
37 | if ((start + len) - p != 0) { | |
38 | _platform_memmove(p, pattern4, (start + len) - p); | |
39 | } | |
40 | } | |
41 | ||
42 | #if VARIANT_STATIC | |
43 | void | |
44 | memset_pattern4(void *b, const void *pattern4, size_t len) | |
45 | { | |
46 | return _platform_memset_pattern4(b, pattern4, len); | |
47 | } | |
48 | #endif | |
49 | ||
50 | #endif | |
51 | ||
52 | ||
53 | #if !_PLATFORM_OPTIMIZED_MEMSET_PATTERN8 | |
54 | ||
55 | void | |
56 | _platform_memset_pattern8(void *b, const void *pattern8, size_t len) | |
57 | { | |
58 | char * start = (char *)b; | |
59 | char * p = (char *)b; | |
60 | while ((start + len) - p >= 8) { | |
61 | _platform_memmove(p, pattern8, 8); | |
62 | p += 8; | |
63 | } | |
64 | if ((start + len) - p != 0) { | |
65 | _platform_memmove(p, pattern8, (start + len) - p); | |
66 | } | |
67 | } | |
68 | ||
69 | #if VARIANT_STATIC | |
70 | void | |
71 | memset_pattern8(void *b, const void *pattern8, size_t len) | |
72 | { | |
73 | return _platform_memset_pattern8(b, pattern8, len); | |
74 | } | |
75 | #endif | |
76 | ||
77 | #endif | |
78 | ||
79 | ||
80 | #if !_PLATFORM_OPTIMIZED_MEMSET_PATTERN16 | |
81 | ||
82 | void | |
83 | _platform_memset_pattern16(void *b, const void *pattern16, size_t len) | |
84 | { | |
85 | char * start = (char *)b; | |
86 | char * p = (char *)b; | |
87 | while ((start + len) - p >= 16) { | |
88 | _platform_memmove(p, pattern16, 16); | |
89 | p += 16; | |
90 | } | |
91 | if ((start + len) - p != 0) { | |
92 | _platform_memmove(p, pattern16, (start + len) - p); | |
93 | } | |
94 | } | |
95 | ||
96 | #if VARIANT_STATIC | |
97 | void | |
98 | memset_pattern16(void *b, const void *pattern16, size_t len) | |
99 | { | |
100 | return _platform_memset_pattern16(b, pattern16, len); | |
101 | } | |
102 | #endif | |
103 | ||
104 | #endif |