mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +00:00
Make more code aarch64 friendly
This commit is contained in:
parent
ca2860947f
commit
2b73e72d59
568 changed files with 2197 additions and 1061 deletions
|
@ -58,37 +58,37 @@
|
|||
// @see libc/str/str.h
|
||||
// @see kCp437i[]
|
||||
kCp437:
|
||||
.short 0x00a0,0x263a,0x263b,0x2665,0x2666,0x2663,0x2660,0x2022 #00: ☺☻♥♦♣♠•
|
||||
.short 0x25d8,0x25cb,0x25d9,0x2642,0x2640,0x266a,0x266b,0x263c #08:◘○◙♂♀♪♫☼
|
||||
.short 0x25ba,0x25c4,0x2195,0x203c,0x00b6,0x00a7,0x25ac,0x21a8 #10:►◄↕‼¶§▬↨
|
||||
.short 0x2191,0x2193,0x2192,0x2190,0x221f,0x2194,0x25b2,0x25bc #18:↑↓→←∟↔▲▼
|
||||
.short 0x0020,0x0021,0x201c,0x0023,0x0024,0x0025,0x0026,0x2018 #20: !“#$%&‘
|
||||
.short 0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f #28:()*+,-./
|
||||
.short 0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037 #30:01234567
|
||||
.short 0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x2047 #38:89:;<=>⁇
|
||||
.short 0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047 #40:@ABCDEFG
|
||||
.short 0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f #48:HIJKLMNO
|
||||
.short 0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057 #50:PQRSTUVW
|
||||
.short 0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f #58:XYZ[\]^_
|
||||
.short 0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067 #60:`abcdefg
|
||||
.short 0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f #68:hijklmno
|
||||
.short 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077 #70:pqrstuvw
|
||||
.short 0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x2302 #78:xyz{|}~⌂
|
||||
.short 0x00c7,0x00fc,0x00e9,0x00e2,0x00e4,0x00e0,0x00e5,0x00e7 #80:Çüéâäàåç
|
||||
.short 0x00ea,0x00eb,0x00e8,0x00ef,0x00ee,0x00ec,0x00c4,0x00c5 #88:êëèïîìÄÅ
|
||||
.short 0x00c9,0x00e6,0x00c6,0x00f4,0x00f6,0x00f2,0x00fb,0x00f9 #90:ÉæÆôöòûù
|
||||
.short 0x00ff,0x00d6,0x00dc,0x00a2,0x00a3,0x00a5,0x20ac,0x0192 #98:ÿÖÜ¢£¥€ƒ
|
||||
.short 0x00e1,0x00ed,0x00f3,0x00fa,0x00f1,0x00d1,0x00aa,0x00ba #a0:áíóúñѪº
|
||||
.short 0x00bf,0x2310,0x00ac,0x00bd,0x00bc,0x00a1,0x00ab,0x00bb #a8:¿⌐¬½¼¡«»
|
||||
.short 0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556 #b0:░▒▓│┤╡╢╖
|
||||
.short 0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510 #b8:╕╣║╗╝╜╛┐
|
||||
.short 0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f #c0:└┴┬├─┼╞╟
|
||||
.short 0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567 #c8:╚╔╩╦╠═╬╧
|
||||
.short 0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b #d0:╨╤╥╙╘╒╓╫
|
||||
.short 0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580 #d8:╪┘┌█▄▌▐▀
|
||||
.short 0x03b1,0x00df,0x0393,0x03c0,0x03a3,0x03c3,0x03bc,0x03c4 #e0:αßΓπΣσμτ
|
||||
.short 0x03a6,0x0398,0x03a9,0x03b4,0x221e,0x03c6,0x03b5,0x2229 #e8:ΦΘΩδ∞φε∩
|
||||
.short 0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248 #f0:≡±≥≤⌠⌡÷≈
|
||||
.short 0x00b0,0x2219,0x00d7,0x221a,0x207f,0x00b2,0x25a0,0x03bb #f8:°∙×√ⁿ²■λ
|
||||
.short 0x00a0,0x263a,0x263b,0x2665,0x2666,0x2663,0x2660,0x2022 //00: ☺☻♥♦♣♠•
|
||||
.short 0x25d8,0x25cb,0x25d9,0x2642,0x2640,0x266a,0x266b,0x263c //08:◘○◙♂♀♪♫☼
|
||||
.short 0x25ba,0x25c4,0x2195,0x203c,0x00b6,0x00a7,0x25ac,0x21a8 //10:►◄↕‼¶§▬↨
|
||||
.short 0x2191,0x2193,0x2192,0x2190,0x221f,0x2194,0x25b2,0x25bc //18:↑↓→←∟↔▲▼
|
||||
.short 0x0020,0x0021,0x201c,0x0023,0x0024,0x0025,0x0026,0x2018 //20: !“//$%&‘
|
||||
.short 0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f //28:()*+,-./
|
||||
.short 0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037 //30:01234567
|
||||
.short 0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x2047 //38:89:;<=>⁇
|
||||
.short 0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047 //40:@ABCDEFG
|
||||
.short 0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f //48:HIJKLMNO
|
||||
.short 0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057 //50:PQRSTUVW
|
||||
.short 0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f //58:XYZ[\]^_
|
||||
.short 0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067 //60:`abcdefg
|
||||
.short 0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f //68:hijklmno
|
||||
.short 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077 //70:pqrstuvw
|
||||
.short 0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x2302 //78:xyz{|}~⌂
|
||||
.short 0x00c7,0x00fc,0x00e9,0x00e2,0x00e4,0x00e0,0x00e5,0x00e7 //80:Çüéâäàåç
|
||||
.short 0x00ea,0x00eb,0x00e8,0x00ef,0x00ee,0x00ec,0x00c4,0x00c5 //88:êëèïîìÄÅ
|
||||
.short 0x00c9,0x00e6,0x00c6,0x00f4,0x00f6,0x00f2,0x00fb,0x00f9 //90:ÉæÆôöòûù
|
||||
.short 0x00ff,0x00d6,0x00dc,0x00a2,0x00a3,0x00a5,0x20ac,0x0192 //98:ÿÖÜ¢£¥€ƒ
|
||||
.short 0x00e1,0x00ed,0x00f3,0x00fa,0x00f1,0x00d1,0x00aa,0x00ba //a0:áíóúñѪº
|
||||
.short 0x00bf,0x2310,0x00ac,0x00bd,0x00bc,0x00a1,0x00ab,0x00bb //a8:¿⌐¬½¼¡«»
|
||||
.short 0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556 //b0:░▒▓│┤╡╢╖
|
||||
.short 0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510 //b8:╕╣║╗╝╜╛┐
|
||||
.short 0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f //c0:└┴┬├─┼╞╟
|
||||
.short 0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567 //c8:╚╔╩╦╠═╬╧
|
||||
.short 0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b //d0:╨╤╥╙╘╒╓╫
|
||||
.short 0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580 //d8:╪┘┌█▄▌▐▀
|
||||
.short 0x03b1,0x00df,0x0393,0x03c0,0x03a3,0x03c3,0x03bc,0x03c4 //e0:αßΓπΣσμτ
|
||||
.short 0x03a6,0x0398,0x03a9,0x03b4,0x221e,0x03c6,0x03b5,0x2229 //e8:ΦΘΩδ∞φε∩
|
||||
.short 0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248 //f0:≡±≥≤⌠⌡÷≈
|
||||
.short 0x00b0,0x2219,0x00d7,0x221a,0x207f,0x00b2,0x25a0,0x03bb //f8:°∙×√ⁿ²■λ
|
||||
.endobj kCp437,globl
|
||||
.previous
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*-*- 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 2022 Justine Alexandra Roberts Tunney │
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
|
@ -16,46 +16,27 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/nexgen32e.h"
|
||||
|
||||
// static const uint64_t kTens[] = {
|
||||
// 1ull,
|
||||
// 10ull,
|
||||
// 100ull,
|
||||
// 1000ull,
|
||||
// 10000ull,
|
||||
// 100000ull,
|
||||
// 1000000ull,
|
||||
// 10000000ull,
|
||||
// 100000000ull,
|
||||
// 1000000000ull,
|
||||
// 10000000000ull,
|
||||
// 100000000000ull,
|
||||
// 1000000000000ull,
|
||||
// 10000000000000ull,
|
||||
// 100000000000000ull,
|
||||
// 1000000000000000ull,
|
||||
// 10000000000000000ull,
|
||||
// 100000000000000000ull,
|
||||
// 1000000000000000000ull,
|
||||
// 10000000000000000000ull,
|
||||
// };
|
||||
|
||||
.initbss 201,_init_kTens
|
||||
kTens: .rept 20
|
||||
.quad 0
|
||||
.endr
|
||||
.endobj kTens,globl
|
||||
.previous
|
||||
|
||||
.init.start 201,_init_kTens
|
||||
push $20
|
||||
pop %rcx
|
||||
push $10
|
||||
pop %r8
|
||||
push $1
|
||||
pop %rax
|
||||
1: stosq
|
||||
mul %r8
|
||||
.loop 1b
|
||||
.init.end 201,_init_kTens
|
||||
const uint64_t kTens[] = {
|
||||
1ull,
|
||||
10ull,
|
||||
100ull,
|
||||
1000ull,
|
||||
10000ull,
|
||||
100000ull,
|
||||
1000000ull,
|
||||
10000000ull,
|
||||
100000000ull,
|
||||
1000000000ull,
|
||||
10000000000ull,
|
||||
100000000000ull,
|
||||
1000000000000ull,
|
||||
10000000000000ull,
|
||||
100000000000000ull,
|
||||
1000000000000000ull,
|
||||
10000000000000000ull,
|
||||
100000000000000000ull,
|
||||
1000000000000000000ull,
|
||||
10000000000000000000ull,
|
||||
};
|
|
@ -26,6 +26,7 @@
|
|||
// @see _gclongjmp()
|
||||
// @see siglongjmp()
|
||||
longjmp:
|
||||
#ifdef __x86_64__
|
||||
mov %esi,%eax
|
||||
test %eax,%eax
|
||||
jnz 1f
|
||||
|
@ -38,5 +39,22 @@ longjmp:
|
|||
mov 40(%rdi),%r14
|
||||
mov 48(%rdi),%r15
|
||||
jmp *56(%rdi)
|
||||
#elif defined(__aarch64__)
|
||||
ldp x19,x20,[x0,#0]
|
||||
ldp x21,x22,[x0,#16]
|
||||
ldp x23,x24,[x0,#32]
|
||||
ldp x25,x26,[x0,#48]
|
||||
ldp x27,x28,[x0,#64]
|
||||
ldp x29,x30,[x0,#80]
|
||||
ldr x2,[x0,#104]
|
||||
mov sp,x2
|
||||
ldp d8 ,d9,[x0,#112]
|
||||
ldp d10,d11,[x0,#128]
|
||||
ldp d12,d13,[x0,#144]
|
||||
ldp d14,d15,[x0,#160]
|
||||
cmp w1,0
|
||||
csinc w0,w1,wzr,ne
|
||||
br x30
|
||||
#endif
|
||||
.endfn longjmp,globl
|
||||
.alias longjmp,_longjmp
|
||||
|
|
|
@ -23,4 +23,4 @@
|
|||
// cc -pg adds this to the start of global functions.
|
||||
mcount: ret
|
||||
.endfn mcount,weak
|
||||
.alias mcount,.mcount # freebsd weirdness?
|
||||
.alias mcount,.mcount // freebsd weirdness?
|
||||
|
|
|
@ -48,8 +48,22 @@ o/$(MODE)/libc/nexgen32e/threaded.o: private \
|
|||
-fno-sanitize=all
|
||||
|
||||
# these assembly files are safe to build on aarch64
|
||||
o/$(MODE)/libc/nexgen32e/mcount.o: libc/nexgen32e/mcount.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/nexgen32e/ksha256.o: libc/nexgen32e/ksha256.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/nexgen32e/ksha512.o: libc/nexgen32e/ksha512.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/nexgen32e/kcp437.o: libc/nexgen32e/kcp437.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/nexgen32e/kreversebits.o: libc/nexgen32e/kreversebits.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/nexgen32e/ktensindex.o: libc/nexgen32e/ktensindex.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/nexgen32e/longjmp.o: libc/nexgen32e/longjmp.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/libc/nexgen32e/setjmp.o: libc/nexgen32e/setjmp.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
|
||||
LIBC_NEXGEN32E_LIBS = $(foreach x,$(LIBC_NEXGEN32E_ARTIFACTS),$($(x)))
|
||||
LIBC_NEXGEN32E_SRCS = $(foreach x,$(LIBC_NEXGEN32E_ARTIFACTS),$($(x)_SRCS))
|
||||
|
|
21
libc/nexgen32e/pid.c
Normal file
21
libc/nexgen32e/pid.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*-*- 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 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/internal.h"
|
||||
|
||||
int __pid;
|
|
@ -26,7 +26,9 @@
|
|||
// @assume system five nexgen32e abi conformant
|
||||
// @note code built w/ microsoft abi compiler can't call this
|
||||
// @see longjmp(), _gclongjmp()
|
||||
setjmp: lea 8(%rsp),%rax
|
||||
setjmp:
|
||||
#ifdef __x86_64__
|
||||
lea 8(%rsp),%rax
|
||||
mov %rax,(%rdi)
|
||||
mov %rbx,8(%rdi)
|
||||
mov %rbp,16(%rdi)
|
||||
|
@ -38,5 +40,21 @@ setjmp: lea 8(%rsp),%rax
|
|||
mov %rax,56(%rdi)
|
||||
xor %eax,%eax
|
||||
ret
|
||||
#elif defined(__aarch64__)
|
||||
stp x19,x20,[x0,#0]
|
||||
stp x21,x22,[x0,#16]
|
||||
stp x23,x24,[x0,#32]
|
||||
stp x25,x26,[x0,#48]
|
||||
stp x27,x28,[x0,#64]
|
||||
stp x29,x30,[x0,#80]
|
||||
mov x2,sp
|
||||
str x2,[x0,#104]
|
||||
stp d8,d9,[x0,#112]
|
||||
stp d10,d11,[x0,#128]
|
||||
stp d12,d13,[x0,#144]
|
||||
stp d14,d15,[x0,#160]
|
||||
mov x0,#0
|
||||
ret
|
||||
#endif
|
||||
.endfn setjmp,globl
|
||||
.alias setjmp,_setjmp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue