Add pseudoteletypewriter to emulator

https://justine.storage.googleapis.com/emulator628.mp4
This commit is contained in:
Justine Tunney 2020-08-26 23:08:08 -07:00
parent e86cff8ba0
commit 5aabacb361
94 changed files with 3245 additions and 2179 deletions

View file

@ -18,42 +18,36 @@
02110-1301 USA
*/
#include "libc/alg/alg.h"
#include "libc/fmt/bing.h"
#include "libc/log/log.h"
#include "libc/macros.h"
#include "libc/nexgen32e/nexgen32e.h"
#include "libc/str/str.h"
#define ALTCOUNT 21
static const struct Cp437Multimappings {
unsigned char b[ALTCOUNT];
char16_t c[ALTCOUNT];
} kCp437iMultimappings = {
#define ALT(I, C, B) .c[I] = C, .b[I] = B
ALT(0, u'\n', '\n'),
ALT(1, u'\r', '\r'),
ALT(2, u'?', '?'), /* TRIGRAPH */
ALT(3, u'\'', '\''), /* CHARACTER LITERAL */
ALT(4, u'\"', '\"'), /* STRING LITERAL */
ALT(5, u'\\', '\\'), /* ESCAPE LITERAL */
ALT(6, u'', '\0'), /* EMPTY SET */
ALT(7, u'', '\0'), /* SYMBOL FOR NULL [sic] */
ALT(7, 0x20A7, 0x9E), /* PESETA SIGN */
ALT(8, u'Π' /* 03A0: GREEK CAPITAL LETTER PI */, 0xE3),
ALT(9, u'' /* 220F: N-ARY PRODUCT */, 0xE3),
ALT(10, u'' /* 2211: N-ARY SUMMATION */, 0xE4),
ALT(11, u'µ' /* 03BC: MICRO SIGN */, 0xE6),
ALT(12, u'' /* 2126: OHM SIGN */, 0xEA),
ALT(13, u'' /* 2202: PARTIAL DIFFERENTIAL */, 0xEB),
ALT(14, u'ε' /* 03D5: PHI SMALL (CLOSED FORM) */, 0xED),
ALT(15, u'ϕ' /* 03D5: PHI SMALL (CLOSED FORM) */, 0xED),
ALT(16, u'' /* 2208: ELEMENT-OF SIGN */, 0xED),
ALT(17, u'' /* 220A: SMALL ELEMENT OF */, 0xEE),
ALT(18, u'' /* 03B5: ELEMENT-OF SIGN */, 0xEE),
ALT(19, u'β' /* 03B2: GREEK SMALL BETA */, 0xE1),
ALT(20, u'ſ' /* 017F: LATIN SMALL LETTER LONG S */, 0xF4),
#undef ALT
static const int kCp437iMultimappings[] = {
u'\n' << 8 | '\n', // NEWLINE
u'\r' << 8 | '\r', // CARRIAGE RETURN
u'?' << 8 | '?', // TRIGRAPH
u'\'' << 8 | '\'', // CHARACTER LITERAL
u'\"' << 8 | '\"', // STRING LITERAL
u'\\' << 8 | '\\', // ESCAPE LITERAL
u'' << 8 | '\0', // EMPTY SET
u'' << 8 | '\0', // SYMBOL FOR NULL [sic]
0x20A7 << 8 | 0x9E, // PESETA SIGN
u'Π' << 8 | 0xE3, // GREEK CAPITAL LETTER PI
u'' << 8 | 0xE3, // N-ARY PRODUCT
u'' << 8 | 0xE4, // N-ARY SUMMATION
u'µ' << 8 | 0xE6, // MICRO SIGN
u'' << 8 | 0xEA, // OHM SIGN
u'' << 8 | 0xEB, // PARTIAL DIFFERENTIAL
u'ϕ' << 8 | 0xED, // PHI SMALL (CLOSED FORM)
u'ε' << 8 | 0xEE, // LATIN SMALL LETTER EPSILON
u'' << 8 | 0xEE, // SMALL ELEMENT OF
u'' << 8 | 0xEE, // ELEMENT-OF SIGN
u'β' << 8 | 0xE1, // GREEK SMALL BETA
u'ſ' << 8 | 0xF4, // LATIN SMALL LETTER LONG S
};
static int g_cp437i[256 + ARRAYLEN(kCp437iMultimappings)];
/**
* Turns CP437 unicode glyph into its binary representation.
*
@ -62,15 +56,24 @@ static const struct Cp437Multimappings {
* @see bing()
*/
int unbing(int c) {
int i;
for (i = 0; i < 256; ++i) {
if (c == kCp437[i]) {
return i;
}
int i, m, l, r;
static bool once;
if (!once) {
for (i = 0; i < 256; ++i) g_cp437i[i] = kCp437[i] << 8 | i;
memcpy(g_cp437i + 256, kCp437iMultimappings, sizeof(kCp437iMultimappings));
insertionsort(ARRAYLEN(g_cp437i), g_cp437i);
once = true;
}
for (i = 0; i < ALTCOUNT; ++i) {
if (c == kCp437iMultimappings.c[i]) {
return kCp437iMultimappings.b[i];
l = 0;
r = ARRAYLEN(g_cp437i) - 1;
while (l <= r) {
m = (l + r) >> 1;
if ((g_cp437i[m] >> 8) < c) {
l = m + 1;
} else if ((g_cp437i[m] >> 8) > c) {
r = m - 1;
} else {
return g_cp437i[m] & 0xff;
}
}
return -1;

View file

@ -318,6 +318,15 @@ typedef uint64_t uintmax_t;
#endif
#endif
#ifndef noclone
#if !defined(__STRICT_ANSI__) && \
(__has_attribute(__noclone__) || __GNUC__ * 100 + __GNUC_MINOR__ >= 405)
#define noclone __attribute__((__noclone__))
#else
#define noclone
#endif
#endif
/**
* Makes function behave as much like macro as possible, meaning:
*

View file

@ -5,11 +5,12 @@
cosmopolitan § liblog
*/
#define kLogFatal 0u
#define kLogError 1u
#define kLogWarn 2u
#define kLogInfo 3u
#define kLogDebug 4u
#define kLogFatal 0u
#define kLogError 1u
#define kLogWarn 2u
#define kLogInfo 3u
#define kLogVerbose 4u
#define kLogDebug 5u
/**
* Log level for compile-time DCE.
@ -20,7 +21,7 @@
/* #elif IsTiny() */
/* #define LOGGABLELEVEL kLogInfo */
#else
#define LOGGABLELEVEL kLogInfo
#define LOGGABLELEVEL kLogVerbose
#endif
#endif
@ -149,6 +150,13 @@ extern unsigned g_loglevel; /* log level for runtime check */
} \
} while (0)
#define VERBOSEF(FMT, ...) \
do { \
if (LOGGABLE(kLogVerbose)) { \
fverbosef(kLogVerbose, __FILE__, __LINE__, NULL, FMT, ##__VA_ARGS__); \
} \
} while (0)
#define VDEBUGF(FMT, VA) \
do { \
if (LOGGABLE(kLogDebug)) { \
@ -163,6 +171,13 @@ extern unsigned g_loglevel; /* log level for runtime check */
} \
} while (0)
#define VFVERBOSEF(F, FMT, VA) \
do { \
if (LOGGABLE(kLogVerbose)) { \
vfverbosef(kLogVerbose, __FILE__, __LINE__, F, FMT, VA); \
} \
} while (0)
#define VFDEBUGF(F, FMT, VA) \
do { \
if (LOGGABLE(kLogDebug)) { \
@ -203,6 +218,8 @@ void __logerrno(const char *, int, const char *) relegated;
#define ATTRV paramsnonnull((5, 6))
void flogf(ARGS, ...) ATTR libcesque;
void vflogf(ARGS, va_list) ATTRV libcesque;
void fverbosef(ARGS, ...) asm("flogf") ATTR relegated libcesque;
void vfverbosef(ARGS, va_list) asm("vflogf") ATTRV relegated libcesque;
void fdebugf(ARGS, ...) asm("flogf") ATTR relegated libcesque;
void vfdebugf(ARGS, va_list) asm("vflogf") ATTRV relegated libcesque;
void ffatalf(ARGS, ...) asm("flogf") ATTR relegated noreturn libcesque;

View file

@ -76,7 +76,6 @@ void vflogf_onfail(FILE *f) {
void(vflogf)(unsigned level, const char *file, int line, FILE *f,
const char *fmt, va_list va) {
static struct timespec ts;
bool flush;
struct tm tm;
long double t2;
const char *prog;
@ -95,12 +94,10 @@ void(vflogf)(unsigned level, const char *file, int line, FILE *f,
timebufp = timebuf;
zonebufp = zonebuf;
dots = nsec;
flush = true;
} else {
timebufp = "---------------";
zonebufp = "---";
dots = nsec - ts.tv_nsec;
flush = true;
}
ts.tv_sec = secs;
ts.tv_nsec = nsec;
@ -113,7 +110,6 @@ void(vflogf)(unsigned level, const char *file, int line, FILE *f,
(vfprintf)(f, fmt, va);
va_end(va);
fputc('\n', f);
if (flush) fflush(f);
if (level == kLogFatal) {
startfatal(file, line);
fprintf(stderr, "fatal error see logfile\n");

View file

@ -17,55 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "ape/lib/pc.h"
#include "libc/dce.h"
#include "libc/nexgen32e/nexgen32e.h"
#include "libc/nt/struct/context.h"
#include "libc/nt/thunk/msabi.h"
#include "libc/nexgen32e/bsf.h"
#define kNtContextXstate 0x00100040
#define kNtXstateAvx 2
#define kNtXstateMaskAvx (1ull << kNtXstateAvx)
static void EnableAvx(void) {
asm volatile("mov\t%%cr4,%%rax\n\t"
"or\t%0,%%rax\n\t"
"mov\t%%rax,%%cr4\n\t"
"xor\t%%ecx,%%ecx\n\t"
"xgetbv\n\t"
"or\t%1,%%eax\n\t"
"xsetbv"
: /* no outputs */
: "i"(CR4_OSXSAVE), "i"(XCR0_X87 | XCR0_SSE | XCR0_AVX)
: "rax", "rcx", "rdx", "memory", "cc");
}
static void EnableAvxOnWindows(void) {
/* typedef uint64_t (*getenabledxstatefeatures_f)(void) __msabi; */
/* typedef bool32 (*initializecontext_f)(void *buffer, uint32_t flags, */
/* struct NtContext **out_context, */
/* uint32_t *inout_buffersize) __msabi;
*/
/* typedef bool32 (*getxstatefeaturesmask_f)(struct NtContext * context, */
/* uint64_t * out_featuremask)
* __msabi; */
/* typedef bool32 (*setxstatefeaturesmask_f)(struct NtContext * context, */
/* uint64_t featuremask) __msabi; */
/* getenabledxstatefeatures_f GetEnabledXStateFeatures; */
/* initializecontext_f InitializeContext; */
/* getxstatefeaturesmask_f GetXStateFeaturesMask; */
/* setxstatefeaturesmask_f SetXStateFeaturesMask; */
}
/**
* Requests authorization from operating system to do 256-bit math.
* @assume avx cpuid check performed by caller
*/
int _init_enableavx(void) {
if (IsMetal()) {
EnableAvx();
} else if (IsWindows()) {
EnableAvxOnWindows();
}
return 0;
int(bsf)(int x) {
return bsf(x);
}

View file

@ -17,12 +17,15 @@ COSMOPOLITAN_C_START_
* 0xffffffff 0 0 1 31 0
*/
int bsf(int);
int bsfl(long);
int bsfll(long long);
int bsfmax(uintmax_t);
#define bsf(u) __builtin_ctz(u)
#define bsfl(u) __builtin_ctzl(u)
#define bsfll(u) __builtin_ctzll(u)
unsigned bsfmax(uintmax_t);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_NEXGEN32E_BSF_H_ */

24
libc/nexgen32e/bsfl.c Normal file
View file

@ -0,0 +1,24 @@
/*-*- 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/nexgen32e/bsf.h"
int(bsfl)(long x) {
return bsfl(x);
}

24
libc/nexgen32e/bsfll.c Normal file
View file

@ -0,0 +1,24 @@
/*-*- 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/nexgen32e/bsf.h"
int(bsfll)(long long x) {
return bsfll(x);
}

24
libc/nexgen32e/bsr.c Normal file
View file

@ -0,0 +1,24 @@
/*-*- 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/nexgen32e/bsr.h"
int(bsr)(int x) {
return bsr(x);
}

View file

@ -17,11 +17,14 @@ COSMOPOLITAN_C_START_
* 0xffffffff 0 0 1 31 0
*/
#define bsr(u) ((sizeof(unsigned) * 8 - 1) ^ __builtin_clz(u))
#define bsrl(u) ((sizeof(unsigned long) * 8 - 1) ^ __builtin_clzl(u))
#define bsrll(u) ((sizeof(unsigned long long) * 8 - 1) ^ __builtin_clzll(u))
int bsr(int);
int bsrl(long);
int bsrll(long long);
int bsrmax(uintmax_t);
unsigned bsrmax(uintmax_t);
#define bsr(u) ((sizeof(int) * 8 - 1) ^ __builtin_clz(u))
#define bsrl(u) ((sizeof(long) * 8 - 1) ^ __builtin_clzl(u))
#define bsrll(u) ((sizeof(long long) * 8 - 1) ^ __builtin_clzll(u))
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */

24
libc/nexgen32e/bsrl.c Normal file
View file

@ -0,0 +1,24 @@
/*-*- 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/nexgen32e/bsr.h"
int(bsrl)(long x) {
return bsrl(x);
}

24
libc/nexgen32e/bsrll.c Normal file
View file

@ -0,0 +1,24 @@
/*-*- 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/nexgen32e/bsr.h"
int(bsrll)(long long x) {
return bsrll(x);
}

View file

@ -24,9 +24,9 @@
void djbsort$avx2(int32_t *, long);
/**
* D.J. Bernstein's fast integer sorting algorithm.
* D.J. Bernstein's outrageously fast integer sorting algorithm.
*/
void djbsort(size_t n, int32_t *a) {
void djbsort(size_t n, int32_t a[n]) {
if (X86_HAVE(AVX2)) {
djbsort$avx2(a, n);
} else {

View file

@ -49,11 +49,11 @@ CollectGarbage:
sub $0x20,%rsp
push %rax
push %rdx
movaps %xmm0,-0x20(%rbp)
movaps %xmm1,-0x10(%rbp)
movdqa %xmm0,-0x20(%rbp)
movdqa %xmm1,-0x10(%rbp)
call *%r9
movaps -0x10(%rbp),%xmm1
movaps -0x20(%rbp),%xmm0
movdqa -0x10(%rbp),%xmm1
movdqa -0x20(%rbp),%xmm0
pop %rdx
pop %rax
leave

View file

@ -70,7 +70,7 @@ kCpuids:.long 0,0,0,0 # EAX=0 (Basic Processor Info)
add $4*4,%rdi
jmp 2b
3: nop
#if 0 && !X86_NEED(AVX2)
#if !X86_NEED(AVX2)
testb X86_HAVE(AVX)(%r8)
jz 5f
testb X86_HAVE(OSXSAVE)(%r8)

View file

@ -17,8 +17,8 @@
#define X86_AES 1H, ECX, 25, _X86_CC_AES, _ /* westmere c. 2010 */
#define X86_APIC 1H, EDX, 9, 0, _
#define X86_ARCH_CAPABILITIES 7H, EDX, 29, 0, _
#define X86_AVX 1H, ECX, 28, _X86_CC_AVX, AVX /* sandybridge c. 2012 */
#define X86_AVX2 7H, EBX, 5, _X86_CC_AVX2, AVX /* haswell c. 2013 */
#define X86_AVX 1H, ECX, 28, _X86_CC_AVX, _ /* sandybridge c. 2012 */
#define X86_AVX2 7H, EBX, 5, _X86_CC_AVX2, _ /* haswell c. 2013 */
#define X86_AVX512BW 7H, EBX, 30, 0, _
#define X86_AVX512CD 7H, EBX, 28, 0, _
#define X86_AVX512DQ 7H, EBX, 17, 0, _
@ -246,17 +246,5 @@
#endif
#define _X86_HOOK__(X) X
#define _X86_HOOK_AVX(X) \
({ \
YOINK(_init_enableavx); \
X; \
})
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
int _init_enableavx(void) pureconst;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_NEXGEN32E_X86FEATURE_H_ */

View file

@ -23,6 +23,11 @@
.source __FILE__
/ Calls global initialization functions.
/
/ @param r12 is argc
/ @param r13 is argv
/ @param r14 is environ
/ @param r15 is auxv
_construct:
push %rbp
mov %rsp,%rbp

View file

@ -43,8 +43,8 @@ static struct CxaAtexitBlocks {
*
* Destructors are called in reverse order. They won't be called if the
* program aborts or _exit() is called. Invocations of this function are
* usually generated by the C++ compiler. Behavior is limitless if you
* choose to link calloc() and free().
* usually generated by the C++ compiler. Behavior is limitless if some
* other module has linked calloc().
*
* @param fp is void(*)(T)
* @param arg is passed to callback
@ -78,8 +78,11 @@ int __cxa_atexit(void *fp, void *arg, void *pred) {
/**
* Triggers global destructors.
*
* They're called in LIFO order. If a destructor adds more destructors,
* then those destructors will be called immediately following, before
* iteration continues.
*
* @param pred can be null to match all
* @note reentrant emptor
*/
void __cxa_finalize(void *pred) {
unsigned i;

View file

@ -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 (!(IsWindows() && 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;

View file

@ -37,6 +37,7 @@ LIBC_RUNTIME_A_DIRECTDEPS = \
LIBC_BITS \
LIBC_CALLS \
LIBC_CONV \
LIBC_TINYMATH \
LIBC_ELF \
LIBC_FMT \
LIBC_NEXGEN32E \

View file

@ -22,6 +22,11 @@
#include "libc/macros.h"
/ Self-bootstraps process upon existence before calling main.
/
/ @param r12 is argc
/ @param r13 is argv
/ @param r14 is environ
/ @param r15 is auxv
_spawn: push %rbp
mov %rsp,%rbp

View file

@ -64,9 +64,10 @@ void *isnotplaintext(const void *, size_t) nothrow nocallback nosideeffect;
3 Continuations follow */
#define INVALID_CODEPOINT 0xfffd
#define UTF16_MASK 0b1111110000000000
#define UTF16_MOAR 0b1101100000000000 /* 0xD800..0xDBFF */
#define UTF16_CONT 0b1101110000000000 /* 0xDC00..0xDBFF */
#define UTF16_MASK 0b1111110000000000
#define UTF16_MOAR 0b1101100000000000 /* 0xD800..0xDBFF */
#define UTF16_CONT 0b1101110000000000 /* 0xDC00..0xDBFF */
unsigned getutf16(const char16_t *, wint_t *);
int pututf16(char16_t *, size_t, wint_t, bool);

8
libc/str/thompike.h Normal file
View file

@ -0,0 +1,8 @@
#ifndef COSMOPOLITAN_LIBC_STR_THOMPIKE_H_
#define COSMOPOLITAN_LIBC_STR_THOMPIKE_H_
#include "libc/nexgen32e/bsr.h"
#define ThomPikeCont(x) ((x & 0b11000000) == 0b10000000)
#define ThomPikeByte(x) (x & (((1 << (x < 252 ? bsr(~x & 0xff) : 1)) - 1) | 3))
#endif /* COSMOPOLITAN_LIBC_STR_THOMPIKE_H_ */

View file

@ -2611,7 +2611,7 @@ syscon ioctl FIONREAD 0x541b 0x4004667f 0x4004667f 0x4004667f 0x4004667f
#syscon ioctl FIONWRITE 0x0 0x0 0x40046677 0x0 -1 # [FreeBSD Generalization] bytes queued in FD's output buffer (same as TIOCOUTQ for TTY FDs; see also SO_SNDBUF)
#syscon ioctl FIONSPACE 0x0 0x0 0x40046676 0x0 -1 # [FreeBSD Generalization] capacity of FD's output buffer, e.g. equivalent to TIOCGSERIAL w/ UART
syscon ioctl TIOCINQ 0x541b 0x4004667f 0x4004667f 0x4004667f 0x4004667f # [Linuxism] same as FIONREAD
syscon ioctl TIOCOUTQ 0x5411 0x40047473 0x40047473 0x40047473 -1 # bytes queued in TTY's output buffer
#syscon ioctl TIOCOUTQ 0x5411 0x40047473 0x40047473 0x40047473 -1 # bytes queued in TTY's output buffer
syscon misc FANOTIFY_METADATA_VERSION 3 0 0 0 0
syscon misc FAPPEND 0x0400 8 8 8 0 # bsd consensus

View file

@ -21,7 +21,7 @@
#include "libc/macros.h"
.source __FILE__
__fpclassify:
tinymath_fpclassify:
.leafprologue
movd %xmm0,%rax
movd %xmm0,%rdx
@ -41,4 +41,5 @@ __fpclassify:
sal $12,%rdx
sete %al
1: .leafepilogue
.endfn __fpclassify,globl
.endfn tinymath_fpclassify,globl
.alias tinymath_fpclassify,__fpclassify

View file

@ -21,7 +21,7 @@
#include "libc/macros.h"
.source __FILE__
__fpclassifyf:
tinymath_fpclassifyf:
.leafprologue
movd %xmm0,%edx
movd %xmm0,%eax
@ -42,4 +42,5 @@ __fpclassifyf:
sete %al
movzbl %al,%eax
1: .leafepilogue
.endfn __fpclassifyf,globl
.endfn tinymath_fpclassifyf,globl
.alias tinymath_fpclassifyf,__fpclassifyf

View file

@ -21,7 +21,7 @@
#include "libc/macros.h"
.source __FILE__
__fpclassifyl:
tinymath_fpclassifyl:
push %rbp
mov %rsp,%rbp
mov 24(%rbp),%rax
@ -50,4 +50,5 @@ __fpclassifyl:
and $FP_NORMAL,%eax
1: pop %rbp
ret
.endfn __fpclassifyl,globl
.endfn tinymath_fpclassifyl,globl
.alias tinymath_fpclassifyl,__fpclassifyl

View file

@ -20,6 +20,10 @@
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is double passed in %xmm0
/ @param 𝑦 is exponent via %edi
tinymath_scalbn:
push %rbp
mov %rsp,%rbp

View file

@ -20,6 +20,10 @@
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is float passed in %xmm0
/ @param 𝑦 is exponent via %edi
tinymath_scalbnf:
push %rbp
mov %rsp,%rbp

View file

@ -20,11 +20,10 @@
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 𝑟ʸ where 𝑟 is radix of hardware architecture.
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is long double passed on stack
/ @param 𝑦 is exponent via %edi
/ @see FLT_RADIX
tinymath_scalbnl:
push %rbp
mov %rsp,%rbp