Permalink
Browse files

Add naive memset_pattern(4|8|16)

This is necessary for clang in xcode 4.1
They might be slow, but should be OK. clang doesn't use them heavily.
  • Loading branch information...
1 parent e754644 commit 8e6140a67306b72a422731b352a219f6296a0c77 @shinh committed Nov 13, 2011
Showing with 23 additions and 0 deletions.
  1. +23 −0 libmac/mac.c
View
@@ -916,6 +916,29 @@ size_t strlcat(char* dst, const char* src, size_t size) {
return strlen(dst);
}
+// TODO(hamaji): The following three functions are slow.
+
+void memset_pattern4(char* b, const char* pattern4, size_t len) {
+ size_t i;
+ for (i = 0; i < len; i++) {
+ b[i] = pattern4[i % 4];
+ }
+}
+
+void memset_pattern8(char* b, const char* pattern4, size_t len) {
+ size_t i;
+ for (i = 0; i < len; i++) {
+ b[i] = pattern4[i % 8];
+ }
+}
+
+void memset_pattern16(char* b, const char* pattern4, size_t len) {
+ size_t i;
+ for (i = 0; i < len; i++) {
+ b[i] = pattern4[i % 16];
+ }
+}
+
int __mb_cur_max() {
// TODO(hamaji): Incorrect for most locales.
return 1;

0 comments on commit 8e6140a

Please sign in to comment.