Browse Source

Fix bugs and have emulator emulate itself

main
Justine Tunney 2 years ago
parent
commit
bd29223891
  1. 19
      build/package
  2. 6
      build/zipobj
  3. 1
      libc/bits/safemacros.h
  4. 5
      libc/dns/resolvedns.c
  5. 2
      libc/fmt/pflink.h
  6. 8
      libc/intrin/shufpd.c
  7. 2
      libc/intrin/shufpd.h
  8. 12
      libc/intrin/shufps.c
  9. 2
      libc/intrin/shufps.h
  10. 1
      libc/log/log.h
  11. 26
      libc/math.h
  12. 2
      libc/nt/thunk/msabi.h
  13. 36
      libc/nt/winsock.h
  14. 1
      libc/runtime/describeos.c
  15. 3
      libc/runtime/hook.greg.c
  16. 1
      libc/runtime/memtrack.c
  17. 2
      libc/runtime/memtrack.h
  18. 2
      libc/runtime/mmap.c
  19. 1
      libc/runtime/runtime.h
  20. 1
      libc/str/str.h
  21. 2
      libc/tinymath/acosl.S
  22. 1
      libc/tinymath/asinl.S
  23. 2
      libc/tinymath/cabsl.S
  24. 2
      libc/tinymath/carg.S
  25. 2
      libc/tinymath/exp10l.S
  26. 2
      libc/tinymath/exp2l.S
  27. 2
      libc/tinymath/expl.S
  28. 19
      libc/tinymath/floor.S
  29. 54
      libc/tinymath/fpclassifyl.S
  30. 2
      libc/tinymath/hypotl.S
  31. 2
      libc/tinymath/ilogb.S
  32. 2
      libc/tinymath/ilogbf.S
  33. 2
      libc/tinymath/ilogbl.S
  34. 31
      libc/tinymath/isgreater.S
  35. 31
      libc/tinymath/isgreaterequal.S
  36. 31
      libc/tinymath/isgreaterequalf.S
  37. 36
      libc/tinymath/isgreaterequall.S
  38. 31
      libc/tinymath/isgreaterf.S
  39. 36
      libc/tinymath/isgreaterl.S
  40. 31
      libc/tinymath/isless.S
  41. 31
      libc/tinymath/islessequal.S
  42. 31
      libc/tinymath/islessequalf.S
  43. 36
      libc/tinymath/islessequall.S
  44. 31
      libc/tinymath/islessf.S
  45. 31
      libc/tinymath/islessgreater.S
  46. 31
      libc/tinymath/islessgreaterf.S
  47. 36
      libc/tinymath/islessgreaterl.S
  48. 36
      libc/tinymath/islessl.S
  49. 29
      libc/tinymath/isunordered.S
  50. 29
      libc/tinymath/isunorderedf.S
  51. 29
      libc/tinymath/isunorderedl.S
  52. 21
      libc/tinymath/ldexp.S
  53. 21
      libc/tinymath/ldexpf.S
  54. 19
      libc/tinymath/ldexpl.S
  55. 6
      libc/tinymath/log1p.S
  56. 6
      libc/tinymath/log1pf.S
  57. 6
      libc/tinymath/log1pl.S
  58. 2
      libc/tinymath/powl.S
  59. 23
      libc/tinymath/scalb.S
  60. 23
      libc/tinymath/scalbf.S
  61. 6
      libc/tinymath/scalbl.S
  62. 40
      libc/tinymath/scalbln.S
  63. 40
      libc/tinymath/scalblnl.S
  64. 44
      libc/tinymath/scalbn.S
  65. 44
      libc/tinymath/scalbnf.S
  66. 40
      libc/tinymath/scalbnl.S
  67. 2
      libc/tinymath/sincos.S
  68. 2
      libc/tinymath/sincosf.S
  69. 4
      libc/tinymath/sqrt.S
  70. 4
      libc/tinymath/sqrtf.S
  71. 10
      libc/tinymath/trunc.S
  72. 3
      test/libc/conv/test.mk
  73. 5
      test/libc/fmt/strerror_test.c
  74. 46
      test/libc/intrin/intrin_test.c
  75. 48
      test/libc/tinymath/ldexp_test.c
  76. 4
      test/tool/build/lib/pml4t_test.c
  77. 1
      third_party/stb/stb_vorbis.c
  78. 6
      third_party/xed/x86.h
  79. 3
      third_party/zlib/deflate.c
  80. 2
      tool/build/calculator.inc
  81. 2
      tool/build/emubin/mips.c
  82. 2
      tool/build/emucrt/emucrt.mk
  83. 70
      tool/build/emulator.c
  84. 37
      tool/build/lib/alu.c
  85. 1
      tool/build/lib/alu.h
  86. 2
      tool/build/lib/buildlib.mk
  87. 5
      tool/build/lib/case.h
  88. 59
      tool/build/lib/cvt.c
  89. 1
      tool/build/lib/dis.c
  90. 1
      tool/build/lib/disarg.c
  91. 425
      tool/build/lib/fpu.c
  92. 11
      tool/build/lib/instruction.c
  93. 32
      tool/build/lib/loader.c
  94. 1115
      tool/build/lib/machine.c
  95. 2
      tool/build/lib/machine.h
  96. 98
      tool/build/lib/pml4t.c
  97. 2
      tool/build/lib/pml4t.h
  98. 5
      tool/build/lib/reset.c
  99. 49
      tool/build/lib/string.c
  100. 4
      tool/build/lib/syscall.c
  101. Some files were not shown because too many files have changed in this diff Show More

19
build/package

@ -18,14 +18,15 @@ else @@ -18,14 +18,15 @@ else
fi
fi
if [ "$SILENT" = "0" ]; then
COLUMNS=${COLUMNS:-80}
COLUMNS=$((COLUMNS - 4))
printf "%s\n" "$*" |
/usr/bin/fold -s -w $COLUMNS |
sed -e '1bb' -e 's/^/ /' -e ':b' -e '$b' -e 's/$/ \\/' >&2
else
printf "$LOGFMT" "${ACTION:-PACKAGE}" "$3" >&2
fi
printf "$LOGFMT" "${ACTION:-PACKAGE}" "$3" >&2
# if [ "$SILENT" = "0" ]; then
# COLUMNS=${COLUMNS:-80}
# COLUMNS=$((COLUMNS - 4))
# printf "%s\n" "$*" |
# /usr/bin/fold -s -w $COLUMNS |
# sed -e '1bb' -e 's/^/ /' -e ':b' -e '$b' -e 's/$/ \\/' >&2
# else
# printf "$LOGFMT" "${ACTION:-PACKAGE}" "$3" >&2
# fi
exec "$@"

6
build/zipobj

@ -42,11 +42,7 @@ else @@ -42,11 +42,7 @@ else
fi
if [ "$SILENT" = "0" ]; then
COLUMNS=${COLUMNS:-80}
COLUMNS=$((COLUMNS - 4))
printf "%s\n" "$*" |
/usr/bin/fold -s -w $COLUMNS |
$SED -e '1bb' -e 's/^/ /' -e ':b' -e '$b' -e 's/$/ \\/' >&2
printf "%s\n" "$*" >&2
else
printf "$LOGFMT" "${ACTION:-ZIPOBJ}" "$3" >&2
fi

1
libc/bits/safemacros.h

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
#ifndef COSMOPOLITAN_LIBC_BITS_SAFEMACROS_H_
#define COSMOPOLITAN_LIBC_BITS_SAFEMACROS_H_
#ifndef __STRICT_ANSI__
#include "libc/limits.h"
#include "libc/macros.h"
#include "libc/runtime/runtime.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)

5
libc/dns/resolvedns.c

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/bits/bits.h"
#include "libc/calls/calls.h"
#include "libc/dns/consts.h"
#include "libc/dns/dns.h"
@ -92,8 +93,8 @@ int resolvedns(const struct ResolvConf *resolvconf, int af, const char *name, @@ -92,8 +93,8 @@ int resolvedns(const struct ResolvConf *resolvconf, int af, const char *name,
}
if (p + 2 + 2 + 4 + 2 < pe) {
uint16_t rtype, rclass, rdlength;
rtype = read16be(p), p += 2;
rclass = read16be(p), p += 2;
rtype = READ16BE(p), p += 2;
rclass = READ16BE(p), p += 2;
/* ttl */ p += 4;
rdlength = read16be(p), p += 2;
if (p + rdlength <= pe && rdlength == 4 &&

2
libc/fmt/pflink.h

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
#ifndef COSMOPOLITAN_LIBC_FMT_PFLINK_H_
#define COSMOPOLITAN_LIBC_FMT_PFLINK_H_
#include "libc/dce.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#ifndef __STRICT_ANSI__
#include "libc/dce.h"
/**
* @fileoverview builtin+preprocessor+linker tricks for printf/scanf.

8
libc/intrin/shufpd.c

@ -18,16 +18,16 @@ @@ -18,16 +18,16 @@
02110-1301 USA
*/
#include "libc/intrin/shufpd.h"
#include "libc/str/str.h"
/**
* Shuffles double vector.
* @param 𝑚 needs to be a literal, constexpr, or embedding
* @mayalias
*/
void(shufpd)(double b[2], const double a[2], uint8_t m) {
void(shufpd)(double c[2], const double b[2], const double a[2], uint8_t m) {
double t[2];
t[0] = a[(m & 0b0000001) >> 0];
t[1] = a[(m & 0b0000010) >> 1];
b[0] = t[0];
b[1] = t[1];
t[1] = b[(m & 0b0000010) >> 1];
memcpy(c, t, 16);
}

2
libc/intrin/shufpd.h

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
void shufpd(double[2], const double[2], uint8_t);
void shufpd(double[2], const double[2], const double[2], uint8_t);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */

12
libc/intrin/shufps.c

@ -18,20 +18,18 @@ @@ -18,20 +18,18 @@
02110-1301 USA
*/
#include "libc/intrin/shufps.h"
#include "libc/str/str.h"
/**
* Shuffles float vector.
* @param 𝑚 needs to be a literal, constexpr, or embedding
* @mayalias
*/
void(shufps)(float b[4], const float a[4], uint8_t m) {
void(shufps)(float c[4], const float b[4], const float a[4], uint8_t m) {
float t[4];
t[0] = a[(m & 0b00000011) >> 0];
t[1] = a[(m & 0b00001100) >> 2];
t[0] = b[(m & 0b00000011) >> 0];
t[1] = b[(m & 0b00001100) >> 2];
t[2] = a[(m & 0b00110000) >> 4];
t[3] = a[(m & 0b11000000) >> 6];
b[0] = t[0];
b[1] = t[1];
b[2] = t[2];
b[3] = t[3];
memcpy(c, t, 16);
}

2
libc/intrin/shufps.h

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
void shufps(float[4], const float[4], uint8_t);
void shufps(float[4], const float[4], const float[4], uint8_t);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */

1
libc/log/log.h

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_LOG_LOG_H_
#define COSMOPOLITAN_LIBC_LOG_LOG_H_
#include "libc/dce.h"
/*───────────────────────────────────────────────────────────────────────────│─╗
cosmopolitan § liblog
*/

26
libc/math.h

@ -80,11 +80,20 @@ typedef float float_t; @@ -80,11 +80,20 @@ typedef float float_t;
typedef double double_t;
#endif
#define isinf(x) __builtin_isinf(x)
#define isnan(x) __builtin_isnan(x)
#define isfinite(x) __builtin_isfinite(x)
#define isnormal(x) __builtin_isnormal(x)
#define signbit(x) __builtin_signbit(x)
#define isinf(x) __builtin_isinf(x)
#define isnan(x) __builtin_isnan(x)
#define isfinite(x) __builtin_isfinite(x)
#define isnormal(x) __builtin_isnormal(x)
#define signbit(x) __builtin_signbit(x)
#define isgreater(x, y) __builtin_isgreater(x, y)
#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
#define isless(x, y) __builtin_isless(x, y)
#define islessequal(x, y) __builtin_islessequal(x, y)
#define islessgreater(x, y) __builtin_islessgreater(x, y)
#define isunordered(x, y) __builtin_isunordered(x, y)
#define fpclassify(x) \
__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
double acos(double);
double acosh(double);
@ -276,13 +285,6 @@ void sincos(double, double *, double *); @@ -276,13 +285,6 @@ void sincos(double, double *, double *);
void sincosf(float, float *, float *);
void sincosl(long double, long double *, long double *);
int __fpclassify(double);
int __fpclassifyf(float);
int __fpclassifyl(long double);
#define fpclassify(X) \
(sizeof(X) == 8 ? __fpclassify(X) \
: sizeof(X) == 4 ? __fpclassifyf(X) : __fpclassifyl(X))
/*───────────────────────────────────────────────────────────────────────────│─╗
cosmopolitan § mathematics » x87
*/

2
libc/nt/thunk/msabi.h

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
* generate code that calls MS ABI functions directly, without needing
* to jump through the assembly thunks.
*/
#if __GNUC__ * 100 + __GNUC_MINOR_ >= 408 || \
#if __GNUC__ * 100 + __GNUC_MINOR__ >= 408 || \
(__has_attribute(__ms_abi__) || defined(__llvm__))
#define __msabi __attribute__((__ms_abi__))
#endif

36
libc/nt/winsock.h

@ -45,15 +45,15 @@ COSMOPOLITAN_C_START_ @@ -45,15 +45,15 @@ COSMOPOLITAN_C_START_
#endif
#define kNtSioSocketCloseNotify 0x9800000Du
#define kNtSioUdpConnreset 0x9800000Cu
#define kNtSioUdpNetreset 0x9800000F
#define kNtSioUdpConnreset 0x9800000Cu
#define kNtSioUdpNetreset 0x9800000F
#define kNtTfDisconnect 0x01
#define kNtTfReuseSocket 0x02
#define kNtTfWriteBehind 0x04
#define kNtTfDisconnect 0x01
#define kNtTfReuseSocket 0x02
#define kNtTfWriteBehind 0x04
#define kNtTfUseDefaultWorker 0x00
#define kNtTfUseSystemThread 0x10
#define kNtTfUseKernelApc 0x20
#define kNtTfUseSystemThread 0x10
#define kNtTfUseKernelApc 0x20
struct sockaddr;
struct sockaddr_in;
@ -295,8 +295,8 @@ struct NtWsaCompletion { @@ -295,8 +295,8 @@ struct NtWsaCompletion {
* functions are declared within their respective wrappers.
*/
nodiscard int32_t WSAStartup(uint16_t wVersionRequested,
struct NtWsaData *lpWSAData) paramsnonnull();
int32_t WSAStartup(uint16_t wVersionRequested, struct NtWsaData *lpWSAData)
paramsnonnull() nodiscard;
int WSACleanup(void);
int WSAGetLastError(void);
@ -312,9 +312,9 @@ int __listen$nt(uint64_t, int); @@ -312,9 +312,9 @@ int __listen$nt(uint64_t, int);
int __setsockopt$nt(uint64_t, int, int, const void *, int);
int __shutdown$nt(uint64_t, int);
nodiscard uint64_t WSASocket(int af, int type, int protocol,
const struct NtWsaProtocolInfo *opt_lpProtocolInfo,
const uint32_t opt_group, uint32_t dwFlags);
uint64_t WSASocket(int af, int type, int protocol,
const struct NtWsaProtocolInfo *opt_lpProtocolInfo,
const uint32_t opt_group, uint32_t dwFlags) nodiscard;
int WSAConnect(uint64_t s, const struct sockaddr *name, const int namelen,
const struct iovec$nt *opt_lpCallerData,
@ -340,11 +340,11 @@ bool32 WSAConnectByList(uint64_t s, @@ -340,11 +340,11 @@ bool32 WSAConnectByList(uint64_t s,
const struct timeval$nt *opt_timeout,
struct NtOverlapped *__Reserved) paramsnonnull((2));
nodiscard int64_t WSAAccept(uint64_t s, struct sockaddr *out_addr,
int32_t *opt_inout_addrlen,
const NtConditionProc opt_lpfnCondition,
const uint32_t *opt_dwCallbackData)
paramsnonnull((2));
int64_t WSAAccept(uint64_t s, struct sockaddr *out_addr,
int32_t *opt_inout_addrlen,
const NtConditionProc opt_lpfnCondition,
const uint32_t *opt_dwCallbackData)
paramsnonnull((2)) nodiscard;
int WSASend(uint64_t s, const struct iovec$nt *lpBuffers,
uint32_t dwBufferCount, uint32_t *opt_out_lpNumberOfBytesSent,
@ -406,7 +406,7 @@ int WSANSPIoctl(int64_t hLookup, uint32_t dwControlCode, @@ -406,7 +406,7 @@ int WSANSPIoctl(int64_t hLookup, uint32_t dwControlCode,
const struct NtWsaCompletion *opt_lpCompletion)
paramsnonnull((3, 5, 7));
nodiscard int64_t WSACreateEvent(void);
int64_t WSACreateEvent(void) nodiscard;
bool32 WSACloseEvent(const int64_t hEvent);
bool32 WSAResetEvent(const int64_t hEvent);
bool32 WSASetEvent(const int64_t hEvent);

1
libc/runtime/describeos.c

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/dce.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"

3
libc/runtime/hook.greg.c

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/bits/bits.h"
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/struct/sigset.h"
@ -71,7 +72,7 @@ privileged void __hook(void ifunc(void), struct SymbolTable *symbols) { @@ -71,7 +72,7 @@ privileged void __hook(void ifunc(void), struct SymbolTable *symbols) {
pe = (unsigned char *)(symbols->addr_base +
symbols->symbols[i + 1].addr_rva);
p < pe - 8; ++p) {
code = read64le(p);
code = READ64LE(p);
/*
* Test for -mrecord-mcount (w/ -fpie or -fpic)

1
libc/runtime/memtrack.c

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
02110-1301 USA
*/
#include "libc/assert.h"
#include "libc/dce.h"
#include "libc/macros.h"
#include "libc/runtime/memtrack.h"
#include "libc/runtime/runtime.h"

2
libc/runtime/memtrack.h

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#define kMappingsSize 0x100000000000 /* 16TB */
#define kMappingsSize 0x0000100000000000 /* 16TB */
#define kMappingsStart (IsGenuineCosmo() ? 0x300000000000 : 0x200000000000)
#define kFixedMappingsStart 0x0000100000000000
#define kFixedMappingsSize kMappingsSize

2
libc/runtime/mmap.c

@ -129,7 +129,7 @@ void *mmap(void *addr, size_t size, int prot, int flags, int fd, int64_t off) { @@ -129,7 +129,7 @@ void *mmap(void *addr, size_t size, int prot, int flags, int fd, int64_t off) {
if (!CANONICAL(addr)) return VIP(einval());
if (!(!!(flags & MAP_ANONYMOUS) ^ (fd != -1))) return VIP(einval());
if (!(!!(flags & MAP_PRIVATE) ^ !!(flags & MAP_SHARED))) return VIP(einval());
if (fd != -1) size = ROUNDUP(size, FRAMESIZE);
if (fd == -1) size = ROUNDUP(size, FRAMESIZE);
if (flags & MAP_FIXED) {
if (UntrackMemoryIntervals(addr, size) == -1) {
return MAP_FAILED;

1
libc/runtime/runtime.h

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_RUNTIME_RUNTIME_H_
#define COSMOPOLITAN_LIBC_RUNTIME_RUNTIME_H_
#include "libc/dce.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗

1
libc/str/str.h

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_STR_STR_H_
#define COSMOPOLITAN_LIBC_STR_STR_H_
#include "libc/bits/bits.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗

2
libc/tinymath/acosl.S

@ -46,7 +46,7 @@ tinymath_acosl: @@ -46,7 +46,7 @@ tinymath_acosl:
fsqrt
fabs # needed in downward rounding mode
#endif
fxch %st(1)
fxch
fpatan
pop %rbp
ret

1
libc/tinymath/asinl.S

@ -51,5 +51,4 @@ tinymath_asinl: @@ -51,5 +51,4 @@ tinymath_asinl:
.alias tinymath_asinl,asinl
.rodata.cst4
.align 4
.Lone: .float 1.0

2
libc/tinymath/cabsl.S

@ -27,7 +27,7 @@ tinymath_cabsl: @@ -27,7 +27,7 @@ tinymath_cabsl:
fldt 32(%rbp)
fldt 16(%rbp)
fmul %st,%st
fxch %st(1)
fxch
fmul %st,%st
faddp %st,%st(1)
fsqrt

2
libc/tinymath/carg.S

@ -29,7 +29,7 @@ tinymath_carg: @@ -29,7 +29,7 @@ tinymath_carg:
fldl -16(%rbp)
movsd %xmm1,-16(%rbp)
fldl -16(%rbp)
fxch %st(1)
fxch
fpatan
fstpl -16(%rbp)
movsd -16(%rbp),%xmm0

2
libc/tinymath/exp10l.S

@ -34,7 +34,7 @@ tinymath_exp10l: @@ -34,7 +34,7 @@ tinymath_exp10l:
fld %st
frndint
fsubr %st,%st(1)
fxch %st(1)
fxch
f2xm1
fld1
faddp

2
libc/tinymath/exp2l.S

@ -32,7 +32,7 @@ tinymath_exp2l: @@ -32,7 +32,7 @@ tinymath_exp2l:
fld %st
frndint
fsubr %st,%st(1)
fxch %st(1)
fxch
f2xm1
fadds .Lone(%rip)
fscale

2
libc/tinymath/expl.S

@ -34,7 +34,7 @@ tinymath_expl: @@ -34,7 +34,7 @@ tinymath_expl:
fld %st
frndint
fsubr %st,%st(1)
fxch %st(1)
fxch
f2xm1
fld1
faddp

19
libc/tinymath/floor.S

@ -25,14 +25,14 @@ @@ -25,14 +25,14 @@
tinymath_floor:
.leafprologue
.profilable
movsd .LC6(%rip),%xmm1
movsd .LC5(%rip),%xmm2
movsd 4f(%rip),%xmm1
movsd 3f(%rip),%xmm2
andpd %xmm0,%xmm1
comisd %xmm1,%xmm2
jbe 1f
cvttsd2siq %xmm0,%rax
pxor %xmm1,%xmm1
movsd .LC4(%rip),%xmm2
movsd 2f(%rip),%xmm2
cvtsi2sdq %rax,%xmm1
movapd %xmm1,%xmm3
cmpnlesd %xmm0,%xmm3
@ -45,13 +45,6 @@ tinymath_floor: @@ -45,13 +45,6 @@ tinymath_floor:
.alias tinymath_floor,floor
.rodata.cst8
.LC4: .long 0
.long 1072693248
.LC5: .long 0
.long 1127219200
.rodata.cst16
.LC6: .long 4294967295
.long 2147483647
.long 0
.long 0
2: .double 1
3: .double 0x0010000000000000
4: .double nan

54
libc/tinymath/fpclassifyl.S

@ -1,54 +0,0 @@ @@ -1,54 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/math.h"
#include "libc/macros.h"
.source __FILE__
tinymath_fpclassifyl:
push %rbp
mov %rsp,%rbp
mov 24(%rbp),%rax
mov 16(%rbp),%rdx
and $0x7fff,%ax
mov %rdx,%rcx
shr $63,%rcx
movzwl %ax,%esi
or %ecx,%esi
jne 2f
cmp $1,%rdx
sbb %eax,%eax
add $3,%eax
jmp 1f
2: cmp $0x7fff,%ax
jne 4f
xor %eax,%eax
test %rcx,%rcx
je 1f
xor %eax,%eax
add %rdx,%rdx
sete %al
jmp 1f
4: mov %ecx,%eax
neg %eax
and $FP_NORMAL,%eax
1: pop %rbp
ret
.endfn tinymath_fpclassifyl,globl
.alias tinymath_fpclassifyl,__fpclassifyl

2
libc/tinymath/hypotl.S

@ -28,7 +28,7 @@ tinymath_hypotl: @@ -28,7 +28,7 @@ tinymath_hypotl:
fldt 32(%rbp)
fldt 16(%rbp)
fmul %st,%st
fxch %st(1)
fxch
fmul %st,%st
faddp
pop %rbp

2
libc/tinymath/ilogb.S

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
/ Returns log exponent part of double.
/ Returns log𝑥 exponent part of double.
/
/ @param 𝑥 is double passed in %xmm0
/ @return result in %eax

2
libc/tinymath/ilogbf.S

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
/ Returns log exponent part of float.
/ Returns logx exponent part of float.
/
/ @param 𝑥 is float passed in %xmm0
/ @return result in %eax

2
libc/tinymath/ilogbl.S

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
/ Returns log exponent part of long double.
/ Returns logx exponent part of long double.
/
/ @param 𝑥 is long double passed on stack
/ @return result in %eax

31
libc/tinymath/isgreater.S

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreaterf:
.leafprologue
.profilable
xor %eax,%eax
comiss %xmm1,%xmm0
seta %al
.leafepilogue
.endfn tinymath_isgreaterf,globl
.alias tinymath_isgreaterf,isgreaterf

31
libc/tinymath/isgreaterequal.S

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreaterequal:
.leafprologue
.profilable
xor %eax,%eax
comisd %xmm1,%xmm0
setnb %al
.leafepilogue
.endfn tinymath_isgreaterequal,globl
.alias tinymath_isgreaterequal,isgreaterequal

31
libc/tinymath/isgreaterequalf.S

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreaterequalf:
.leafprologue
.profilable
xor %eax,%eax
comiss %xmm1,%xmm0
setnb %al
.leafepilogue
.endfn tinymath_isgreaterequalf,globl
.alias tinymath_isgreaterequalf,isgreaterequalf

36
libc/tinymath/isgreaterequall.S

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreaterequall:
push %rbp
mov %rsp,%rbp
.profilable
fldt 32(%rbp)
fldt 16(%rbp)
xor %eax,%eax
fcomip %st(1),%st
fstp %st
setnb %al
pop %rbp
ret
.endfn tinymath_isgreaterequall,globl
.alias tinymath_isgreaterequall,isgreaterequall

31
libc/tinymath/isgreaterf.S

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreater:
.leafprologue
.profilable
xor %eax,%eax
comisd %xmm1,%xmm0
seta %al
.leafepilogue
.endfn tinymath_isgreater,globl
.alias tinymath_isgreater,isgreater

36
libc/tinymath/isgreaterl.S

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreaterl:
push %rbp
mov %rsp,%rbp
.profilable
fldt 32(%rbp)
fldt 16(%rbp)
xor %eax,%eax
fcomip %st(1),%st
fstp %st
seta %al
pop %rbp
ret
.endfn tinymath_isgreaterl,globl
.alias tinymath_isgreaterl,isgreaterl

31
libc/tinymath/isless.S

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isless:
.leafprologue
.profilable
xor %eax,%eax
comisd %xmm0,%xmm1
seta %al
.leafepilogue
.endfn tinymath_isless,globl
.alias tinymath_isless,isless

31
libc/tinymath/islessequal.S

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessequal:
.leafprologue
.profilable
xor %eax,%eax
comisd %xmm0,%xmm1
setnb %al
.leafepilogue
.endfn tinymath_islessequal,globl
.alias tinymath_islessequal,islessequal

31
libc/tinymath/islessequalf.S

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessequalf:
.leafprologue
.profilable
xor %eax,%eax
comiss %xmm0,%xmm1
setnb %al
.leafepilogue
.endfn tinymath_islessequalf,globl
.alias tinymath_islessequalf,islessequalf

36
libc/tinymath/islessequall.S

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessequall:
push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
xor %eax,%eax
fldt 32(%rbp)
fcomip %st(1),%st
fstp %st
setnb %al
pop %rbp
ret
.endfn tinymath_islessequall,globl
.alias tinymath_islessequall,islessequall

31
libc/tinymath/islessf.S

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessf:
.leafprologue
.profilable
xor %eax,%eax
comiss %xmm0,%xmm1
seta %al
.leafepilogue
.endfn tinymath_islessf,globl
.alias tinymath_islessf,islessf

31
libc/tinymath/islessgreater.S

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by