mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-31 23:10:27 +00:00
Get LIBC_MEM and LIBC_STDIO building with aarch64
This commit is contained in:
parent
ae0ee59614
commit
d04430f4ef
81 changed files with 440 additions and 1064 deletions
4
third_party/dlmalloc/dlmalloc.c
vendored
4
third_party/dlmalloc/dlmalloc.c
vendored
|
@ -1,3 +1,4 @@
|
|||
#include "third_party/dlmalloc/dlmalloc.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
|
@ -16,7 +17,6 @@
|
|||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "third_party/dlmalloc/dlmalloc.h"
|
||||
#include "third_party/dlmalloc/vespene.internal.h"
|
||||
// clang-format off
|
||||
|
||||
|
@ -1418,7 +1418,7 @@ int dlmallopt(int param_number, int value) {
|
|||
return change_mparam(param_number, value);
|
||||
}
|
||||
|
||||
size_t dlmalloc_usable_size(const void* mem) {
|
||||
size_t dlmalloc_usable_size(void* mem) {
|
||||
mchunkptr p;
|
||||
size_t bytes;
|
||||
if (mem) {
|
||||
|
|
2
third_party/dlmalloc/dlmalloc.h
vendored
2
third_party/dlmalloc/dlmalloc.h
vendored
|
@ -415,7 +415,7 @@ void dlmalloc_stats(void);
|
|||
p = malloc(n);
|
||||
assert(malloc_usable_size(p) >= 256);
|
||||
*/
|
||||
size_t dlmalloc_usable_size(const void*);
|
||||
size_t dlmalloc_usable_size(void*);
|
||||
|
||||
/*
|
||||
mspace is an opaque type representing an independent
|
||||
|
|
12
third_party/dlmalloc/dlmalloc.mk
vendored
12
third_party/dlmalloc/dlmalloc.mk
vendored
|
@ -9,16 +9,8 @@ THIRD_PARTY_DLMALLOC_A = o/$(MODE)/third_party/dlmalloc/dlmalloc.a
|
|||
THIRD_PARTY_DLMALLOC_A_FILES := $(wildcard third_party/dlmalloc/*)
|
||||
THIRD_PARTY_DLMALLOC_A_HDRS = $(filter %.h,$(THIRD_PARTY_DLMALLOC_A_FILES))
|
||||
THIRD_PARTY_DLMALLOC_A_INCS = $(filter %.inc,$(THIRD_PARTY_DLMALLOC_A_FILES))
|
||||
THIRD_PARTY_DLMALLOC_A_SRCS_S = $(filter %.S,$(THIRD_PARTY_DLMALLOC_A_FILES))
|
||||
THIRD_PARTY_DLMALLOC_A_SRCS_C = $(filter %.c,$(THIRD_PARTY_DLMALLOC_A_FILES))
|
||||
|
||||
THIRD_PARTY_DLMALLOC_A_SRCS = \
|
||||
$(THIRD_PARTY_DLMALLOC_A_SRCS_S) \
|
||||
$(THIRD_PARTY_DLMALLOC_A_SRCS_C)
|
||||
|
||||
THIRD_PARTY_DLMALLOC_A_OBJS = \
|
||||
$(THIRD_PARTY_DLMALLOC_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
||||
$(THIRD_PARTY_DLMALLOC_A_SRCS_C:%.c=o/$(MODE)/%.o)
|
||||
THIRD_PARTY_DLMALLOC_A_SRCS = $(filter %.c,$(THIRD_PARTY_DLMALLOC_A_FILES))
|
||||
THIRD_PARTY_DLMALLOC_A_OBJS = $(THIRD_PARTY_DLMALLOC_A_SRCS:%.c=o/$(MODE)/%.o)
|
||||
|
||||
THIRD_PARTY_DLMALLOC_A_CHECKS = \
|
||||
$(THIRD_PARTY_DLMALLOC_A).pkg \
|
||||
|
|
27
third_party/dlmalloc/init.S
vendored
27
third_party/dlmalloc/init.S
vendored
|
@ -1,27 +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 2022 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"
|
||||
|
||||
.init.start 600,_init_dlmalloc
|
||||
push %rdi
|
||||
push %rsi
|
||||
call init_mparams
|
||||
pop %rsi
|
||||
pop %rdi
|
||||
.init.end 600,_init_dlmalloc
|
4
third_party/dlmalloc/init.inc
vendored
4
third_party/dlmalloc/init.inc
vendored
|
@ -1,7 +1,5 @@
|
|||
// clang-format off
|
||||
|
||||
STATIC_YOINK("_init_dlmalloc");
|
||||
|
||||
/* ---------------------------- setting mparams -------------------------- */
|
||||
|
||||
#if LOCK_AT_FORK
|
||||
|
@ -11,7 +9,7 @@ static void dlmalloc_post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); }
|
|||
#endif /* LOCK_AT_FORK */
|
||||
|
||||
/* Initialize mparams */
|
||||
int init_mparams(void) {
|
||||
__attribute__((__constructor__)) int init_mparams(void) {
|
||||
#ifdef NEED_GLOBAL_LOCK_INIT
|
||||
if (malloc_global_mutex_status <= 0)
|
||||
init_malloc_global_mutex();
|
||||
|
|
7
third_party/ggml/ggml.mk
vendored
7
third_party/ggml/ggml.mk
vendored
|
@ -45,12 +45,17 @@ $(THIRD_PARTY_GGML_A_OBJS): private \
|
|||
OVERRIDE_CFLAGS += \
|
||||
-O3 \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-fdata-sections
|
||||
|
||||
ifeq ($(ARCH), x86_64)
|
||||
$(THIRD_PARTY_GGML_A_OBJS): private \
|
||||
OVERRIDE_CFLAGS += \
|
||||
-msse3 \
|
||||
-mavx \
|
||||
-mavx2 \
|
||||
-mf16c \
|
||||
-mfma
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# command for running inference on large language models
|
||||
|
|
4
third_party/zlib/adler32simd.c
vendored
4
third_party/zlib/adler32simd.c
vendored
|
@ -58,6 +58,8 @@ asm(".include \"libc/disclaimer.inc\"");
|
|||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
#define NMAX 5552
|
||||
|
||||
#ifdef ADLER32_SIMD_SSSE3
|
||||
|
||||
uint32_t adler32_simd_(uint32_t adler, const unsigned char *buf, size_t len) {
|
||||
/*
|
||||
* Split Adler-32 into component sums.
|
||||
|
@ -192,3 +194,5 @@ uint32_t adler32_simd_(uint32_t adler, const unsigned char *buf, size_t len) {
|
|||
*/
|
||||
return s1 | (s2 << 16);
|
||||
}
|
||||
|
||||
#endif /* ADLER32_SIMD_SSSE3 */
|
||||
|
|
4
third_party/zlib/zlib.mk
vendored
4
third_party/zlib/zlib.mk
vendored
|
@ -41,17 +41,17 @@ $(THIRD_PARTY_ZLIB_A).pkg: \
|
|||
$(THIRD_PARTY_ZLIB_A_OBJS) \
|
||||
$(foreach x,$(THIRD_PARTY_ZLIB_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
ifeq ($(ARCH), x86_64)
|
||||
o/$(MODE)/third_party/zlib/adler32simd.o: private \
|
||||
OVERRIDE_CFLAGS += \
|
||||
-mssse3
|
||||
|
||||
o/$(MODE)/third_party/zlib/adler32.o: private \
|
||||
OVERRIDE_CPPFLAGS += \
|
||||
-DADLER32_SIMD_SSSE3
|
||||
|
||||
o/$(MODE)/third_party/zlib/deflate.o: private \
|
||||
OVERRIDE_CPPFLAGS += \
|
||||
-DCRC32_SIMD_SSE42_PCLMUL
|
||||
endif
|
||||
|
||||
$(THIRD_PARTY_ZLIB_A_OBJS): private \
|
||||
OVERRIDE_CFLAGS += \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue