Index: uspace/lib/bithenge/Makefile.linux
===================================================================
--- uspace/lib/bithenge/Makefile.linux	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/Makefile.linux	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -53,5 +53,5 @@
 ifdef FAILURE
 	CFLAGS += -DBITHENGE_FAILURE_ENABLE=1
-	SOURCES += failure.c
+	SOURCES += src/failure.c
 endif
 
Index: uspace/lib/bithenge/include/bithenge/blob.h
===================================================================
--- uspace/lib/bithenge/include/bithenge/blob.h	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/include/bithenge/blob.h	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -39,4 +39,5 @@
 
 #include <sys/types.h>
+#include <errno.h>
 #include "tree.h"
 
Index: uspace/lib/bithenge/include/bithenge/helenos/os.h
===================================================================
--- uspace/lib/bithenge/include/bithenge/helenos/os.h	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ 	(revision )
@@ -1,93 +1,0 @@
-/*
- * Copyright (c) 2012 Sean Bartell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BITHENGE_HELENOS_OS_H_
-#define BITHENGE_HELENOS_OS_H_
-
-#include <bool.h>
-#include <byteorder.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <macros.h>
-#include <mem.h>
-#include <stdlib.h>
-#include <str.h>
-#include <str_error.h>
-
-typedef int64_t bithenge_int_t;
-#define BITHENGE_PRId PRId64
-
-typedef struct {
-	const char *string;
-	size_t offset;
-	wchar_t ch;
-} string_iterator_t;
-
-static inline string_iterator_t string_iterator(const char *string)
-{
-	string_iterator_t i;
-	i.string = string;
-	i.offset = 0;
-	i.ch = str_decode(i.string, &i.offset, STR_NO_LIMIT);
-	return i;
-}
-
-static inline bool string_iterator_done(const string_iterator_t *i)
-{
-	return i->ch == L'\0';
-}
-
-static inline int string_iterator_next(string_iterator_t *i, wchar_t *out)
-{
-	*out = i->ch;
-	if (*out == U_SPECIAL)
-		return EINVAL;
-	i->ch = str_decode(i->string, &i->offset, STR_NO_LIMIT);
-	return EOK;
-}
-
-static inline void *memchr(const void *s, int c, size_t n)
-{
-	for (size_t i = 0; i < n; i++)
-		if (((char *)s)[i] == c)
-			return (void *)(s + i);
-	return NULL;
-}
-
-static inline int bithenge_parse_int(const char *start, bithenge_int_t *result)
-{
-	const char *real_start = *start == '-' ? start + 1 : start;
-	uint64_t val;
-	int rc = str_uint64_t(real_start, NULL, 10, false, &val);
-	*result = val;
-	if (*start == '-')
-		*result = -*result;
-	return rc;
-}
-
-#endif
Index: uspace/lib/bithenge/include/bithenge/linux/os.h
===================================================================
--- uspace/lib/bithenge/include/bithenge/linux/os.h	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ 	(revision )
@@ -1,141 +1,0 @@
-/*
- * Copyright (c) 2012 Sean Bartell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BITHENGE_LINUX_OS_H_
-#define BITHENGE_LINUX_OS_H_
-
-#include <endian.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <memory.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
-#include <wchar.h>
-
-#define max(aleph, bet) ((aleph) > (bet) ? (aleph) : (bet))
-#define min(aleph, bet) ((aleph) < (bet) ? (aleph) : (bet))
-
-#define EOK 0
-#define ELIMIT EINVAL
-
-typedef intmax_t bithenge_int_t;
-#define BITHENGE_PRId PRIdMAX
-typedef uint64_t aoff64_t;
-typedef const char *string_iterator_t;
-
-static inline string_iterator_t string_iterator(const char *string)
-{
-	return string;
-}
-
-static inline int string_iterator_next(string_iterator_t *i, wchar_t *out)
-{
-	wint_t rc = btowc(*(*i)++); // TODO
-	*out = (wchar_t) rc;
-	return rc == WEOF ? EILSEQ : EOK;
-}
-
-static inline bool string_iterator_done(const string_iterator_t *i)
-{
-	return !**i;
-}
-
-static inline size_t str_length(const char *string)
-{
-	return strlen(string);
-}
-
-static inline const char *str_chr(const char *string, wchar_t ch)
-{
-	return strchr(string, wctob(ch)); // TODO
-}
-
-static inline int str_cmp(const char *s1, const char *s2)
-{
-	return strcmp(s1, s2);
-}
-
-static inline int str_lcmp(const char *s1, const char *s2, size_t max_len)
-{
-	return strncmp(s1, s2, max_len);
-}
-
-static inline char *str_dup(const char *s)
-{
-	return strdup(s);
-}
-
-static inline char *str_ndup(const char *s, size_t max_len)
-{
-	return strndup(s, max_len);
-}
-
-static inline const char *str_error(int e)
-{
-	return strerror(e);
-}
-
-static inline uint16_t uint16_t_le2host(uint16_t val)
-{
-	return le16toh(val);
-}
-
-static inline uint16_t uint16_t_be2host(uint16_t val)
-{
-	return be16toh(val);
-}
-
-static inline uint32_t uint32_t_le2host(uint32_t val)
-{
-	return le32toh(val);
-}
-
-static inline uint32_t uint32_t_be2host(uint32_t val)
-{
-	return be32toh(val);
-}
-
-static inline uint64_t uint64_t_le2host(uint64_t val)
-{
-	return le64toh(val);
-}
-
-static inline uint64_t uint64_t_be2host(uint64_t val)
-{
-	return be64toh(val);
-}
-
-static inline int bithenge_parse_int(const char *start, bithenge_int_t *result)
-{
-	errno = 0;
-	*result = strtoll(start, NULL, 10);
-	return errno;
-}
-
-#endif
Index: uspace/lib/bithenge/include/bithenge/os.h
===================================================================
--- uspace/lib/bithenge/include/bithenge/os.h	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/include/bithenge/os.h	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2012 Sean Bartell
+ * Copyright (c) 2012 Vojtech Horky
  * All rights reserved.
  *
@@ -30,17 +31,19 @@
 #define BITHENGE_OS_H_
 
+
 #ifdef __HELENOS__
-#include "helenos/os.h"
+typedef int64_t bithenge_int_t;
+#define BITHENGE_PRId PRId64
+
 #else
-#include "linux/os.h"
-#endif
+/* Assuming GNU/Linux system. */
 
-#ifdef BITHENGE_FAILURE_ENABLE
-#include "failure.h"
-#else
-static inline int bithenge_should_fail(void)
-{
-	return 0;
-}
+#include <inttypes.h>
+#include <stdbool.h>
+#define BITHENGE_PRId PRIdMAX
+typedef intmax_t bithenge_int_t;
+typedef uint64_t aoff64_t;
+#define EOK 0
+
 #endif
 
Index: uspace/lib/bithenge/src/blob.c
===================================================================
--- uspace/lib/bithenge/src/blob.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/blob.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -38,6 +38,6 @@
 #include <errno.h>
 #include <stdlib.h>
+#include "common.h"
 #include <bithenge/blob.h>
-#include <bithenge/os.h>
 #include <bithenge/tree.h>
 
Index: uspace/lib/bithenge/src/common.h
===================================================================
--- uspace/lib/bithenge/src/common.h	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
+++ uspace/lib/bithenge/src/common.h	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012 Sean Bartell
+ * Copyright (c) 2012 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BITHENGE_COMMON_H_
+#define BITHENGE_COMMON_H_
+
+#ifdef __HELENOS__
+#include "helenos/common.h"
+#else
+#include "linux/common.h"
+#endif
+
+#ifdef BITHENGE_FAILURE_ENABLE
+#include "failure.h"
+#else
+static inline int bithenge_should_fail(void)
+{
+	return 0;
+}
+#endif
+
+#endif
Index: uspace/lib/bithenge/src/compound.c
===================================================================
--- uspace/lib/bithenge/src/compound.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/compound.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -38,7 +38,7 @@
 #include <bithenge/compound.h>
 #include <bithenge/expression.h>
-#include <bithenge/os.h>
 #include <bithenge/transform.h>
 #include <bithenge/tree.h>
+#include "common.h"
 
 
Index: uspace/lib/bithenge/src/expression.c
===================================================================
--- uspace/lib/bithenge/src/expression.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/expression.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -38,7 +38,7 @@
 #include <errno.h>
 #include <stdlib.h>
+#include "common.h"
 #include <bithenge/blob.h>
 #include <bithenge/expression.h>
-#include <bithenge/os.h>
 #include <bithenge/transform.h>
 #include <bithenge/tree.h>
Index: uspace/lib/bithenge/src/failure.c
===================================================================
--- uspace/lib/bithenge/src/failure.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/failure.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -46,6 +46,6 @@
 #include <unistd.h>
 #define BITHENGE_FAILURE_DECLS_ONLY 1
-#include <bithenge/failure.h>
-#include "os.h"
+#include "failure.h"
+#include "common.h"
 
 /* This file raises fake errors from system calls, to test that Bithenge
Index: uspace/lib/bithenge/src/failure.h
===================================================================
--- uspace/lib/bithenge/src/failure.h	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/failure.h	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -45,5 +45,4 @@
 #include <sys/types.h>
 #include <unistd.h>
-#include "os.h"
 
 int bithenge_should_fail(void);
Index: uspace/lib/bithenge/src/file.c
===================================================================
--- uspace/lib/bithenge/src/file.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/file.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -44,7 +44,7 @@
 #include <sys/types.h>
 #include <unistd.h>
+#include "common.h"
 #include <bithenge/blob.h>
 #include <bithenge/file.h>
-#include <bithenge/os.h>
 
 typedef struct {
Index: uspace/lib/bithenge/src/helenos/common.h
===================================================================
--- uspace/lib/bithenge/src/helenos/common.h	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
+++ uspace/lib/bithenge/src/helenos/common.h	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2012 Sean Bartell
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BITHENGE_HELENOS_COMMON_H_
+#define BITHENGE_HELENOS_COMMON_H_
+
+#include <bithenge/os.h>
+#include <bool.h>
+#include <byteorder.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <macros.h>
+#include <mem.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <str.h>
+#include <str_error.h>
+
+#define BITHENGE_PRId PRId64
+
+typedef struct {
+	const char *string;
+	size_t offset;
+	wchar_t ch;
+} string_iterator_t;
+
+static inline string_iterator_t string_iterator(const char *string)
+{
+	string_iterator_t i;
+	i.string = string;
+	i.offset = 0;
+	i.ch = str_decode(i.string, &i.offset, STR_NO_LIMIT);
+	return i;
+}
+
+static inline bool string_iterator_done(const string_iterator_t *i)
+{
+	return i->ch == L'\0';
+}
+
+static inline int string_iterator_next(string_iterator_t *i, wchar_t *out)
+{
+	*out = i->ch;
+	if (*out == U_SPECIAL)
+		return EINVAL;
+	i->ch = str_decode(i->string, &i->offset, STR_NO_LIMIT);
+	return EOK;
+}
+
+static inline void *memchr(const void *s, int c, size_t n)
+{
+	for (size_t i = 0; i < n; i++)
+		if (((char *)s)[i] == c)
+			return (void *)(s + i);
+	return NULL;
+}
+
+static inline int bithenge_parse_int(const char *start, bithenge_int_t *result)
+{
+	const char *real_start = *start == '-' ? start + 1 : start;
+	uint64_t val;
+	int rc = str_uint64_t(real_start, NULL, 10, false, &val);
+	*result = val;
+	if (*start == '-')
+		*result = -*result;
+	return rc;
+}
+
+#endif
Index: uspace/lib/bithenge/src/linux/common.h
===================================================================
--- uspace/lib/bithenge/src/linux/common.h	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
+++ uspace/lib/bithenge/src/linux/common.h	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2012 Sean Bartell
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BITHENGE_LINUX_COMMON_H_
+#define BITHENGE_LINUX_COMMON_H_
+
+#include <endian.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <memory.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+#define max(aleph, bet) ((aleph) > (bet) ? (aleph) : (bet))
+#define min(aleph, bet) ((aleph) < (bet) ? (aleph) : (bet))
+
+#define EOK 0
+#define ELIMIT EINVAL
+
+typedef intmax_t bithenge_int_t;
+#define BITHENGE_PRId PRIdMAX
+typedef uint64_t aoff64_t;
+typedef const char *string_iterator_t;
+
+static inline string_iterator_t string_iterator(const char *string)
+{
+	return string;
+}
+
+static inline int string_iterator_next(string_iterator_t *i, wchar_t *out)
+{
+	wint_t rc = btowc(*(*i)++); // TODO
+	*out = (wchar_t) rc;
+	return rc == WEOF ? EILSEQ : EOK;
+}
+
+static inline bool string_iterator_done(const string_iterator_t *i)
+{
+	return !**i;
+}
+
+static inline size_t str_length(const char *string)
+{
+	return strlen(string);
+}
+
+static inline const char *str_chr(const char *string, wchar_t ch)
+{
+	return strchr(string, wctob(ch)); // TODO
+}
+
+static inline int str_cmp(const char *s1, const char *s2)
+{
+	return strcmp(s1, s2);
+}
+
+static inline int str_lcmp(const char *s1, const char *s2, size_t max_len)
+{
+	return strncmp(s1, s2, max_len);
+}
+
+static inline char *str_dup(const char *s)
+{
+	return strdup(s);
+}
+
+static inline char *str_ndup(const char *s, size_t max_len)
+{
+	return strndup(s, max_len);
+}
+
+static inline const char *str_error(int e)
+{
+	return strerror(e);
+}
+
+static inline uint16_t uint16_t_le2host(uint16_t val)
+{
+	return le16toh(val);
+}
+
+static inline uint16_t uint16_t_be2host(uint16_t val)
+{
+	return be16toh(val);
+}
+
+static inline uint32_t uint32_t_le2host(uint32_t val)
+{
+	return le32toh(val);
+}
+
+static inline uint32_t uint32_t_be2host(uint32_t val)
+{
+	return be32toh(val);
+}
+
+static inline uint64_t uint64_t_le2host(uint64_t val)
+{
+	return le64toh(val);
+}
+
+static inline uint64_t uint64_t_be2host(uint64_t val)
+{
+	return be64toh(val);
+}
+
+static inline int bithenge_parse_int(const char *start, bithenge_int_t *result)
+{
+	errno = 0;
+	*result = strtoll(start, NULL, 10);
+	return errno;
+}
+
+#endif
Index: uspace/lib/bithenge/src/print.c
===================================================================
--- uspace/lib/bithenge/src/print.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/print.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -43,4 +43,5 @@
 #include <bithenge/print.h>
 #include <bithenge/tree.h>
+#include "common.h"
 
 typedef struct {
Index: uspace/lib/bithenge/src/script.c
===================================================================
--- uspace/lib/bithenge/src/script.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/script.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -40,9 +40,9 @@
 #include <bithenge/compound.h>
 #include <bithenge/expression.h>
-#include <bithenge/os.h>
 #include <bithenge/script.h>
 #include <bithenge/sequence.h>
 #include <bithenge/transform.h>
 #include <bithenge/tree.h>
+#include "common.h"
 
 /** @cond internal */
Index: uspace/lib/bithenge/src/sequence.c
===================================================================
--- uspace/lib/bithenge/src/sequence.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/sequence.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -38,7 +38,7 @@
 #include <bithenge/blob.h>
 #include <bithenge/expression.h>
-#include <bithenge/os.h>
 #include <bithenge/sequence.h>
 #include <bithenge/tree.h>
+#include "common.h"
 
 
Index: uspace/lib/bithenge/src/source.c
===================================================================
--- uspace/lib/bithenge/src/source.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/source.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -40,4 +40,5 @@
 #include <bithenge/file.h>
 #include <bithenge/source.h>
+#include "common.h"
 
 #ifdef __HELENOS__
Index: uspace/lib/bithenge/src/transform.c
===================================================================
--- uspace/lib/bithenge/src/transform.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/transform.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -40,7 +40,7 @@
 #include <stdlib.h>
 #include <bithenge/blob.h>
-#include <bithenge/os.h>
 #include <bithenge/print.h>
 #include <bithenge/transform.h>
+#include "common.h"
 
 
Index: uspace/lib/bithenge/src/tree.c
===================================================================
--- uspace/lib/bithenge/src/tree.c	(revision 2ee052618efd63ef34d285c7fec3254af7d6e49c)
+++ uspace/lib/bithenge/src/tree.c	(revision be1dcc2699d4c96f7d72aa17f9743e49dfc9ec30)
@@ -38,6 +38,6 @@
 #include <stdlib.h>
 #include <bithenge/blob.h>
-#include <bithenge/os.h>
 #include <bithenge/tree.h>
+#include "common.h"
 
 static void blob_destroy(bithenge_node_t *base)
