Browse Source

Fold conv package into fmt

Both packages had nearly identical dependency requirements, so merging
them should help reduce the complexity of the build graph.
main
Justine Tunney 1 year ago
parent
commit
1fc91f3580
  1. 4
      Makefile
  2. 2
      dsp/mpeg/mpeg1.c
  3. 2
      examples/cp.c
  4. 1
      examples/examples.mk
  5. 2
      examples/findprime.c
  6. 2
      examples/ispell.c
  7. 2
      examples/nesemu1.cc
  8. 6
      examples/peek.c
  9. 2
      examples/printprimes.c
  10. 2
      examples/subprocess.c
  11. 2
      examples/unbourne.c
  12. 6
      libc/bits/abs.c
  13. 9
      libc/calls/calls.mk
  14. 2
      libc/calls/clock_gettime.c
  15. 2
      libc/calls/commandv.c
  16. 2
      libc/calls/fstat-nt.c
  17. 2
      libc/calls/getpriority-nt.c
  18. 2
      libc/calls/getrusage-nt.c
  19. 2
      libc/calls/getsetpriority-nt.c
  20. 2
      libc/calls/gettimeofday-nt.c
  21. 2
      libc/calls/hefty/fork-nt.c
  22. 1
      libc/calls/hefty/hefty.mk
  23. 2
      libc/calls/hefty/mkntcmdline.c
  24. 2
      libc/calls/hefty/mkntenvblock.c
  25. 2
      libc/calls/hefty/ntspawn.c
  26. 2
      libc/calls/hefty/spawnve-sysv.c
  27. 2
      libc/calls/isdebuggerpresent.c
  28. 2
      libc/calls/nice.c
  29. 6
      libc/calls/openanon.c
  30. 2
      libc/calls/setitimer-nt.c
  31. 2
      libc/calls/utimensat-nt.c
  32. 2
      libc/calls/wait4-nt.c
  33. 85
      libc/conv/conv.mk
  34. 8
      libc/conv/isslash.internal.h
  35. 2
      libc/dns/getaddrinfo.c
  36. 2
      libc/fmt/abs.c
  37. 4
      libc/fmt/atoi.c
  38. 4
      libc/fmt/atol.c
  39. 4
      libc/fmt/atoll.c
  40. 4
      libc/fmt/basename.c
  41. 4
      libc/fmt/basename_n.c
  42. 6
      libc/fmt/conv.h
  43. 2
      libc/fmt/convertmicros.c
  44. 2
      libc/fmt/dirname.c
  45. 6
      libc/fmt/div.c
  46. 2
      libc/fmt/dosdatetimetounix.c
  47. 2
      libc/fmt/filetimetotime.c
  48. 2
      libc/fmt/filetimetotimespec.c
  49. 2
      libc/fmt/filetimetotimeval.c
  50. 21
      libc/fmt/fmt.mk
  51. 2
      libc/fmt/imaxabs.c
  52. 0
      libc/fmt/imaxabs.thunk.S
  53. 4
      libc/fmt/isabspath.c
  54. 10
      libc/fmt/isslash.internal.h
  55. 2
      libc/fmt/itoa.c
  56. 6
      libc/fmt/itoa.h
  57. 4
      libc/fmt/itoa128radix10.greg.c
  58. 4
      libc/fmt/itoa64.c
  59. 2
      libc/fmt/itoa64fixed16.greg.c
  60. 4
      libc/fmt/itoa64radix10.greg.c
  61. 4
      libc/fmt/itoa64radix16.greg.c
  62. 4
      libc/fmt/itoa64radix8.c
  63. 0
      libc/fmt/kmonthyearday.c
  64. 6
      libc/fmt/labs.c
  65. 6
      libc/fmt/ldiv.c
  66. 6
      libc/fmt/llabs.c
  67. 6
      libc/fmt/lldiv.c
  68. 2
      libc/fmt/ltpcpy.c
  69. 2
      libc/fmt/palandntoa.c
  70. 2
      libc/fmt/palandprintf.c
  71. 2
      libc/fmt/rounddecimalplaces.c
  72. 0
      libc/fmt/strlol.internal.h
  73. 2
      libc/fmt/strtoimax.c
  74. 4
      libc/fmt/strtol.c
  75. 4
      libc/fmt/strtoll.c
  76. 2
      libc/fmt/strtonum.c
  77. 4
      libc/fmt/strtoul.c
  78. 4
      libc/fmt/strtoull.c
  79. 2
      libc/fmt/strtoumax.c
  80. 2
      libc/fmt/timespectofiletime.c
  81. 2
      libc/fmt/timetofiletime.c
  82. 2
      libc/fmt/timevaltofiletime.c
  83. 2
      libc/fmt/unsleb128.c
  84. 2
      libc/fmt/vcscanf.c
  85. 6
      libc/fmt/wcslol.internal.h
  86. 2
      libc/fmt/wcstoimax.c
  87. 4
      libc/fmt/wcstol.c
  88. 2
      libc/isystem/endian.h
  89. 2
      libc/isystem/stdlib.h
  90. 1
      libc/libc.mk
  91. 2
      libc/log/asan.c
  92. 2
      libc/log/backtrace2.c
  93. 2
      libc/log/backtrace3.c
  94. 2
      libc/log/checkfail_ndebug.c
  95. 2
      libc/log/getttysize.c
  96. 9
      libc/log/log.mk
  97. 2
      libc/log/vflogf.c
  98. 9
      libc/mem/mem.mk
  99. 2
      libc/mem/reallocarray.c
  100. 55
      libc/runtime/gothere.greg.c
  101. Some files were not shown because too many files have changed in this diff Show More

4
Makefile

@ -104,7 +104,6 @@ include ape/lib/apelib.mk # │ @@ -104,7 +104,6 @@ include ape/lib/apelib.mk # │
include ape/ape.mk #─┘
include libc/sysv/sysv.mk #─┐
include libc/nt/nt.mk # ├──system
include libc/conv/conv.mk # │
include libc/fmt/fmt.mk # │
include libc/rand/rand.mk #─┘
include libc/calls/calls.mk #─┐
@ -186,7 +185,6 @@ include test/libc/dns/test.mk @@ -186,7 +185,6 @@ include test/libc/dns/test.mk
include test/libc/rand/test.mk
include test/libc/time/test.mk
include test/libc/stdio/test.mk
include test/libc/conv/test.mk
include test/libc/release/test.mk
include test/libc/test.mk
include test/ape/lib/test.mk
@ -251,7 +249,6 @@ COSMOPOLITAN_OBJECTS = \ @@ -251,7 +249,6 @@ COSMOPOLITAN_OBJECTS = \
LIBC_BITS \
LIBC_CALLS \
LIBC_CALLS_HEFTY \
LIBC_CONV \
LIBC_CRYPTO \
LIBC_DNS \
LIBC_ELF \
@ -286,7 +283,6 @@ COSMOPOLITAN_HEADERS = \ @@ -286,7 +283,6 @@ COSMOPOLITAN_HEADERS = \
LIBC_ALG \
LIBC_BITS \
LIBC_CALLS \
LIBC_CONV \
LIBC_CRYPTO \
LIBC_DNS \
LIBC_ELF \

2
dsp/mpeg/mpeg1.c

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
#include "dsp/mpeg/mpeg.h"
#include "dsp/mpeg/video.h"
#include "libc/bits/initializer.internal.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/log/log.h"
#include "libc/macros.h"
#include "libc/math.h"

2
examples/cp.c

@ -9,8 +9,8 @@ @@ -9,8 +9,8 @@
#endif
#include "libc/calls/calls.h"
#include "libc/calls/hefty/copyfile.h"
#include "libc/conv/conv.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/fmt.h"
#include "libc/runtime/gc.h"
#include "libc/runtime/runtime.h"

1
examples/examples.mk

@ -46,7 +46,6 @@ EXAMPLES_DIRECTDEPS = \ @@ -46,7 +46,6 @@ EXAMPLES_DIRECTDEPS = \
LIBC_BITS \
LIBC_CALLS \
LIBC_CALLS_HEFTY \
LIBC_CONV \
LIBC_FMT \
LIBC_LOG \
LIBC_LOG_ASAN \

2
examples/findprime.c

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
#include "libc/bits/bits.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/itimerval.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/limits.h"
#include "libc/log/check.h"
#include "libc/log/color.internal.h"

2
examples/ispell.c

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
#include "libc/alg/critbit0.h"
#include "libc/bits/bits.h"
#include "libc/calls/calls.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/macros.h"

2
examples/nesemu1.cc

@ -18,8 +18,8 @@ @@ -18,8 +18,8 @@
#include "libc/calls/hefty/spawn.h"
#include "libc/calls/struct/itimerval.h"
#include "libc/calls/struct/winsize.h"
#include "libc/conv/conv.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/fmt.h"
#include "libc/inttypes.h"
#include "libc/log/check.h"

6
examples/peek.c

@ -17,14 +17,16 @@ @@ -17,14 +17,16 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/runtime/interruptiblecall.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/sig.h"
struct InterruptibleCall icall;
static intptr_t peek(intptr_t *addr) { return *addr; }
static intptr_t peek(intptr_t *addr) {
return *addr;
}
int main(int argc, char *argv[]) {
int i;

2
examples/printprimes.c

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ │
*/
#endif
#include "libc/conv/itoa.h"
#include "libc/fmt/itoa.h"
#include "libc/math.h"
#include "libc/stdio/stdio.h"

2
examples/subprocess.c

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
#include "libc/alg/alg.h"
#include "libc/calls/calls.h"
#include "libc/calls/hefty/spawn.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/limits.h"
#include "libc/log/check.h"
#include "libc/runtime/gc.h"

2
examples/unbourne.c

@ -120,9 +120,9 @@ @@ -120,9 +120,9 @@
#include "libc/calls/struct/stat.h"
#include "libc/calls/struct/tms.h"
#include "libc/calls/termios.h"
#include "libc/conv/conv.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/fmt.h"
#include "libc/limits.h"
#include "libc/log/log.h"

6
libc/bits/abs.c

@ -17,7 +17,9 @@ @@ -17,7 +17,9 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/macros.h"
int(abs)(int x) { return ABS(x); }
int(abs)(int x) {
return ABS(x);
}

9
libc/calls/calls.mk

@ -39,15 +39,14 @@ LIBC_CALLS_A_CHECKS = \ @@ -39,15 +39,14 @@ LIBC_CALLS_A_CHECKS = \
LIBC_CALLS_A_DIRECTDEPS = \
LIBC_FMT \
LIBC_STR \
LIBC_RAND \
LIBC_CONV \
LIBC_STUBS \
LIBC_NEXGEN32E \
LIBC_NT_NTDLL \
LIBC_NT_ADVAPI32 \
LIBC_NT_KERNEL32 \
LIBC_NT_KERNELBASE \
LIBC_NT_NTDLL \
LIBC_RAND \
LIBC_STR \
LIBC_STUBS \
LIBC_SYSV_CALLS \
LIBC_SYSV

2
libc/calls/clock_gettime.c

@ -23,8 +23,8 @@ @@ -23,8 +23,8 @@
#include "libc/calls/internal.h"
#include "libc/calls/struct/timespec.h"
#include "libc/calls/struct/timeval.h"
#include "libc/conv/conv.h"
#include "libc/dce.h"
#include "libc/fmt/conv.h"
#include "libc/mach.h"
#include "libc/nt/struct/filetime.h"
#include "libc/nt/struct/systemtime.h"

2
libc/calls/commandv.c

@ -20,9 +20,9 @@ @@ -20,9 +20,9 @@
#include "libc/bits/progn.internal.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/conv/conv.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/nt/ntdll.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"

2
libc/calls/fstat-nt.c

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/internal.h"
#include "libc/calls/struct/stat.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/nt/enum/fileflagandattributes.h"
#include "libc/nt/enum/fileinfobyhandleclass.h"
#include "libc/nt/enum/filetype.h"

2
libc/calls/getpriority-nt.c

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/kntprioritycombos.internal.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/nexgen32e/ffs.h"
#include "libc/nt/enum/processcreationflags.h"
#include "libc/nt/enum/threadpriority.h"

2
libc/calls/getrusage-nt.c

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/struct/rusage.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/nt/accounting.h"
#include "libc/nt/runtime.h"
#include "libc/nt/thread.h"

2
libc/calls/getsetpriority-nt.c

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/calls/calls.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/sysv/consts/prio.h"
#include "libc/sysv/errfuns.h"

2
libc/calls/gettimeofday-nt.c

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
*/
#include "libc/calls/internal.h"
#include "libc/calls/struct/timeval.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/nt/struct/filetime.h"
#include "libc/nt/struct/systemtime.h"
#include "libc/nt/synchronization.h"

2
libc/calls/hefty/fork-nt.c

@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
#include "libc/calls/hefty/ntspawn.h"
#include "libc/calls/hefty/spawn.h"
#include "libc/calls/internal.h"
#include "libc/conv/itoa.h"
#include "libc/fmt/itoa.h"
#include "libc/nt/enum/filemapflags.h"
#include "libc/nt/enum/pageflags.h"
#include "libc/nt/enum/startf.h"

1
libc/calls/hefty/hefty.mk

@ -37,7 +37,6 @@ LIBC_CALLS_HEFTY_A_CHECKS = \ @@ -37,7 +37,6 @@ LIBC_CALLS_HEFTY_A_CHECKS = \
LIBC_CALLS_HEFTY_A_DIRECTDEPS = \
LIBC_ALG \
LIBC_CALLS \
LIBC_CONV \
LIBC_FMT \
LIBC_MEM \
LIBC_NEXGEN32E \

2
libc/calls/hefty/mkntcmdline.c

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
#include "libc/alg/arraylist2.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/hefty/ntspawn.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/macros.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/hascharacter.internal.h"

2
libc/calls/hefty/mkntenvblock.c

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
*/
#include "libc/alg/arraylist2.internal.h"
#include "libc/calls/hefty/ntspawn.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/macros.h"
#include "libc/mem/mem.h"
#include "libc/str/oldutf16.internal.h"

2
libc/calls/hefty/ntspawn.c

@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/hefty/ntspawn.h"
#include "libc/calls/internal.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/nt/enum/processcreationflags.h"
#include "libc/nt/process.h"
#include "libc/nt/runtime.h"

2
libc/calls/hefty/spawnve-sysv.c

@ -22,8 +22,8 @@ @@ -22,8 +22,8 @@
#include "libc/calls/hefty/internal.h"
#include "libc/calls/hefty/spawn.h"
#include "libc/calls/internal.h"
#include "libc/conv/conv.h"
#include "libc/dce.h"
#include "libc/fmt/conv.h"
#include "libc/mem/mem.h"
#include "libc/paths.h"
#include "libc/runtime/runtime.h"

2
libc/calls/isdebuggerpresent.c

@ -21,8 +21,8 @@ @@ -21,8 +21,8 @@
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/conv/conv.h"
#include "libc/dce.h"
#include "libc/fmt/conv.h"
#include "libc/log/log.h"
#include "libc/nexgen32e/vendor.internal.h"
#include "libc/nt/struct/teb.h"

2
libc/calls/nice.c

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/sysv/consts/prio.h"
static int clamp(int p) {

6
libc/calls/openanon.c

@ -20,10 +20,10 @@ @@ -20,10 +20,10 @@
#include "libc/assert.h"
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/conv/conv.h"
#include "libc/conv/isslash.internal.h"
#include "libc/conv/itoa.h"
#include "libc/dce.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/isslash.internal.h"
#include "libc/fmt/itoa.h"
#include "libc/nt/createfile.h"
#include "libc/nt/enum/accessmask.h"
#include "libc/nt/enum/creationdisposition.h"

2
libc/calls/setitimer-nt.c

@ -20,8 +20,8 @@ @@ -20,8 +20,8 @@
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/struct/itimerval.h"
#include "libc/conv/conv.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/log/check.h"
#include "libc/nexgen32e/nexgen32e.h"
#include "libc/nt/files.h"

2
libc/calls/utimensat-nt.c

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/calls/internal.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/nt/createfile.h"
#include "libc/nt/enum/accessmask.h"
#include "libc/nt/enum/creationdisposition.h"

2
libc/calls/wait4-nt.c

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/struct/rusage.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/macros.h"
#include "libc/nt/accounting.h"
#include "libc/nt/enum/status.h"

85
libc/conv/conv.mk

@ -1,85 +0,0 @@ @@ -1,85 +0,0 @@
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
#
# SYNOPSIS
#
# Cosmopolitan Data Conversions
#
# DESCRIPTION
#
# This package provides functions that convert between data types.
# It's intended to be lower level than the memory and formatting
# libraries.
PKGS += LIBC_CONV
LIBC_CONV_ARTIFACTS += LIBC_CONV_A
LIBC_CONV = $(LIBC_CONV_A_DEPS) $(LIBC_CONV_A)
LIBC_CONV_A = o/$(MODE)/libc/conv/conv.a
LIBC_CONV_A_FILES := $(wildcard libc/conv/*)
LIBC_CONV_A_HDRS = $(filter %.h,$(LIBC_CONV_A_FILES))
LIBC_CONV_A_SRCS_S = $(filter %.S,$(LIBC_CONV_A_FILES))
LIBC_CONV_A_SRCS_C = $(filter %.c,$(LIBC_CONV_A_FILES))
LIBC_CONV_A_SRCS = \
$(LIBC_CONV_A_SRCS_S) \
$(LIBC_CONV_A_SRCS_C)
LIBC_CONV_A_OBJS = \
$(LIBC_CONV_A_SRCS:%=o/$(MODE)/%.zip.o) \
$(LIBC_CONV_A_SRCS_S:%.S=o/$(MODE)/%.o) \
$(LIBC_CONV_A_SRCS_C:%.c=o/$(MODE)/%.o)
LIBC_CONV_A_CHECKS = \
$(LIBC_CONV_A).pkg \
$(LIBC_CONV_A_HDRS:%=o/$(MODE)/%.ok)
LIBC_CONV_A_DIRECTDEPS = \
LIBC_NEXGEN32E \
LIBC_STUBS \
LIBC_STR \
LIBC_TINYMATH \
LIBC_SYSV \
THIRD_PARTY_COMPILER_RT
LIBC_CONV_A_DEPS := \
$(call uniq,$(foreach x,$(LIBC_CONV_A_DIRECTDEPS),$($(x))))
$(LIBC_CONV_A): libc/conv/ \
$(LIBC_CONV_A).pkg \
$(LIBC_CONV_A_OBJS)
$(LIBC_CONV_A).pkg: \
$(LIBC_CONV_A_OBJS) \
$(foreach x,$(LIBC_CONV_A_DIRECTDEPS),$($(x)_A).pkg)
o/$(MODE)/libc/conv/dosdatetimetounix.o \
o/$(MODE)/libc/conv/itoa64radix10.greg.o \
o/$(MODE)/libc/conv/timetofiletime.o \
o/$(MODE)/libc/conv/filetimetotime.o \
o/$(MODE)/libc/conv/timespectofiletime.o \
o/$(MODE)/libc/conv/filetimetotimespec.o \
o/$(MODE)/libc/conv/filetimetotimeval.o: \
OVERRIDE_CFLAGS += \
-O3
o/$(MODE)/libc/conv/itoa64radix10.greg.o \
o/$(MODE)/libc/conv/itoa128radix10.greg.o: \
OVERRIDE_CFLAGS += \
-fwrapv
$(LIBC_CONV_A_OBJS): \
OVERRIDE_CFLAGS += \
$(NO_MAGIC)
LIBC_CONV_LIBS = $(foreach x,$(LIBC_CONV_ARTIFACTS),$($(x)))
LIBC_CONV_SRCS = $(foreach x,$(LIBC_CONV_ARTIFACTS),$($(x)_SRCS))
LIBC_CONV_HDRS = $(foreach x,$(LIBC_CONV_ARTIFACTS),$($(x)_HDRS))
LIBC_CONV_BINS = $(foreach x,$(LIBC_CONV_ARTIFACTS),$($(x)_BINS))
LIBC_CONV_CHECKS = $(foreach x,$(LIBC_CONV_ARTIFACTS),$($(x)_CHECKS))
LIBC_CONV_OBJS = $(foreach x,$(LIBC_CONV_ARTIFACTS),$($(x)_OBJS))
LIBC_CONV_TESTS = $(foreach x,$(LIBC_CONV_ARTIFACTS),$($(x)_TESTS))
$(LIBC_CONV_OBJS): $(BUILD_FILES) libc/conv/conv.mk
.PHONY: o/$(MODE)/libc/conv
o/$(MODE)/libc/conv: $(LIBC_CONV_CHECKS)

8
libc/conv/isslash.internal.h

@ -1,8 +0,0 @@ @@ -1,8 +0,0 @@
#ifndef COSMOPOLITAN_LIBC_CONV_ISSLASH_H_
#define COSMOPOLITAN_LIBC_CONV_ISSLASH_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
forceinline bool isslash(int c) { return c == '/' || c == '\\'; }
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CONV_ISSLASH_H_ */

2
libc/dns/getaddrinfo.c

@ -19,10 +19,10 @@ @@ -19,10 +19,10 @@
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/conv/conv.h"
#include "libc/dns/dns.h"
#include "libc/dns/hoststxt.h"
#include "libc/dns/resolvconf.h"
#include "libc/fmt/conv.h"
#include "libc/mem/mem.h"
#include "libc/sock/sock.h"
#include "libc/str/str.h"

2
libc/conv/abs.c → libc/fmt/abs.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
int(abs)(int x) {
return 0 < x ? x : -x;

4
libc/conv/atoi.c → libc/fmt/atoi.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/strlol.internal.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/strlol.internal.h"
#include "libc/limits.h"
/**

4
libc/conv/atol.c → libc/fmt/atol.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/strlol.internal.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/strlol.internal.h"
#include "libc/limits.h"
long atol(const char *s) {

4
libc/conv/atoll.c → libc/fmt/atoll.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/strlol.internal.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/strlol.internal.h"
#include "libc/limits.h"
long long atoll(const char *s) {

4
libc/conv/basename.c → libc/fmt/basename.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/isslash.internal.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/isslash.internal.h"
#include "libc/str/str.h"
/**

4
libc/conv/basename_n.c → libc/fmt/basename_n.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/isslash.internal.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/isslash.internal.h"
/**
* Returns pointer to last filename component in path.

6
libc/conv/conv.h → libc/fmt/conv.h

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_CONV_CONV_H_
#define COSMOPOLITAN_LIBC_CONV_CONV_H_
#ifndef COSMOPOLITAN_LIBC_FMT_CONV_H_
#define COSMOPOLITAN_LIBC_FMT_CONV_H_
#include "libc/calls/struct/timespec.h"
#include "libc/calls/struct/timeval.h"
#include "libc/nt/struct/filetime.h"
@ -103,4 +103,4 @@ intmax_t __imaxabs(intmax_t) libcesque pureconst; @@ -103,4 +103,4 @@ intmax_t __imaxabs(intmax_t) libcesque pureconst;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CONV_CONV_H_ */
#endif /* COSMOPOLITAN_LIBC_FMT_CONV_H_ */

2
libc/conv/convertmicros.c → libc/fmt/convertmicros.c

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/calls/struct/timeval.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/time/time.h"
long convertmicros(const struct timeval *tv, long tick) {

2
libc/conv/dirname.c → libc/fmt/dirname.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/str/str.h"
#define ISDELIM(c) (c == '/' || c == '\\' || c == '.')

6
libc/conv/div.c → libc/fmt/div.c

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
div_t(div)(int num, int den) { return div(num, den); }
div_t(div)(int num, int den) {
return div(num, den);
}

2
libc/conv/dosdatetimetounix.c → libc/fmt/dosdatetimetounix.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/macros.h"
#include "libc/time/time.h"

2
libc/conv/filetimetotime.c → libc/fmt/filetimetotime.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/nt/struct/filetime.h"
int64_t filetimetotime(struct NtFileTime ft) {

2
libc/conv/filetimetotimespec.c → libc/fmt/filetimetotimespec.c

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/calls/calls.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/nt/struct/filetime.h"
/**

2
libc/conv/filetimetotimeval.c → libc/fmt/filetimetotimeval.c

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
*/
#include "libc/calls/calls.h"
#include "libc/calls/struct/timeval.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/nt/struct/filetime.h"
void FileTimeToTimeVal(struct timeval *tv, struct NtFileTime ft) {

21
libc/fmt/fmt.mk

@ -34,12 +34,12 @@ LIBC_FMT_A_CHECKS = \ @@ -34,12 +34,12 @@ LIBC_FMT_A_CHECKS = \
$(LIBC_FMT_A_HDRS:%=o/$(MODE)/%.ok)
LIBC_FMT_A_DIRECTDEPS = \
LIBC_STUBS \
LIBC_STR \
LIBC_TINYMATH \
LIBC_NEXGEN32E \
LIBC_NT_KERNELBASE \
LIBC_STR \
LIBC_STUBS \
LIBC_SYSV \
LIBC_TINYMATH \
THIRD_PARTY_COMPILER_RT
LIBC_FMT_A_DEPS := \
@ -57,6 +57,21 @@ $(LIBC_FMT_A_OBJS): \ @@ -57,6 +57,21 @@ $(LIBC_FMT_A_OBJS): \
OVERRIDE_CFLAGS += \
-fno-jump-tables
o/$(MODE)/libc/fmt/dosdatetimetounix.o \
o/$(MODE)/libc/fmt/itoa64radix10.greg.o \
o/$(MODE)/libc/fmt/timetofiletime.o \
o/$(MODE)/libc/fmt/filetimetotime.o \
o/$(MODE)/libc/fmt/timespectofiletime.o \
o/$(MODE)/libc/fmt/filetimetotimespec.o \
o/$(MODE)/libc/fmt/filetimetotimeval.o: \
OVERRIDE_CFLAGS += \
-O3
o/$(MODE)/libc/fmt/itoa64radix10.greg.o \
o/$(MODE)/libc/fmt/itoa128radix10.greg.o: \
OVERRIDE_CFLAGS += \
-fwrapv
LIBC_FMT_LIBS = $(foreach x,$(LIBC_FMT_ARTIFACTS),$($(x)))
LIBC_FMT_SRCS = $(foreach x,$(LIBC_FMT_ARTIFACTS),$($(x)_SRCS))
LIBC_FMT_HDRS = $(foreach x,$(LIBC_FMT_ARTIFACTS),$($(x)_HDRS))

2
libc/conv/imaxabs.c → libc/fmt/imaxabs.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/macros.h"
intmax_t(imaxabs)(intmax_t x) {

0
libc/conv/imaxabs.thunk.S → libc/fmt/imaxabs.thunk.S

4
libc/conv/isabspath.c → libc/fmt/isabspath.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/isslash.internal.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/isslash.internal.h"
/**
* Returns true if pathname could be absolute on any known platform.

10
libc/fmt/isslash.internal.h

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
#ifndef COSMOPOLITAN_LIBC_FMT_ISSLASH_H_
#define COSMOPOLITAN_LIBC_FMT_ISSLASH_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
forceinline bool isslash(int c) {
return c == '/' || c == '\\';
}
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_FMT_ISSLASH_H_ */

2
libc/fmt/itoa.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/fmt.h"
STATIC_YOINK("ntoa");

6
libc/conv/itoa.h → libc/fmt/itoa.h

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_CONV_ITOA_H_
#define COSMOPOLITAN_LIBC_CONV_ITOA_H_
#ifndef COSMOPOLITAN_LIBC_FMT_ITOA_H_
#define COSMOPOLITAN_LIBC_FMT_ITOA_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
@ -29,4 +29,4 @@ size_t uint128toarray_radix10(uint128_t, char *); @@ -29,4 +29,4 @@ size_t uint128toarray_radix10(uint128_t, char *);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CONV_ITOA_H_ */
#endif /* COSMOPOLITAN_LIBC_FMT_ITOA_H_ */

4
libc/conv/itoa128radix10.greg.c → libc/fmt/itoa128radix10.greg.c

@ -18,8 +18,8 @@ @@ -18,8 +18,8 @@
02110-1301 USA
*/
#include "libc/alg/reverse.h"
#include "libc/conv/conv.h"
#include "libc/conv/itoa.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/itoa.h"
#include "libc/limits.h"
uint128_t __udivmodti4(uint128_t, uint128_t, uint128_t *);

4
libc/conv/itoa64.c → libc/fmt/itoa64.c

@ -18,8 +18,8 @@ @@ -18,8 +18,8 @@
02110-1301 USA
*/
#include "libc/alg/reverse.h"
#include "libc/conv/conv.h"
#include "libc/conv/itoa.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/itoa.h"
noinline size_t uint64toarray(uint64_t i, char *a, int r) {
size_t j;

2
libc/conv/itoa64fixed16.greg.c → libc/fmt/itoa64fixed16.greg.c

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/assert.h"
#include "libc/conv/itoa.h"
#include "libc/fmt/itoa.h"
size_t uint64toarray_fixed16(uint64_t x, char b[hasatleast 17], uint8_t k) {
int i;

4
libc/conv/itoa64radix10.greg.c → libc/fmt/itoa64radix10.greg.c

@ -18,8 +18,8 @@ @@ -18,8 +18,8 @@
02110-1301 USA
*/
#include "libc/alg/reverse.h"
#include "libc/conv/conv.h"
#include "libc/conv/itoa.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/itoa.h"
#include "libc/limits.h"
/**

4
libc/conv/itoa64radix16.greg.c → libc/fmt/itoa64radix16.greg.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/itoa.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/itoa.h"
#include "libc/macros.h"
#include "libc/nexgen32e/bsr.h"

4
libc/conv/itoa64radix8.c → libc/fmt/itoa64radix8.c

@ -18,8 +18,8 @@ @@ -18,8 +18,8 @@
02110-1301 USA
*/
#include "libc/alg/reverse.h"
#include "libc/conv/conv.h"
#include "libc/conv/itoa.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/itoa.h"
#include "libc/limits.h"
/**

0
libc/conv/kmonthyearday.c → libc/fmt/kmonthyearday.c

6
libc/conv/labs.c → libc/fmt/labs.c

@ -17,7 +17,9 @@ @@ -17,7 +17,9 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/macros.h"
long(labs)(long x) { return ABS(x); }
long(labs)(long x) {
return ABS(x);
}

6
libc/conv/ldiv.c → libc/fmt/ldiv.c

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
ldiv_t(ldiv)(long num, long den) { return ldiv(num, den); }
ldiv_t(ldiv)(long num, long den) {
return ldiv(num, den);
}

6
libc/conv/llabs.c → libc/fmt/llabs.c

@ -17,7 +17,9 @@ @@ -17,7 +17,9 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/macros.h"
long long(llabs)(long long x) { return ABS(x); }
long long(llabs)(long long x) {
return ABS(x);
}

6
libc/conv/lldiv.c → libc/fmt/lldiv.c

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
lldiv_t(lldiv)(long long num, long long den) { return lldiv(num, den); }
lldiv_t(lldiv)(long long num, long long den) {
return lldiv(num, den);
}

2
libc/conv/ltpcpy.c → libc/fmt/ltpcpy.c

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/bits/bits.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
char *ltpcpy(char *dst, long x) {
unsigned len = llog10(abs(x)) + 1;

2
libc/fmt/palandntoa.c

@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
THE SOFTWARE.
*/
#include "libc/assert.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/paland.inc"
#include "libc/fmt/palandprintf.internal.h"

2
libc/fmt/palandprintf.c

@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
#include "libc/assert.h"
#include "libc/bits/bits.h"
#include "libc/bits/weaken.h"
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/fmt.h"
#include "libc/fmt/paland.inc"
#include "libc/fmt/palandprintf.internal.h"

2
libc/conv/rounddecimalplaces.c → libc/fmt/rounddecimalplaces.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/math.h"
double RoundDecimalPlaces(double f, double digs, double rounder(double)) {

0
libc/conv/strlol.internal.h → libc/fmt/strlol.internal.h

2
libc/conv/strtoimax.c → libc/fmt/strtoimax.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/limits.h"
#include "libc/nexgen32e/bsr.h"
#include "libc/str/str.h"

4
libc/conv/strtol.c → libc/fmt/strtol.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/strlol.internal.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/strlol.internal.h"
#include "libc/limits.h"
/**

4
libc/conv/strtoll.c → libc/fmt/strtoll.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/strlol.internal.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/strlol.internal.h"
#include "libc/limits.h"
long long strtoll(const char *s, char **endptr, int optional_base) {

2
libc/conv/strtonum.c → libc/fmt/strtonum.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/fmt/conv.h"
#include "libc/str/str.h"
#include "libc/sysv/errfuns.h"

4
libc/conv/strtoul.c → libc/fmt/strtoul.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/strlol.internal.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/strlol.internal.h"
#include "libc/limits.h"
unsigned long strtoul(const char *s, char **endptr, int optional_base) {

4
libc/conv/strtoull.c → libc/fmt/strtoull.c

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/conv/conv.h"
#include "libc/conv/strlol.internal.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/strlol.internal.h"
#include "libc/limits.h"
unsigned long long strtoull(const char *s, char **endptr, int optional_base) {

2
libc/conv/strtoumax.c → libc/fmt/strtoumax.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA