-#ifndef _ERRNO_H_
-#define _ERRNO_H_
+/**
+ * Acess2 C Library
+ * - By John Hodge (thePowersGang)
+ *
+ * errno.h
+ * - Error values and related functions
+ */
+#ifndef _LIBC_ERRNO_H_
+#define _LIBC_ERRNO_H_
-// TODO: Fully implement errno.h, make sure it matches the kernel one
+#include <stddef.h> // size_t
-extern int _errno;
-#define errno _errno
+extern int *libc_geterrno(void);
+#define errno (*libc_geterrno())
-#define strerror(_x) "Unimplemented"
+extern int strerror_r(int errnum, char *buf, size_t buflen);
+extern char *strerror(int errnum);
-enum
-{
- EOK,
- EINVAL,
- ERANGE,
- ENODEV,
- EBADF,
- EINTR,
- EAGAIN,
- ENOMEM,
-
- EADDRNOTAVAIL,
- EINPROGRESS,
-
- E_LAST
-};
+#include "errno.enum.h"
#endif