mirror of
				https://github.com/jart/cosmopolitan.git
				synced 2025-10-27 03:16:44 +00:00 
			
		
		
		
	Get llama.com building as an aarch64 native binary
This commit is contained in:
		
							parent
							
								
									d04430f4ef
								
							
						
					
					
						commit
						4c093155a3
					
				
					 40 changed files with 7842 additions and 11683 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							|  | @ -1,33 +0,0 @@ | ||||||
| /*-*- 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                              │ |  | ||||||
| │                                                                              │ |  | ||||||
| │ 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/dns/hoststxt.h" |  | ||||||
| #include "libc/mem/mem.h" |  | ||||||
| #include "libc/runtime/runtime.h" |  | ||||||
| 
 |  | ||||||
| /**
 |  | ||||||
|  * Frees HOSTS.TXT data structure populated by ParseHostsTxt(). |  | ||||||
|  */ |  | ||||||
| void FreeHostsTxt(struct HostsTxt **ht) { |  | ||||||
|   if (*ht) { |  | ||||||
|     free((*ht)->entries.p); |  | ||||||
|     free((*ht)->strings.p); |  | ||||||
|     free(*ht); |  | ||||||
|     *ht = 0; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  | @ -24,6 +24,7 @@ | ||||||
| #include "libc/intrin/pushpop.h" | #include "libc/intrin/pushpop.h" | ||||||
| #include "libc/intrin/safemacros.internal.h" | #include "libc/intrin/safemacros.internal.h" | ||||||
| #include "libc/macros.internal.h" | #include "libc/macros.internal.h" | ||||||
|  | #include "libc/mem/mem.h" | ||||||
| #include "libc/nt/systeminfo.h" | #include "libc/nt/systeminfo.h" | ||||||
| #include "libc/runtime/runtime.h" | #include "libc/runtime/runtime.h" | ||||||
| #include "libc/stdio/stdio.h" | #include "libc/stdio/stdio.h" | ||||||
|  | @ -85,3 +86,21 @@ const struct HostsTxt *GetHostsTxt(void) { | ||||||
|   pthread_mutex_unlock(&init->lock); |   pthread_mutex_unlock(&init->lock); | ||||||
|   return g_hoststxt; |   return g_hoststxt; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | /**
 | ||||||
|  |  * Frees HOSTS.TXT data structure populated by ParseHostsTxt(). | ||||||
|  |  */ | ||||||
|  | void FreeHostsTxt(struct HostsTxt **ht) { | ||||||
|  |   if (*ht) { | ||||||
|  |     if ((*ht)->entries.p != g_hoststxt_init.entries) { | ||||||
|  |       free((*ht)->entries.p); | ||||||
|  |     } | ||||||
|  |     if ((*ht)->strings.p != g_hoststxt_init.strings) { | ||||||
|  |       free((*ht)->strings.p); | ||||||
|  |     } | ||||||
|  |     if (*ht != &g_hoststxt_init.ht) { | ||||||
|  |       free(*ht); | ||||||
|  |     } | ||||||
|  |     *ht = 0; | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -175,6 +175,36 @@ | ||||||
| #define R_X86_64_REX_GOTPCRELX   42 /* 7 bytes */ | #define R_X86_64_REX_GOTPCRELX   42 /* 7 bytes */ | ||||||
| #define R_X86_64_NUM             43 | #define R_X86_64_NUM             43 | ||||||
| 
 | 
 | ||||||
|  | #define R_AARCH64_NONE   0 | ||||||
|  | #define R_AARCH64_ABS64  257 | ||||||
|  | #define R_AARCH64_ABS32  258 | ||||||
|  | #define R_AARCH64_ABS16  259 | ||||||
|  | #define R_AARCH64_PREL64 260 | ||||||
|  | #define R_AARCH64_PREL32 261 | ||||||
|  | #define R_AARCH64_PREL16 262 | ||||||
|  | 
 | ||||||
|  | #define R_PPC_NONE   0 | ||||||
|  | #define R_PPC_ADDR32 1 | ||||||
|  | #define R_PPC_ADDR24 2 | ||||||
|  | #define R_PPC_ADDR16 3 | ||||||
|  | 
 | ||||||
|  | #define R_PPC64_NONE   R_PPC_NONE | ||||||
|  | #define R_PPC64_ADDR32 R_PPC_ADDR32 | ||||||
|  | #define R_PPC64_ADDR24 R_PPC_ADDR24 | ||||||
|  | #define R_PPC64_ADDR16 R_PPC_ADDR16 | ||||||
|  | 
 | ||||||
|  | #define R_RISCV_NONE     0 | ||||||
|  | #define R_RISCV_32       1 | ||||||
|  | #define R_RISCV_64       2 | ||||||
|  | #define R_RISCV_RELATIVE 3 | ||||||
|  | 
 | ||||||
|  | #define R_390_NONE 0 | ||||||
|  | #define R_390_8    1 | ||||||
|  | #define R_390_12   2 | ||||||
|  | #define R_390_16   3 | ||||||
|  | #define R_390_32   4 | ||||||
|  | #define R_390_PC32 5 | ||||||
|  | 
 | ||||||
| #define STB_LOCAL      0 | #define STB_LOCAL      0 | ||||||
| #define STB_GLOBAL     1 | #define STB_GLOBAL     1 | ||||||
| #define STB_WEAK       2 | #define STB_WEAK       2 | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
 | /*-*- 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│ | │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         │ | │ Permission to use, copy, modify, and/or distribute this software for         │ | ||||||
| │ any purpose with or without fee is hereby granted, provided that the         │ | │ any purpose with or without fee is hereby granted, provided that the         │ | ||||||
|  | @ -16,6 +16,13 @@ | ||||||
| │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR             │ | │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR             │ | ||||||
| │ PERFORMANCE OF THIS SOFTWARE.                                                │ | │ PERFORMANCE OF THIS SOFTWARE.                                                │ | ||||||
| ╚─────────────────────────────────────────────────────────────────────────────*/ | ╚─────────────────────────────────────────────────────────────────────────────*/ | ||||||
| #include "libc/thread/thread.h" | #include "libc/intrin/intrin.h" | ||||||
|  | #include "libc/intrin/kprintf.h" | ||||||
| 
 | 
 | ||||||
| pthread_mutex_t __mmi_lock_obj;  // recursive :'(
 | void __cxa_pure_virtual(void) { | ||||||
|  | #ifndef NDEBUG | ||||||
|  |   kprintf("__cxa_pure_virtual() called\n" | ||||||
|  |           "Did you call a virtual method from a destructor?\n"); | ||||||
|  | #endif | ||||||
|  |   __builtin_trap(); | ||||||
|  | } | ||||||
|  | @ -23,6 +23,7 @@ | ||||||
| #include "libc/intrin/asan.internal.h" | #include "libc/intrin/asan.internal.h" | ||||||
| #include "libc/intrin/bits.h" | #include "libc/intrin/bits.h" | ||||||
| #include "libc/intrin/directmap.internal.h" | #include "libc/intrin/directmap.internal.h" | ||||||
|  | #include "libc/intrin/kprintf.h" | ||||||
| #include "libc/intrin/likely.h" | #include "libc/intrin/likely.h" | ||||||
| #include "libc/intrin/strace.internal.h" | #include "libc/intrin/strace.internal.h" | ||||||
| #include "libc/log/libfatal.internal.h" | #include "libc/log/libfatal.internal.h" | ||||||
|  |  | ||||||
|  | @ -16,8 +16,18 @@ | ||||||
| │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR             │ | │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR             │ | ||||||
| │ PERFORMANCE OF THIS SOFTWARE.                                                │ | │ PERFORMANCE OF THIS SOFTWARE.                                                │ | ||||||
| ╚─────────────────────────────────────────────────────────────────────────────*/ | ╚─────────────────────────────────────────────────────────────────────────────*/ | ||||||
|  | #include "libc/macros.internal.h" | ||||||
| #include "libc/runtime/memtrack.internal.h" | #include "libc/runtime/memtrack.internal.h" | ||||||
| 
 | #include "libc/thread/thread.h" | ||||||
| STATIC_YOINK("_init__mmi"); |  | ||||||
| 
 | 
 | ||||||
| struct MemoryIntervals _mmi; | struct MemoryIntervals _mmi; | ||||||
|  | pthread_mutex_t __mmi_lock_obj;  // recursive :'(
 | ||||||
|  | 
 | ||||||
|  | __attribute__((__constructor__)) void __mmi_init(void) { | ||||||
|  |   static bool once; | ||||||
|  |   if (once) return; | ||||||
|  |   _mmi.n = ARRAYLEN(_mmi.s); | ||||||
|  |   _mmi.p = _mmi.s; | ||||||
|  |   __mmi_lock_obj._type = PTHREAD_MUTEX_RECURSIVE; | ||||||
|  |   once = true; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -1,26 +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 2021 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/thread/thread.h" |  | ||||||
| #include "libc/macros.internal.h" |  | ||||||
| 
 |  | ||||||
| 	.init.start 200,_init__mmi |  | ||||||
| 	movb	$OPEN_MAX,_mmi+8 |  | ||||||
| 	movl	$_mmi+24,_mmi+16 |  | ||||||
| 	movb	$PTHREAD_MUTEX_RECURSIVE,__mmi_lock_obj+4(%rip) |  | ||||||
| 	.init.end 200,_init__mmi |  | ||||||
|  | @ -26,6 +26,8 @@ | ||||||
| #include "libc/stdio/stdio.h" | #include "libc/stdio/stdio.h" | ||||||
| #include "libc/str/str.h" | #include "libc/str/str.h" | ||||||
| 
 | 
 | ||||||
|  | #ifdef __x86_64__ | ||||||
|  | 
 | ||||||
| static double GetTotal(const struct countbranch *p) { | static double GetTotal(const struct countbranch *p) { | ||||||
|   return p->total; |   return p->total; | ||||||
| } | } | ||||||
|  | @ -101,3 +103,5 @@ static textstartup void countbranch_init() { | ||||||
| const void *const countbranch_ctor[] initarray = { | const void *const countbranch_ctor[] initarray = { | ||||||
|     countbranch_init, |     countbranch_init, | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | #endif /* __x86_64__ */ | ||||||
|  |  | ||||||
|  | @ -26,6 +26,8 @@ | ||||||
| #include "libc/runtime/runtime.h" | #include "libc/runtime/runtime.h" | ||||||
| #include "libc/stdio/stdio.h" | #include "libc/stdio/stdio.h" | ||||||
| 
 | 
 | ||||||
|  | #ifdef __x86_64__ | ||||||
|  | 
 | ||||||
| static long GetLongSum(const long *h, size_t n) { | static long GetLongSum(const long *h, size_t n) { | ||||||
|   long t; |   long t; | ||||||
|   size_t i; |   size_t i; | ||||||
|  | @ -80,3 +82,5 @@ static textstartup void countexpr_init() { | ||||||
| const void *const countexpr_ctor[] initarray = { | const void *const countexpr_ctor[] initarray = { | ||||||
|     countexpr_init, |     countexpr_init, | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | #endif /* __x86_64__ */ | ||||||
|  |  | ||||||
|  | @ -43,6 +43,7 @@ LIBC_LOG_A_DIRECTDEPS =					\ | ||||||
| 	LIBC_TIME					\
 | 	LIBC_TIME					\
 | ||||||
| 	LIBC_TINYMATH					\
 | 	LIBC_TINYMATH					\
 | ||||||
| 	LIBC_ZIPOS					\
 | 	LIBC_ZIPOS					\
 | ||||||
|  | 	THIRD_PARTY_COMPILER_RT				\
 | ||||||
| 	THIRD_PARTY_DLMALLOC				\
 | 	THIRD_PARTY_DLMALLOC				\
 | ||||||
| 	THIRD_PARTY_GDTOA | 	THIRD_PARTY_GDTOA | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -47,6 +47,8 @@ | ||||||
| #include "libc/thread/tls.h" | #include "libc/thread/tls.h" | ||||||
| #include "third_party/libcxx/math.h" | #include "third_party/libcxx/math.h" | ||||||
| 
 | 
 | ||||||
|  | #ifdef __x86_64__ | ||||||
|  | 
 | ||||||
| /**
 | /**
 | ||||||
|  * @fileoverview Abnormal termination handling & GUI debugging. |  * @fileoverview Abnormal termination handling & GUI debugging. | ||||||
|  * @see libc/onkill.c |  * @see libc/onkill.c | ||||||
|  | @ -361,3 +363,5 @@ ItsATrap: | ||||||
|   strace_enabled(+1); |   strace_enabled(+1); | ||||||
|   ftrace_enabled(+1); |   ftrace_enabled(+1); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | #endif /* __x86_64__ */ | ||||||
|  |  | ||||||
|  | @ -34,6 +34,8 @@ | ||||||
| #include "libc/sysv/consts/sig.h" | #include "libc/sysv/consts/sig.h" | ||||||
| #include "libc/sysv/consts/ss.h" | #include "libc/sysv/consts/ss.h" | ||||||
| 
 | 
 | ||||||
|  | #ifdef __x86_64__ | ||||||
|  | 
 | ||||||
| STATIC_YOINK("zipos");                       // for symtab
 | STATIC_YOINK("zipos");                       // for symtab
 | ||||||
| STATIC_YOINK("__die");                       // for backtracing
 | STATIC_YOINK("__die");                       // for backtracing
 | ||||||
| STATIC_YOINK("ShowBacktrace");               // for backtracing
 | STATIC_YOINK("ShowBacktrace");               // for backtracing
 | ||||||
|  | @ -123,3 +125,8 @@ void ShowCrashReports(void) { | ||||||
|   } |   } | ||||||
|   GetSymbolTable(); |   GetSymbolTable(); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | #else | ||||||
|  | void ShowCrashReports(void) { | ||||||
|  | } | ||||||
|  | #endif /* __x86_64__ */ | ||||||
|  |  | ||||||
|  | @ -24,6 +24,8 @@ | ||||||
| #include "libc/runtime/symbols.internal.h" | #include "libc/runtime/symbols.internal.h" | ||||||
| #include "libc/sysv/errfuns.h" | #include "libc/sysv/errfuns.h" | ||||||
| 
 | 
 | ||||||
|  | #ifdef __x86_64__ | ||||||
|  | 
 | ||||||
| static bool __watch_busy; | static bool __watch_busy; | ||||||
| static void *__watch_addr; | static void *__watch_addr; | ||||||
| static size_t __watch_size; | static size_t __watch_size; | ||||||
|  | @ -85,3 +87,5 @@ int __watch(void *addr, size_t size) { | ||||||
|   Copy(__watch_last, __watch_addr, __watch_size); |   Copy(__watch_last, __watch_addr, __watch_size); | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | #endif /* __x86_64__ */ | ||||||
|  |  | ||||||
|  | @ -175,6 +175,13 @@ | ||||||
| #endif | #endif | ||||||
| .endm | .endm | ||||||
| 
 | 
 | ||||||
|  | //	Embeds Fixed-Width Zero-Padded String.
 | ||||||
|  | //	@note	.fxstr is better
 | ||||||
|  | .macro	.ascin str:req fieldsize:req | ||||||
|  | 1347:	.ascii	"\str" | ||||||
|  |  .org	1347b+\fieldsize,0x00 | ||||||
|  | .endm | ||||||
|  | 
 | ||||||
| #ifdef __x86_64__ | #ifdef __x86_64__ | ||||||
| 
 | 
 | ||||||
| #if __MNO_VZEROUPPER__ + 0 | #if __MNO_VZEROUPPER__ + 0 | ||||||
|  | @ -297,13 +304,6 @@ | ||||||
|  .endif |  .endif | ||||||
| .endm | .endm | ||||||
| 
 | 
 | ||||||
| //	Embeds Fixed-Width Zero-Padded String.
 |  | ||||||
| //	@note	.fxstr is better
 |  | ||||||
| .macro	.ascin str:req fieldsize:req |  | ||||||
| 1347:	.ascii	"\str" |  | ||||||
|  .org	1347b+\fieldsize,0x00 |  | ||||||
| .endm |  | ||||||
| 
 |  | ||||||
| //	Marks symbols as object en-masse.
 | //	Marks symbols as object en-masse.
 | ||||||
| //	@note	zero-padded ≠ nul-terminated
 | //	@note	zero-padded ≠ nul-terminated
 | ||||||
| .macro	.object	symbol rest:vararg | .macro	.object	symbol rest:vararg | ||||||
|  |  | ||||||
|  | @ -1,84 +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                              │ |  | ||||||
| │                                                                              │ |  | ||||||
| │ 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/macros.internal.h" |  | ||||||
| 
 |  | ||||||
| //	Frees memory the C++ way. |  | ||||||
| // |  | ||||||
| //	\param	%rdi is pointer, or NULL for no-op |  | ||||||
| //	\param	%rsi is ignored |  | ||||||
| //	\param	%rdx is ignored |  | ||||||
| _ZdlPvSt11align_val_tRKSt9nothrow_t: |  | ||||||
| //	operator delete(void*, std::align_val_t, std::nothrow_t const&) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdlPvSt11align_val_tRKSt9nothrow_t,weak |  | ||||||
| _ZdaPvSt11align_val_tRKSt9nothrow_t: |  | ||||||
| //	operator delete[](void*, std::align_val_t, std::nothrow_t const&) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdaPvSt11align_val_tRKSt9nothrow_t,weak |  | ||||||
| _ZdlPvRKSt9nothrow_t: |  | ||||||
| //	operator delete(void*, std::nothrow_t const&) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdlPvRKSt9nothrow_t,weak |  | ||||||
| _ZdaPvRKSt9nothrow_t: |  | ||||||
| //	operator delete[](void*, std::nothrow_t const&) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdaPvRKSt9nothrow_t,weak |  | ||||||
| _ZdlPvmSt11align_val_t: |  | ||||||
| //	operator delete(void*, unsigned long, std::align_val_t) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdlPvmSt11align_val_t,weak |  | ||||||
| _ZdaPvmSt11align_val_t: |  | ||||||
| //	operator delete[](void*, unsigned long, std::align_val_t) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdaPvmSt11align_val_t,weak |  | ||||||
| _ZdlPvSt11align_val_t: |  | ||||||
| //	operator delete(void*, std::align_val_t) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdlPvSt11align_val_t,weak |  | ||||||
| _ZdaPvSt11align_val_t: |  | ||||||
| //	operator delete[](void*, std::align_val_t) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdaPvSt11align_val_t,weak |  | ||||||
| _ZdaPvm: |  | ||||||
| //	operator delete[](void*, unsigned long): |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdaPvm,weak |  | ||||||
| _ZdlPvm: |  | ||||||
| //	operator delete(void*, unsigned long) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdlPvm,weak |  | ||||||
| _ZdaPv: |  | ||||||
| //	operator delete[](void*) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZdaPv,weak |  | ||||||
| _ZdlPv: |  | ||||||
| //	operator delete(void*) |  | ||||||
| 	jmp	*hook_free(%rip) |  | ||||||
| 	.endfn	_ZdlPv,weak |  | ||||||
|  | @ -1,47 +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                              │ |  | ||||||
| │                                                                              │ |  | ||||||
| │ 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/macros.internal.h" |  | ||||||
| 
 |  | ||||||
| //	Allocates memory the C++ way. |  | ||||||
| // |  | ||||||
| //	\param	%rdi is bytes to allocate |  | ||||||
| //	\param	%rsi is ignored |  | ||||||
| //	\return	new memory or NULL on OOM |  | ||||||
| _ZnamRKSt9nothrow_t: |  | ||||||
| //	operator new[](unsigned long, std::nothrow_t const&) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZnamRKSt9nothrow_t,weak |  | ||||||
| _ZnwmRKSt9nothrow_t: |  | ||||||
| //	operator new(unsigned long, std::nothrow_t const&) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZnwmRKSt9nothrow_t,weak |  | ||||||
| _Znam: |  | ||||||
| //	operator new[](unsigned long) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_Znam,weak |  | ||||||
| _Znwm: |  | ||||||
| //	operator new(unsigned long) |  | ||||||
| 	test	%rdi,%rdi |  | ||||||
| 	jne	1f |  | ||||||
| 	mov	$1,%edi |  | ||||||
| 1:	jmp	*hook_malloc(%rip) |  | ||||||
| 	.endfn	_Znwm,weak |  | ||||||
|  | @ -1,52 +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                              │ |  | ||||||
| │                                                                              │ |  | ||||||
| │ 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/macros.internal.h" |  | ||||||
| 
 |  | ||||||
| //	Allocates aligned memory the C++ way. |  | ||||||
| // |  | ||||||
| //	\param	%rdi is bytes to allocate |  | ||||||
| //	\param	%rsi is byte alignment |  | ||||||
| //	\param	%rdx is ignored |  | ||||||
| //	\return	new memory or NULL on OOM |  | ||||||
| _ZnamSt11align_val_tRKSt9nothrow_t: |  | ||||||
| //	operator new[](unsigned long, std::align_val_t, std::nothrow_t const&) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZnamSt11align_val_tRKSt9nothrow_t,weak |  | ||||||
| _ZnwmSt11align_val_tRKSt9nothrow_t: |  | ||||||
| //	operator new(unsigned long, std::align_val_t, std::nothrow_t const&) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZnwmSt11align_val_tRKSt9nothrow_t,weak |  | ||||||
| _ZnwmSt11align_val_t: |  | ||||||
| //	operator new(unsigned long, std::align_val_t) |  | ||||||
| 	nop |  | ||||||
| //	𝑠𝑙𝑖𝑑𝑒 |  | ||||||
| 	.endfn	_ZnwmSt11align_val_t,weak |  | ||||||
| _ZnamSt11align_val_t: |  | ||||||
| //	operator new[](unsigned long, std::align_val_t) |  | ||||||
| 	test	%rdi,%rdi |  | ||||||
| 	jnz	1f |  | ||||||
| 	mov	$1,%eax |  | ||||||
| 1:	mov	$__BIGGEST_ALIGNMENT__,%eax |  | ||||||
| 	cmp	%rax,%rsi |  | ||||||
| 	cmovb	%rax,%rsi |  | ||||||
| 	xchg	%rdi,%rsi |  | ||||||
| 	jmp	*hook_memalign(%rip) |  | ||||||
| 	.endfn	_ZnamSt11align_val_t,weak |  | ||||||
|  | @ -6,14 +6,11 @@ PKGS += LIBC_MEM | ||||||
| LIBC_MEM_ARTIFACTS += LIBC_MEM_A | LIBC_MEM_ARTIFACTS += LIBC_MEM_A | ||||||
| LIBC_MEM = $(LIBC_MEM_A_DEPS) $(LIBC_MEM_A) | LIBC_MEM = $(LIBC_MEM_A_DEPS) $(LIBC_MEM_A) | ||||||
| LIBC_MEM_A = o/$(MODE)/libc/mem/mem.a | LIBC_MEM_A = o/$(MODE)/libc/mem/mem.a | ||||||
|  | LIBC_MEM_A_FILES := $(wildcard libc/mem/*) | ||||||
| LIBC_MEM_A_HDRS = $(filter %.h,$(LIBC_MEM_A_FILES)) | LIBC_MEM_A_HDRS = $(filter %.h,$(LIBC_MEM_A_FILES)) | ||||||
| LIBC_MEM_A_SRCS = $(filter %.c,$(LIBC_MEM_A_FILES)) | LIBC_MEM_A_SRCS = $(filter %.c,$(LIBC_MEM_A_FILES)) | ||||||
| LIBC_MEM_A_OBJS = $(LIBC_MEM_A_SRCS:%.c=o/$(MODE)/%.o) | LIBC_MEM_A_OBJS = $(LIBC_MEM_A_SRCS:%.c=o/$(MODE)/%.o) | ||||||
| 
 | 
 | ||||||
| LIBC_MEM_A_FILES :=				\
 |  | ||||||
| 	$(wildcard libc/mem/*)			\
 |  | ||||||
| 	$(wildcard libc/mem/cxx/*) |  | ||||||
| 
 |  | ||||||
| LIBC_MEM_A_CHECKS =				\
 | LIBC_MEM_A_CHECKS =				\
 | ||||||
| 	$(LIBC_MEM_A).pkg			\
 | 	$(LIBC_MEM_A).pkg			\
 | ||||||
| 	$(LIBC_MEM_A_HDRS:%=o/$(MODE)/%.ok) | 	$(LIBC_MEM_A_HDRS:%=o/$(MODE)/%.ok) | ||||||
|  |  | ||||||
|  | @ -48,6 +48,8 @@ o/$(MODE)/libc/nexgen32e/threaded.o: private		\ | ||||||
| 			-fno-sanitize=all | 			-fno-sanitize=all | ||||||
| 
 | 
 | ||||||
| # these assembly files are safe to build on aarch64
 | # these assembly files are safe to build on aarch64
 | ||||||
|  | o/$(MODE)/libc/nexgen32e/zip.o: libc/nexgen32e/zip.S | ||||||
|  | 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | ||||||
| o/$(MODE)/libc/nexgen32e/mcount.o: libc/nexgen32e/mcount.S | o/$(MODE)/libc/nexgen32e/mcount.o: libc/nexgen32e/mcount.S | ||||||
| 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | ||||||
| o/$(MODE)/libc/nexgen32e/ksha256.o: libc/nexgen32e/ksha256.S | o/$(MODE)/libc/nexgen32e/ksha256.o: libc/nexgen32e/ksha256.S | ||||||
|  |  | ||||||
|  | @ -32,14 +32,14 @@ __zip_start: | ||||||
| 	... | 	... | ||||||
| 	*/.section .zip.5,"",@progbits
 | 	*/.section .zip.5,"",@progbits
 | ||||||
| __zip_end: | __zip_end: | ||||||
| 	.long	kZipCdirHdrMagic	# magic | 	.long	kZipCdirHdrMagic	// magic | ||||||
| 	.short	0			# disk | 	.short	0			// disk | ||||||
| 	.short	0			# starting disk | 	.short	0			// starting disk | ||||||
| 	.short	v_zip_records		# number of records on disk | 	.short	v_zip_records		// number of records on disk | ||||||
| 	.short	v_zip_records		# records | 	.short	v_zip_records		// records | ||||||
| 	.long	v_zip_cdirsize		# size of central directory | 	.long	v_zip_cdirsize		// size of central directory | ||||||
| 	.long	RVA(__zip_start)	# central directory offset | 	.long	RVA(__zip_start)	// central directory offset | ||||||
| 	.short	v_zip_commentsize	# comment size | 	.short	v_zip_commentsize	// comment size | ||||||
| 	.endobj	__zip_end,globl,hidden | 	.endobj	__zip_end,globl,hidden | ||||||
| 	.weak	v_zip_records
 | 	.weak	v_zip_records
 | ||||||
| 	.weak	v_zip_cdirsize
 | 	.weak	v_zip_cdirsize
 | ||||||
|  |  | ||||||
|  | @ -141,6 +141,7 @@ cosmo:	push	%rbp | ||||||
| 	push	%rsi | 	push	%rsi | ||||||
| 
 | 
 | ||||||
| //	allocate stack | //	allocate stack | ||||||
|  | 	call	__mmi_init | ||||||
| 	movabs	$ape_stack_vaddr,%rdi | 	movabs	$ape_stack_vaddr,%rdi | ||||||
| 	mov	$ape_stack_memsz,%esi | 	mov	$ape_stack_memsz,%esi | ||||||
| 	mov	$ape_stack_prot,%edx | 	mov	$ape_stack_prot,%edx | ||||||
|  |  | ||||||
|  | @ -45,6 +45,7 @@ struct MemoryIntervals { | ||||||
| 
 | 
 | ||||||
| extern struct MemoryIntervals _mmi; | extern struct MemoryIntervals _mmi; | ||||||
| 
 | 
 | ||||||
|  | void __mmi_init(void); | ||||||
| void __mmi_lock(void); | void __mmi_lock(void); | ||||||
| void __mmi_unlock(void); | void __mmi_unlock(void); | ||||||
| void __mmi_funlock(void); | void __mmi_funlock(void); | ||||||
|  |  | ||||||
|  | @ -122,6 +122,8 @@ o/$(MODE)/libc/runtime/clone-linux.o: libc/runtime/clone-linux.S | ||||||
| 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | ||||||
| o/$(MODE)/libc/runtime/ftrace-hook.o: libc/runtime/ftrace-hook.S | o/$(MODE)/libc/runtime/ftrace-hook.o: libc/runtime/ftrace-hook.S | ||||||
| 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | ||||||
|  | o/$(MODE)/libc/runtime/dsohandle.o: libc/runtime/dsohandle.S | ||||||
|  | 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | ||||||
| 
 | 
 | ||||||
| LIBC_RUNTIME_LIBS = $(foreach x,$(LIBC_RUNTIME_ARTIFACTS),$($(x))) | LIBC_RUNTIME_LIBS = $(foreach x,$(LIBC_RUNTIME_ARTIFACTS),$($(x))) | ||||||
| LIBC_RUNTIME_SRCS = $(foreach x,$(LIBC_RUNTIME_ARTIFACTS),$($(x)_SRCS)) | LIBC_RUNTIME_SRCS = $(foreach x,$(LIBC_RUNTIME_ARTIFACTS),$($(x)_SRCS)) | ||||||
|  |  | ||||||
|  | @ -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                              │ |  | ||||||
| │                                                                              │ |  | ||||||
| │ 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/macros.internal.h" |  | ||||||
| 
 |  | ||||||
| //	Did you call a virtual method from a destructor? |  | ||||||
| __cxa_pure_virtual: |  | ||||||
| 	push	%rbp |  | ||||||
| 	mov	%rsp,%rbp |  | ||||||
| 	.profilable |  | ||||||
| 	call	abort |  | ||||||
| 	pop	%rbp |  | ||||||
| 	ret |  | ||||||
| 	.endfn	__cxa_pure_virtual,globl |  | ||||||
|  | @ -40,7 +40,8 @@ LIBC_TIME_A_DIRECTDEPS =			\ | ||||||
| 	LIBC_STUBS				\
 | 	LIBC_STUBS				\
 | ||||||
| 	LIBC_SYSV				\
 | 	LIBC_SYSV				\
 | ||||||
| 	LIBC_SYSV_CALLS				\
 | 	LIBC_SYSV_CALLS				\
 | ||||||
| 	LIBC_ZIPOS | 	LIBC_ZIPOS				\
 | ||||||
|  | 	THIRD_PARTY_COMPILER_RT | ||||||
| 
 | 
 | ||||||
| LIBC_TIME_A_DEPS :=				\
 | LIBC_TIME_A_DEPS :=				\
 | ||||||
| 	$(call uniq,$(foreach x,$(LIBC_TIME_A_DIRECTDEPS),$($(x)))) | 	$(call uniq,$(foreach x,$(LIBC_TIME_A_DIRECTDEPS),$($(x)))) | ||||||
|  | @ -72,6 +73,15 @@ o/$(MODE)/libc/time/iso8601us.o: private	\ | ||||||
| o/$(MODE)/usr/share/zoneinfo/.zip.o:		\ | o/$(MODE)/usr/share/zoneinfo/.zip.o:		\ | ||||||
| 	usr/share/zoneinfo | 	usr/share/zoneinfo | ||||||
| 
 | 
 | ||||||
|  | o/$(MODE)/libc/time/kmonthname.o: libc/time/kmonthname.S | ||||||
|  | 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | ||||||
|  | o/$(MODE)/libc/time/kmonthnameshort.o: libc/time/kmonthnameshort.S | ||||||
|  | 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | ||||||
|  | o/$(MODE)/libc/time/kweekdayname.o: libc/time/kweekdayname.S | ||||||
|  | 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | ||||||
|  | o/$(MODE)/libc/time/kweekdaynameshort.o: libc/time/kweekdaynameshort.S | ||||||
|  | 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | ||||||
|  | 
 | ||||||
| LIBC_TIME_LIBS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x))) | LIBC_TIME_LIBS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x))) | ||||||
| LIBC_TIME_SRCS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)_SRCS)) | LIBC_TIME_SRCS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)_SRCS)) | ||||||
| LIBC_TIME_HDRS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)_HDRS)) | LIBC_TIME_HDRS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)_HDRS)) | ||||||
|  |  | ||||||
|  | @ -57,6 +57,10 @@ o/$(MODE)/libc/zipos/.cosmo.zip.o: private		\ | ||||||
| 		ZIPOBJ_FLAGS +=				\
 | 		ZIPOBJ_FLAGS +=				\
 | ||||||
| 			-B | 			-B | ||||||
| 
 | 
 | ||||||
|  | # these assembly files are safe to build on aarch64
 | ||||||
|  | o/$(MODE)/libc/zipos/zipos.o: libc/zipos/zipos.S | ||||||
|  | 	@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< | ||||||
|  | 
 | ||||||
| LIBC_ZIPOS_LIBS = $(foreach zipos,$(LIBC_ZIPOS_ARTIFACTS),$($(zipos))) | LIBC_ZIPOS_LIBS = $(foreach zipos,$(LIBC_ZIPOS_ARTIFACTS),$($(zipos))) | ||||||
| LIBC_ZIPOS_SRCS = $(foreach zipos,$(LIBC_ZIPOS_ARTIFACTS),$($(zipos)_SRCS)) | LIBC_ZIPOS_SRCS = $(foreach zipos,$(LIBC_ZIPOS_ARTIFACTS),$($(zipos)_SRCS)) | ||||||
| LIBC_ZIPOS_HDRS = $(foreach zipos,$(LIBC_ZIPOS_ARTIFACTS),$($(zipos)_HDRS)) | LIBC_ZIPOS_HDRS = $(foreach zipos,$(LIBC_ZIPOS_ARTIFACTS),$($(zipos)_HDRS)) | ||||||
|  |  | ||||||
|  | @ -111,7 +111,8 @@ o/$(MODE)/test/libc/release/smokecxx.com.dbg:				\ | ||||||
| 		o/$(MODE)/ape/public/ape.lds				\
 | 		o/$(MODE)/ape/public/ape.lds				\
 | ||||||
| 		o/$(MODE)/libc/crt/crt.o				\
 | 		o/$(MODE)/libc/crt/crt.o				\
 | ||||||
| 		o/$(MODE)/ape/ape.o					\
 | 		o/$(MODE)/ape/ape.o					\
 | ||||||
| 		o/$(MODE)/cosmopolitan.a | 		o/$(MODE)/cosmopolitan.a				\
 | ||||||
|  | 		o/$(MODE)/third_party/libcxx/libcxx.a | ||||||
| 	@$(COMPILE) -ALD $(LD)						\
 | 	@$(COMPILE) -ALD $(LD)						\
 | ||||||
| 		-static							\
 | 		-static							\
 | ||||||
| 		-no-pie							\
 | 		-no-pie							\
 | ||||||
|  | @ -120,6 +121,7 @@ o/$(MODE)/test/libc/release/smokecxx.com.dbg:				\ | ||||||
| 		o/$(MODE)/test/libc/release/smokecxx.o			\
 | 		o/$(MODE)/test/libc/release/smokecxx.o			\
 | ||||||
| 		o/$(MODE)/libc/crt/crt.o				\
 | 		o/$(MODE)/libc/crt/crt.o				\
 | ||||||
| 		o/$(MODE)/ape/ape.o					\
 | 		o/$(MODE)/ape/ape.o					\
 | ||||||
|  | 		o/$(MODE)/third_party/libcxx/libcxx.a			\
 | ||||||
| 		o/$(MODE)/cosmopolitan.a				\
 | 		o/$(MODE)/cosmopolitan.a				\
 | ||||||
| 		-o $@ | 		-o $@ | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										183
									
								
								third_party/aarch64/arm_fp16.h
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										183
									
								
								third_party/aarch64/arm_fp16.h
									
										
									
									
										vendored
									
									
								
							|  | @ -8,454 +8,459 @@ | ||||||
| #pragma GCC push_options | #pragma GCC push_options | ||||||
| #pragma GCC target("arch=armv8.2-a+fp16") | #pragma GCC target("arch=armv8.2-a+fp16") | ||||||
| 
 | 
 | ||||||
|  | #define FUNC(T)                   \ | ||||||
|  |   __extension__ extern __inline T \ | ||||||
|  |       __attribute__((__always_inline__, __gnu_inline__, __artificial__)) | ||||||
|  | 
 | ||||||
| typedef __fp16 float16_t; | typedef __fp16 float16_t; | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vabsh_f16(float16_t __a) { | vabsh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_abshf(__a); |   return __builtin_aarch64_abshf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vceqzh_f16(float16_t __a) { | vceqzh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_cmeqhf_uss(__a, 0.0f); |   return __builtin_aarch64_cmeqhf_uss(__a, 0.0f); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcgezh_f16(float16_t __a) { | vcgezh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_cmgehf_uss(__a, 0.0f); |   return __builtin_aarch64_cmgehf_uss(__a, 0.0f); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcgtzh_f16(float16_t __a) { | vcgtzh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_cmgthf_uss(__a, 0.0f); |   return __builtin_aarch64_cmgthf_uss(__a, 0.0f); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vclezh_f16(float16_t __a) { | vclezh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_cmlehf_uss(__a, 0.0f); |   return __builtin_aarch64_cmlehf_uss(__a, 0.0f); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcltzh_f16(float16_t __a) { | vcltzh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_cmlthf_uss(__a, 0.0f); |   return __builtin_aarch64_cmlthf_uss(__a, 0.0f); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_f16_s16(int16_t __a) { | vcvth_f16_s16(int16_t __a) { | ||||||
|   return __builtin_aarch64_floathihf(__a); |   return __builtin_aarch64_floathihf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_f16_s32(int32_t __a) { | vcvth_f16_s32(int32_t __a) { | ||||||
|   return __builtin_aarch64_floatsihf(__a); |   return __builtin_aarch64_floatsihf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_f16_s64(int64_t __a) { | vcvth_f16_s64(int64_t __a) { | ||||||
|   return __builtin_aarch64_floatdihf(__a); |   return __builtin_aarch64_floatdihf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_f16_u16(uint16_t __a) { | vcvth_f16_u16(uint16_t __a) { | ||||||
|   return __builtin_aarch64_floatunshihf_us(__a); |   return __builtin_aarch64_floatunshihf_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_f16_u32(uint32_t __a) { | vcvth_f16_u32(uint32_t __a) { | ||||||
|   return __builtin_aarch64_floatunssihf_us(__a); |   return __builtin_aarch64_floatunssihf_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_f16_u64(uint64_t __a) { | vcvth_f16_u64(uint64_t __a) { | ||||||
|   return __builtin_aarch64_floatunsdihf_us(__a); |   return __builtin_aarch64_floatunsdihf_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int16_t __attribute__((__always_inline__)) | FUNC(int16_t) | ||||||
| vcvth_s16_f16(float16_t __a) { | vcvth_s16_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_fix_trunchfhi(__a); |   return __builtin_aarch64_fix_trunchfhi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int32_t __attribute__((__always_inline__)) | FUNC(int32_t) | ||||||
| vcvth_s32_f16(float16_t __a) { | vcvth_s32_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_fix_trunchfsi(__a); |   return __builtin_aarch64_fix_trunchfsi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int64_t __attribute__((__always_inline__)) | FUNC(int64_t) | ||||||
| vcvth_s64_f16(float16_t __a) { | vcvth_s64_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_fix_trunchfdi(__a); |   return __builtin_aarch64_fix_trunchfdi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcvth_u16_f16(float16_t __a) { | vcvth_u16_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_fixuns_trunchfhi_us(__a); |   return __builtin_aarch64_fixuns_trunchfhi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint32_t __attribute__((__always_inline__)) | FUNC(uint32_t) | ||||||
| vcvth_u32_f16(float16_t __a) { | vcvth_u32_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_fixuns_trunchfsi_us(__a); |   return __builtin_aarch64_fixuns_trunchfsi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint64_t __attribute__((__always_inline__)) | FUNC(uint64_t) | ||||||
| vcvth_u64_f16(float16_t __a) { | vcvth_u64_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_fixuns_trunchfdi_us(__a); |   return __builtin_aarch64_fixuns_trunchfdi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int16_t __attribute__((__always_inline__)) | FUNC(int16_t) | ||||||
| vcvtah_s16_f16(float16_t __a) { | vcvtah_s16_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lroundhfhi(__a); |   return __builtin_aarch64_lroundhfhi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int32_t __attribute__((__always_inline__)) | FUNC(int32_t) | ||||||
| vcvtah_s32_f16(float16_t __a) { | vcvtah_s32_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lroundhfsi(__a); |   return __builtin_aarch64_lroundhfsi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int64_t __attribute__((__always_inline__)) | FUNC(int64_t) | ||||||
| vcvtah_s64_f16(float16_t __a) { | vcvtah_s64_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lroundhfdi(__a); |   return __builtin_aarch64_lroundhfdi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcvtah_u16_f16(float16_t __a) { | vcvtah_u16_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lrounduhfhi_us(__a); |   return __builtin_aarch64_lrounduhfhi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint32_t __attribute__((__always_inline__)) | FUNC(uint32_t) | ||||||
| vcvtah_u32_f16(float16_t __a) { | vcvtah_u32_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lrounduhfsi_us(__a); |   return __builtin_aarch64_lrounduhfsi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint64_t __attribute__((__always_inline__)) | FUNC(uint64_t) | ||||||
| vcvtah_u64_f16(float16_t __a) { | vcvtah_u64_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lrounduhfdi_us(__a); |   return __builtin_aarch64_lrounduhfdi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int16_t __attribute__((__always_inline__)) | FUNC(int16_t) | ||||||
| vcvtmh_s16_f16(float16_t __a) { | vcvtmh_s16_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lfloorhfhi(__a); |   return __builtin_aarch64_lfloorhfhi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int32_t __attribute__((__always_inline__)) | FUNC(int32_t) | ||||||
| vcvtmh_s32_f16(float16_t __a) { | vcvtmh_s32_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lfloorhfsi(__a); |   return __builtin_aarch64_lfloorhfsi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int64_t __attribute__((__always_inline__)) | FUNC(int64_t) | ||||||
| vcvtmh_s64_f16(float16_t __a) { | vcvtmh_s64_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lfloorhfdi(__a); |   return __builtin_aarch64_lfloorhfdi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcvtmh_u16_f16(float16_t __a) { | vcvtmh_u16_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lflooruhfhi_us(__a); |   return __builtin_aarch64_lflooruhfhi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint32_t __attribute__((__always_inline__)) | FUNC(uint32_t) | ||||||
| vcvtmh_u32_f16(float16_t __a) { | vcvtmh_u32_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lflooruhfsi_us(__a); |   return __builtin_aarch64_lflooruhfsi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint64_t __attribute__((__always_inline__)) | FUNC(uint64_t) | ||||||
| vcvtmh_u64_f16(float16_t __a) { | vcvtmh_u64_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lflooruhfdi_us(__a); |   return __builtin_aarch64_lflooruhfdi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int16_t __attribute__((__always_inline__)) | FUNC(int16_t) | ||||||
| vcvtnh_s16_f16(float16_t __a) { | vcvtnh_s16_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lfrintnhfhi(__a); |   return __builtin_aarch64_lfrintnhfhi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int32_t __attribute__((__always_inline__)) | FUNC(int32_t) | ||||||
| vcvtnh_s32_f16(float16_t __a) { | vcvtnh_s32_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lfrintnhfsi(__a); |   return __builtin_aarch64_lfrintnhfsi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int64_t __attribute__((__always_inline__)) | FUNC(int64_t) | ||||||
| vcvtnh_s64_f16(float16_t __a) { | vcvtnh_s64_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lfrintnhfdi(__a); |   return __builtin_aarch64_lfrintnhfdi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcvtnh_u16_f16(float16_t __a) { | vcvtnh_u16_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lfrintnuhfhi_us(__a); |   return __builtin_aarch64_lfrintnuhfhi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint32_t __attribute__((__always_inline__)) | FUNC(uint32_t) | ||||||
| vcvtnh_u32_f16(float16_t __a) { | vcvtnh_u32_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lfrintnuhfsi_us(__a); |   return __builtin_aarch64_lfrintnuhfsi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint64_t __attribute__((__always_inline__)) | FUNC(uint64_t) | ||||||
| vcvtnh_u64_f16(float16_t __a) { | vcvtnh_u64_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lfrintnuhfdi_us(__a); |   return __builtin_aarch64_lfrintnuhfdi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int16_t __attribute__((__always_inline__)) | FUNC(int16_t) | ||||||
| vcvtph_s16_f16(float16_t __a) { | vcvtph_s16_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lceilhfhi(__a); |   return __builtin_aarch64_lceilhfhi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int32_t __attribute__((__always_inline__)) | FUNC(int32_t) | ||||||
| vcvtph_s32_f16(float16_t __a) { | vcvtph_s32_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lceilhfsi(__a); |   return __builtin_aarch64_lceilhfsi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int64_t __attribute__((__always_inline__)) | FUNC(int64_t) | ||||||
| vcvtph_s64_f16(float16_t __a) { | vcvtph_s64_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lceilhfdi(__a); |   return __builtin_aarch64_lceilhfdi(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcvtph_u16_f16(float16_t __a) { | vcvtph_u16_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lceiluhfhi_us(__a); |   return __builtin_aarch64_lceiluhfhi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint32_t __attribute__((__always_inline__)) | FUNC(uint32_t) | ||||||
| vcvtph_u32_f16(float16_t __a) { | vcvtph_u32_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lceiluhfsi_us(__a); |   return __builtin_aarch64_lceiluhfsi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint64_t __attribute__((__always_inline__)) | FUNC(uint64_t) | ||||||
| vcvtph_u64_f16(float16_t __a) { | vcvtph_u64_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_lceiluhfdi_us(__a); |   return __builtin_aarch64_lceiluhfdi_us(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vnegh_f16(float16_t __a) { | vnegh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_neghf(__a); |   return __builtin_aarch64_neghf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrecpeh_f16(float16_t __a) { | vrecpeh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_frecpehf(__a); |   return __builtin_aarch64_frecpehf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrecpxh_f16(float16_t __a) { | vrecpxh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_frecpxhf(__a); |   return __builtin_aarch64_frecpxhf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrndh_f16(float16_t __a) { | vrndh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_btrunchf(__a); |   return __builtin_aarch64_btrunchf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrndah_f16(float16_t __a) { | vrndah_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_roundhf(__a); |   return __builtin_aarch64_roundhf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrndih_f16(float16_t __a) { | vrndih_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_nearbyinthf(__a); |   return __builtin_aarch64_nearbyinthf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrndmh_f16(float16_t __a) { | vrndmh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_floorhf(__a); |   return __builtin_aarch64_floorhf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrndnh_f16(float16_t __a) { | vrndnh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_frintnhf(__a); |   return __builtin_aarch64_frintnhf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrndph_f16(float16_t __a) { | vrndph_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_ceilhf(__a); |   return __builtin_aarch64_ceilhf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrndxh_f16(float16_t __a) { | vrndxh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_rinthf(__a); |   return __builtin_aarch64_rinthf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrsqrteh_f16(float16_t __a) { | vrsqrteh_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_rsqrtehf(__a); |   return __builtin_aarch64_rsqrtehf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vsqrth_f16(float16_t __a) { | vsqrth_f16(float16_t __a) { | ||||||
|   return __builtin_aarch64_sqrthf(__a); |   return __builtin_aarch64_sqrthf(__a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vaddh_f16(float16_t __a, float16_t __b) { | vaddh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __a + __b; |   return __a + __b; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vabdh_f16(float16_t __a, float16_t __b) { | vabdh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_fabdhf(__a, __b); |   return __builtin_aarch64_fabdhf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcageh_f16(float16_t __a, float16_t __b) { | vcageh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_facgehf_uss(__a, __b); |   return __builtin_aarch64_facgehf_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcagth_f16(float16_t __a, float16_t __b) { | vcagth_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_facgthf_uss(__a, __b); |   return __builtin_aarch64_facgthf_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcaleh_f16(float16_t __a, float16_t __b) { | vcaleh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_faclehf_uss(__a, __b); |   return __builtin_aarch64_faclehf_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcalth_f16(float16_t __a, float16_t __b) { | vcalth_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_faclthf_uss(__a, __b); |   return __builtin_aarch64_faclthf_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vceqh_f16(float16_t __a, float16_t __b) { | vceqh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_cmeqhf_uss(__a, __b); |   return __builtin_aarch64_cmeqhf_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcgeh_f16(float16_t __a, float16_t __b) { | vcgeh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_cmgehf_uss(__a, __b); |   return __builtin_aarch64_cmgehf_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcgth_f16(float16_t __a, float16_t __b) { | vcgth_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_cmgthf_uss(__a, __b); |   return __builtin_aarch64_cmgthf_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcleh_f16(float16_t __a, float16_t __b) { | vcleh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_cmlehf_uss(__a, __b); |   return __builtin_aarch64_cmlehf_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vclth_f16(float16_t __a, float16_t __b) { | vclth_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_cmlthf_uss(__a, __b); |   return __builtin_aarch64_cmlthf_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_n_f16_s16(int16_t __a, const int __b) { | vcvth_n_f16_s16(int16_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_scvtfhi(__a, __b); |   return __builtin_aarch64_scvtfhi(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_n_f16_s32(int32_t __a, const int __b) { | vcvth_n_f16_s32(int32_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_scvtfsihf(__a, __b); |   return __builtin_aarch64_scvtfsihf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_n_f16_s64(int64_t __a, const int __b) { | vcvth_n_f16_s64(int64_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_scvtfdihf(__a, __b); |   return __builtin_aarch64_scvtfdihf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_n_f16_u16(uint16_t __a, const int __b) { | vcvth_n_f16_u16(uint16_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_ucvtfhi_sus(__a, __b); |   return __builtin_aarch64_ucvtfhi_sus(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_n_f16_u32(uint32_t __a, const int __b) { | vcvth_n_f16_u32(uint32_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_ucvtfsihf_sus(__a, __b); |   return __builtin_aarch64_ucvtfsihf_sus(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vcvth_n_f16_u64(uint64_t __a, const int __b) { | vcvth_n_f16_u64(uint64_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_ucvtfdihf_sus(__a, __b); |   return __builtin_aarch64_ucvtfdihf_sus(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int16_t __attribute__((__always_inline__)) | FUNC(int16_t) | ||||||
| vcvth_n_s16_f16(float16_t __a, const int __b) { | vcvth_n_s16_f16(float16_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_fcvtzshf(__a, __b); |   return __builtin_aarch64_fcvtzshf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int32_t __attribute__((__always_inline__)) | FUNC(int32_t) | ||||||
| vcvth_n_s32_f16(float16_t __a, const int __b) { | vcvth_n_s32_f16(float16_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_fcvtzshfsi(__a, __b); |   return __builtin_aarch64_fcvtzshfsi(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline int64_t __attribute__((__always_inline__)) | FUNC(int64_t) | ||||||
| vcvth_n_s64_f16(float16_t __a, const int __b) { | vcvth_n_s64_f16(float16_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_fcvtzshfdi(__a, __b); |   return __builtin_aarch64_fcvtzshfdi(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint16_t __attribute__((__always_inline__)) | FUNC(uint16_t) | ||||||
| vcvth_n_u16_f16(float16_t __a, const int __b) { | vcvth_n_u16_f16(float16_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_fcvtzuhf_uss(__a, __b); |   return __builtin_aarch64_fcvtzuhf_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint32_t __attribute__((__always_inline__)) | FUNC(uint32_t) | ||||||
| vcvth_n_u32_f16(float16_t __a, const int __b) { | vcvth_n_u32_f16(float16_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_fcvtzuhfsi_uss(__a, __b); |   return __builtin_aarch64_fcvtzuhfsi_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline uint64_t __attribute__((__always_inline__)) | FUNC(uint64_t) | ||||||
| vcvth_n_u64_f16(float16_t __a, const int __b) { | vcvth_n_u64_f16(float16_t __a, const int __b) { | ||||||
|   return __builtin_aarch64_fcvtzuhfdi_uss(__a, __b); |   return __builtin_aarch64_fcvtzuhfdi_uss(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vdivh_f16(float16_t __a, float16_t __b) { | vdivh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __a / __b; |   return __a / __b; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vmaxh_f16(float16_t __a, float16_t __b) { | vmaxh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_fmaxhf(__a, __b); |   return __builtin_aarch64_fmaxhf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vmaxnmh_f16(float16_t __a, float16_t __b) { | vmaxnmh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_fmaxhf(__a, __b); |   return __builtin_aarch64_fmaxhf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vminh_f16(float16_t __a, float16_t __b) { | vminh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_fminhf(__a, __b); |   return __builtin_aarch64_fminhf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vminnmh_f16(float16_t __a, float16_t __b) { | vminnmh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_fminhf(__a, __b); |   return __builtin_aarch64_fminhf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vmulh_f16(float16_t __a, float16_t __b) { | vmulh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __a * __b; |   return __a * __b; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vmulxh_f16(float16_t __a, float16_t __b) { | vmulxh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_fmulxhf(__a, __b); |   return __builtin_aarch64_fmulxhf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrecpsh_f16(float16_t __a, float16_t __b) { | vrecpsh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_frecpshf(__a, __b); |   return __builtin_aarch64_frecpshf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vrsqrtsh_f16(float16_t __a, float16_t __b) { | vrsqrtsh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __builtin_aarch64_rsqrtshf(__a, __b); |   return __builtin_aarch64_rsqrtshf(__a, __b); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vsubh_f16(float16_t __a, float16_t __b) { | vsubh_f16(float16_t __a, float16_t __b) { | ||||||
|   return __a - __b; |   return __a - __b; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vfmah_f16(float16_t __a, float16_t __b, float16_t __c) { | vfmah_f16(float16_t __a, float16_t __b, float16_t __c) { | ||||||
|   return __builtin_aarch64_fmahf(__b, __c, __a); |   return __builtin_aarch64_fmahf(__b, __c, __a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __extension__ static __inline float16_t __attribute__((__always_inline__)) | FUNC(float16_t) | ||||||
| vfmsh_f16(float16_t __a, float16_t __b, float16_t __c) { | vfmsh_f16(float16_t __a, float16_t __b, float16_t __c) { | ||||||
|   return __builtin_aarch64_fnmahf(__b, __c, __a); |   return __builtin_aarch64_fnmahf(__b, __c, __a); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #pragma GCC pop_options | #pragma GCC pop_options | ||||||
| 
 | 
 | ||||||
|  | #undef FUNC | ||||||
| #endif /* __aarch64__ */ | #endif /* __aarch64__ */ | ||||||
| #endif /* _AARCH64_FP16_H_ */ | #endif /* _AARCH64_FP16_H_ */ | ||||||
|  |  | ||||||
							
								
								
									
										18855
									
								
								third_party/aarch64/arm_neon.h
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										18855
									
								
								third_party/aarch64/arm_neon.h
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										1
									
								
								third_party/ggml/ggml.c
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								third_party/ggml/ggml.c
									
										
									
									
										vendored
									
									
								
							|  | @ -38,6 +38,7 @@ | ||||||
| #include "libc/sysv/consts/clock.h" | #include "libc/sysv/consts/clock.h" | ||||||
| #include "libc/thread/thread.h" | #include "libc/thread/thread.h" | ||||||
| #include "libc/time/time.h" | #include "libc/time/time.h" | ||||||
|  | #include "third_party/aarch64/arm_neon.h" | ||||||
| #include "third_party/intel/immintrin.internal.h" | #include "third_party/intel/immintrin.internal.h" | ||||||
| #include "third_party/libcxx/math.h" | #include "third_party/libcxx/math.h" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										3
									
								
								third_party/ggml/ggml.mk
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								third_party/ggml/ggml.mk
									
										
									
									
										vendored
									
									
								
							|  | @ -27,7 +27,8 @@ THIRD_PARTY_GGML_A_DIRECTDEPS =						\ | ||||||
| 	LIBC_STR							\
 | 	LIBC_STR							\
 | ||||||
| 	LIBC_STUBS							\
 | 	LIBC_STUBS							\
 | ||||||
| 	LIBC_SYSV							\
 | 	LIBC_SYSV							\
 | ||||||
| 	LIBC_TINYMATH | 	LIBC_TINYMATH							\
 | ||||||
|  | 	THIRD_PARTY_COMPILER_RT | ||||||
| 
 | 
 | ||||||
| THIRD_PARTY_GGML_A_DEPS :=						\
 | THIRD_PARTY_GGML_A_DEPS :=						\
 | ||||||
| 	$(call uniq,$(foreach x,$(THIRD_PARTY_GGML_A_DIRECTDEPS),$($(x)))) | 	$(call uniq,$(foreach x,$(THIRD_PARTY_GGML_A_DIRECTDEPS),$($(x)))) | ||||||
|  |  | ||||||
							
								
								
									
										3
									
								
								third_party/ggml/main.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								third_party/ggml/main.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -99,14 +99,15 @@ int main(int argc, char ** argv) { | ||||||
| 
 | 
 | ||||||
|     params.model = "models/llama-7B/ggml-model.bin"; |     params.model = "models/llama-7B/ggml-model.bin"; | ||||||
| 
 | 
 | ||||||
|  | #ifdef __x86_64__ | ||||||
|     if (!X86_HAVE(AVX2)) return on_missing_feature("avx2"); |     if (!X86_HAVE(AVX2)) return on_missing_feature("avx2"); | ||||||
|     if (!X86_HAVE(AVX)) return on_missing_feature("avx"); |     if (!X86_HAVE(AVX)) return on_missing_feature("avx"); | ||||||
|     if (!X86_HAVE(FMA)) return on_missing_feature("fma"); |     if (!X86_HAVE(FMA)) return on_missing_feature("fma"); | ||||||
|     if (!X86_HAVE(SSE3)) return on_missing_feature("sse3"); |     if (!X86_HAVE(SSE3)) return on_missing_feature("sse3"); | ||||||
| 
 |  | ||||||
|     if (!X86_HAVE(F16C)) { |     if (!X86_HAVE(F16C)) { | ||||||
|         fprintf(stderr, "%s: warning: cpuid f16c not detected; inference might crash\n", __func__); |         fprintf(stderr, "%s: warning: cpuid f16c not detected; inference might crash\n", __func__); | ||||||
|     } |     } | ||||||
|  | #endif /* __x86_64__ */ | ||||||
| 
 | 
 | ||||||
|     if (gpt_params_parse(argc, argv, params) == false) { |     if (gpt_params_parse(argc, argv, params) == false) { | ||||||
|         return 1; |         return 1; | ||||||
|  |  | ||||||
							
								
								
									
										3
									
								
								third_party/zlib/zlib.mk
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								third_party/zlib/zlib.mk
									
										
									
									
										vendored
									
									
								
							|  | @ -45,6 +45,9 @@ ifeq ($(ARCH), x86_64) | ||||||
| o/$(MODE)/third_party/zlib/adler32simd.o: private	\ | o/$(MODE)/third_party/zlib/adler32simd.o: private	\ | ||||||
| 		OVERRIDE_CFLAGS +=			\
 | 		OVERRIDE_CFLAGS +=			\
 | ||||||
| 			-mssse3 | 			-mssse3 | ||||||
|  | o/$(MODE)/third_party/zlib/adler32simd.o: private	\ | ||||||
|  | 		OVERRIDE_CPPFLAGS +=			\
 | ||||||
|  | 			-DADLER32_SIMD_SSSE3 | ||||||
| o/$(MODE)/third_party/zlib/adler32.o: private		\ | o/$(MODE)/third_party/zlib/adler32.o: private		\ | ||||||
| 		OVERRIDE_CPPFLAGS +=			\
 | 		OVERRIDE_CPPFLAGS +=			\
 | ||||||
| 			-DADLER32_SIMD_SSSE3 | 			-DADLER32_SIMD_SSSE3 | ||||||
|  |  | ||||||
|  | @ -16,6 +16,7 @@ | ||||||
| │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR             │ | │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR             │ | ||||||
| │ PERFORMANCE OF THIS SOFTWARE.                                                │ | │ PERFORMANCE OF THIS SOFTWARE.                                                │ | ||||||
| ╚─────────────────────────────────────────────────────────────────────────────*/ | ╚─────────────────────────────────────────────────────────────────────────────*/ | ||||||
|  | #include "tool/build/lib/elfwriter.h" | ||||||
| #include "libc/assert.h" | #include "libc/assert.h" | ||||||
| #include "libc/calls/calls.h" | #include "libc/calls/calls.h" | ||||||
| #include "libc/elf/def.h" | #include "libc/elf/def.h" | ||||||
|  | @ -30,7 +31,6 @@ | ||||||
| #include "libc/sysv/consts/o.h" | #include "libc/sysv/consts/o.h" | ||||||
| #include "libc/sysv/consts/prot.h" | #include "libc/sysv/consts/prot.h" | ||||||
| #include "libc/x/xasprintf.h" | #include "libc/x/xasprintf.h" | ||||||
| #include "tool/build/lib/elfwriter.h" |  | ||||||
| 
 | 
 | ||||||
| static const Elf64_Ehdr kObjHeader = { | static const Elf64_Ehdr kObjHeader = { | ||||||
|     .e_ident = {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, ELFCLASS64, ELFDATA2LSB, 1, |     .e_ident = {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, ELFCLASS64, ELFDATA2LSB, 1, | ||||||
|  | @ -166,6 +166,15 @@ struct ElfWriter *elfwriter_open(const char *path, int mode) { | ||||||
|                                         elf->mapsize, PROT_READ | PROT_WRITE, |                                         elf->mapsize, PROT_READ | PROT_WRITE, | ||||||
|                                         MAP_SHARED | MAP_FIXED, elf->fd, 0))); |                                         MAP_SHARED | MAP_FIXED, elf->fd, 0))); | ||||||
|   elf->ehdr = memcpy(elf->map, &kObjHeader, (elf->wrote = sizeof(kObjHeader))); |   elf->ehdr = memcpy(elf->map, &kObjHeader, (elf->wrote = sizeof(kObjHeader))); | ||||||
|  |   if (strstr(path, "/aarch64")) { | ||||||
|  |     elf->ehdr->e_machine = EM_AARCH64; | ||||||
|  |   } else if (strstr(path, "/powerpc64")) { | ||||||
|  |     elf->ehdr->e_machine = EM_PPC64; | ||||||
|  |   } else if (strstr(path, "/riscv")) { | ||||||
|  |     elf->ehdr->e_machine = EM_RISCV; | ||||||
|  |   } else if (strstr(path, "/s390")) { | ||||||
|  |     elf->ehdr->e_machine = EM_S390; | ||||||
|  |   } | ||||||
|   elf->strtab = newinterner(); |   elf->strtab = newinterner(); | ||||||
|   elf->shstrtab = newinterner(); |   elf->shstrtab = newinterner(); | ||||||
|   intern(elf->strtab, ""); |   intern(elf->strtab, ""); | ||||||
|  | @ -274,3 +283,20 @@ void elfwriter_appendrela(struct ElfWriter *elf, uint64_t r_offset, | ||||||
|                                                .offset = r_offset, |                                                .offset = r_offset, | ||||||
|                                                .addend = r_addend}))); |                                                .addend = r_addend}))); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | uint32_t elfwriter_relatype_abs32(const struct ElfWriter *elf) { | ||||||
|  |   switch (elf->ehdr->e_machine) { | ||||||
|  |     case EM_NEXGEN32E: | ||||||
|  |       return R_X86_64_32; | ||||||
|  |     case EM_AARCH64: | ||||||
|  |       return R_AARCH64_ABS32; | ||||||
|  |     case EM_PPC64: | ||||||
|  |       return R_PPC64_ADDR32; | ||||||
|  |     case EM_RISCV: | ||||||
|  |       return R_RISCV_32; | ||||||
|  |     case EM_S390: | ||||||
|  |       return R_390_32; | ||||||
|  |     default: | ||||||
|  |       notpossible; | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -64,6 +64,7 @@ void elfwriter_commit(struct ElfWriter *, size_t); | ||||||
| void elfwriter_finishsection(struct ElfWriter *); | void elfwriter_finishsection(struct ElfWriter *); | ||||||
| void elfwriter_appendrela(struct ElfWriter *, uint64_t, struct ElfWriterSymRef, | void elfwriter_appendrela(struct ElfWriter *, uint64_t, struct ElfWriterSymRef, | ||||||
|                           uint32_t, int64_t); |                           uint32_t, int64_t); | ||||||
|  | uint32_t elfwriter_relatype_abs32(const struct ElfWriter *); | ||||||
| struct ElfWriterSymRef elfwriter_linksym(struct ElfWriter *, const char *, int, | struct ElfWriterSymRef elfwriter_linksym(struct ElfWriter *, const char *, int, | ||||||
|                                          int); |                                          int); | ||||||
| struct ElfWriterSymRef elfwriter_appendsym(struct ElfWriter *, const char *, | struct ElfWriterSymRef elfwriter_appendsym(struct ElfWriter *, const char *, | ||||||
|  |  | ||||||
|  | @ -27,6 +27,7 @@ void elfwriter_yoink(struct ElfWriter *elf, const char *symbol, int stb) { | ||||||
|   memcpy(p, kNopl, sizeof(kNopl)); |   memcpy(p, kNopl, sizeof(kNopl)); | ||||||
|   sym = elfwriter_linksym(elf, symbol, ELF64_ST_INFO(stb, STT_OBJECT), |   sym = elfwriter_linksym(elf, symbol, ELF64_ST_INFO(stb, STT_OBJECT), | ||||||
|                           STV_HIDDEN); |                           STV_HIDDEN); | ||||||
|   elfwriter_appendrela(elf, sizeof(kNopl) - 4, sym, R_X86_64_32, 0); |   elfwriter_appendrela(elf, sizeof(kNopl) - 4, sym, | ||||||
|  |                        elfwriter_relatype_abs32(elf), 0); | ||||||
|   elfwriter_commit(elf, sizeof(kNopl)); |   elfwriter_commit(elf, sizeof(kNopl)); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -215,8 +215,8 @@ void elfwriter_zip(struct ElfWriter *elf, const char *symbol, const char *name, | ||||||
|   elfwriter_appendsym(elf, _gc(xasprintf("%s%s", "zip+cdir:", name)), |   elfwriter_appendsym(elf, _gc(xasprintf("%s%s", "zip+cdir:", name)), | ||||||
|                       ELF64_ST_INFO(STB_LOCAL, STT_OBJECT), STV_DEFAULT, 0, |                       ELF64_ST_INFO(STB_LOCAL, STT_OBJECT), STV_DEFAULT, 0, | ||||||
|                       kZipCdirHdrLinkableSizeBootstrap); |                       kZipCdirHdrLinkableSizeBootstrap); | ||||||
|   elfwriter_appendrela(elf, kZipCfileOffsetOffset, lfilesym, R_X86_64_32, |   elfwriter_appendrela(elf, kZipCfileOffsetOffset, lfilesym, | ||||||
|                        -imagebase); |                        elfwriter_relatype_abs32(elf), -imagebase); | ||||||
|   elfwriter_commit(elf, kZipCdirHdrLinkableSizeBootstrap); |   elfwriter_commit(elf, kZipCdirHdrLinkableSizeBootstrap); | ||||||
|   elfwriter_finishsection(elf); |   elfwriter_finishsection(elf); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -52,6 +52,7 @@ | ||||||
|     "__BMI2__" |     "__BMI2__" | ||||||
|     "__FMA__" |     "__FMA__" | ||||||
|     "__FMA4__" |     "__FMA4__" | ||||||
|  |     "__F16C__" | ||||||
|     "__CLZERO__" |     "__CLZERO__" | ||||||
|     "__MWAITX__" |     "__MWAITX__" | ||||||
|     "__SGX__" |     "__SGX__" | ||||||
|  | @ -78,8 +79,12 @@ | ||||||
|   '("__x86_64__" |   '("__x86_64__" | ||||||
|     "__arm__" |     "__arm__" | ||||||
|     "__aarch64__" |     "__aarch64__" | ||||||
|  |     "__AARCH64EB__" | ||||||
|  |     "__ARM_NEON" | ||||||
|     "__powerpc__" |     "__powerpc__" | ||||||
|     "__powerpc64__" |     "__powerpc64__" | ||||||
|  |     "__POWER9_VECTOR__" | ||||||
|  |     "__wasm_simd128__" | ||||||
|     "_ARCH_PWR5X" |     "_ARCH_PWR5X" | ||||||
|     "__mips__" |     "__mips__" | ||||||
|     "__s390__" |     "__s390__" | ||||||
|  | @ -204,6 +209,8 @@ | ||||||
|   '("__llvm__" |   '("__llvm__" | ||||||
|     "__clang__" |     "__clang__" | ||||||
|     "_MSC_VER" |     "_MSC_VER" | ||||||
|  |     "_WIN32" | ||||||
|  |     "__MINGW32__" | ||||||
|     "__INTEL_COMPILER")) |     "__INTEL_COMPILER")) | ||||||
| 
 | 
 | ||||||
| (defconst cosmo-cpp-constants | (defconst cosmo-cpp-constants | ||||||
|  |  | ||||||
|  | @ -18,6 +18,7 @@ | ||||||
| ╚─────────────────────────────────────────────────────────────────────────────*/ | ╚─────────────────────────────────────────────────────────────────────────────*/ | ||||||
| #include "tool/viz/lib/formatstringtable.h" | #include "tool/viz/lib/formatstringtable.h" | ||||||
| #include "libc/intrin/safemacros.internal.h" | #include "libc/intrin/safemacros.internal.h" | ||||||
|  | #include "libc/mem/mem.h" | ||||||
| #include "libc/str/strwidth.h" | #include "libc/str/strwidth.h" | ||||||
| 
 | 
 | ||||||
| void *FreeStringTableCells(long yn, long xn, char *T[yn][xn]) { | void *FreeStringTableCells(long yn, long xn, char *T[yn][xn]) { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue