mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 08:18:30 +00:00
Improve documentation
The Cosmo API documentation page is pretty good now https://justine.lol/cosmopolitan/documentation.html
This commit is contained in:
parent
13437dd19b
commit
1bc3a25505
367 changed files with 2542 additions and 26178 deletions
|
@ -22,12 +22,13 @@
|
|||
|
||||
/ Returns arc tangent of 𝑥.
|
||||
/
|
||||
/ 1 3 1 5 1 7 1 9 1 11
|
||||
/ atan(𝑥) = 𝑥 - - 𝑥 + - 𝑥 - - 𝑥 + - 𝑥 - -- 𝑥 ...
|
||||
/ 3 5 7 9 11
|
||||
/
|
||||
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
|
||||
/ @return result of computation on FPU stack in %st
|
||||
/ @define atan(𝑥) = Σₙ₌₀₋∞ 2²ⁿ(𝑛!)²/(𝟸𝑛+𝟷)!(𝑥²ⁿ⁺¹/(𝑥²+𝟷)ⁿ⁺¹)
|
||||
/ 1 3 1 5 1 7 1 9 1 11
|
||||
/ @define atan(𝑥) = 𝑥 - - 𝑥 + - 𝑥 - - 𝑥 + - 𝑥 - -- 𝑥 ...
|
||||
/ 3 5 7 9 11
|
||||
tinymath_atanl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
|
|
|
@ -24,19 +24,19 @@ tinymath_copysign:
|
|||
.leafprologue
|
||||
.profilable
|
||||
movapd %xmm1,%xmm2
|
||||
andpd .L1(%rip),%xmm0
|
||||
andpd .L2(%rip),%xmm2
|
||||
andpd .Lnan(%rip),%xmm0
|
||||
andpd .Lneg0(%rip),%xmm2
|
||||
orpd %xmm2,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_copysign,globl
|
||||
.alias tinymath_copysign,copysign
|
||||
|
||||
.rodata.cst16
|
||||
.L1: .long 4294967295
|
||||
.long 2147483647
|
||||
.Lnan: .long 0xffffffff
|
||||
.long 0x7fffffff
|
||||
.long 0
|
||||
.long 0
|
||||
.L2: .long 0
|
||||
.Lneg0: .long 0
|
||||
.long -2147483648
|
||||
.long 0
|
||||
.long 0
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
/ Returns absolute value of double.
|
||||
/
|
||||
/ @param xmm0 has double in lower half
|
||||
/ @return xmm0 has result in lower half
|
||||
fabs: .leafprologue
|
||||
.profilable
|
||||
mov $0x7fffffffffffffff,%rax
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-*- 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│
|
||||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
|
@ -17,13 +17,20 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
#include "libc/tinymath/tinymath.h"
|
||||
|
||||
tinymath_fmax:
|
||||
.leafprologue
|
||||
.profilable
|
||||
maxsd %xmm1,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_fmax,globl
|
||||
.alias tinymath_fmax,fmax
|
||||
/**
|
||||
* Returns maximum of two doubles.
|
||||
*
|
||||
* If one argument is NAN then the other is returned.
|
||||
* This function is designed to do the right thing with
|
||||
* signed zeroes.
|
||||
*/
|
||||
double fmax(double x, double y) {
|
||||
if (__builtin_isnan(x)) return y;
|
||||
if (__builtin_isnan(y)) return x;
|
||||
if (__builtin_signbit(x) != __builtin_signbit(y)) {
|
||||
return __builtin_signbit(x) ? y : x; /* C99 Annex F.9.9.2 */
|
||||
}
|
||||
return x < y ? y : x;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*-*- 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│
|
||||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
|
@ -17,24 +17,20 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
#include "libc/tinymath/tinymath.h"
|
||||
|
||||
/ 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
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fldt 16(%rbp)
|
||||
fcomi %st(1),%st
|
||||
fcmovb %st(1),%st
|
||||
fstp %st(1)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_fmaxl,globl
|
||||
.alias tinymath_fmaxl,fmaxl
|
||||
/**
|
||||
* Returns maximum of two floats.
|
||||
*
|
||||
* If one argument is NAN then the other is returned.
|
||||
* This function is designed to do the right thing with
|
||||
* signed zeroes.
|
||||
*/
|
||||
float fmaxf(float x, float y) {
|
||||
if (__builtin_isnan(x)) return y;
|
||||
if (__builtin_isnan(y)) return x;
|
||||
if (__builtin_signbitf(x) != __builtin_signbitf(y)) {
|
||||
return __builtin_signbitf(x) ? y : x; /* C99 Annex F.9.9.2 */
|
||||
}
|
||||
return x < y ? y : x;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*-*- 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│
|
||||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
|
@ -17,13 +17,20 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
#include "libc/tinymath/tinymath.h"
|
||||
|
||||
tinymath_fmin:
|
||||
.leafprologue
|
||||
.profilable
|
||||
minsd %xmm1,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_fmin,globl
|
||||
.alias tinymath_fmin,fmin
|
||||
/**
|
||||
* Returns maximum of two long doubles.
|
||||
*
|
||||
* If one argument is NAN then the other is returned.
|
||||
* This function is designed to do the right thing with
|
||||
* signed zeroes.
|
||||
*/
|
||||
long double fmaxl(long double x, long double y) {
|
||||
if (__builtin_isnan(x)) return y;
|
||||
if (__builtin_isnan(y)) return x;
|
||||
if (__builtin_signbitl(x) != __builtin_signbitl(y)) {
|
||||
return __builtin_signbitl(x) ? y : x; /* C99 Annex F.9.9.2 */
|
||||
}
|
||||
return x < y ? y : x;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*-*- 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│
|
||||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
|
@ -17,13 +17,20 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
#include "libc/tinymath/tinymath.h"
|
||||
|
||||
tinymath_fmaxf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
maxss %xmm1,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_fmaxf,globl
|
||||
.alias tinymath_fmaxf,fmaxf
|
||||
/**
|
||||
* Returns minimum of two doubles.
|
||||
*
|
||||
* If one argument is NAN then the other is returned.
|
||||
* This function is designed to do the right thing with
|
||||
* signed zeroes.
|
||||
*/
|
||||
double fmin(double x, double y) {
|
||||
if (__builtin_isnan(x)) return y;
|
||||
if (__builtin_isnan(y)) return x;
|
||||
if (__builtin_signbit(x) != __builtin_signbit(y)) {
|
||||
return __builtin_signbit(x) ? x : y; /* C99 Annex F.9.9.2 */
|
||||
}
|
||||
return x < y ? x : y;
|
||||
}
|
|
@ -1,29 +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_fminf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
minss %xmm1,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_fminf,globl
|
||||
.alias tinymath_fminf,fminf
|
|
@ -1,5 +1,5 @@
|
|||
/*-*- 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│
|
||||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
|
@ -17,24 +17,20 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
#include "libc/tinymath/tinymath.h"
|
||||
|
||||
/ 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
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fldt 16(%rbp)
|
||||
fcomi %st(1),%st
|
||||
fcmovnbe %st(1),%st
|
||||
fstp %st(1)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_fminl,globl
|
||||
.alias tinymath_fminl,fminl
|
||||
/**
|
||||
* Returns minimum of two floats.
|
||||
*
|
||||
* If one argument is NAN then the other is returned.
|
||||
* This function is designed to do the right thing with
|
||||
* signed zeroes.
|
||||
*/
|
||||
float fmin(float x, float y) {
|
||||
if (__builtin_isnan(x)) return y;
|
||||
if (__builtin_isnan(y)) return x;
|
||||
if (__builtin_signbitf(x) != __builtin_signbitf(y)) {
|
||||
return __builtin_signbitf(x) ? x : y; /* C99 Annex F.9.9.2 */
|
||||
}
|
||||
return x < y ? x : y;
|
||||
}
|
36
libc/tinymath/fminl.c
Normal file
36
libc/tinymath/fminl.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*-*- 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│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ 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/tinymath/tinymath.h"
|
||||
|
||||
/**
|
||||
* Returns minimum of two long doubles.
|
||||
*
|
||||
* If one argument is NAN then the other is returned.
|
||||
* This function is designed to do the right thing with
|
||||
* signed zeroes.
|
||||
*/
|
||||
long double fminl(long double x, long double y) {
|
||||
if (__builtin_isnan(x)) return y;
|
||||
if (__builtin_isnan(y)) return x;
|
||||
if (__builtin_signbitl(x) != __builtin_signbitl(y)) {
|
||||
return __builtin_signbitl(x) ? x : y; /* C99 Annex F.9.9.2 */
|
||||
}
|
||||
return x < y ? x : y;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue