diff --git a/libc/Makefile b/libc/Makefile
index 9981ae7a..8670e0ee 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -25,6 +25,7 @@ dirent/alphasort.o \
dirent/dir.o \
dirent/versionsort.o \
errno/errno.o \
+inttypes/imaxdiv.o \
inttypes/strtoimax.o \
inttypes/strtoumax.o \
inttypes/wcstoimax.o \
diff --git a/libc/include/inttypes.h b/libc/include/inttypes.h
index 0836025a..c454c6ad 100644
--- a/libc/include/inttypes.h
+++ b/libc/include/inttypes.h
@@ -200,8 +200,14 @@ __BEGIN_DECLS
@include(wchar_t.h)
+typedef struct
+{
+ intmax_t quot;
+ intmax_t rem;
+} imaxdiv_t;
+
intmax_t imaxabs(intmax_t);
-/* TODO: imaxdiv */
+imaxdiv_t imaxdiv(intmax_t, intmax_t);
intmax_t strtoimax(const char* __restrict, char** __restrict, int);
uintmax_t strtoumax(const char* __restrict, char** __restrict, int);
intmax_t wcstoimax(const wchar_t* __restrict, wchar_t** __restrict, int);
diff --git a/libc/inttypes/imaxdiv.cpp b/libc/inttypes/imaxdiv.cpp
new file mode 100644
index 00000000..a5ad4efc
--- /dev/null
+++ b/libc/inttypes/imaxdiv.cpp
@@ -0,0 +1,33 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2013
+
+ This file is part of the Sortix C Library.
+
+ The Sortix C Library is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ The Sortix C Library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with the Sortix C Library. If not, see .
+
+ inttypes/imaxdiv.cpp
+ Compute quotient and remainder of integer division.
+
+*******************************************************************************/
+
+#include
+
+extern "C" imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom)
+{
+ imaxdiv_t ret;
+ ret.quot = numer / denom;
+ ret.rem = numer % denom;
+ return ret;
+}