diff --git a/libc/Makefile b/libc/Makefile
index 8d9985cf..8464bcf3 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -17,22 +17,13 @@ CXXFLAGS=-std=gnu++11 -fno-exceptions -fno-rtti
ASFLAGS=
FREEOBJS=\
-abort.o \
-abs.o \
_assert.o \
-atof.o \
-atoi.o \
-atoll.o \
-atol.o \
-bsearch.o \
-calloc.o \
clearerr.o \
c++.o \
ctype.o \
dirent/alphasort.o \
dirent/dir.o \
dirent/versionsort.o \
-div.o \
errno.o \
fabs.o \
fbufsize.o \
@@ -72,13 +63,6 @@ fwrite.o \
fwriting.o \
getdelim.o \
getline.o \
-heap.o \
-integer.o \
-ldiv.o \
-lldiv.o \
-mblen.o \
-mbstowcs.o \
-mbtowc.o \
op-new.o \
rewind.o \
setbuf.o \
@@ -88,9 +72,30 @@ sigdelset.o \
sigemptyset.o \
sigfillset.o \
sigismember.o \
-sort.o \
sprint.o \
sscanf.o \
+stdlib/abort.o \
+stdlib/abs.o \
+stdlib/atof.o \
+stdlib/atoi.o \
+stdlib/atoll.o \
+stdlib/atol.o \
+stdlib/bsearch.o \
+stdlib/calloc.o \
+stdlib/div.o \
+stdlib/heap.o \
+stdlib/integer.o \
+stdlib/ldiv.o \
+stdlib/lldiv.o \
+stdlib/mblen.o \
+stdlib/mbstowcs.o \
+stdlib/mbtowc.o \
+stdlib/qsort.o \
+stdlib/strtod.o \
+stdlib/strtof.o \
+stdlib/strtold.o \
+stdlib/wcstombs.o \
+stdlib/wctomb.o \
string/memccpy.o \
string/memchr.o \
string/memcmp.o \
@@ -125,9 +130,6 @@ string/strtok.o \
string/strtok_r.o \
string/strverscmp.o \
string/strxfrm.o \
-strtod.o \
-strtof.o \
-strtold.o \
time/asctime.o \
time/asctime_r.o \
time/gmtime.o \
@@ -156,8 +158,6 @@ wchar/wcsrchr.o \
wchar/wcsrtombs.o \
wchar/wcsspn.o \
wchar/wcstok.o \
-wcstombs.o \
-wctomb.o \
wctype.o \
HOSTEDOBJS=\
@@ -169,8 +169,6 @@ arpa/inet/inet_ntoa.o \
arpa/inet/inet_ntop.o \
arpa/inet/inet_pton.o \
calltrace.o \
-canonicalize_file_name_at.o \
-canonicalize_file_name.o \
chdir.o \
chmod.o \
chown.o \
@@ -189,7 +187,6 @@ dispmsg_issue.o \
dlfcn.o \
dup2.o \
dup.o \
-env.o \
errorprint.o \
execle.o \
execl.o \
@@ -199,8 +196,6 @@ execv.o \
execvpe.o \
execvp.o \
_exit.o \
-_Exit.o \
-exit.o \
faccessat.o \
fchdirat.o \
fchdir.o \
@@ -266,7 +261,6 @@ memstat.o \
mkdirat.o \
mkdir.o \
mkpartition.o \
-mktemp.o \
netdb/endhostent.o \
netdb/endnetent.o \
netdb/endprotoent.o \
@@ -289,7 +283,6 @@ netdb/sethostent.o \
netdb/setnetent.o \
netdb/setprotoent.o \
netdb/setservent.o \
-on_exit.o \
openat.o \
open.o \
pathconf.o \
@@ -304,13 +297,11 @@ putc.o \
pwent.o \
pwritev.o \
raise.o \
-rand.o \
readdirents.o \
readlinkat.o \
readlink.o \
read.o \
readv.o \
-realpath.o \
removeat.o \
remove.o \
renameat.o \
@@ -336,6 +327,16 @@ sigprocmask.o \
sleep.o \
stat.o \
stdio.o \
+stdlib/canonicalize_file_name_at.o \
+stdlib/canonicalize_file_name.o \
+stdlib/env.o \
+stdlib/_Exit.o \
+stdlib/exit.o \
+stdlib/mktemp.o \
+stdlib/on_exit.o \
+stdlib/rand.o \
+stdlib/realpath.o \
+stdlib/system.o \
sysconf.o \
sys/socket/accept4.o \
sys/socket/accept.o \
@@ -356,7 +357,6 @@ sys/socket/shutdown.o \
sys/socket/sockatmark.o \
sys/socket/socket.o \
sys/socket/socketpair.o \
-system.o \
sys/time/gettimeofday.o \
tcgetpgrp.o \
tcgetwinsize.o \
diff --git a/libc/sortix/stdlib/.gitignore b/libc/sortix/stdlib/.gitignore
new file mode 100644
index 00000000..e69de29b
diff --git a/libc/_Exit.cpp b/libc/stdlib/_Exit.cpp
similarity index 98%
rename from libc/_Exit.cpp
rename to libc/stdlib/_Exit.cpp
index e8c4100e..fc2c7efa 100644
--- a/libc/_Exit.cpp
+++ b/libc/stdlib/_Exit.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- _Exit.cpp
+ stdlib/_Exit.cpp
Terminates the current process.
*******************************************************************************/
diff --git a/libc/abort.cpp b/libc/stdlib/abort.cpp
similarity index 98%
rename from libc/abort.cpp
rename to libc/stdlib/abort.cpp
index 76a39be3..eb9155cb 100644
--- a/libc/abort.cpp
+++ b/libc/stdlib/abort.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- abort.cpp
+ stdlib/abort.cpp
Abnormal process termination.
*******************************************************************************/
diff --git a/libc/abs.cpp b/libc/stdlib/abs.cpp
similarity index 98%
rename from libc/abs.cpp
rename to libc/stdlib/abs.cpp
index 19994684..a48ccdea 100644
--- a/libc/abs.cpp
+++ b/libc/stdlib/abs.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- abs.cpp
+ stdlib/abs.cpp
Allows taking the absolute value of integer types.
*******************************************************************************/
diff --git a/libc/atof.cpp b/libc/stdlib/atof.cpp
similarity index 91%
rename from libc/atof.cpp
rename to libc/stdlib/atof.cpp
index b3b970e6..092066f4 100644
--- a/libc/atof.cpp
+++ b/libc/stdlib/atof.cpp
@@ -17,8 +17,8 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- atof.cpp
- Converts floats represented as strings to binary representation.
+ stdlib/atof.cpp
+ Converts floating numbers represented as strings to binary representation.
*******************************************************************************/
diff --git a/libc/atoi.cpp b/libc/stdlib/atoi.cpp
similarity index 98%
rename from libc/atoi.cpp
rename to libc/stdlib/atoi.cpp
index 62d4bde2..36ef6c57 100644
--- a/libc/atoi.cpp
+++ b/libc/stdlib/atoi.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- atoi.cpp
+ stdlib/atoi.cpp
Converts integers represented as strings to binary representation.
*******************************************************************************/
diff --git a/libc/atol.cpp b/libc/stdlib/atol.cpp
similarity index 98%
rename from libc/atol.cpp
rename to libc/stdlib/atol.cpp
index c7b1b498..cda94620 100644
--- a/libc/atol.cpp
+++ b/libc/stdlib/atol.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- atol.cpp
+ stdlib/atol.cpp
Converts integers represented as strings to binary representation.
*******************************************************************************/
diff --git a/libc/atoll.cpp b/libc/stdlib/atoll.cpp
similarity index 98%
rename from libc/atoll.cpp
rename to libc/stdlib/atoll.cpp
index 501d1302..7e648baf 100644
--- a/libc/atoll.cpp
+++ b/libc/stdlib/atoll.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- atoll.cpp
+ stdlib/atoll.cpp
Converts integers represented as strings to binary representation.
*******************************************************************************/
diff --git a/libc/bsearch.cpp b/libc/stdlib/bsearch.cpp
similarity index 98%
rename from libc/bsearch.cpp
rename to libc/stdlib/bsearch.cpp
index 5f1c704f..28ea0b92 100644
--- a/libc/bsearch.cpp
+++ b/libc/stdlib/bsearch.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- bsearch.cpp
+ stdlib/bsearch.cpp
Binary search.
*******************************************************************************/
diff --git a/libc/calloc.cpp b/libc/stdlib/calloc.cpp
similarity index 98%
rename from libc/calloc.cpp
rename to libc/stdlib/calloc.cpp
index d665ec62..ff7daf89 100644
--- a/libc/calloc.cpp
+++ b/libc/stdlib/calloc.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- calloc.cpp
+ stdlib/calloc.cpp
Allocates zeroed memory.
*******************************************************************************/
diff --git a/libc/canonicalize_file_name.cpp b/libc/stdlib/canonicalize_file_name.cpp
similarity index 96%
rename from libc/canonicalize_file_name.cpp
rename to libc/stdlib/canonicalize_file_name.cpp
index 0a87a5b2..01d94890 100644
--- a/libc/canonicalize_file_name.cpp
+++ b/libc/stdlib/canonicalize_file_name.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- canonicalize_file_name.cpp
+ stdlib/canonicalize_file_name.cpp
Return the canonicalized filename.
*******************************************************************************/
diff --git a/libc/canonicalize_file_name_at.cpp b/libc/stdlib/canonicalize_file_name_at.cpp
similarity index 99%
rename from libc/canonicalize_file_name_at.cpp
rename to libc/stdlib/canonicalize_file_name_at.cpp
index 0bb3ffb4..5c6d1003 100644
--- a/libc/canonicalize_file_name_at.cpp
+++ b/libc/stdlib/canonicalize_file_name_at.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- canonicalize_file_name_at.cpp
+ stdlib/canonicalize_file_name_at.cpp
Return the canonicalized filename.
*******************************************************************************/
diff --git a/libc/div.cpp b/libc/stdlib/div.cpp
similarity index 98%
rename from libc/div.cpp
rename to libc/stdlib/div.cpp
index e5dc79c8..c7b73e00 100644
--- a/libc/div.cpp
+++ b/libc/stdlib/div.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- div.cpp
+ stdlib/div.cpp
Compute quotient and remainder of integer division.
*******************************************************************************/
diff --git a/libc/env.cpp b/libc/stdlib/env.cpp
similarity index 99%
rename from libc/env.cpp
rename to libc/stdlib/env.cpp
index 7bd64db0..35de740b 100644
--- a/libc/env.cpp
+++ b/libc/stdlib/env.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- env.cpp
+ stdlib/env.cpp
Environmental variables utilities.
*******************************************************************************/
diff --git a/libc/exit.cpp b/libc/stdlib/exit.cpp
similarity index 98%
rename from libc/exit.cpp
rename to libc/stdlib/exit.cpp
index 15d7a718..fed7fa57 100644
--- a/libc/exit.cpp
+++ b/libc/stdlib/exit.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- exit.cpp
+ stdlib/exit.cpp
Terminates the current process.
*******************************************************************************/
diff --git a/libc/heap.cpp b/libc/stdlib/heap.cpp
similarity index 99%
rename from libc/heap.cpp
rename to libc/stdlib/heap.cpp
index 7cab6c15..b0207de9 100644
--- a/libc/heap.cpp
+++ b/libc/stdlib/heap.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- heap.cpp
+ stdlib/heap.cpp
Functions that allocate/free memory from a dynamic memory heap.
*******************************************************************************/
diff --git a/libc/integer.cpp b/libc/stdlib/integer.cpp
similarity index 99%
rename from libc/integer.cpp
rename to libc/stdlib/integer.cpp
index 0cb5608f..cb272442 100644
--- a/libc/integer.cpp
+++ b/libc/stdlib/integer.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- integer.cpp
+ stdlib/integer.cpp
Converts integers represented as strings to binary representation.
*******************************************************************************/
diff --git a/libc/ldiv.cpp b/libc/stdlib/ldiv.cpp
similarity index 98%
rename from libc/ldiv.cpp
rename to libc/stdlib/ldiv.cpp
index 5fd5d544..f2fb0422 100644
--- a/libc/ldiv.cpp
+++ b/libc/stdlib/ldiv.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- ldiv.cpp
+ stdlib/ldiv.cpp
Compute quotient and remainder of integer division.
*******************************************************************************/
diff --git a/libc/lldiv.cpp b/libc/stdlib/lldiv.cpp
similarity index 98%
rename from libc/lldiv.cpp
rename to libc/stdlib/lldiv.cpp
index 5567a6ba..4f23988f 100644
--- a/libc/lldiv.cpp
+++ b/libc/stdlib/lldiv.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- lldiv.cpp
+ stdlib/lldiv.cpp
Compute quotient and remainder of integer division.
*******************************************************************************/
diff --git a/libc/mblen.cpp b/libc/stdlib/mblen.cpp
similarity index 98%
rename from libc/mblen.cpp
rename to libc/stdlib/mblen.cpp
index 6cbf0ad9..c4378cbd 100644
--- a/libc/mblen.cpp
+++ b/libc/stdlib/mblen.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- mblen.cpp
+ stdlib/mblen.cpp
Determine number of bytes in next multibyte character.
*******************************************************************************/
diff --git a/libc/mbstowcs.cpp b/libc/stdlib/mbstowcs.cpp
similarity index 98%
rename from libc/mbstowcs.cpp
rename to libc/stdlib/mbstowcs.cpp
index e5ed34d2..b899f63c 100644
--- a/libc/mbstowcs.cpp
+++ b/libc/stdlib/mbstowcs.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- mbstowcs.cpp
+ stdlib/mbstowcs.cpp
Convert a multibyte string to a wide-character string.
*******************************************************************************/
diff --git a/libc/mbtowc.cpp b/libc/stdlib/mbtowc.cpp
similarity index 98%
rename from libc/mbtowc.cpp
rename to libc/stdlib/mbtowc.cpp
index 69ef75c2..fffdee4f 100644
--- a/libc/mbtowc.cpp
+++ b/libc/stdlib/mbtowc.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- mbtowc.cpp
+ stdlib/mbtowc.cpp
Convert a multibyte sequence to a wide character.
*******************************************************************************/
diff --git a/libc/mktemp.cpp b/libc/stdlib/mktemp.cpp
similarity index 98%
rename from libc/mktemp.cpp
rename to libc/stdlib/mktemp.cpp
index 1195ee9c..6b5b4d62 100644
--- a/libc/mktemp.cpp
+++ b/libc/stdlib/mktemp.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- mktemp.cpp
+ stdlib/mktemp.cpp
Make a unique temporary filename.
*******************************************************************************/
diff --git a/libc/on_exit.cpp b/libc/stdlib/on_exit.cpp
similarity index 98%
rename from libc/on_exit.cpp
rename to libc/stdlib/on_exit.cpp
index f571619a..36b9cd6e 100644
--- a/libc/on_exit.cpp
+++ b/libc/stdlib/on_exit.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- on_exit.cpp
+ stdlib/on_exit.cpp
Hooks that is called upon process exit.
*******************************************************************************/
diff --git a/libc/sort.cpp b/libc/stdlib/qsort.cpp
similarity index 98%
rename from libc/sort.cpp
rename to libc/stdlib/qsort.cpp
index 213fd457..9390443f 100644
--- a/libc/sort.cpp
+++ b/libc/stdlib/qsort.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- sort.cpp
+ stdlib/qsort.cpp
Utility functions related to sorting and sorted data.
*******************************************************************************/
diff --git a/libc/rand.cpp b/libc/stdlib/rand.cpp
similarity index 98%
rename from libc/rand.cpp
rename to libc/stdlib/rand.cpp
index d0c16981..dbc4d5e3 100644
--- a/libc/rand.cpp
+++ b/libc/stdlib/rand.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- rand.cpp
+ stdlib/rand.cpp
Returns a random value.
*******************************************************************************/
diff --git a/libc/realpath.cpp b/libc/stdlib/realpath.cpp
similarity index 98%
rename from libc/realpath.cpp
rename to libc/stdlib/realpath.cpp
index 575f55e5..144fb3d1 100644
--- a/libc/realpath.cpp
+++ b/libc/stdlib/realpath.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- realpath.cpp
+ stdlib/realpath.cpp
Return the canonicalized filename.
*******************************************************************************/
diff --git a/libc/strtod.cpp b/libc/stdlib/strtod.cpp
similarity index 98%
rename from libc/strtod.cpp
rename to libc/stdlib/strtod.cpp
index 72c35372..c64e8389 100644
--- a/libc/strtod.cpp
+++ b/libc/stdlib/strtod.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- strtod.cpp
+ stdlib/strtod.cpp
Converts floating numbers represented as strings to binary representation.
*******************************************************************************/
diff --git a/libc/strtof.cpp b/libc/stdlib/strtof.cpp
similarity index 99%
rename from libc/strtof.cpp
rename to libc/stdlib/strtof.cpp
index 2ed84e61..5cde7c41 100644
--- a/libc/strtof.cpp
+++ b/libc/stdlib/strtof.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- strtof.cpp
+ stdlib/strtof.cpp
Converts floating numbers represented as strings to binary representation.
*******************************************************************************/
diff --git a/libc/strtold.cpp b/libc/stdlib/strtold.cpp
similarity index 97%
rename from libc/strtold.cpp
rename to libc/stdlib/strtold.cpp
index 61f850b2..db981fa5 100644
--- a/libc/strtold.cpp
+++ b/libc/stdlib/strtold.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- strtold.cpp
+ stdlib/strtold.cpp
Converts floating numbers represented as strings to binary representation.
*******************************************************************************/
diff --git a/libc/system.cpp b/libc/stdlib/system.cpp
similarity index 98%
rename from libc/system.cpp
rename to libc/stdlib/system.cpp
index df52aa07..1f2d12aa 100644
--- a/libc/system.cpp
+++ b/libc/stdlib/system.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- system.cpp
+ stdlib/system.cpp
Execute a shell command.
*******************************************************************************/
diff --git a/libc/wcstombs.cpp b/libc/stdlib/wcstombs.cpp
similarity index 98%
rename from libc/wcstombs.cpp
rename to libc/stdlib/wcstombs.cpp
index 23598024..d305ff0a 100644
--- a/libc/wcstombs.cpp
+++ b/libc/stdlib/wcstombs.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- wcstombs.cpp
+ stdlib/wcstombs.cpp
Convert a wide-character string to multibyte string.
*******************************************************************************/
diff --git a/libc/wctomb.cpp b/libc/stdlib/wctomb.cpp
similarity index 98%
rename from libc/wctomb.cpp
rename to libc/stdlib/wctomb.cpp
index 478275db..ecbf22df 100644
--- a/libc/wctomb.cpp
+++ b/libc/stdlib/wctomb.cpp
@@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- wctomb.cpp
+ stdlib/wctomb.cpp
Convert a wide character to a multibyte sequence.
*******************************************************************************/