@@ -22,3 +22,17 @@ log2_roundup(unsigned int i)
}
return rval;
}
+
+void *
+memchr_inv(const void *start, int c, size_t bytes)
+{
+ const unsigned char *p = start;
+
+ while (bytes > 0) {
+ if (*p != (unsigned char)c)
+ return (void *)p;
+ bytes--;
+ }
+
+ return NULL;
+}
@@ -6,6 +6,8 @@
#ifndef __LIBFROG_UTIL_H__
#define __LIBFROG_UTIL_H__
+#include <sys/types.h>
+
unsigned int log2_roundup(unsigned int i);
#define min_t(type,x,y) \
@@ -13,4 +15,6 @@ unsigned int log2_roundup(unsigned int i);
#define max_t(type,x,y) \
({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
+void *memchr_inv(const void *start, int c, size_t bytes);
+
#endif /* __LIBFROG_UTIL_H__ */