Get address sanitizer mostly working

This commit is contained in:
Justine Tunney 2020-09-03 05:44:37 -07:00
parent 1f1f3cd477
commit 7327c345f9
149 changed files with 3777 additions and 3457 deletions

View file

@ -20,6 +20,11 @@
#include "libc/macros.h"
.source __FILE__
/ Returns maximum of two long doubles.
/
/ @param 𝑥 is long double passed on stack in 16-bytes
/ @param 𝑦 is also pushed on stack, in reverse order
/ @return result in %st0
tinymath_fmaxl:
push %rbp
mov %rsp,%rbp

View file

@ -20,6 +20,11 @@
#include "libc/macros.h"
.source __FILE__
/ Returns minimum of two long doubles.
/
/ @param 𝑥 is long double passed on stack in 16-bytes
/ @param 𝑦 is also pushed on stack, in reverse order
/ @return result in %st0
tinymath_fminl:
push %rbp
mov %rsp,%rbp

View file

@ -22,8 +22,8 @@
/ Returns 𝑥^𝑦.
/
/ @param 𝑦 is double scalar in low half of %xmm0
/ @param 𝑥 is double scalar in low half of %xmm1
/ @param 𝑥 is double scalar in low half of %xmm0
/ @param 𝑦 is double scalar in low half of %xmm1
/ @return double scalar in low half of %xmm0
tinymath_pow:
ezlea tinymath_powl,ax

View file

@ -1,5 +1,5 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
/*-*- 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
@ -17,8 +17,15 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/tinymath/tinymath.h"
#include "libc/macros.h"
double(powi)(double a, int b) {
return tinymath_powl(a, b);
}
/ Returns 𝑥^𝑦.
/
/ @param 𝑥 is double scalar in low half of %xmm0
/ @param 𝑦 is int passed in %edi
/ @return double scalar in low half of %xmm0
tinymath_powi:
cvtsi2sd %edi,%xmm1
jmp tinymath_pow
.endfn tinymath_powi,globl
.alias tinymath_powi,powi

View file

@ -1,5 +1,5 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
/*-*- 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
@ -17,8 +17,15 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/tinymath/tinymath.h"
#include "libc/macros.h"
float powif(float a, int b) {
return tinymath_powl(a, b);
}
/ Returns 𝑥^𝑦.
/
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @param 𝑦 is int passed in %edi
/ @return double scalar in low half of %xmm0
tinymath_powif:
cvtsi2ss %edi,%xmm1
jmp tinymath_pow
.endfn tinymath_powif,globl
.alias tinymath_powif,powif

View file

@ -1,5 +1,5 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
/*-*- 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
@ -17,8 +17,25 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/tinymath/tinymath.h"
#include "libc/macros.h"
long double powil(long double a, int b) {
return tinymath_powl(a, b);
}
/ Returns 𝑥^𝑦.
/
/ @param 𝑥 is long double passed on stack
/ @param 𝑦 is int passed in %edi
/ @return %st
tinymath_powil:
push %rbp
mov %rsp,%rbp
.profilable
sub $32,%rsp
mov %edi,-4(%rbp)
fildl -4(%rbp)
fstpt (%rsp)
push 16+8(%rbp)
push 16+0(%rbp)
call tinymath_powl
leave
ret
.endfn tinymath_powil,globl
.alias tinymath_powil,powil

View file

@ -22,6 +22,11 @@
#include "libc/macros.h"
.source __FILE__
/ Rounds to nearest integer.
/
/ @param is double passed in %xmm0
/ @return double in %xmm0
/ @note rounding behavior can be changed in mxcsr
tinymath_rint:
#if !X86_NEED(SSE4_2)
testb X86_HAVE(SSE4_2)+kCpuids(%rip)

View file

@ -20,6 +20,11 @@
#include "libc/macros.h"
.source __FILE__
/ Rounds to nearest integer.
/
/ @param is long double passed on stack
/ @return long double in %st
/ @note rounding behavior can be changed in control word
tinymath_rintl:
push %rbp
mov %rsp,%rbp

View file

@ -6,6 +6,7 @@ PKGS += LIBC_TINYMATH
LIBC_TINYMATH_ARTIFACTS += LIBC_TINYMATH_A
LIBC_TINYMATH = $(LIBC_TINYMATH_A_DEPS) $(LIBC_TINYMATH_A)
LIBC_TINYMATH_A = o/$(MODE)/libc/tinymath/tinymath.a
LIBC_TINYMATH_A_FILES := $(wildcard libc/tinymath/*)
LIBC_TINYMATH_A_HDRS = $(filter %.h,$(LIBC_TINYMATH_A_FILES))
LIBC_TINYMATH_A_SRCS_A = $(filter %.s,$(LIBC_TINYMATH_A_FILES))
LIBC_TINYMATH_A_SRCS_S = $(filter %.S,$(LIBC_TINYMATH_A_FILES))
@ -13,10 +14,6 @@ LIBC_TINYMATH_A_SRCS_C = $(filter %.c,$(LIBC_TINYMATH_A_FILES))
LIBC_TINYMATH_A_SRCS = $(LIBC_TINYMATH_A_SRCS_S) $(LIBC_TINYMATH_A_SRCS_C)
LIBC_TINYMATH_A_CHECKS = $(LIBC_TINYMATH_A).pkg
LIBC_TINYMATH_A_FILES := \
$(wildcard libc/tinymath/*) \
$(wildcard libc/tinymath/delegates/*)
LIBC_TINYMATH_A_OBJS = \
$(LIBC_TINYMATH_A_SRCS:%=o/$(MODE)/%.zip.o) \
$(LIBC_TINYMATH_A_SRCS_A:%.s=o/$(MODE)/%.o) \