Index: abi/include/_bits/errno.h
===================================================================
--- abi/include/_bits/errno.h	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ abi/include/_bits/errno.h	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2017 CZ.NIC, z.s.p.o.
+ * 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.
+ */
+
+/* Authors:
+ *	Jiří Zárevúcky (jzr) <zarevucky.jiri@gmail.com>
+ */
+
+/** @addtogroup bits
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _BITS_ERRNO_H_
+#define _BITS_ERRNO_H_
+
+#ifdef __OPAQUE_ERRNO__
+#include <_bits/opaque_handle.h>
+
+opaque_handle(errno_t);
+typedef errno_t sys_errno_t;
+#define __errno_t(val) ((errno_t) val)
+
+#else
+
+#include <_bits/native.h>
+
+/**
+ * The type of <errno.h> constants. Normally, this is an alias for `int`,
+ * but we support an alternative definition that allows us to verify
+ * integrity of error handling without using external tools.
+ */
+typedef int errno_t;
+
+/**
+ * Same as `errno_t`, except represented as `sysarg_t`. Used in kernel in
+ * places where error number is always passed, but the type must be `sysarg_t`.
+ */
+typedef sysarg_t sys_errno_t;
+
+/**
+ * A C++-style "cast" to `errno_t`.
+ * Used in <abi/errno.h> to define error constants. Normally, it doesn't do
+ * anything at all.
+ */
+#define __errno_t(val) val
+
+#endif
+
+#endif
Index: abi/include/_bits/opaque_handle.h
===================================================================
--- abi/include/_bits/opaque_handle.h	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ abi/include/_bits/opaque_handle.h	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017 CZ.NIC, z.s.p.o.
+ * 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.
+ */
+
+/* Authors:
+ *	Jiří Zárevúcky (jzr) <zarevucky.jiri@gmail.com>
+ */
+
+/** @addtogroup bits
+ * @{
+ */
+
+#ifndef _BITS_OPAQUE_HANDLE_H_
+#define _BITS_OPAQUE_HANDLE_H_
+
+#define opaque_handle(__name) typedef struct __opaque_##__name *__name
+
+#endif
+
+/** @}
+ */
Index: abi/include/abi/errno.h
===================================================================
--- abi/include/abi/errno.h	(revision a1026daf544b91d3c8e6d81817113aece3c7440e)
+++ abi/include/abi/errno.h	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
@@ -1,38 +1,44 @@
 /* Generated file. Edit errno.in instead. */
-#define EOK                   0
-#define ENOENT               -1
-#define ENOMEM               -2
-#define ELIMIT               -3
-#define EREFUSED             -4
-#define EFORWARD             -5
-#define EPERM                -6
-#define EHANGUP              -7
-#define EPARTY               -8
-#define EEXIST               -9
-#define EBADMEM             -10
-#define ENOTSUP             -11
-#define EADDRNOTAVAIL       -12
-#define ETIMEOUT            -13
-#define EINVAL              -14
-#define EBUSY               -15
-#define EOVERFLOW           -16
-#define EINTR               -17
-#define EMFILE              -18
-#define ENAMETOOLONG       -256
-#define EISDIR             -257
-#define ENOTDIR            -258
-#define ENOSPC             -259
-#define ENOTEMPTY          -261
-#define EBADF              -262
-#define EDOM               -263
-#define ERANGE             -264
-#define EXDEV              -265
-#define EIO                -266
-#define EMLINK             -267
-#define ENXIO              -268
-#define ENOFS              -269
-#define EBADCHECKSUM       -300
-#define ESTALL             -301
-#define EEMPTY             -302
-#define ENAK               -303
-#define EAGAIN           -11002
+#define EOK             __errno_t(      0)
+#define ENOENT          __errno_t(     -1)
+#define ENOMEM          __errno_t(     -2)
+#define ELIMIT          __errno_t(     -3)
+#define EREFUSED        __errno_t(     -4)
+#define EFORWARD        __errno_t(     -5)
+#define EPERM           __errno_t(     -6)
+#define EHANGUP         __errno_t(     -7)
+#define EPARTY          __errno_t(     -8)
+#define EEXIST          __errno_t(     -9)
+#define EBADMEM         __errno_t(    -10)
+#define ENOTSUP         __errno_t(    -11)
+#define EADDRNOTAVAIL   __errno_t(    -12)
+#define ETIMEOUT        __errno_t(    -13)
+#define EINVAL          __errno_t(    -14)
+#define EBUSY           __errno_t(    -15)
+#define EOVERFLOW       __errno_t(    -16)
+#define EINTR           __errno_t(    -17)
+#define EMFILE          __errno_t(    -18)
+#define ENAMETOOLONG    __errno_t(   -256)
+#define EISDIR          __errno_t(   -257)
+#define ENOTDIR         __errno_t(   -258)
+#define ENOSPC          __errno_t(   -259)
+#define ENOTEMPTY       __errno_t(   -261)
+#define EBADF           __errno_t(   -262)
+#define EDOM            __errno_t(   -263)
+#define ERANGE          __errno_t(   -264)
+#define EXDEV           __errno_t(   -265)
+#define EIO             __errno_t(   -266)
+#define EMLINK          __errno_t(   -267)
+#define ENXIO           __errno_t(   -268)
+#define ENOFS           __errno_t(   -269)
+#define EBADCHECKSUM    __errno_t(   -300)
+#define ESTALL          __errno_t(   -301)
+#define EEMPTY          __errno_t(   -302)
+#define ENAK            __errno_t(   -303)
+#define EAGAIN          __errno_t( -11002)
+
+#define HTTP_EMULTIPLE_HEADERS  __errno_t( -20001)
+#define HTTP_EMISSING_HEADER    __errno_t( -20002)
+#define HTTP_EPARSE             __errno_t( -20003)
+
+#define EXT4_ERR_BAD_DX_DIR     __errno_t( -75000)
Index: abi/include/abi/errno.in
===================================================================
--- abi/include/abi/errno.in	(revision a1026daf544b91d3c8e6d81817113aece3c7440e)
+++ abi/include/abi/errno.in	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
@@ -35,3 +35,9 @@
 __errno_entry(EEMPTY         ,   -302, "Resource is empty")
 __errno_entry(ENAK           ,   -303, "Negative acknowledgement")
-__errno_entry(EAGAIN         , -11002, "Operation could not proceed. Try again.")
+__errno_entry(EAGAIN         , -11002, "Operation could not proceed, try again")
+
+__errno_entry(HTTP_EMULTIPLE_HEADERS , -20001, "HTTP: Multiple headers")  // libhttp error codes. Defining them here is a temporary hack.
+__errno_entry(HTTP_EMISSING_HEADER   , -20002, "HTTP: Missing header")
+__errno_entry(HTTP_EPARSE            , -20003, "HTTP: Parse error")
+
+__errno_entry(EXT4_ERR_BAD_DX_DIR    , -75000, "EXT4: Filesystem corrupted")  // libext4
Index: abi/include/abi/ipc/ipc.h
===================================================================
--- abi/include/abi/ipc/ipc.h	(revision a1026daf544b91d3c8e6d81817113aece3c7440e)
+++ abi/include/abi/ipc/ipc.h	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
@@ -70,5 +70,5 @@
 
 /* Macros for manipulating calling data */
-#define IPC_SET_RETVAL(data, retval)  ((data).args[0] = (retval))
+#define IPC_SET_RETVAL(data, retval)  ((data).args[0] = (sysarg_t) (retval))
 #define IPC_SET_IMETHOD(data, val)    ((data).args[0] = (val))
 #define IPC_SET_ARG1(data, val)       ((data).args[1] = (val))
@@ -79,5 +79,5 @@
 
 #define IPC_GET_IMETHOD(data)  ((data).args[0])
-#define IPC_GET_RETVAL(data)   ((data).args[0])
+#define IPC_GET_RETVAL(data)   ((errno_t) (data).args[0])
 
 #define IPC_GET_ARG1(data)  ((data).args[1])
