// Copyright (2013) Jann Horn <jann@thejh.net>
-// This code is licensed under the AGPLv3.
-#include <string.h>
+#ifdef __SSE2__
#include <emmintrin.h>
+#endif
+
+#include <string.h>
HEADER #include <stdint.h>
HEADER #define streq(a,b) (!strcmp((a),(b)))
+HEADER #define TPRINTF(name, ...) \
+HEADER char *name; \
+HEADER do { \
+HEADER int __tprintf_size = snprintf(NULL, 0, __VA_ARGS__); \
+HEADER assert(__tprintf_size != -1); \
+HEADER name = alloca(__tprintf_size+1); \
+HEADER int __tprintf_size2 = snprintf(name, __tprintf_size+1, __VA_ARGS__); \
+HEADER assert(__tprintf_size == __tprintf_size2); \
+HEADER } while (0); //////////////////////////////////////////////////////////
+
PUBLIC_FN int count_char_occurences(char *s, char c) {
int n=0;
while (*s) {
size_t res = 0;
#ifdef __SSE2__
- #include <emmintrin.h>
// do it the simple way until we get to the next 16-byte-aligned address
while ((((uint64_t)b)&0xf) && b<be) if (*(b++)==c) res++;
int res = 0;
#ifdef __SSE2__
- #include <emmintrin.h>
// do it the simple way until we get to the next 16-byte-aligned address
while ((((uint64_t)b)&0xf) && b<be) if (*(b++)==c) res++;