Adding upstream version 1.65.7.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
5189956325
commit
32b8eb3fd7
4153 changed files with 2487292 additions and 0 deletions
10
internal/archive/archive.go
Normal file
10
internal/archive/archive.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2024 The Libc Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package archive
|
||||
|
||||
const (
|
||||
Version = "musl-7ada6dde6f9dc6a2836c3d92c2f762d35fd229e0"
|
||||
File = Version + ".tar.gz"
|
||||
)
|
31
internal/autogen/linux_386.mod
Normal file
31
internal/autogen/linux_386.mod
Normal file
|
@ -0,0 +1,31 @@
|
|||
module modernc.org/libc
|
||||
|
||||
go 1.23.0
|
||||
|
||||
retract v1.43.0
|
||||
|
||||
require (
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/ncruces/go-strftime v0.1.9
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
|
||||
golang.org/x/sys v0.33.0
|
||||
modernc.org/cc/v4 v4.26.1
|
||||
modernc.org/ccgo/v4 v4.28.0
|
||||
modernc.org/fileutil v1.3.1
|
||||
modernc.org/mathutil v1.7.1
|
||||
modernc.org/memory v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/tools v0.33.0 // indirect
|
||||
modernc.org/gc/v2 v2.6.5 // indirect
|
||||
modernc.org/opt v0.1.4 // indirect
|
||||
modernc.org/sortutil v1.2.1 // indirect
|
||||
modernc.org/strutil v1.2.1 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
)
|
31
internal/autogen/linux_amd64.mod
Normal file
31
internal/autogen/linux_amd64.mod
Normal file
|
@ -0,0 +1,31 @@
|
|||
module modernc.org/libc
|
||||
|
||||
go 1.23.0
|
||||
|
||||
retract v1.43.0
|
||||
|
||||
require (
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/ncruces/go-strftime v0.1.9
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
|
||||
golang.org/x/sys v0.33.0
|
||||
modernc.org/cc/v4 v4.26.1
|
||||
modernc.org/ccgo/v4 v4.28.0
|
||||
modernc.org/fileutil v1.3.1
|
||||
modernc.org/mathutil v1.7.1
|
||||
modernc.org/memory v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/tools v0.33.0 // indirect
|
||||
modernc.org/gc/v2 v2.6.5 // indirect
|
||||
modernc.org/opt v0.1.4 // indirect
|
||||
modernc.org/sortutil v1.2.1 // indirect
|
||||
modernc.org/strutil v1.2.1 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
)
|
31
internal/autogen/linux_arm.mod
Normal file
31
internal/autogen/linux_arm.mod
Normal file
|
@ -0,0 +1,31 @@
|
|||
module modernc.org/libc
|
||||
|
||||
go 1.23.0
|
||||
|
||||
retract v1.43.0
|
||||
|
||||
require (
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/ncruces/go-strftime v0.1.9
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
|
||||
golang.org/x/sys v0.33.0
|
||||
modernc.org/cc/v4 v4.26.1
|
||||
modernc.org/ccgo/v4 v4.28.0
|
||||
modernc.org/fileutil v1.3.1
|
||||
modernc.org/mathutil v1.7.1
|
||||
modernc.org/memory v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/tools v0.33.0 // indirect
|
||||
modernc.org/gc/v2 v2.6.5 // indirect
|
||||
modernc.org/opt v0.1.4 // indirect
|
||||
modernc.org/sortutil v1.2.1 // indirect
|
||||
modernc.org/strutil v1.2.1 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
)
|
31
internal/autogen/linux_arm64.mod
Normal file
31
internal/autogen/linux_arm64.mod
Normal file
|
@ -0,0 +1,31 @@
|
|||
module modernc.org/libc
|
||||
|
||||
go 1.23.0
|
||||
|
||||
retract v1.43.0
|
||||
|
||||
require (
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/ncruces/go-strftime v0.1.9
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
|
||||
golang.org/x/sys v0.33.0
|
||||
modernc.org/cc/v4 v4.26.1
|
||||
modernc.org/ccgo/v4 v4.28.0
|
||||
modernc.org/fileutil v1.3.1
|
||||
modernc.org/mathutil v1.7.1
|
||||
modernc.org/memory v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/tools v0.33.0 // indirect
|
||||
modernc.org/gc/v2 v2.6.5 // indirect
|
||||
modernc.org/opt v0.1.4 // indirect
|
||||
modernc.org/sortutil v1.2.1 // indirect
|
||||
modernc.org/strutil v1.2.1 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
)
|
31
internal/autogen/linux_loong64.mod
Normal file
31
internal/autogen/linux_loong64.mod
Normal file
|
@ -0,0 +1,31 @@
|
|||
module modernc.org/libc
|
||||
|
||||
go 1.23.0
|
||||
|
||||
retract v1.43.0
|
||||
|
||||
require (
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/ncruces/go-strftime v0.1.9
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
|
||||
golang.org/x/sys v0.33.0
|
||||
modernc.org/cc/v4 v4.26.1
|
||||
modernc.org/ccgo/v4 v4.28.0
|
||||
modernc.org/fileutil v1.3.1
|
||||
modernc.org/mathutil v1.7.1
|
||||
modernc.org/memory v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/tools v0.33.0 // indirect
|
||||
modernc.org/gc/v2 v2.6.5 // indirect
|
||||
modernc.org/opt v0.1.4 // indirect
|
||||
modernc.org/sortutil v1.2.1 // indirect
|
||||
modernc.org/strutil v1.2.1 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
)
|
31
internal/autogen/linux_ppc64le.mod
Normal file
31
internal/autogen/linux_ppc64le.mod
Normal file
|
@ -0,0 +1,31 @@
|
|||
module modernc.org/libc
|
||||
|
||||
go 1.23.0
|
||||
|
||||
retract v1.43.0
|
||||
|
||||
require (
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/ncruces/go-strftime v0.1.9
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
|
||||
golang.org/x/sys v0.33.0
|
||||
modernc.org/cc/v4 v4.26.1
|
||||
modernc.org/ccgo/v4 v4.28.0
|
||||
modernc.org/fileutil v1.3.1
|
||||
modernc.org/mathutil v1.7.1
|
||||
modernc.org/memory v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/tools v0.33.0 // indirect
|
||||
modernc.org/gc/v2 v2.6.5 // indirect
|
||||
modernc.org/opt v0.1.4 // indirect
|
||||
modernc.org/sortutil v1.2.1 // indirect
|
||||
modernc.org/strutil v1.2.1 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
)
|
31
internal/autogen/linux_riscv64.mod
Normal file
31
internal/autogen/linux_riscv64.mod
Normal file
|
@ -0,0 +1,31 @@
|
|||
module modernc.org/libc
|
||||
|
||||
go 1.23.0
|
||||
|
||||
retract v1.43.0
|
||||
|
||||
require (
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/ncruces/go-strftime v0.1.9
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
|
||||
golang.org/x/sys v0.33.0
|
||||
modernc.org/cc/v4 v4.26.1
|
||||
modernc.org/ccgo/v4 v4.28.0
|
||||
modernc.org/fileutil v1.3.1
|
||||
modernc.org/mathutil v1.7.1
|
||||
modernc.org/memory v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/tools v0.33.0 // indirect
|
||||
modernc.org/gc/v2 v2.6.5 // indirect
|
||||
modernc.org/opt v0.1.4 // indirect
|
||||
modernc.org/sortutil v1.2.1 // indirect
|
||||
modernc.org/strutil v1.2.1 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
)
|
31
internal/autogen/linux_s390x.mod
Normal file
31
internal/autogen/linux_s390x.mod
Normal file
|
@ -0,0 +1,31 @@
|
|||
module modernc.org/libc
|
||||
|
||||
go 1.23.0
|
||||
|
||||
retract v1.43.0
|
||||
|
||||
require (
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/ncruces/go-strftime v0.1.9
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
|
||||
golang.org/x/sys v0.33.0
|
||||
modernc.org/cc/v4 v4.26.1
|
||||
modernc.org/ccgo/v4 v4.28.0
|
||||
modernc.org/fileutil v1.3.1
|
||||
modernc.org/mathutil v1.7.1
|
||||
modernc.org/memory v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/tools v0.33.0 // indirect
|
||||
modernc.org/gc/v2 v2.6.5 // indirect
|
||||
modernc.org/opt v0.1.4 // indirect
|
||||
modernc.org/sortutil v1.2.1 // indirect
|
||||
modernc.org/strutil v1.2.1 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
)
|
95
internal/overlay/linux/386/musl/include/alltypes.h.in
Normal file
95
internal/overlay/linux/386/musl/include/alltypes.h.in
Normal file
|
@ -0,0 +1,95 @@
|
|||
#define __LITTLE_ENDIAN 1234
|
||||
#define __BIG_ENDIAN 4321
|
||||
#define __USE_TIME_BITS64 1
|
||||
|
||||
TYPEDEF unsigned _Addr size_t;
|
||||
TYPEDEF unsigned _Addr uintptr_t;
|
||||
TYPEDEF _Addr ptrdiff_t;
|
||||
TYPEDEF _Addr ssize_t;
|
||||
TYPEDEF _Addr intptr_t;
|
||||
TYPEDEF _Addr regoff_t;
|
||||
TYPEDEF _Reg register_t;
|
||||
TYPEDEF _Int64 time_t;
|
||||
TYPEDEF _Int64 suseconds_t;
|
||||
|
||||
TYPEDEF signed char int8_t;
|
||||
TYPEDEF signed short int16_t;
|
||||
TYPEDEF signed int int32_t;
|
||||
TYPEDEF signed _Int64 int64_t;
|
||||
TYPEDEF signed _Int64 intmax_t;
|
||||
TYPEDEF unsigned char uint8_t;
|
||||
TYPEDEF unsigned short uint16_t;
|
||||
TYPEDEF unsigned int uint32_t;
|
||||
TYPEDEF unsigned _Int64 uint64_t;
|
||||
TYPEDEF unsigned _Int64 u_int64_t;
|
||||
TYPEDEF unsigned _Int64 uintmax_t;
|
||||
|
||||
TYPEDEF unsigned mode_t;
|
||||
TYPEDEF unsigned _Reg nlink_t;
|
||||
TYPEDEF _Int64 off_t;
|
||||
TYPEDEF unsigned _Int64 ino_t;
|
||||
TYPEDEF unsigned _Int64 dev_t;
|
||||
TYPEDEF long blksize_t;
|
||||
TYPEDEF _Int64 blkcnt_t;
|
||||
TYPEDEF unsigned _Int64 fsblkcnt_t;
|
||||
TYPEDEF unsigned _Int64 fsfilcnt_t;
|
||||
|
||||
TYPEDEF unsigned wint_t;
|
||||
TYPEDEF unsigned long wctype_t;
|
||||
|
||||
TYPEDEF void * timer_t;
|
||||
TYPEDEF int clockid_t;
|
||||
TYPEDEF long clock_t;
|
||||
STRUCT timeval { time_t tv_sec; suseconds_t tv_usec; };
|
||||
STRUCT timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); };
|
||||
|
||||
TYPEDEF int pid_t;
|
||||
TYPEDEF unsigned id_t;
|
||||
TYPEDEF unsigned uid_t;
|
||||
TYPEDEF unsigned gid_t;
|
||||
TYPEDEF int key_t;
|
||||
TYPEDEF unsigned useconds_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
TYPEDEF unsigned long pthread_t;
|
||||
#else
|
||||
TYPEDEF struct __pthread * pthread_t;
|
||||
#endif
|
||||
TYPEDEF int pthread_once_t;
|
||||
TYPEDEF unsigned pthread_key_t;
|
||||
TYPEDEF int pthread_spinlock_t;
|
||||
TYPEDEF struct { unsigned __attr; } pthread_mutexattr_t;
|
||||
TYPEDEF struct { unsigned __attr; } pthread_condattr_t;
|
||||
TYPEDEF struct { unsigned __attr; } pthread_barrierattr_t;
|
||||
TYPEDEF struct { unsigned __attr[2]; } pthread_rwlockattr_t;
|
||||
|
||||
STRUCT _IO_FILE { char __x; };
|
||||
TYPEDEF struct _IO_FILE FILE;
|
||||
|
||||
TYPEDEF __builtin_va_list va_list;
|
||||
TYPEDEF __builtin_va_list __isoc_va_list;
|
||||
|
||||
TYPEDEF struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
|
||||
|
||||
TYPEDEF struct __locale_struct * locale_t;
|
||||
|
||||
TYPEDEF struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t;
|
||||
|
||||
STRUCT iovec { void *iov_base; size_t iov_len; };
|
||||
|
||||
STRUCT winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; };
|
||||
|
||||
TYPEDEF unsigned socklen_t;
|
||||
TYPEDEF unsigned short sa_family_t;
|
||||
|
||||
TYPEDEF struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t;
|
||||
TYPEDEF struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; int __ccgo_room; } pthread_mutex_t;
|
||||
TYPEDEF struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; int __ccgo_room; } mtx_t;
|
||||
TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t;
|
||||
TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t;
|
||||
TYPEDEF struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t;
|
||||
TYPEDEF struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t;
|
||||
|
||||
#undef _Addr
|
||||
#undef _Int64
|
||||
#undef _Reg
|
333
internal/overlay/linux/386/musl/src/internal/atomic.h
Normal file
333
internal/overlay/linux/386/musl/src/internal/atomic.h
Normal file
|
@ -0,0 +1,333 @@
|
|||
#ifndef _ATOMIC_H
|
||||
#define _ATOMIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "atomic_arch.h"
|
||||
|
||||
#ifdef a_ll
|
||||
|
||||
#ifndef a_pre_llsc
|
||||
#define a_pre_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_post_llsc
|
||||
#define a_post_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#define a_cas a_cas
|
||||
static inline int a_cas(volatile int *p, int t, int s)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (old==t && !a_sc(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, (unsigned)old + v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old & v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old | v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef a_ll_p
|
||||
|
||||
#ifndef a_cas_p
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
void *old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll_p(p);
|
||||
while (old==t && !a_sc_p(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#error missing definition of a_cas
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, (unsigned)old+v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old&v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old|v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_and
|
||||
#define a_and a_and
|
||||
static inline void a_and(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_and(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or
|
||||
#define a_or a_or
|
||||
static inline void a_or(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_or(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_inc
|
||||
#define a_inc a_inc
|
||||
static inline void a_inc(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_dec
|
||||
#define a_dec a_dec
|
||||
static inline void a_dec(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_store
|
||||
#define a_store a_store
|
||||
static inline void a_store(volatile int *p, int v)
|
||||
{
|
||||
#ifdef a_barrier
|
||||
a_barrier();
|
||||
*p = v;
|
||||
a_barrier();
|
||||
#else
|
||||
a_swap(p, v);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_barrier
|
||||
#define a_barrier a_barrier
|
||||
static inline void a_barrier()
|
||||
{
|
||||
volatile int tmp = 0;
|
||||
a_cas(&tmp, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_spin
|
||||
#define a_spin a_barrier
|
||||
#endif
|
||||
|
||||
#ifndef a_and_64
|
||||
#define a_and_64 a_and_64
|
||||
static inline void a_and_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]+1) a_and((int *)p, u.r[0]);
|
||||
if (u.r[1]+1) a_and((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_64
|
||||
#define a_or_64 a_or_64
|
||||
static inline void a_or_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]) a_or((int *)p, u.r[0]);
|
||||
if (u.r[1]) a_or((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_cas_p
|
||||
typedef char a_cas_p_undefined_but_pointer_not_32bit[-sizeof(char) == 0xffffffff ? 1 : -1];
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
return (void *)a_cas((volatile int *)p, (int)t, (int)s);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_l
|
||||
#define a_or_l a_or_l
|
||||
static inline void a_or_l(volatile void *p, long v)
|
||||
{
|
||||
if (sizeof(long) == sizeof(int)) a_or(p, v);
|
||||
else a_or_64(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_crash
|
||||
#define a_crash a_crash
|
||||
static inline void a_crash()
|
||||
{
|
||||
*(volatile char *)0=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_32
|
||||
#define a_ctz_32 a_ctz_32
|
||||
static inline int a_ctz_32(uint32_t x)
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
return 31-a_clz_32(x&-x);
|
||||
#else
|
||||
static const char debruijn32[32] = {
|
||||
0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13,
|
||||
31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14
|
||||
};
|
||||
return debruijn32[(x&-x)*0x076be629 >> 27];
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_64
|
||||
#define a_ctz_64 a_ctz_64
|
||||
static inline int a_ctz_64(uint64_t x)
|
||||
{
|
||||
static const char debruijn64[64] = {
|
||||
0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
|
||||
62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
|
||||
63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
|
||||
51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
|
||||
};
|
||||
if (sizeof(long) < 8) {
|
||||
uint32_t y = x;
|
||||
if (!y) {
|
||||
y = x>>32;
|
||||
return 32 + a_ctz_32(y);
|
||||
}
|
||||
return a_ctz_32(y);
|
||||
}
|
||||
return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58];
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int a_ctz_l(unsigned long x)
|
||||
{
|
||||
return (sizeof(long) < 8) ? a_ctz_32(x) : a_ctz_64(x);
|
||||
}
|
||||
|
||||
#ifndef a_clz_64
|
||||
#define a_clz_64 a_clz_64
|
||||
static inline int a_clz_64(uint64_t x)
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
if (x>>32)
|
||||
return a_clz_32(x>>32);
|
||||
return a_clz_32(x) + 32;
|
||||
#else
|
||||
uint32_t y;
|
||||
int r;
|
||||
if (x>>32) y=x>>32, r=0; else y=x, r=32;
|
||||
if (y>>16) y>>=16; else r |= 16;
|
||||
if (y>>8) y>>=8; else r |= 8;
|
||||
if (y>>4) y>>=4; else r |= 4;
|
||||
if (y>>2) y>>=2; else r |= 2;
|
||||
return r | !(y>>1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_clz_32
|
||||
#define a_clz_32 a_clz_32
|
||||
static inline int a_clz_32(uint32_t x)
|
||||
{
|
||||
x >>= 1;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x++;
|
||||
return 31-a_ctz_32(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
95
internal/overlay/linux/arm/musl/include/alltypes.h.in
Normal file
95
internal/overlay/linux/arm/musl/include/alltypes.h.in
Normal file
|
@ -0,0 +1,95 @@
|
|||
#define __LITTLE_ENDIAN 1234
|
||||
#define __BIG_ENDIAN 4321
|
||||
#define __USE_TIME_BITS64 1
|
||||
|
||||
TYPEDEF unsigned _Addr size_t;
|
||||
TYPEDEF unsigned _Addr uintptr_t;
|
||||
TYPEDEF _Addr ptrdiff_t;
|
||||
TYPEDEF _Addr ssize_t;
|
||||
TYPEDEF _Addr intptr_t;
|
||||
TYPEDEF _Addr regoff_t;
|
||||
TYPEDEF _Reg register_t;
|
||||
TYPEDEF _Int64 time_t;
|
||||
TYPEDEF _Int64 suseconds_t;
|
||||
|
||||
TYPEDEF signed char int8_t;
|
||||
TYPEDEF signed short int16_t;
|
||||
TYPEDEF signed int int32_t;
|
||||
TYPEDEF signed _Int64 int64_t;
|
||||
TYPEDEF signed _Int64 intmax_t;
|
||||
TYPEDEF unsigned char uint8_t;
|
||||
TYPEDEF unsigned short uint16_t;
|
||||
TYPEDEF unsigned int uint32_t;
|
||||
TYPEDEF unsigned _Int64 uint64_t;
|
||||
TYPEDEF unsigned _Int64 u_int64_t;
|
||||
TYPEDEF unsigned _Int64 uintmax_t;
|
||||
|
||||
TYPEDEF unsigned mode_t;
|
||||
TYPEDEF unsigned _Reg nlink_t;
|
||||
TYPEDEF _Int64 off_t;
|
||||
TYPEDEF unsigned _Int64 ino_t;
|
||||
TYPEDEF unsigned _Int64 dev_t;
|
||||
TYPEDEF long blksize_t;
|
||||
TYPEDEF _Int64 blkcnt_t;
|
||||
TYPEDEF unsigned _Int64 fsblkcnt_t;
|
||||
TYPEDEF unsigned _Int64 fsfilcnt_t;
|
||||
|
||||
TYPEDEF unsigned wint_t;
|
||||
TYPEDEF unsigned long wctype_t;
|
||||
|
||||
TYPEDEF void * timer_t;
|
||||
TYPEDEF int clockid_t;
|
||||
TYPEDEF long clock_t;
|
||||
STRUCT timeval { time_t tv_sec; suseconds_t tv_usec; };
|
||||
STRUCT timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); };
|
||||
|
||||
TYPEDEF int pid_t;
|
||||
TYPEDEF unsigned id_t;
|
||||
TYPEDEF unsigned uid_t;
|
||||
TYPEDEF unsigned gid_t;
|
||||
TYPEDEF int key_t;
|
||||
TYPEDEF unsigned useconds_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
TYPEDEF unsigned long pthread_t;
|
||||
#else
|
||||
TYPEDEF struct __pthread * pthread_t;
|
||||
#endif
|
||||
TYPEDEF int pthread_once_t;
|
||||
TYPEDEF unsigned pthread_key_t;
|
||||
TYPEDEF int pthread_spinlock_t;
|
||||
TYPEDEF struct { unsigned __attr; } pthread_mutexattr_t;
|
||||
TYPEDEF struct { unsigned __attr; } pthread_condattr_t;
|
||||
TYPEDEF struct { unsigned __attr; } pthread_barrierattr_t;
|
||||
TYPEDEF struct { unsigned __attr[2]; } pthread_rwlockattr_t;
|
||||
|
||||
STRUCT _IO_FILE { char __x; };
|
||||
TYPEDEF struct _IO_FILE FILE;
|
||||
|
||||
TYPEDEF __builtin_va_list va_list;
|
||||
TYPEDEF __builtin_va_list __isoc_va_list;
|
||||
|
||||
TYPEDEF struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
|
||||
|
||||
TYPEDEF struct __locale_struct * locale_t;
|
||||
|
||||
TYPEDEF struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t;
|
||||
|
||||
STRUCT iovec { void *iov_base; size_t iov_len; };
|
||||
|
||||
STRUCT winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; };
|
||||
|
||||
TYPEDEF unsigned socklen_t;
|
||||
TYPEDEF unsigned short sa_family_t;
|
||||
|
||||
TYPEDEF struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t;
|
||||
TYPEDEF struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; int __ccgo_room; } pthread_mutex_t;
|
||||
TYPEDEF struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; int __ccgo_room; } mtx_t;
|
||||
TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t;
|
||||
TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t;
|
||||
TYPEDEF struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t;
|
||||
TYPEDEF struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t;
|
||||
|
||||
#undef _Addr
|
||||
#undef _Int64
|
||||
#undef _Reg
|
333
internal/overlay/linux/arm/musl/src/internal/atomic.h
Normal file
333
internal/overlay/linux/arm/musl/src/internal/atomic.h
Normal file
|
@ -0,0 +1,333 @@
|
|||
#ifndef _ATOMIC_H
|
||||
#define _ATOMIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "atomic_arch.h"
|
||||
|
||||
#ifdef a_ll
|
||||
|
||||
#ifndef a_pre_llsc
|
||||
#define a_pre_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_post_llsc
|
||||
#define a_post_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#define a_cas a_cas
|
||||
static inline int a_cas(volatile int *p, int t, int s)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (old==t && !a_sc(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, (unsigned)old + v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old & v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old | v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef a_ll_p
|
||||
|
||||
#ifndef a_cas_p
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
void *old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll_p(p);
|
||||
while (old==t && !a_sc_p(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#error missing definition of a_cas
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, (unsigned)old+v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old&v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old|v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_and
|
||||
#define a_and a_and
|
||||
static inline void a_and(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_and(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or
|
||||
#define a_or a_or
|
||||
static inline void a_or(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_or(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_inc
|
||||
#define a_inc a_inc
|
||||
static inline void a_inc(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_dec
|
||||
#define a_dec a_dec
|
||||
static inline void a_dec(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_store
|
||||
#define a_store a_store
|
||||
static inline void a_store(volatile int *p, int v)
|
||||
{
|
||||
#ifdef a_barrier
|
||||
a_barrier();
|
||||
*p = v;
|
||||
a_barrier();
|
||||
#else
|
||||
a_swap(p, v);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_barrier
|
||||
#define a_barrier a_barrier
|
||||
static inline void a_barrier()
|
||||
{
|
||||
volatile int tmp = 0;
|
||||
a_cas(&tmp, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_spin
|
||||
#define a_spin a_barrier
|
||||
#endif
|
||||
|
||||
#ifndef a_and_64
|
||||
#define a_and_64 a_and_64
|
||||
static inline void a_and_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]+1) a_and((int *)p, u.r[0]);
|
||||
if (u.r[1]+1) a_and((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_64
|
||||
#define a_or_64 a_or_64
|
||||
static inline void a_or_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]) a_or((int *)p, u.r[0]);
|
||||
if (u.r[1]) a_or((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_cas_p
|
||||
typedef char a_cas_p_undefined_but_pointer_not_32bit[-sizeof(char) == 0xffffffff ? 1 : -1];
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
return (void *)a_cas((volatile int *)p, (int)t, (int)s);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_l
|
||||
#define a_or_l a_or_l
|
||||
static inline void a_or_l(volatile void *p, long v)
|
||||
{
|
||||
if (sizeof(long) == sizeof(int)) a_or(p, v);
|
||||
else a_or_64(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_crash
|
||||
#define a_crash a_crash
|
||||
static inline void a_crash()
|
||||
{
|
||||
*(volatile char *)0=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_32
|
||||
#define a_ctz_32 a_ctz_32
|
||||
static inline int a_ctz_32(uint32_t x)
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
return 31-a_clz_32(x&-x);
|
||||
#else
|
||||
static const char debruijn32[32] = {
|
||||
0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13,
|
||||
31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14
|
||||
};
|
||||
return debruijn32[(x&-x)*0x076be629 >> 27];
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_64
|
||||
#define a_ctz_64 a_ctz_64
|
||||
static inline int a_ctz_64(uint64_t x)
|
||||
{
|
||||
static const char debruijn64[64] = {
|
||||
0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
|
||||
62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
|
||||
63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
|
||||
51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
|
||||
};
|
||||
if (sizeof(long) < 8) {
|
||||
uint32_t y = x;
|
||||
if (!y) {
|
||||
y = x>>32;
|
||||
return 32 + a_ctz_32(y);
|
||||
}
|
||||
return a_ctz_32(y);
|
||||
}
|
||||
return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58];
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int a_ctz_l(unsigned long x)
|
||||
{
|
||||
return (sizeof(long) < 8) ? a_ctz_32(x) : a_ctz_64(x);
|
||||
}
|
||||
|
||||
#ifndef a_clz_64
|
||||
#define a_clz_64 a_clz_64
|
||||
static inline int a_clz_64(uint64_t x)
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
if (x>>32)
|
||||
return a_clz_32(x>>32);
|
||||
return a_clz_32(x) + 32;
|
||||
#else
|
||||
uint32_t y;
|
||||
int r;
|
||||
if (x>>32) y=x>>32, r=0; else y=x, r=32;
|
||||
if (y>>16) y>>=16; else r |= 16;
|
||||
if (y>>8) y>>=8; else r |= 8;
|
||||
if (y>>4) y>>=4; else r |= 4;
|
||||
if (y>>2) y>>=2; else r |= 2;
|
||||
return r | !(y>>1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_clz_32
|
||||
#define a_clz_32 a_clz_32
|
||||
static inline int a_clz_32(uint32_t x)
|
||||
{
|
||||
x >>= 1;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x++;
|
||||
return 31-a_ctz_32(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
341
internal/overlay/linux/loong64/musl/src/internal/atomic.h
Normal file
341
internal/overlay/linux/loong64/musl/src/internal/atomic.h
Normal file
|
@ -0,0 +1,341 @@
|
|||
#ifndef _ATOMIC_H
|
||||
#define _ATOMIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "atomic_arch.h"
|
||||
|
||||
#ifdef a_ll
|
||||
|
||||
#ifndef a_pre_llsc
|
||||
#define a_pre_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_post_llsc
|
||||
#define a_post_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#define a_cas a_cas
|
||||
static inline int a_cas(volatile int *p, int t, int s)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (old==t && !a_sc(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, (unsigned)old + v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old & v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old | v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef a_ll_p
|
||||
|
||||
#ifndef a_cas_p
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
void *old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll_p(p);
|
||||
while (old==t && !a_sc_p(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#error missing definition of a_cas
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, (unsigned)old+v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old&v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old|v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_and
|
||||
#define a_and a_and
|
||||
static inline void a_and(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_and(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or
|
||||
#define a_or a_or
|
||||
static inline void a_or(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_or(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_inc
|
||||
#define a_inc a_inc
|
||||
static inline void a_inc(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_dec
|
||||
#define a_dec a_dec
|
||||
static inline void a_dec(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_store
|
||||
#define a_store a_store
|
||||
static inline void a_store(volatile int *p, int v)
|
||||
{
|
||||
#ifdef a_barrier
|
||||
a_barrier();
|
||||
*p = v;
|
||||
a_barrier();
|
||||
#else
|
||||
a_swap(p, v);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_barrier
|
||||
#define a_barrier a_barrier
|
||||
static inline void a_barrier()
|
||||
{
|
||||
volatile int tmp = 0;
|
||||
a_cas(&tmp, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_spin
|
||||
#define a_spin a_barrier
|
||||
#endif
|
||||
|
||||
#ifndef a_and_64
|
||||
#define a_and_64 a_and_64
|
||||
static inline void a_and_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]+1) a_and((int *)p, u.r[0]);
|
||||
if (u.r[1]+1) a_and((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_64
|
||||
#define a_or_64 a_or_64
|
||||
static inline void a_or_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]) a_or((int *)p, u.r[0]);
|
||||
if (u.r[1]) a_or((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_cas_p
|
||||
typedef char a_cas_p_undefined_but_pointer_not_32bit[-sizeof(char) == 0xffffffff ? 1 : -1];
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
return (void *)a_cas((volatile int *)p, (int)t, (int)s);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_l
|
||||
#define a_or_l a_or_l
|
||||
static inline void a_or_l(volatile void *p, long v)
|
||||
{
|
||||
if (sizeof(long) == sizeof(int)) a_or(p, v);
|
||||
else a_or_64(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_crash
|
||||
#define a_crash a_crash
|
||||
static inline void a_crash()
|
||||
{
|
||||
*(volatile char *)0=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_32
|
||||
#define a_ctz_32 a_ctz_32
|
||||
static inline int a_ctz_32(uint32_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
return 31-a_clz_32(x&-x);
|
||||
#else
|
||||
static const char debruijn32[32] = {
|
||||
0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13,
|
||||
31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14
|
||||
};
|
||||
return debruijn32[(x&-x)*0x076be629 >> 27];
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_64
|
||||
#define a_ctz_64 a_ctz_64
|
||||
static inline int a_ctz_64(uint64_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
static const char debruijn64[64] = {
|
||||
0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
|
||||
62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
|
||||
63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
|
||||
51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
|
||||
};
|
||||
if (sizeof(long) < 8) {
|
||||
uint32_t y = x;
|
||||
if (!y) {
|
||||
y = x>>32;
|
||||
return 32 + a_ctz_32(y);
|
||||
}
|
||||
return a_ctz_32(y);
|
||||
}
|
||||
return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58];
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static inline int a_ctz_l(unsigned long x)
|
||||
{
|
||||
return (sizeof(long) < 8) ? a_ctz_32(x) : a_ctz_64(x);
|
||||
}
|
||||
|
||||
#ifndef a_clz_64
|
||||
#define a_clz_64 a_clz_64
|
||||
static inline int a_clz_64(uint64_t x)
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
if (x>>32)
|
||||
return a_clz_32(x>>32);
|
||||
return a_clz_32(x) + 32;
|
||||
#else
|
||||
uint32_t y;
|
||||
int r;
|
||||
if (x>>32) y=x>>32, r=0; else y=x, r=32;
|
||||
if (y>>16) y>>=16; else r |= 16;
|
||||
if (y>>8) y>>=8; else r |= 8;
|
||||
if (y>>4) y>>=4; else r |= 4;
|
||||
if (y>>2) y>>=2; else r |= 2;
|
||||
return r | !(y>>1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_clz_32
|
||||
#define a_clz_32 a_clz_32
|
||||
static inline int a_clz_32(uint32_t x)
|
||||
{
|
||||
x >>= 1;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x++;
|
||||
return 31-a_ctz_32(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
341
internal/overlay/linux/ppc64le/musl/src/internal/atomic.h
Normal file
341
internal/overlay/linux/ppc64le/musl/src/internal/atomic.h
Normal file
|
@ -0,0 +1,341 @@
|
|||
#ifndef _ATOMIC_H
|
||||
#define _ATOMIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "atomic_arch.h"
|
||||
|
||||
#ifdef a_ll
|
||||
|
||||
#ifndef a_pre_llsc
|
||||
#define a_pre_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_post_llsc
|
||||
#define a_post_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#define a_cas a_cas
|
||||
static inline int a_cas(volatile int *p, int t, int s)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (old==t && !a_sc(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, (unsigned)old + v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old & v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old | v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef a_ll_p
|
||||
|
||||
#ifndef a_cas_p
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
void *old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll_p(p);
|
||||
while (old==t && !a_sc_p(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#error missing definition of a_cas
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, (unsigned)old+v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old&v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old|v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_and
|
||||
#define a_and a_and
|
||||
static inline void a_and(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_and(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or
|
||||
#define a_or a_or
|
||||
static inline void a_or(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_or(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_inc
|
||||
#define a_inc a_inc
|
||||
static inline void a_inc(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_dec
|
||||
#define a_dec a_dec
|
||||
static inline void a_dec(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_store
|
||||
#define a_store a_store
|
||||
static inline void a_store(volatile int *p, int v)
|
||||
{
|
||||
#ifdef a_barrier
|
||||
a_barrier();
|
||||
*p = v;
|
||||
a_barrier();
|
||||
#else
|
||||
a_swap(p, v);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_barrier
|
||||
#define a_barrier a_barrier
|
||||
static inline void a_barrier()
|
||||
{
|
||||
volatile int tmp = 0;
|
||||
a_cas(&tmp, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_spin
|
||||
#define a_spin a_barrier
|
||||
#endif
|
||||
|
||||
#ifndef a_and_64
|
||||
#define a_and_64 a_and_64
|
||||
static inline void a_and_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]+1) a_and((int *)p, u.r[0]);
|
||||
if (u.r[1]+1) a_and((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_64
|
||||
#define a_or_64 a_or_64
|
||||
static inline void a_or_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]) a_or((int *)p, u.r[0]);
|
||||
if (u.r[1]) a_or((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_cas_p
|
||||
typedef char a_cas_p_undefined_but_pointer_not_32bit[-sizeof(char) == 0xffffffff ? 1 : -1];
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
return (void *)a_cas((volatile int *)p, (int)t, (int)s);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_l
|
||||
#define a_or_l a_or_l
|
||||
static inline void a_or_l(volatile void *p, long v)
|
||||
{
|
||||
if (sizeof(long) == sizeof(int)) a_or(p, v);
|
||||
else a_or_64(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_crash
|
||||
#define a_crash a_crash
|
||||
static inline void a_crash()
|
||||
{
|
||||
*(volatile char *)0=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_32
|
||||
#define a_ctz_32 a_ctz_32
|
||||
static inline int a_ctz_32(uint32_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
return 31-a_clz_32(x&-x);
|
||||
#else
|
||||
static const char debruijn32[32] = {
|
||||
0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13,
|
||||
31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14
|
||||
};
|
||||
return debruijn32[(x&-x)*0x076be629 >> 27];
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_64
|
||||
#define a_ctz_64 a_ctz_64
|
||||
static inline int a_ctz_64(uint64_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
static const char debruijn64[64] = {
|
||||
0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
|
||||
62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
|
||||
63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
|
||||
51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
|
||||
};
|
||||
if (sizeof(long) < 8) {
|
||||
uint32_t y = x;
|
||||
if (!y) {
|
||||
y = x>>32;
|
||||
return 32 + a_ctz_32(y);
|
||||
}
|
||||
return a_ctz_32(y);
|
||||
}
|
||||
return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58];
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static inline int a_ctz_l(unsigned long x)
|
||||
{
|
||||
return (sizeof(long) < 8) ? a_ctz_32(x) : a_ctz_64(x);
|
||||
}
|
||||
|
||||
#ifndef a_clz_64
|
||||
#define a_clz_64 a_clz_64
|
||||
static inline int a_clz_64(uint64_t x)
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
if (x>>32)
|
||||
return a_clz_32(x>>32);
|
||||
return a_clz_32(x) + 32;
|
||||
#else
|
||||
uint32_t y;
|
||||
int r;
|
||||
if (x>>32) y=x>>32, r=0; else y=x, r=32;
|
||||
if (y>>16) y>>=16; else r |= 16;
|
||||
if (y>>8) y>>=8; else r |= 8;
|
||||
if (y>>4) y>>=4; else r |= 4;
|
||||
if (y>>2) y>>=2; else r |= 2;
|
||||
return r | !(y>>1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_clz_32
|
||||
#define a_clz_32 a_clz_32
|
||||
static inline int a_clz_32(uint32_t x)
|
||||
{
|
||||
x >>= 1;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x++;
|
||||
return 31-a_ctz_32(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
344
internal/overlay/linux/riscv64/musl/src/internal/atomic.h
Normal file
344
internal/overlay/linux/riscv64/musl/src/internal/atomic.h
Normal file
|
@ -0,0 +1,344 @@
|
|||
#ifndef _ATOMIC_H
|
||||
#define _ATOMIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "atomic_arch.h"
|
||||
|
||||
#ifdef a_ll
|
||||
|
||||
#ifndef a_pre_llsc
|
||||
#define a_pre_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_post_llsc
|
||||
#define a_post_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#define a_cas a_cas
|
||||
static inline int a_cas(volatile int *p, int t, int s)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (old==t && !a_sc(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, (unsigned)old + v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old & v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old | v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef a_ll_p
|
||||
|
||||
#ifndef a_cas_p
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
void *old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll_p(p);
|
||||
while (old==t && !a_sc_p(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#error missing definition of a_cas
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, (unsigned)old+v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old&v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old|v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_and
|
||||
#define a_and a_and
|
||||
static inline void a_and(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_and(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or
|
||||
#define a_or a_or
|
||||
static inline void a_or(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_or(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_inc
|
||||
#define a_inc a_inc
|
||||
static inline void a_inc(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_dec
|
||||
#define a_dec a_dec
|
||||
static inline void a_dec(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_store
|
||||
#define a_store a_store
|
||||
static inline void a_store(volatile int *p, int v)
|
||||
{
|
||||
#ifdef a_barrier
|
||||
a_barrier();
|
||||
*p = v;
|
||||
a_barrier();
|
||||
#else
|
||||
a_swap(p, v);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_barrier
|
||||
#define a_barrier a_barrier
|
||||
static void a_barrier()
|
||||
{
|
||||
volatile int tmp = 0;
|
||||
a_cas(&tmp, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_spin
|
||||
#define a_spin a_barrier
|
||||
#endif
|
||||
|
||||
#ifndef a_and_64
|
||||
#define a_and_64 a_and_64
|
||||
static inline void a_and_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]+1) a_and((int *)p, u.r[0]);
|
||||
if (u.r[1]+1) a_and((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_64
|
||||
#define a_or_64 a_or_64
|
||||
static inline void a_or_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]) a_or((int *)p, u.r[0]);
|
||||
if (u.r[1]) a_or((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_cas_p
|
||||
typedef char a_cas_p_undefined_but_pointer_not_32bit[-sizeof(char) == 0xffffffff ? 1 : -1];
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
return (void *)a_cas((volatile int *)p, (int)t, (int)s);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_l
|
||||
#define a_or_l a_or_l
|
||||
static inline void a_or_l(volatile void *p, long v)
|
||||
{
|
||||
if (sizeof(long) == sizeof(int)) a_or(p, v);
|
||||
else a_or_64(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_crash
|
||||
#define a_crash a_crash
|
||||
static inline void a_crash()
|
||||
{
|
||||
*(volatile char *)0=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_32
|
||||
#define a_ctz_32 a_ctz_32
|
||||
static inline int a_ctz_32(uint32_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
return 31-a_clz_32(x&-x);
|
||||
#else
|
||||
static const char debruijn32[32] = {
|
||||
0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13,
|
||||
31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14
|
||||
};
|
||||
return debruijn32[(x&-x)*0x076be629 >> 27];
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_64
|
||||
#define a_ctz_64 a_ctz_64
|
||||
static inline int a_ctz_64(uint64_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
static const char debruijn64[64] = {
|
||||
0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
|
||||
62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
|
||||
63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
|
||||
51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
|
||||
};
|
||||
if (sizeof(long) < 8) {
|
||||
uint32_t y = x;
|
||||
if (!y) {
|
||||
y = x>>32;
|
||||
return 32 + a_ctz_32(y);
|
||||
}
|
||||
return a_ctz_32(y);
|
||||
}
|
||||
return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58];
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static inline int a_ctz_l(unsigned long x);
|
||||
#ifndef __CCGO__
|
||||
static inline int a_ctz_l(unsigned long x)
|
||||
{
|
||||
return (sizeof(long) < 8) ? a_ctz_32(x) : a_ctz_64(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_clz_64
|
||||
#define a_clz_64 a_clz_64
|
||||
static inline int a_clz_64(uint64_t x)
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
if (x>>32)
|
||||
return a_clz_32(x>>32);
|
||||
return a_clz_32(x) + 32;
|
||||
#else
|
||||
uint32_t y;
|
||||
int r;
|
||||
if (x>>32) y=x>>32, r=0; else y=x, r=32;
|
||||
if (y>>16) y>>=16; else r |= 16;
|
||||
if (y>>8) y>>=8; else r |= 8;
|
||||
if (y>>4) y>>=4; else r |= 4;
|
||||
if (y>>2) y>>=2; else r |= 2;
|
||||
return r | !(y>>1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_clz_32
|
||||
#define a_clz_32 a_clz_32
|
||||
static inline int a_clz_32(uint32_t x)
|
||||
{
|
||||
x >>= 1;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x++;
|
||||
return 31-a_ctz_32(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
341
internal/overlay/linux/s390x/musl/src/internal/atomic.h
Normal file
341
internal/overlay/linux/s390x/musl/src/internal/atomic.h
Normal file
|
@ -0,0 +1,341 @@
|
|||
#ifndef _ATOMIC_H
|
||||
#define _ATOMIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "atomic_arch.h"
|
||||
|
||||
#ifdef a_ll
|
||||
|
||||
#ifndef a_pre_llsc
|
||||
#define a_pre_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_post_llsc
|
||||
#define a_post_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#define a_cas a_cas
|
||||
static inline int a_cas(volatile int *p, int t, int s)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (old==t && !a_sc(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, (unsigned)old + v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old & v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old | v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef a_ll_p
|
||||
|
||||
#ifndef a_cas_p
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
void *old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll_p(p);
|
||||
while (old==t && !a_sc_p(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#error missing definition of a_cas
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, (unsigned)old+v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old&v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old|v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_and
|
||||
#define a_and a_and
|
||||
static inline void a_and(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_and(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or
|
||||
#define a_or a_or
|
||||
static inline void a_or(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_or(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_inc
|
||||
#define a_inc a_inc
|
||||
static inline void a_inc(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_dec
|
||||
#define a_dec a_dec
|
||||
static inline void a_dec(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_store
|
||||
#define a_store a_store
|
||||
static inline void a_store(volatile int *p, int v)
|
||||
{
|
||||
#ifdef a_barrier
|
||||
a_barrier();
|
||||
*p = v;
|
||||
a_barrier();
|
||||
#else
|
||||
a_swap(p, v);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_barrier
|
||||
#define a_barrier a_barrier
|
||||
static inline void a_barrier()
|
||||
{
|
||||
volatile int tmp = 0;
|
||||
a_cas(&tmp, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_spin
|
||||
#define a_spin a_barrier
|
||||
#endif
|
||||
|
||||
#ifndef a_and_64
|
||||
#define a_and_64 a_and_64
|
||||
static inline void a_and_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]+1) a_and((int *)p, u.r[0]);
|
||||
if (u.r[1]+1) a_and((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_64
|
||||
#define a_or_64 a_or_64
|
||||
static inline void a_or_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]) a_or((int *)p, u.r[0]);
|
||||
if (u.r[1]) a_or((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_cas_p
|
||||
typedef char a_cas_p_undefined_but_pointer_not_32bit[-sizeof(char) == 0xffffffff ? 1 : -1];
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
return (void *)a_cas((volatile int *)p, (int)t, (int)s);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_l
|
||||
#define a_or_l a_or_l
|
||||
static inline void a_or_l(volatile void *p, long v)
|
||||
{
|
||||
if (sizeof(long) == sizeof(int)) a_or(p, v);
|
||||
else a_or_64(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_crash
|
||||
#define a_crash a_crash
|
||||
static inline void a_crash()
|
||||
{
|
||||
*(volatile char *)0=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_32
|
||||
#define a_ctz_32 a_ctz_32
|
||||
static inline int a_ctz_32(uint32_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
return 31-a_clz_32(x&-x);
|
||||
#else
|
||||
static const char debruijn32[32] = {
|
||||
0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13,
|
||||
31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14
|
||||
};
|
||||
return debruijn32[(x&-x)*0x076be629 >> 27];
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_64
|
||||
#define a_ctz_64 a_ctz_64
|
||||
static inline int a_ctz_64(uint64_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
static const char debruijn64[64] = {
|
||||
0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
|
||||
62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
|
||||
63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
|
||||
51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
|
||||
};
|
||||
if (sizeof(long) < 8) {
|
||||
uint32_t y = x;
|
||||
if (!y) {
|
||||
y = x>>32;
|
||||
return 32 + a_ctz_32(y);
|
||||
}
|
||||
return a_ctz_32(y);
|
||||
}
|
||||
return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58];
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static inline int a_ctz_l(unsigned long x)
|
||||
{
|
||||
return (sizeof(long) < 8) ? a_ctz_32(x) : a_ctz_64(x);
|
||||
}
|
||||
|
||||
#ifndef a_clz_64
|
||||
#define a_clz_64 a_clz_64
|
||||
static inline int a_clz_64(uint64_t x)
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
if (x>>32)
|
||||
return a_clz_32(x>>32);
|
||||
return a_clz_32(x) + 32;
|
||||
#else
|
||||
uint32_t y;
|
||||
int r;
|
||||
if (x>>32) y=x>>32, r=0; else y=x, r=32;
|
||||
if (y>>16) y>>=16; else r |= 16;
|
||||
if (y>>8) y>>=8; else r |= 8;
|
||||
if (y>>4) y>>=4; else r |= 4;
|
||||
if (y>>2) y>>=2; else r |= 2;
|
||||
return r | !(y>>1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_clz_32
|
||||
#define a_clz_32 a_clz_32
|
||||
static inline int a_clz_32(uint32_t x)
|
||||
{
|
||||
x >>= 1;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x++;
|
||||
return 31-a_ctz_32(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
39
internal/overlay/musl/arch/aarch64/bits/float.h
Normal file
39
internal/overlay/musl/arch/aarch64/bits/float.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef __CCGO__
|
||||
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
|
||||
#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
|
||||
#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
|
||||
#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
|
||||
|
||||
#define LDBL_MANT_DIG 113
|
||||
#define LDBL_MIN_EXP (-16381)
|
||||
#define LDBL_MAX_EXP 16384
|
||||
|
||||
#define LDBL_DIG 33
|
||||
#define LDBL_MIN_10_EXP (-4931)
|
||||
#define LDBL_MAX_10_EXP 4932
|
||||
|
||||
#define DECIMAL_DIG 36
|
||||
|
||||
#else // __CCGO__
|
||||
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
|
||||
#define LDBL_MIN 2.22507385850720138309e-308L
|
||||
#define LDBL_MAX 1.79769313486231570815e+308L
|
||||
#define LDBL_EPSILON 2.22044604925031308085e-16L
|
||||
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
#define LDBL_MAX_EXP 1024
|
||||
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_MIN_10_EXP (-307)
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
|
||||
#define DECIMAL_DIG 17
|
||||
|
||||
#endif // __CCGO__
|
1
internal/overlay/musl/arch/aarch64/fp_arch.h
Normal file
1
internal/overlay/musl/arch/aarch64/fp_arch.h
Normal file
|
@ -0,0 +1 @@
|
|||
|
15
internal/overlay/musl/arch/aarch64/pthread_arch.h
Normal file
15
internal/overlay/musl/arch/aarch64/pthread_arch.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
static inline uintptr_t __get_tp();
|
||||
|
||||
#ifndef __CCGO__
|
||||
static inline uintptr_t __get_tp()
|
||||
{
|
||||
uintptr_t tp;
|
||||
__asm__ ("mrs %0,tpidr_el0" : "=r"(tp));
|
||||
return tp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define TLS_ABOVE_TP
|
||||
#define GAP_ABOVE_TP 16
|
||||
|
||||
#define MC_PC pc
|
90
internal/overlay/musl/arch/aarch64/syscall_arch.h
Normal file
90
internal/overlay/musl/arch/aarch64/syscall_arch.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
#define __SYSCALL_LL_E(x) (x)
|
||||
#define __SYSCALL_LL_O(x) (x)
|
||||
|
||||
static __inline long __syscall0(long n);
|
||||
static __inline long __syscall1(long n, long a1);
|
||||
static __inline long __syscall2(long n, long a1, long a2);
|
||||
static __inline long __syscall3(long n, long a1, long a2, long a3);
|
||||
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4);
|
||||
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5);
|
||||
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
|
||||
|
||||
#ifndef __CCGO__
|
||||
|
||||
#define __asm_syscall(...) do { \
|
||||
__asm__ __volatile__ ( "svc 0" \
|
||||
: "=r"(x0) : __VA_ARGS__ : "memory", "cc"); \
|
||||
return x0; \
|
||||
} while (0)
|
||||
|
||||
static inline long __syscall0(long n)
|
||||
{
|
||||
register long x8 __asm__("x8") = n;
|
||||
register long x0 __asm__("x0");
|
||||
__asm_syscall("r"(x8));
|
||||
}
|
||||
|
||||
static inline long __syscall1(long n, long a)
|
||||
{
|
||||
register long x8 __asm__("x8") = n;
|
||||
register long x0 __asm__("x0") = a;
|
||||
__asm_syscall("r"(x8), "0"(x0));
|
||||
}
|
||||
|
||||
static inline long __syscall2(long n, long a, long b)
|
||||
{
|
||||
register long x8 __asm__("x8") = n;
|
||||
register long x0 __asm__("x0") = a;
|
||||
register long x1 __asm__("x1") = b;
|
||||
__asm_syscall("r"(x8), "0"(x0), "r"(x1));
|
||||
}
|
||||
|
||||
static inline long __syscall3(long n, long a, long b, long c)
|
||||
{
|
||||
register long x8 __asm__("x8") = n;
|
||||
register long x0 __asm__("x0") = a;
|
||||
register long x1 __asm__("x1") = b;
|
||||
register long x2 __asm__("x2") = c;
|
||||
__asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2));
|
||||
}
|
||||
|
||||
static inline long __syscall4(long n, long a, long b, long c, long d)
|
||||
{
|
||||
register long x8 __asm__("x8") = n;
|
||||
register long x0 __asm__("x0") = a;
|
||||
register long x1 __asm__("x1") = b;
|
||||
register long x2 __asm__("x2") = c;
|
||||
register long x3 __asm__("x3") = d;
|
||||
__asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3));
|
||||
}
|
||||
|
||||
static inline long __syscall5(long n, long a, long b, long c, long d, long e)
|
||||
{
|
||||
register long x8 __asm__("x8") = n;
|
||||
register long x0 __asm__("x0") = a;
|
||||
register long x1 __asm__("x1") = b;
|
||||
register long x2 __asm__("x2") = c;
|
||||
register long x3 __asm__("x3") = d;
|
||||
register long x4 __asm__("x4") = e;
|
||||
__asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4));
|
||||
}
|
||||
|
||||
static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
register long x8 __asm__("x8") = n;
|
||||
register long x0 __asm__("x0") = a;
|
||||
register long x1 __asm__("x1") = b;
|
||||
register long x2 __asm__("x2") = c;
|
||||
register long x3 __asm__("x3") = d;
|
||||
register long x4 __asm__("x4") = e;
|
||||
register long x5 __asm__("x5") = f;
|
||||
__asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5));
|
||||
}
|
||||
|
||||
#define VDSO_USEFUL
|
||||
#define VDSO_CGT_SYM "__kernel_clock_gettime"
|
||||
#define VDSO_CGT_VER "LINUX_2.6.39"
|
||||
|
||||
#endif // __CCGO__
|
||||
|
||||
#define IPC_64 0
|
139
internal/overlay/musl/arch/arm/atomic_arch.h
Normal file
139
internal/overlay/musl/arch/arm/atomic_arch.h
Normal file
|
@ -0,0 +1,139 @@
|
|||
#include "libc.h"
|
||||
|
||||
#if __ARM_ARCH_4__ || __ARM_ARCH_4T__ || __ARM_ARCH == 4
|
||||
#define BLX "mov lr,pc\n\tbx"
|
||||
#else
|
||||
#define BLX "blx"
|
||||
#endif
|
||||
|
||||
extern hidden uintptr_t __a_cas_ptr, __a_barrier_ptr;
|
||||
|
||||
#if ((__ARM_ARCH_6__ || __ARM_ARCH_6K__ || __ARM_ARCH_6KZ__ || __ARM_ARCH_6ZK__) && !__thumb__) \
|
||||
|| __ARM_ARCH_6T2__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
|
||||
|
||||
#define a_ll a_ll
|
||||
static inline int a_ll(volatile int *p)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
int v;
|
||||
__asm__ __volatile__ ("ldrex %0, %1" : "=r"(v) : "Q"(*p));
|
||||
return v;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_sc a_sc
|
||||
static inline int a_sc(volatile int *p, int v)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
int r;
|
||||
__asm__ __volatile__ ("strex %0,%2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory");
|
||||
return !r;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#if __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
|
||||
|
||||
#define a_barrier a_barrier
|
||||
static inline void a_barrier()
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__ ("dmb ish" : : : "memory");
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define a_pre_llsc a_barrier
|
||||
#define a_post_llsc a_barrier
|
||||
|
||||
#else
|
||||
|
||||
#define a_cas a_cas
|
||||
static inline int a_cas(volatile int *p, int t, int s)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
for (;;) {
|
||||
register int r0 __asm__("r0") = t;
|
||||
register int r1 __asm__("r1") = s;
|
||||
register volatile int *r2 __asm__("r2") = p;
|
||||
register uintptr_t r3 __asm__("r3") = __a_cas_ptr;
|
||||
int old;
|
||||
__asm__ __volatile__ (
|
||||
BLX " r3"
|
||||
: "+r"(r0), "+r"(r3) : "r"(r1), "r"(r2)
|
||||
: "memory", "lr", "ip", "cc" );
|
||||
if (!r0) return t;
|
||||
if ((old=*p)!=t) return old;
|
||||
}
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef a_barrier
|
||||
#define a_barrier a_barrier
|
||||
static inline void a_barrier()
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
register uintptr_t ip __asm__("ip") = __a_barrier_ptr;
|
||||
__asm__ __volatile__( BLX " ip" : "+r"(ip) : : "memory", "cc", "lr" );
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define a_crash a_crash
|
||||
static inline void a_crash()
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
#ifndef __thumb__
|
||||
".word 0xe7f000f0"
|
||||
#else
|
||||
".short 0xdeff"
|
||||
#endif
|
||||
: : : "memory");
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#if __ARM_ARCH >= 5 && (!__thumb__ || __thumb2__)
|
||||
|
||||
#define a_clz_32 a_clz_32
|
||||
static inline int a_clz_32(uint32_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ ("clz %0, %1" : "=r"(x) : "r"(x));
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#if __ARM_ARCH_6T2__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
|
||||
|
||||
#define a_ctz_32 a_ctz_32
|
||||
static inline int a_ctz_32(uint32_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
uint32_t xr;
|
||||
__asm__ ("rbit %0, %1" : "=r"(xr) : "r"(x));
|
||||
return a_clz_32(xr);
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
16
internal/overlay/musl/arch/arm/bits/float.h
Normal file
16
internal/overlay/musl/arch/arm/bits/float.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
|
||||
#define LDBL_MIN 2.22507385850720138309e-308L
|
||||
#define LDBL_MAX 1.79769313486231570815e+308L
|
||||
#define LDBL_EPSILON 2.22044604925031308085e-16L
|
||||
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
#define LDBL_MAX_EXP 1024
|
||||
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_MIN_10_EXP (-307)
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
|
||||
#define DECIMAL_DIG 17
|
36
internal/overlay/musl/arch/arm/pthread_arch.h
Normal file
36
internal/overlay/musl/arch/arm/pthread_arch.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
static inline uintptr_t __get_tp();
|
||||
|
||||
#ifndef __CCGO__
|
||||
#if ((__ARM_ARCH_6K__ || __ARM_ARCH_6KZ__ || __ARM_ARCH_6ZK__) && !__thumb__) \
|
||||
|| __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
|
||||
|
||||
static inline uintptr_t __get_tp()
|
||||
{
|
||||
uintptr_t tp;
|
||||
__asm__ ( "mrc p15,0,%0,c13,c0,3" : "=r"(tp) );
|
||||
return tp;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if __ARM_ARCH_4__ || __ARM_ARCH_4T__ || __ARM_ARCH == 4
|
||||
#define BLX "mov lr,pc\n\tbx"
|
||||
#else
|
||||
#define BLX "blx"
|
||||
#endif
|
||||
|
||||
static inline uintptr_t __get_tp()
|
||||
{
|
||||
extern hidden uintptr_t __a_gettp_ptr;
|
||||
register uintptr_t tp __asm__("r0");
|
||||
__asm__ ( BLX " %1" : "=r"(tp) : "r"(__a_gettp_ptr) : "cc", "lr" );
|
||||
return tp;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define TLS_ABOVE_TP
|
||||
#define GAP_ABOVE_TP 8
|
||||
|
||||
#define MC_PC arm_pc
|
127
internal/overlay/musl/arch/arm/syscall_arch.h
Normal file
127
internal/overlay/musl/arch/arm/syscall_arch.h
Normal file
|
@ -0,0 +1,127 @@
|
|||
#ifdef __CCGO__
|
||||
|
||||
static __inline long __syscall0(long n);
|
||||
static __inline long __syscall1(long n, long a1);
|
||||
static __inline long __syscall2(long n, long a1, long a2);
|
||||
static __inline long __syscall3(long n, long a1, long a2, long a3);
|
||||
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4);
|
||||
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5);
|
||||
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
|
||||
|
||||
#define __SYSCALL_LL_E(x) ((int)(x)), ((int)((x)>>32))
|
||||
#define __SYSCALL_LL_O(x) 0, __SYSCALL_LL_E((x))
|
||||
|
||||
#else // __CCGO__
|
||||
|
||||
#define __SYSCALL_LL_E(x) \
|
||||
((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
|
||||
((union { long long ll; long l[2]; }){ .ll = x }).l[1]
|
||||
#define __SYSCALL_LL_O(x) 0, __SYSCALL_LL_E((x))
|
||||
|
||||
#ifdef __thumb__
|
||||
|
||||
/* Avoid use of r7 in asm constraints when producing thumb code,
|
||||
* since it's reserved as frame pointer and might not be supported. */
|
||||
#define __ASM____R7__
|
||||
#define __asm_syscall(...) do { \
|
||||
__asm__ __volatile__ ( "mov %1,r7 ; mov r7,%2 ; svc 0 ; mov r7,%1" \
|
||||
: "=r"(r0), "=&r"((int){0}) : __VA_ARGS__ : "memory"); \
|
||||
return r0; \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define __ASM____R7__ __asm__("r7")
|
||||
#define __asm_syscall(...) do { \
|
||||
__asm__ __volatile__ ( "svc 0" \
|
||||
: "=r"(r0) : __VA_ARGS__ : "memory"); \
|
||||
return r0; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/* For thumb2, we can allow 8-bit immediate syscall numbers, saving a
|
||||
* register in the above dance around r7. Does not work for thumb1 where
|
||||
* only movs, not mov, supports immediates, and we can't use movs because
|
||||
* it doesn't support high regs. */
|
||||
#ifdef __thumb2__
|
||||
#define R7_OPERAND "rI"(r7)
|
||||
#else
|
||||
#define R7_OPERAND "r"(r7)
|
||||
#endif
|
||||
|
||||
static inline long __syscall0(long n)
|
||||
{
|
||||
register long r7 __ASM____R7__ = n;
|
||||
register long r0 __asm__("r0");
|
||||
__asm_syscall(R7_OPERAND);
|
||||
}
|
||||
|
||||
static inline long __syscall1(long n, long a)
|
||||
{
|
||||
register long r7 __ASM____R7__ = n;
|
||||
register long r0 __asm__("r0") = a;
|
||||
__asm_syscall(R7_OPERAND, "0"(r0));
|
||||
}
|
||||
|
||||
static inline long __syscall2(long n, long a, long b)
|
||||
{
|
||||
register long r7 __ASM____R7__ = n;
|
||||
register long r0 __asm__("r0") = a;
|
||||
register long r1 __asm__("r1") = b;
|
||||
__asm_syscall(R7_OPERAND, "0"(r0), "r"(r1));
|
||||
}
|
||||
|
||||
static inline long __syscall3(long n, long a, long b, long c)
|
||||
{
|
||||
register long r7 __ASM____R7__ = n;
|
||||
register long r0 __asm__("r0") = a;
|
||||
register long r1 __asm__("r1") = b;
|
||||
register long r2 __asm__("r2") = c;
|
||||
__asm_syscall(R7_OPERAND, "0"(r0), "r"(r1), "r"(r2));
|
||||
}
|
||||
|
||||
static inline long __syscall4(long n, long a, long b, long c, long d)
|
||||
{
|
||||
register long r7 __ASM____R7__ = n;
|
||||
register long r0 __asm__("r0") = a;
|
||||
register long r1 __asm__("r1") = b;
|
||||
register long r2 __asm__("r2") = c;
|
||||
register long r3 __asm__("r3") = d;
|
||||
__asm_syscall(R7_OPERAND, "0"(r0), "r"(r1), "r"(r2), "r"(r3));
|
||||
}
|
||||
|
||||
static inline long __syscall5(long n, long a, long b, long c, long d, long e)
|
||||
{
|
||||
register long r7 __ASM____R7__ = n;
|
||||
register long r0 __asm__("r0") = a;
|
||||
register long r1 __asm__("r1") = b;
|
||||
register long r2 __asm__("r2") = c;
|
||||
register long r3 __asm__("r3") = d;
|
||||
register long r4 __asm__("r4") = e;
|
||||
__asm_syscall(R7_OPERAND, "0"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4));
|
||||
}
|
||||
|
||||
static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
register long r7 __ASM____R7__ = n;
|
||||
register long r0 __asm__("r0") = a;
|
||||
register long r1 __asm__("r1") = b;
|
||||
register long r2 __asm__("r2") = c;
|
||||
register long r3 __asm__("r3") = d;
|
||||
register long r4 __asm__("r4") = e;
|
||||
register long r5 __asm__("r5") = f;
|
||||
__asm_syscall(R7_OPERAND, "0"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4), "r"(r5));
|
||||
}
|
||||
|
||||
#define SYSCALL_IPC_BROKEN_MODE
|
||||
|
||||
#define VDSO_USEFUL
|
||||
#define VDSO_CGT32_SYM "__vdso_clock_gettime"
|
||||
#define VDSO_CGT32_VER "LINUX_2.6"
|
||||
#define VDSO_CGT_SYM "__vdso_clock_gettime64"
|
||||
#define VDSO_CGT_VER "LINUX_2.6"
|
||||
#define VDSO_CGT_WORKAROUND 1
|
||||
|
||||
#endif // __CCGO__
|
||||
|
||||
#define SYSCALL_FADVISE_6_ARG
|
164
internal/overlay/musl/arch/i386/atomic_arch.h
Normal file
164
internal/overlay/musl/arch/i386/atomic_arch.h
Normal file
|
@ -0,0 +1,164 @@
|
|||
#define a_cas a_cas
|
||||
static inline int a_cas(volatile int *p, int t, int s)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"lock ; cmpxchg %3, %1"
|
||||
: "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" );
|
||||
return t;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"xchg %0, %1"
|
||||
: "=r"(v), "=m"(*p) : "0"(v) : "memory" );
|
||||
return v;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"lock ; xadd %0, %1"
|
||||
: "=r"(v), "=m"(*p) : "0"(v) : "memory" );
|
||||
return v;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_and a_and
|
||||
static inline void a_and(volatile int *p, int v)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"lock ; and %1, %0"
|
||||
: "=m"(*p) : "r"(v) : "memory" );
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_or a_or
|
||||
static inline void a_or(volatile int *p, int v)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"lock ; or %1, %0"
|
||||
: "=m"(*p) : "r"(v) : "memory" );
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_inc a_inc
|
||||
static inline void a_inc(volatile int *p)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"lock ; incl %0"
|
||||
: "=m"(*p) : "m"(*p) : "memory" );
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_dec a_dec
|
||||
static inline void a_dec(volatile int *p)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"lock ; decl %0"
|
||||
: "=m"(*p) : "m"(*p) : "memory" );
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_store a_store
|
||||
static inline void a_store(volatile int *p, int x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"mov %1, %0 ; lock ; orl $0,(%%esp)"
|
||||
: "=m"(*p) : "r"(x) : "memory" );
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_barrier a_barrier
|
||||
static inline void a_barrier()
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__( "" : : : "memory" );
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_spin a_spin
|
||||
static inline void a_spin()
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__( "pause" : : : "memory" );
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_crash a_crash
|
||||
static inline void a_crash()
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__ __volatile__( "hlt" : : : "memory" );
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_ctz_64 a_ctz_64
|
||||
static inline int a_ctz_64(uint64_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
int r;
|
||||
__asm__( "bsf %1,%0 ; jnz 1f ; bsf %2,%0 ; add $32,%0\n1:"
|
||||
: "=&r"(r) : "r"((unsigned)x), "r"((unsigned)(x>>32)) );
|
||||
return r;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_ctz_32 a_ctz_32
|
||||
static inline int a_ctz_32(uint32_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
int r;
|
||||
__asm__( "bsf %1,%0" : "=r"(r) : "r"(x) );
|
||||
return r;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
#define a_clz_32 a_clz_32
|
||||
static inline int a_clz_32(uint32_t x)
|
||||
#ifndef __CCGO__
|
||||
{
|
||||
__asm__( "bsr %1,%0 ; xor $31,%0" : "=r"(x) : "r"(x) );
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
43
internal/overlay/musl/arch/i386/bits/float.h
Normal file
43
internal/overlay/musl/arch/i386/bits/float.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef __CCGO__
|
||||
|
||||
#ifdef __FLT_EVAL_METHOD__
|
||||
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
|
||||
#else
|
||||
#define FLT_EVAL_METHOD 2
|
||||
#endif
|
||||
|
||||
#define LDBL_TRUE_MIN 3.6451995318824746025e-4951L
|
||||
#define LDBL_MIN 3.3621031431120935063e-4932L
|
||||
#define LDBL_MAX 1.1897314953572317650e+4932L
|
||||
#define LDBL_EPSILON 1.0842021724855044340e-19L
|
||||
|
||||
#define LDBL_MANT_DIG 64
|
||||
#define LDBL_MIN_EXP (-16381)
|
||||
#define LDBL_MAX_EXP 16384
|
||||
|
||||
#define LDBL_DIG 18
|
||||
#define LDBL_MIN_10_EXP (-4931)
|
||||
#define LDBL_MAX_10_EXP 4932
|
||||
|
||||
#define DECIMAL_DIG 21
|
||||
|
||||
#else // __CCGO__
|
||||
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
|
||||
#define LDBL_MIN 2.22507385850720138309e-308L
|
||||
#define LDBL_MAX 1.79769313486231570815e+308L
|
||||
#define LDBL_EPSILON 2.22044604925031308085e-16L
|
||||
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
#define LDBL_MAX_EXP 1024
|
||||
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_MIN_10_EXP (-307)
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
|
||||
#define DECIMAL_DIG 17
|
||||
|
||||
#endif // __CCGO__
|
12
internal/overlay/musl/arch/i386/pthread_arch.h
Normal file
12
internal/overlay/musl/arch/i386/pthread_arch.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
static inline uintptr_t __get_tp();
|
||||
|
||||
#ifndef __CCGO__
|
||||
static inline uintptr_t __get_tp()
|
||||
{
|
||||
uintptr_t tp;
|
||||
__asm__ ("movl %%gs:0,%0" : "=r" (tp) );
|
||||
return tp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MC_PC gregs[REG_EIP]
|
106
internal/overlay/musl/arch/i386/syscall_arch.h
Normal file
106
internal/overlay/musl/arch/i386/syscall_arch.h
Normal file
|
@ -0,0 +1,106 @@
|
|||
#ifdef __CCGO__
|
||||
|
||||
static __inline long __syscall0(long n);
|
||||
static __inline long __syscall1(long n, long a1);
|
||||
static __inline long __syscall2(long n, long a1, long a2);
|
||||
static __inline long __syscall3(long n, long a1, long a2, long a3);
|
||||
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4);
|
||||
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5);
|
||||
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
|
||||
|
||||
#define __SYSCALL_LL_E(x) ((int)(x)), ((int)((x)>>32))
|
||||
#define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
|
||||
|
||||
#else // __CCGO__
|
||||
|
||||
#define __SYSCALL_LL_E(x) \
|
||||
((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
|
||||
((union { long long ll; long l[2]; }){ .ll = x }).l[1]
|
||||
#define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
|
||||
|
||||
#if SYSCALL_NO_TLS
|
||||
#define SYSCALL_INSNS "int $128"
|
||||
#else
|
||||
#define SYSCALL_INSNS "call *%%gs:16"
|
||||
#endif
|
||||
|
||||
#define SYSCALL_INSNS_12 "xchg %%ebx,%%edx ; " SYSCALL_INSNS " ; xchg %%ebx,%%edx"
|
||||
#define SYSCALL_INSNS_34 "xchg %%ebx,%%edi ; " SYSCALL_INSNS " ; xchg %%ebx,%%edi"
|
||||
|
||||
static inline long __syscall0(long n)
|
||||
{
|
||||
unsigned long __ret;
|
||||
__asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n) : "memory");
|
||||
return __ret;
|
||||
}
|
||||
|
||||
static inline long __syscall1(long n, long a1)
|
||||
{
|
||||
unsigned long __ret;
|
||||
__asm__ __volatile__ (SYSCALL_INSNS_12 : "=a"(__ret) : "a"(n), "d"(a1) : "memory");
|
||||
return __ret;
|
||||
}
|
||||
|
||||
static inline long __syscall2(long n, long a1, long a2)
|
||||
{
|
||||
unsigned long __ret;
|
||||
__asm__ __volatile__ (SYSCALL_INSNS_12 : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2) : "memory");
|
||||
return __ret;
|
||||
}
|
||||
|
||||
static inline long __syscall3(long n, long a1, long a2, long a3)
|
||||
{
|
||||
unsigned long __ret;
|
||||
#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
|
||||
__asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3) : "memory");
|
||||
#else
|
||||
__asm__ __volatile__ (SYSCALL_INSNS_34 : "=a"(__ret) : "a"(n), "D"(a1), "c"(a2), "d"(a3) : "memory");
|
||||
#endif
|
||||
return __ret;
|
||||
}
|
||||
|
||||
static inline long __syscall4(long n, long a1, long a2, long a3, long a4)
|
||||
{
|
||||
unsigned long __ret;
|
||||
#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
|
||||
__asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4) : "memory");
|
||||
#else
|
||||
__asm__ __volatile__ (SYSCALL_INSNS_34 : "=a"(__ret) : "a"(n), "D"(a1), "c"(a2), "d"(a3), "S"(a4) : "memory");
|
||||
#endif
|
||||
return __ret;
|
||||
}
|
||||
|
||||
static inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
|
||||
{
|
||||
unsigned long __ret;
|
||||
#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
|
||||
__asm__ __volatile__ (SYSCALL_INSNS
|
||||
: "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
|
||||
#else
|
||||
__asm__ __volatile__ ("pushl %2 ; push %%ebx ; mov 4(%%esp),%%ebx ; " SYSCALL_INSNS " ; pop %%ebx ; add $4,%%esp"
|
||||
: "=a"(__ret) : "a"(n), "g"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
|
||||
#endif
|
||||
return __ret;
|
||||
}
|
||||
|
||||
static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
|
||||
{
|
||||
unsigned long __ret;
|
||||
#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
|
||||
__asm__ __volatile__ ("pushl %7 ; push %%ebp ; mov 4(%%esp),%%ebp ; " SYSCALL_INSNS " ; pop %%ebp ; add $4,%%esp"
|
||||
: "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5), "g"(a6) : "memory");
|
||||
#else
|
||||
unsigned long a1a6[2] = { a1, a6 };
|
||||
__asm__ __volatile__ ("pushl %1 ; push %%ebx ; push %%ebp ; mov 8(%%esp),%%ebx ; mov 4(%%ebx),%%ebp ; mov (%%ebx),%%ebx ; " SYSCALL_INSNS " ; pop %%ebp ; pop %%ebx ; add $4,%%esp"
|
||||
: "=a"(__ret) : "g"(&a1a6), "a"(n), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
|
||||
#endif
|
||||
return __ret;
|
||||
}
|
||||
|
||||
#define VDSO_USEFUL
|
||||
#define VDSO_CGT32_SYM "__vdso_clock_gettime"
|
||||
#define VDSO_CGT32_VER "LINUX_2.6"
|
||||
#define VDSO_CGT_SYM "__vdso_clock_gettime64"
|
||||
#define VDSO_CGT_VER "LINUX_2.6"
|
||||
|
||||
#endif // __CCGO__
|
39
internal/overlay/musl/arch/loongarch64/bits/float.h
Normal file
39
internal/overlay/musl/arch/loongarch64/bits/float.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef __CCGO__
|
||||
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
|
||||
#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
|
||||
#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
|
||||
#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
|
||||
|
||||
#define LDBL_MANT_DIG 113
|
||||
#define LDBL_MIN_EXP (-16381)
|
||||
#define LDBL_MAX_EXP 16384
|
||||
|
||||
#define LDBL_DIG 33
|
||||
#define LDBL_MIN_10_EXP (-4931)
|
||||
#define LDBL_MAX_10_EXP 4932
|
||||
|
||||
#define DECIMAL_DIG 36
|
||||
|
||||
#else // __CCGO__
|
||||
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
|
||||
#define LDBL_MIN 2.22507385850720138309e-308L
|
||||
#define LDBL_MAX 1.79769313486231570815e+308L
|
||||
#define LDBL_EPSILON 2.22044604925031308085e-16L
|
||||
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
#define LDBL_MAX_EXP 1024
|
||||
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_MIN_10_EXP (-307)
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
|
||||
#define DECIMAL_DIG 17
|
||||
|
||||
#endif // __CCGO__
|
15
internal/overlay/musl/arch/loongarch64/pthread_arch.h
Normal file
15
internal/overlay/musl/arch/loongarch64/pthread_arch.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
static inline uintptr_t __get_tp();
|
||||
|
||||
#ifndef __CCGO__
|
||||
static inline uintptr_t __get_tp()
|
||||
{
|
||||
register uintptr_t tp __asm__("tp");
|
||||
__asm__ ("" : "=r" (tp) );
|
||||
return tp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define TLS_ABOVE_TP
|
||||
#define GAP_ABOVE_TP 0
|
||||
#define DTP_OFFSET 0
|
||||
#define MC_PC __pc
|
149
internal/overlay/musl/arch/loongarch64/syscall_arch.h
Normal file
149
internal/overlay/musl/arch/loongarch64/syscall_arch.h
Normal file
|
@ -0,0 +1,149 @@
|
|||
#define __SYSCALL_LL_E(x) (x)
|
||||
#define __SYSCALL_LL_O(x) (x)
|
||||
|
||||
static __inline long __syscall0(long n);
|
||||
static __inline long __syscall1(long n, long a1);
|
||||
static __inline long __syscall2(long n, long a1, long a2);
|
||||
static __inline long __syscall3(long n, long a1, long a2, long a3);
|
||||
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4);
|
||||
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5);
|
||||
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
|
||||
|
||||
#ifndef __CCGO__
|
||||
|
||||
#define SYSCALL_CLOBBERLIST \
|
||||
"$t0", "$t1", "$t2", "$t3", \
|
||||
"$t4", "$t5", "$t6", "$t7", "$t8", "memory"
|
||||
|
||||
static inline long __syscall0(long n)
|
||||
{
|
||||
register long a7 __asm__("$a7") = n;
|
||||
register long a0 __asm__("$a0");
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"syscall 0"
|
||||
: "=r"(a0)
|
||||
: "r"(a7)
|
||||
: SYSCALL_CLOBBERLIST);
|
||||
return a0;
|
||||
}
|
||||
|
||||
static inline long __syscall1(long n, long a)
|
||||
{
|
||||
register long a7 __asm__("$a7") = n;
|
||||
register long a0 __asm__("$a0") = a;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"syscall 0"
|
||||
: "+r"(a0)
|
||||
: "r"(a7)
|
||||
: SYSCALL_CLOBBERLIST);
|
||||
return a0;
|
||||
}
|
||||
|
||||
static inline long __syscall2(long n, long a, long b)
|
||||
{
|
||||
register long a7 __asm__("$a7") = n;
|
||||
register long a0 __asm__("$a0") = a;
|
||||
register long a1 __asm__("$a1") = b;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"syscall 0"
|
||||
: "+r"(a0)
|
||||
: "r"(a7), "r"(a1)
|
||||
: SYSCALL_CLOBBERLIST);
|
||||
return a0;
|
||||
}
|
||||
|
||||
static inline long __syscall3(long n, long a, long b, long c)
|
||||
{
|
||||
register long a7 __asm__("$a7") = n;
|
||||
register long a0 __asm__("$a0") = a;
|
||||
register long a1 __asm__("$a1") = b;
|
||||
register long a2 __asm__("$a2") = c;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"syscall 0"
|
||||
: "+r"(a0)
|
||||
: "r"(a7), "r"(a1), "r"(a2)
|
||||
: SYSCALL_CLOBBERLIST);
|
||||
return a0;
|
||||
}
|
||||
|
||||
static inline long __syscall4(long n, long a, long b, long c, long d)
|
||||
{
|
||||
register long a7 __asm__("$a7") = n;
|
||||
register long a0 __asm__("$a0") = a;
|
||||
register long a1 __asm__("$a1") = b;
|
||||
register long a2 __asm__("$a2") = c;
|
||||
register long a3 __asm__("$a3") = d;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"syscall 0"
|
||||
: "+r"(a0)
|
||||
: "r"(a7), "r"(a1), "r"(a2), "r"(a3)
|
||||
: SYSCALL_CLOBBERLIST);
|
||||
return a0;
|
||||
}
|
||||
|
||||
static inline long __syscall5(long n, long a, long b, long c, long d, long e)
|
||||
{
|
||||
register long a7 __asm__("$a7") = n;
|
||||
register long a0 __asm__("$a0") = a;
|
||||
register long a1 __asm__("$a1") = b;
|
||||
register long a2 __asm__("$a2") = c;
|
||||
register long a3 __asm__("$a3") = d;
|
||||
register long a4 __asm__("$a4") = e;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"syscall 0"
|
||||
: "+r"(a0)
|
||||
: "r"(a7), "r"(a1), "r"(a2), "r"(a3), "r"(a4)
|
||||
: SYSCALL_CLOBBERLIST);
|
||||
return a0;
|
||||
}
|
||||
|
||||
static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
register long a7 __asm__("$a7") = n;
|
||||
register long a0 __asm__("$a0") = a;
|
||||
register long a1 __asm__("$a1") = b;
|
||||
register long a2 __asm__("$a2") = c;
|
||||
register long a3 __asm__("$a3") = d;
|
||||
register long a4 __asm__("$a4") = e;
|
||||
register long a5 __asm__("$a5") = f;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"syscall 0"
|
||||
: "+r"(a0)
|
||||
: "r"(a7), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5)
|
||||
: SYSCALL_CLOBBERLIST);
|
||||
return a0;
|
||||
}
|
||||
|
||||
static inline long __syscall7(long n, long a, long b, long c, long d, long e, long f, long g)
|
||||
{
|
||||
register long a7 __asm__("$a7") = n;
|
||||
register long a0 __asm__("$a0") = a;
|
||||
register long a1 __asm__("$a1") = b;
|
||||
register long a2 __asm__("$a2") = c;
|
||||
register long a3 __asm__("$a3") = d;
|
||||
register long a4 __asm__("$a4") = e;
|
||||
register long a5 __asm__("$a5") = f;
|
||||
register long a6 __asm__("$a6") = g;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"syscall 0"
|
||||
: "+r"(a0)
|
||||
: "r"(a7), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5), "r"(a6)
|
||||
: SYSCALL_CLOBBERLIST);
|
||||
return a0;
|
||||
}
|
||||
|
||||
#define VDSO_USEFUL
|
||||
#define VDSO_CGT_SYM "__vdso_clock_gettime"
|
||||
#define VDSO_CGT_VER "LINUX_5.10"
|
||||
|
||||
#endif // __CCGO__
|
||||
|
||||
#define IPC_64 0
|
20
internal/overlay/musl/arch/powerpc64/pthread_arch.h
Normal file
20
internal/overlay/musl/arch/powerpc64/pthread_arch.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
static inline uintptr_t __get_tp();
|
||||
|
||||
#ifndef __CCGO__
|
||||
static inline uintptr_t __get_tp()
|
||||
{
|
||||
register uintptr_t tp __asm__("r13");
|
||||
__asm__ ("" : "=r" (tp) );
|
||||
return tp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define TLS_ABOVE_TP
|
||||
#define GAP_ABOVE_TP 0
|
||||
|
||||
#define TP_OFFSET 0x7000
|
||||
#define DTP_OFFSET 0x8000
|
||||
|
||||
// the kernel calls the ip "nip", it's the first saved value after the 32
|
||||
// GPRs.
|
||||
#define MC_PC gp_regs[32]
|
102
internal/overlay/musl/arch/powerpc64/syscall_arch.h
Normal file
102
internal/overlay/musl/arch/powerpc64/syscall_arch.h
Normal file
|
@ -0,0 +1,102 @@
|
|||
#define __SYSCALL_LL_E(x) (x)
|
||||
#define __SYSCALL_LL_O(x) (x)
|
||||
|
||||
static __inline long __syscall0(long n);
|
||||
static __inline long __syscall1(long n, long a1);
|
||||
static __inline long __syscall2(long n, long a1, long a2);
|
||||
static __inline long __syscall3(long n, long a1, long a2, long a3);
|
||||
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4);
|
||||
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5);
|
||||
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
|
||||
|
||||
#ifndef __CCGO__
|
||||
|
||||
static inline long __syscall0(long n)
|
||||
{
|
||||
register long r0 __asm__("r0") = n;
|
||||
register long r3 __asm__("r3");
|
||||
__asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
|
||||
: "+r"(r0), "=r"(r3)
|
||||
:: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
|
||||
return r3;
|
||||
}
|
||||
|
||||
static inline long __syscall1(long n, long a)
|
||||
{
|
||||
register long r0 __asm__("r0") = n;
|
||||
register long r3 __asm__("r3") = a;
|
||||
__asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
|
||||
: "+r"(r0), "+r"(r3)
|
||||
:: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
|
||||
return r3;
|
||||
}
|
||||
|
||||
static inline long __syscall2(long n, long a, long b)
|
||||
{
|
||||
register long r0 __asm__("r0") = n;
|
||||
register long r3 __asm__("r3") = a;
|
||||
register long r4 __asm__("r4") = b;
|
||||
__asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
|
||||
: "+r"(r0), "+r"(r3), "+r"(r4)
|
||||
:: "memory", "cr0", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
|
||||
return r3;
|
||||
}
|
||||
|
||||
static inline long __syscall3(long n, long a, long b, long c)
|
||||
{
|
||||
register long r0 __asm__("r0") = n;
|
||||
register long r3 __asm__("r3") = a;
|
||||
register long r4 __asm__("r4") = b;
|
||||
register long r5 __asm__("r5") = c;
|
||||
__asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
|
||||
: "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5)
|
||||
:: "memory", "cr0", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
|
||||
return r3;
|
||||
}
|
||||
|
||||
static inline long __syscall4(long n, long a, long b, long c, long d)
|
||||
{
|
||||
register long r0 __asm__("r0") = n;
|
||||
register long r3 __asm__("r3") = a;
|
||||
register long r4 __asm__("r4") = b;
|
||||
register long r5 __asm__("r5") = c;
|
||||
register long r6 __asm__("r6") = d;
|
||||
__asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
|
||||
: "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5), "+r"(r6)
|
||||
:: "memory", "cr0", "r7", "r8", "r9", "r10", "r11", "r12");
|
||||
return r3;
|
||||
}
|
||||
|
||||
static inline long __syscall5(long n, long a, long b, long c, long d, long e)
|
||||
{
|
||||
register long r0 __asm__("r0") = n;
|
||||
register long r3 __asm__("r3") = a;
|
||||
register long r4 __asm__("r4") = b;
|
||||
register long r5 __asm__("r5") = c;
|
||||
register long r6 __asm__("r6") = d;
|
||||
register long r7 __asm__("r7") = e;
|
||||
__asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
|
||||
: "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5), "+r"(r6), "+r"(r7)
|
||||
:: "memory", "cr0", "r8", "r9", "r10", "r11", "r12");
|
||||
return r3;
|
||||
}
|
||||
|
||||
static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
register long r0 __asm__("r0") = n;
|
||||
register long r3 __asm__("r3") = a;
|
||||
register long r4 __asm__("r4") = b;
|
||||
register long r5 __asm__("r5") = c;
|
||||
register long r6 __asm__("r6") = d;
|
||||
register long r7 __asm__("r7") = e;
|
||||
register long r8 __asm__("r8") = f;
|
||||
__asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
|
||||
: "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5), "+r"(r6), "+r"(r7), "+r"(r8)
|
||||
:: "memory", "cr0", "r9", "r10", "r11", "r12");
|
||||
return r3;
|
||||
}
|
||||
|
||||
#define SO_RCVTIMEO_OLD 18
|
||||
#define SO_SNDTIMEO_OLD 19
|
||||
|
||||
#endif // __CCGO__
|
39
internal/overlay/musl/arch/riscv64/bits/float.h
Normal file
39
internal/overlay/musl/arch/riscv64/bits/float.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef __CCGO__
|
||||
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
|
||||
#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
|
||||
#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
|
||||
#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
|
||||
|
||||
#define LDBL_MANT_DIG 113
|
||||
#define LDBL_MIN_EXP (-16381)
|
||||
#define LDBL_MAX_EXP 16384
|
||||
|
||||
#define LDBL_DIG 33
|
||||
#define LDBL_MIN_10_EXP (-4931)
|
||||
#define LDBL_MAX_10_EXP 4932
|
||||
|
||||
#define DECIMAL_DIG 36
|
||||
|
||||
#else // __CCGO__
|
||||
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
|
||||
#define LDBL_MIN 2.22507385850720138309e-308L
|
||||
#define LDBL_MAX 1.79769313486231570815e+308L
|
||||
#define LDBL_EPSILON 2.22044604925031308085e-16L
|
||||
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
#define LDBL_MAX_EXP 1024
|
||||
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_MIN_10_EXP (-307)
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
|
||||
#define DECIMAL_DIG 17
|
||||
|
||||
#endif // __CCGO__
|
17
internal/overlay/musl/arch/riscv64/pthread_arch.h
Normal file
17
internal/overlay/musl/arch/riscv64/pthread_arch.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
static inline uintptr_t __get_tp();
|
||||
|
||||
#ifndef __CCGO__
|
||||
static inline uintptr_t __get_tp()
|
||||
{
|
||||
uintptr_t tp;
|
||||
__asm__ __volatile__("mv %0, tp" : "=r"(tp));
|
||||
return tp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define TLS_ABOVE_TP
|
||||
#define GAP_ABOVE_TP 0
|
||||
|
||||
#define DTP_OFFSET 0x800
|
||||
|
||||
#define MC_PC __gregs[0]
|
90
internal/overlay/musl/arch/riscv64/syscall_arch.h
Normal file
90
internal/overlay/musl/arch/riscv64/syscall_arch.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
#define __SYSCALL_LL_E(x) (x)
|
||||
#define __SYSCALL_LL_O(x) (x)
|
||||
|
||||
static __inline long __syscall0(long n);
|
||||
static __inline long __syscall1(long n, long a1);
|
||||
static __inline long __syscall2(long n, long a1, long a2);
|
||||
static __inline long __syscall3(long n, long a1, long a2, long a3);
|
||||
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4);
|
||||
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5);
|
||||
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
|
||||
|
||||
#ifndef __CCGO__
|
||||
|
||||
#define __asm_syscall(...) \
|
||||
__asm__ __volatile__ ("ecall\n\t" \
|
||||
: "=r"(a0) : __VA_ARGS__ : "memory"); \
|
||||
return a0; \
|
||||
|
||||
static inline long __syscall0(long n)
|
||||
{
|
||||
register long a7 __asm__("a7") = n;
|
||||
register long a0 __asm__("a0");
|
||||
__asm_syscall("r"(a7))
|
||||
}
|
||||
|
||||
static inline long __syscall1(long n, long a)
|
||||
{
|
||||
register long a7 __asm__("a7") = n;
|
||||
register long a0 __asm__("a0") = a;
|
||||
__asm_syscall("r"(a7), "0"(a0))
|
||||
}
|
||||
|
||||
static inline long __syscall2(long n, long a, long b)
|
||||
{
|
||||
register long a7 __asm__("a7") = n;
|
||||
register long a0 __asm__("a0") = a;
|
||||
register long a1 __asm__("a1") = b;
|
||||
__asm_syscall("r"(a7), "0"(a0), "r"(a1))
|
||||
}
|
||||
|
||||
static inline long __syscall3(long n, long a, long b, long c)
|
||||
{
|
||||
register long a7 __asm__("a7") = n;
|
||||
register long a0 __asm__("a0") = a;
|
||||
register long a1 __asm__("a1") = b;
|
||||
register long a2 __asm__("a2") = c;
|
||||
__asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2))
|
||||
}
|
||||
|
||||
static inline long __syscall4(long n, long a, long b, long c, long d)
|
||||
{
|
||||
register long a7 __asm__("a7") = n;
|
||||
register long a0 __asm__("a0") = a;
|
||||
register long a1 __asm__("a1") = b;
|
||||
register long a2 __asm__("a2") = c;
|
||||
register long a3 __asm__("a3") = d;
|
||||
__asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3))
|
||||
}
|
||||
|
||||
static inline long __syscall5(long n, long a, long b, long c, long d, long e)
|
||||
{
|
||||
register long a7 __asm__("a7") = n;
|
||||
register long a0 __asm__("a0") = a;
|
||||
register long a1 __asm__("a1") = b;
|
||||
register long a2 __asm__("a2") = c;
|
||||
register long a3 __asm__("a3") = d;
|
||||
register long a4 __asm__("a4") = e;
|
||||
__asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4))
|
||||
}
|
||||
|
||||
static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
register long a7 __asm__("a7") = n;
|
||||
register long a0 __asm__("a0") = a;
|
||||
register long a1 __asm__("a1") = b;
|
||||
register long a2 __asm__("a2") = c;
|
||||
register long a3 __asm__("a3") = d;
|
||||
register long a4 __asm__("a4") = e;
|
||||
register long a5 __asm__("a5") = f;
|
||||
__asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5))
|
||||
}
|
||||
|
||||
#endif // __CCGO__
|
||||
|
||||
#define VDSO_USEFUL
|
||||
/* We don't have a clock_gettime function.
|
||||
#define VDSO_CGT_SYM "__vdso_clock_gettime"
|
||||
#define VDSO_CGT_VER "LINUX_2.6" */
|
||||
|
||||
#define IPC_64 0
|
39
internal/overlay/musl/arch/s390x/bits/float.h
Normal file
39
internal/overlay/musl/arch/s390x/bits/float.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef __CCGO__
|
||||
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
|
||||
#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
|
||||
#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
|
||||
#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
|
||||
|
||||
#define LDBL_MANT_DIG 113
|
||||
#define LDBL_MIN_EXP (-16381)
|
||||
#define LDBL_MAX_EXP 16384
|
||||
|
||||
#define LDBL_DIG 33
|
||||
#define LDBL_MIN_10_EXP (-4931)
|
||||
#define LDBL_MAX_10_EXP 4932
|
||||
|
||||
#define DECIMAL_DIG 36
|
||||
|
||||
#else // __CCGO__
|
||||
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
|
||||
#define LDBL_MIN 2.22507385850720138309e-308L
|
||||
#define LDBL_MAX 1.79769313486231570815e+308L
|
||||
#define LDBL_EPSILON 2.22044604925031308085e-16L
|
||||
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
#define LDBL_MAX_EXP 1024
|
||||
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_MIN_10_EXP (-307)
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
|
||||
#define DECIMAL_DIG 17
|
||||
|
||||
#endif // __CCGO__
|
16
internal/overlay/musl/arch/s390x/pthread_arch.h
Normal file
16
internal/overlay/musl/arch/s390x/pthread_arch.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
static inline uintptr_t __get_tp();
|
||||
|
||||
#ifndef __CCGO__
|
||||
static inline uintptr_t __get_tp()
|
||||
{
|
||||
uintptr_t tp;
|
||||
__asm__ (
|
||||
"ear %0, %%a0\n"
|
||||
"sllg %0, %0, 32\n"
|
||||
"ear %0, %%a1\n"
|
||||
: "=r"(tp));
|
||||
return tp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MC_PC psw.addr
|
86
internal/overlay/musl/arch/s390x/syscall_arch.h
Normal file
86
internal/overlay/musl/arch/s390x/syscall_arch.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
#define __SYSCALL_LL_E(x) (x)
|
||||
#define __SYSCALL_LL_O(x) (x)
|
||||
|
||||
static __inline long __syscall0(long n);
|
||||
static __inline long __syscall1(long n, long a1);
|
||||
static __inline long __syscall2(long n, long a1, long a2);
|
||||
static __inline long __syscall3(long n, long a1, long a2, long a3);
|
||||
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4);
|
||||
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5);
|
||||
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
|
||||
|
||||
#ifndef __CCGO__
|
||||
|
||||
#define __asm_syscall(ret, ...) do { \
|
||||
__asm__ __volatile__ ("svc 0\n" \
|
||||
: ret : __VA_ARGS__ : "memory"); \
|
||||
return r2; \
|
||||
} while (0)
|
||||
|
||||
static inline long __syscall0(long n)
|
||||
{
|
||||
register long r1 __asm__("r1") = n;
|
||||
register long r2 __asm__("r2");
|
||||
__asm_syscall("=r"(r2), "r"(r1));
|
||||
}
|
||||
|
||||
static inline long __syscall1(long n, long a)
|
||||
{
|
||||
register long r1 __asm__("r1") = n;
|
||||
register long r2 __asm__("r2") = a;
|
||||
__asm_syscall("+r"(r2), "r"(r1));
|
||||
}
|
||||
|
||||
static inline long __syscall2(long n, long a, long b)
|
||||
{
|
||||
register long r1 __asm__("r1") = n;
|
||||
register long r2 __asm__("r2") = a;
|
||||
register long r3 __asm__("r3") = b;
|
||||
__asm_syscall("+r"(r2), "r"(r1), "r"(r3));
|
||||
}
|
||||
|
||||
static inline long __syscall3(long n, long a, long b, long c)
|
||||
{
|
||||
register long r1 __asm__("r1") = n;
|
||||
register long r2 __asm__("r2") = a;
|
||||
register long r3 __asm__("r3") = b;
|
||||
register long r4 __asm__("r4") = c;
|
||||
__asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4));
|
||||
}
|
||||
|
||||
static inline long __syscall4(long n, long a, long b, long c, long d)
|
||||
{
|
||||
register long r1 __asm__("r1") = n;
|
||||
register long r2 __asm__("r2") = a;
|
||||
register long r3 __asm__("r3") = b;
|
||||
register long r4 __asm__("r4") = c;
|
||||
register long r5 __asm__("r5") = d;
|
||||
__asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4), "r"(r5));
|
||||
}
|
||||
|
||||
static inline long __syscall5(long n, long a, long b, long c, long d, long e)
|
||||
{
|
||||
register long r1 __asm__("r1") = n;
|
||||
register long r2 __asm__("r2") = a;
|
||||
register long r3 __asm__("r3") = b;
|
||||
register long r4 __asm__("r4") = c;
|
||||
register long r5 __asm__("r5") = d;
|
||||
register long r6 __asm__("r6") = e;
|
||||
__asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4), "r"(r5), "r"(r6));
|
||||
}
|
||||
|
||||
static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
if (n == SYS_mmap) return __syscall1(n, (long)(long[]){a,b,c,d,e,f});
|
||||
|
||||
register long r1 __asm__("r1") = n;
|
||||
register long r2 __asm__("r2") = a;
|
||||
register long r3 __asm__("r3") = b;
|
||||
register long r4 __asm__("r4") = c;
|
||||
register long r5 __asm__("r5") = d;
|
||||
register long r6 __asm__("r6") = e;
|
||||
register long r7 __asm__("r7") = f;
|
||||
__asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7));
|
||||
}
|
||||
|
||||
#endif // __CCGO__
|
43
internal/overlay/musl/arch/x86_64/bits/float.h
Normal file
43
internal/overlay/musl/arch/x86_64/bits/float.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef __CCGO__
|
||||
|
||||
#ifdef __FLT_EVAL_METHOD__
|
||||
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
|
||||
#else
|
||||
#define FLT_EVAL_METHOD 0
|
||||
#endif
|
||||
|
||||
#define LDBL_TRUE_MIN 3.6451995318824746025e-4951L
|
||||
#define LDBL_MIN 3.3621031431120935063e-4932L
|
||||
#define LDBL_MAX 1.1897314953572317650e+4932L
|
||||
#define LDBL_EPSILON 1.0842021724855044340e-19L
|
||||
|
||||
#define LDBL_MANT_DIG 64
|
||||
#define LDBL_MIN_EXP (-16381)
|
||||
#define LDBL_MAX_EXP 16384
|
||||
|
||||
#define LDBL_DIG 18
|
||||
#define LDBL_MIN_10_EXP (-4931)
|
||||
#define LDBL_MAX_10_EXP 4932
|
||||
|
||||
#define DECIMAL_DIG 21
|
||||
|
||||
#else // __CCGO__
|
||||
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
||||
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
|
||||
#define LDBL_MIN 2.22507385850720138309e-308L
|
||||
#define LDBL_MAX 1.79769313486231570815e+308L
|
||||
#define LDBL_EPSILON 2.22044604925031308085e-16L
|
||||
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
#define LDBL_MAX_EXP 1024
|
||||
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_MIN_10_EXP (-307)
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
|
||||
#define DECIMAL_DIG 17
|
||||
|
||||
#endif // __CCGO__
|
12
internal/overlay/musl/arch/x86_64/pthread_arch.h
Normal file
12
internal/overlay/musl/arch/x86_64/pthread_arch.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
static inline uintptr_t __get_tp();
|
||||
|
||||
#ifndef __CCGO__
|
||||
static inline uintptr_t __get_tp()
|
||||
{
|
||||
uintptr_t tp;
|
||||
__asm__ ("mov %%fs:0,%0" : "=r" (tp) );
|
||||
return tp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MC_PC gregs[REG_RIP]
|
82
internal/overlay/musl/arch/x86_64/syscall_arch.h
Normal file
82
internal/overlay/musl/arch/x86_64/syscall_arch.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
#define __SYSCALL_LL_E(x) (x)
|
||||
#define __SYSCALL_LL_O(x) (x)
|
||||
|
||||
static __inline long __syscall0(long n);
|
||||
static __inline long __syscall1(long n, long a1);
|
||||
static __inline long __syscall2(long n, long a1, long a2);
|
||||
static __inline long __syscall3(long n, long a1, long a2, long a3);
|
||||
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4);
|
||||
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5);
|
||||
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6);
|
||||
|
||||
#ifndef __CCGO__
|
||||
|
||||
static __inline long __syscall0(long n)
|
||||
{
|
||||
unsigned long ret;
|
||||
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n) : "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline long __syscall1(long n, long a1)
|
||||
{
|
||||
unsigned long ret;
|
||||
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1) : "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline long __syscall2(long n, long a1, long a2)
|
||||
{
|
||||
unsigned long ret;
|
||||
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2)
|
||||
: "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline long __syscall3(long n, long a1, long a2, long a3)
|
||||
{
|
||||
unsigned long ret;
|
||||
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
|
||||
"d"(a3) : "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4)
|
||||
{
|
||||
unsigned long ret;
|
||||
register long r10 __asm__("r10") = a4;
|
||||
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
|
||||
"d"(a3), "r"(r10): "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
|
||||
{
|
||||
unsigned long ret;
|
||||
register long r10 __asm__("r10") = a4;
|
||||
register long r8 __asm__("r8") = a5;
|
||||
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
|
||||
"d"(a3), "r"(r10), "r"(r8) : "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
|
||||
{
|
||||
unsigned long ret;
|
||||
register long r10 __asm__("r10") = a4;
|
||||
register long r8 __asm__("r8") = a5;
|
||||
register long r9 __asm__("r9") = a6;
|
||||
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
|
||||
"d"(a3), "r"(r10), "r"(r8), "r"(r9) : "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define VDSO_USEFUL
|
||||
#define VDSO_CGT_SYM "__vdso_clock_gettime"
|
||||
#define VDSO_CGT_VER "LINUX_2.6"
|
||||
#define VDSO_GETCPU_SYM "__vdso_getcpu"
|
||||
#define VDSO_GETCPU_VER "LINUX_2.6"
|
||||
|
||||
#endif // __CCGO__
|
||||
|
||||
#define IPC_64 0
|
336
internal/overlay/musl/src/internal/atomic.h
Normal file
336
internal/overlay/musl/src/internal/atomic.h
Normal file
|
@ -0,0 +1,336 @@
|
|||
#ifndef _ATOMIC_H
|
||||
#define _ATOMIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "atomic_arch.h"
|
||||
|
||||
#ifdef a_ll
|
||||
|
||||
#ifndef a_pre_llsc
|
||||
#define a_pre_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_post_llsc
|
||||
#define a_post_llsc()
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#define a_cas a_cas
|
||||
static inline int a_cas(volatile int *p, int t, int s)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (old==t && !a_sc(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, (unsigned)old + v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old & v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll(p);
|
||||
while (!a_sc(p, old | v));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef a_ll_p
|
||||
|
||||
#ifndef a_cas_p
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
void *old;
|
||||
a_pre_llsc();
|
||||
do old = a_ll_p(p);
|
||||
while (old==t && !a_sc_p(p, s));
|
||||
a_post_llsc();
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef a_cas
|
||||
#error missing definition of a_cas
|
||||
#endif
|
||||
|
||||
#ifndef a_swap
|
||||
#define a_swap a_swap
|
||||
static inline int a_swap(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_add
|
||||
#define a_fetch_add a_fetch_add
|
||||
static inline int a_fetch_add(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, (unsigned)old+v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_fetch_and
|
||||
#define a_fetch_and a_fetch_and
|
||||
static inline int a_fetch_and(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old&v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
#ifndef a_fetch_or
|
||||
#define a_fetch_or a_fetch_or
|
||||
static inline int a_fetch_or(volatile int *p, int v)
|
||||
{
|
||||
int old;
|
||||
do old = *p;
|
||||
while (a_cas(p, old, old|v) != old);
|
||||
return old;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_and
|
||||
#define a_and a_and
|
||||
static inline void a_and(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_and(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or
|
||||
#define a_or a_or
|
||||
static inline void a_or(volatile int *p, int v)
|
||||
{
|
||||
a_fetch_or(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_inc
|
||||
#define a_inc a_inc
|
||||
static inline void a_inc(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_dec
|
||||
#define a_dec a_dec
|
||||
static inline void a_dec(volatile int *p)
|
||||
{
|
||||
a_fetch_add(p, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_store
|
||||
#define a_store a_store
|
||||
static inline void a_store(volatile int *p, int v)
|
||||
{
|
||||
#ifdef a_barrier
|
||||
a_barrier();
|
||||
*p = v;
|
||||
a_barrier();
|
||||
#else
|
||||
a_swap(p, v);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_barrier
|
||||
#define a_barrier a_barrier
|
||||
static void a_barrier()
|
||||
{
|
||||
volatile int tmp = 0;
|
||||
a_cas(&tmp, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_spin
|
||||
#define a_spin a_barrier
|
||||
#endif
|
||||
|
||||
#ifndef a_and_64
|
||||
#define a_and_64 a_and_64
|
||||
static inline void a_and_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]+1) a_and((int *)p, u.r[0]);
|
||||
if (u.r[1]+1) a_and((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_64
|
||||
#define a_or_64 a_or_64
|
||||
static inline void a_or_64(volatile uint64_t *p, uint64_t v)
|
||||
{
|
||||
union { uint64_t v; uint32_t r[2]; } u = { v };
|
||||
if (u.r[0]) a_or((int *)p, u.r[0]);
|
||||
if (u.r[1]) a_or((int *)p+1, u.r[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_cas_p
|
||||
typedef char a_cas_p_undefined_but_pointer_not_32bit[-sizeof(char) == 0xffffffff ? 1 : -1];
|
||||
#define a_cas_p a_cas_p
|
||||
static inline void *a_cas_p(volatile void *p, void *t, void *s)
|
||||
{
|
||||
return (void *)a_cas((volatile int *)p, (int)t, (int)s);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_or_l
|
||||
#define a_or_l a_or_l
|
||||
static inline void a_or_l(volatile void *p, long v)
|
||||
{
|
||||
if (sizeof(long) == sizeof(int)) a_or(p, v);
|
||||
else a_or_64(p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_crash
|
||||
#define a_crash a_crash
|
||||
static inline void a_crash()
|
||||
{
|
||||
*(volatile char *)0=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_32
|
||||
#define a_ctz_32 a_ctz_32
|
||||
static inline int a_ctz_32(uint32_t x)
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
return 31-a_clz_32(x&-x);
|
||||
#else
|
||||
static const char debruijn32[32] = {
|
||||
0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13,
|
||||
31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14
|
||||
};
|
||||
return debruijn32[(x&-x)*0x076be629 >> 27];
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_ctz_64
|
||||
#define a_ctz_64 a_ctz_64
|
||||
static inline int a_ctz_64(uint64_t x)
|
||||
{
|
||||
static const char debruijn64[64] = {
|
||||
0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
|
||||
62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
|
||||
63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
|
||||
51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
|
||||
};
|
||||
if (sizeof(long) < 8) {
|
||||
uint32_t y = x;
|
||||
if (!y) {
|
||||
y = x>>32;
|
||||
return 32 + a_ctz_32(y);
|
||||
}
|
||||
return a_ctz_32(y);
|
||||
}
|
||||
return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58];
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int a_ctz_l(unsigned long x);
|
||||
#ifndef __CCGO__
|
||||
static inline int a_ctz_l(unsigned long x)
|
||||
{
|
||||
return (sizeof(long) < 8) ? a_ctz_32(x) : a_ctz_64(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_clz_64
|
||||
#define a_clz_64 a_clz_64
|
||||
static inline int a_clz_64(uint64_t x)
|
||||
{
|
||||
#ifdef a_clz_32
|
||||
if (x>>32)
|
||||
return a_clz_32(x>>32);
|
||||
return a_clz_32(x) + 32;
|
||||
#else
|
||||
uint32_t y;
|
||||
int r;
|
||||
if (x>>32) y=x>>32, r=0; else y=x, r=32;
|
||||
if (y>>16) y>>=16; else r |= 16;
|
||||
if (y>>8) y>>=8; else r |= 8;
|
||||
if (y>>4) y>>=4; else r |= 4;
|
||||
if (y>>2) y>>=2; else r |= 2;
|
||||
return r | !(y>>1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_clz_32
|
||||
#define a_clz_32 a_clz_32
|
||||
static inline int a_clz_32(uint32_t x)
|
||||
{
|
||||
x >>= 1;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x++;
|
||||
return 31-a_ctz_32(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
279
internal/overlay/musl/src/internal/libm.h
Normal file
279
internal/overlay/musl/src/internal/libm.h
Normal file
|
@ -0,0 +1,279 @@
|
|||
#ifndef _LIBM_H
|
||||
#define _LIBM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <endian.h>
|
||||
#include "fp_arch.h"
|
||||
|
||||
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
|
||||
#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
union ldshape {
|
||||
long double f;
|
||||
struct {
|
||||
uint64_t m;
|
||||
uint16_t se;
|
||||
} i;
|
||||
};
|
||||
#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
|
||||
/* This is the m68k variant of 80-bit long double, and this definition only works
|
||||
* on archs where the alignment requirement of uint64_t is <= 4. */
|
||||
union ldshape {
|
||||
long double f;
|
||||
struct {
|
||||
uint16_t se;
|
||||
uint16_t pad;
|
||||
uint64_t m;
|
||||
} i;
|
||||
};
|
||||
#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
union ldshape {
|
||||
long double f;
|
||||
struct {
|
||||
uint64_t lo;
|
||||
uint32_t mid;
|
||||
uint16_t top;
|
||||
uint16_t se;
|
||||
} i;
|
||||
struct {
|
||||
uint64_t lo;
|
||||
uint64_t hi;
|
||||
} i2;
|
||||
};
|
||||
#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
|
||||
union ldshape {
|
||||
long double f;
|
||||
struct {
|
||||
uint16_t se;
|
||||
uint16_t top;
|
||||
uint32_t mid;
|
||||
uint64_t lo;
|
||||
} i;
|
||||
struct {
|
||||
uint64_t hi;
|
||||
uint64_t lo;
|
||||
} i2;
|
||||
};
|
||||
#else
|
||||
#error Unsupported long double representation
|
||||
#endif
|
||||
|
||||
/* Support non-nearest rounding mode. */
|
||||
#define WANT_ROUNDING 1
|
||||
/* Support signaling NaNs. */
|
||||
#define WANT_SNAN 0
|
||||
|
||||
#if WANT_SNAN
|
||||
#error SNaN is unsupported
|
||||
#else
|
||||
#define issignalingf_inline(x) 0
|
||||
#define issignaling_inline(x) 0
|
||||
#endif
|
||||
|
||||
#ifndef TOINT_INTRINSICS
|
||||
#define TOINT_INTRINSICS 0
|
||||
#endif
|
||||
|
||||
#if TOINT_INTRINSICS
|
||||
/* Round x to nearest int in all rounding modes, ties have to be rounded
|
||||
consistently with converttoint so the results match. If the result
|
||||
would be outside of [-2^31, 2^31-1] then the semantics is unspecified. */
|
||||
static double_t roundtoint(double_t);
|
||||
|
||||
/* Convert x to nearest int in all rounding modes, ties have to be rounded
|
||||
consistently with roundtoint. If the result is not representible in an
|
||||
int32_t then the semantics is unspecified. */
|
||||
static int32_t converttoint(double_t);
|
||||
#endif
|
||||
|
||||
/* Helps static branch prediction so hot path can be better optimized. */
|
||||
#ifndef __CCGO__
|
||||
#ifdef __GNUC__
|
||||
#define predict_true(x) __builtin_expect(!!(x), 1)
|
||||
#define predict_false(x) __builtin_expect(x, 0)
|
||||
#else
|
||||
#define predict_true(x) (x)
|
||||
#define predict_false(x) (x)
|
||||
#endif
|
||||
#else // __CCGO__
|
||||
#define predict_true(x) (x)
|
||||
#define predict_false(x) (x)
|
||||
#endif // __CCGO__
|
||||
|
||||
/* Evaluate an expression as the specified type. With standard excess
|
||||
precision handling a type cast or assignment is enough (with
|
||||
-ffloat-store an assignment is required, in old compilers argument
|
||||
passing and return statement may not drop excess precision). */
|
||||
|
||||
static inline float eval_as_float(float x)
|
||||
{
|
||||
float y = x;
|
||||
return y;
|
||||
}
|
||||
|
||||
static inline double eval_as_double(double x)
|
||||
{
|
||||
double y = x;
|
||||
return y;
|
||||
}
|
||||
|
||||
/* fp_barrier returns its input, but limits code transformations
|
||||
as if it had a side-effect (e.g. observable io) and returned
|
||||
an arbitrary value. */
|
||||
|
||||
#ifndef fp_barrierf
|
||||
#define fp_barrierf fp_barrierf
|
||||
static inline float fp_barrierf(float x)
|
||||
{
|
||||
volatile float y = x;
|
||||
return y;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef fp_barrier
|
||||
#define fp_barrier fp_barrier
|
||||
static inline double fp_barrier(double x)
|
||||
{
|
||||
volatile double y = x;
|
||||
return y;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef fp_barrierl
|
||||
#define fp_barrierl fp_barrierl
|
||||
static inline long double fp_barrierl(long double x)
|
||||
{
|
||||
volatile long double y = x;
|
||||
return y;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* fp_force_eval ensures that the input value is computed when that's
|
||||
otherwise unused. To prevent the constant folding of the input
|
||||
expression, an additional fp_barrier may be needed or a compilation
|
||||
mode that does so (e.g. -frounding-math in gcc). Then it can be
|
||||
used to evaluate an expression for its fenv side-effects only. */
|
||||
|
||||
#ifndef fp_force_evalf
|
||||
#define fp_force_evalf fp_force_evalf
|
||||
static inline void fp_force_evalf(float x)
|
||||
{
|
||||
volatile float y;
|
||||
y = x;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef fp_force_eval
|
||||
#define fp_force_eval fp_force_eval
|
||||
static inline void fp_force_eval(double x)
|
||||
{
|
||||
volatile double y;
|
||||
y = x;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef fp_force_evall
|
||||
#define fp_force_evall fp_force_evall
|
||||
static inline void fp_force_evall(long double x)
|
||||
{
|
||||
volatile long double y;
|
||||
y = x;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define FORCE_EVAL(x) do { \
|
||||
if (sizeof(x) == sizeof(float)) { \
|
||||
fp_force_evalf(x); \
|
||||
} else if (sizeof(x) == sizeof(double)) { \
|
||||
fp_force_eval(x); \
|
||||
} else { \
|
||||
fp_force_evall(x); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define asuint(f) ((union{float _f; uint32_t _i;}){f})._i
|
||||
#define asfloat(i) ((union{uint32_t _i; float _f;}){i})._f
|
||||
#define asuint64(f) ((union{double _f; uint64_t _i;}){f})._i
|
||||
#define asdouble(i) ((union{uint64_t _i; double _f;}){i})._f
|
||||
|
||||
#define EXTRACT_WORDS(hi,lo,d) \
|
||||
do { \
|
||||
uint64_t __u = asuint64(d); \
|
||||
(hi) = __u >> 32; \
|
||||
(lo) = (uint32_t)__u; \
|
||||
} while (0)
|
||||
|
||||
#define GET_HIGH_WORD(hi,d) \
|
||||
do { \
|
||||
(hi) = asuint64(d) >> 32; \
|
||||
} while (0)
|
||||
|
||||
#define GET_LOW_WORD(lo,d) \
|
||||
do { \
|
||||
(lo) = (uint32_t)asuint64(d); \
|
||||
} while (0)
|
||||
|
||||
#define INSERT_WORDS(d,hi,lo) \
|
||||
do { \
|
||||
(d) = asdouble(((uint64_t)(hi)<<32) | (uint32_t)(lo)); \
|
||||
} while (0)
|
||||
|
||||
#define SET_HIGH_WORD(d,hi) \
|
||||
INSERT_WORDS(d, hi, (uint32_t)asuint64(d))
|
||||
|
||||
#define SET_LOW_WORD(d,lo) \
|
||||
INSERT_WORDS(d, asuint64(d)>>32, lo)
|
||||
|
||||
#define GET_FLOAT_WORD(w,d) \
|
||||
do { \
|
||||
(w) = asuint(d); \
|
||||
} while (0)
|
||||
|
||||
#define SET_FLOAT_WORD(d,w) \
|
||||
do { \
|
||||
(d) = asfloat(w); \
|
||||
} while (0)
|
||||
|
||||
hidden int __rem_pio2_large(double*,double*,int,int,int);
|
||||
|
||||
hidden int __rem_pio2(double,double*);
|
||||
hidden double __sin(double,double,int);
|
||||
hidden double __cos(double,double);
|
||||
hidden double __tan(double,double,int);
|
||||
hidden double __expo2(double,double);
|
||||
|
||||
hidden int __rem_pio2f(float,double*);
|
||||
hidden float __sindf(double);
|
||||
hidden float __cosdf(double);
|
||||
hidden float __tandf(double,int);
|
||||
hidden float __expo2f(float,float);
|
||||
|
||||
hidden int __rem_pio2l(long double, long double *);
|
||||
hidden long double __sinl(long double, long double, int);
|
||||
hidden long double __cosl(long double, long double);
|
||||
hidden long double __tanl(long double, long double, int);
|
||||
|
||||
hidden long double __polevll(long double, const long double *, int);
|
||||
hidden long double __p1evll(long double, const long double *, int);
|
||||
|
||||
extern int __signgam;
|
||||
hidden double __lgamma_r(double, int *);
|
||||
hidden float __lgammaf_r(float, int *);
|
||||
|
||||
/* error handling functions */
|
||||
hidden float __math_xflowf(uint32_t, float);
|
||||
hidden float __math_uflowf(uint32_t);
|
||||
hidden float __math_oflowf(uint32_t);
|
||||
hidden float __math_divzerof(uint32_t);
|
||||
hidden float __math_invalidf(float);
|
||||
hidden double __math_xflow(uint32_t, double);
|
||||
hidden double __math_uflow(uint32_t);
|
||||
hidden double __math_oflow(uint32_t);
|
||||
hidden double __math_divzero(uint32_t);
|
||||
hidden double __math_invalid(double);
|
||||
#if LDBL_MANT_DIG != DBL_MANT_DIG
|
||||
hidden long double __math_invalidl(long double);
|
||||
#endif
|
||||
|
||||
#endif
|
238
internal/overlay/musl/src/internal/pthread_impl.h
Normal file
238
internal/overlay/musl/src/internal/pthread_impl.h
Normal file
|
@ -0,0 +1,238 @@
|
|||
#ifndef _PTHREAD_IMPL_H
|
||||
#define _PTHREAD_IMPL_H
|
||||
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <sys/mman.h>
|
||||
#include "libc.h"
|
||||
#include "syscall.h"
|
||||
#include "atomic.h"
|
||||
#include "futex.h"
|
||||
|
||||
#include "pthread_arch.h"
|
||||
|
||||
#define pthread __pthread
|
||||
|
||||
struct pthread {
|
||||
/* Part 1 -- these fields may be external or
|
||||
* internal (accessed via asm) ABI. Do not change. */
|
||||
struct pthread *self;
|
||||
#ifndef TLS_ABOVE_TP
|
||||
uintptr_t *dtv;
|
||||
#endif
|
||||
struct pthread *prev, *next; /* non-ABI */
|
||||
uintptr_t sysinfo;
|
||||
#ifndef TLS_ABOVE_TP
|
||||
#ifdef CANARY_PAD
|
||||
uintptr_t canary_pad;
|
||||
#endif
|
||||
uintptr_t canary;
|
||||
#endif
|
||||
|
||||
#ifndef __CCGO__
|
||||
/* Part 2 -- implementation details, non-ABI. */
|
||||
int tid;
|
||||
int errno_val;
|
||||
volatile int detach_state;
|
||||
volatile int cancel;
|
||||
volatile unsigned char canceldisable, cancelasync;
|
||||
unsigned char tsd_used:1;
|
||||
unsigned char dlerror_flag:1;
|
||||
unsigned char *map_base;
|
||||
size_t map_size;
|
||||
void *stack;
|
||||
size_t stack_size;
|
||||
size_t guard_size;
|
||||
void *result;
|
||||
struct __ptcb *cancelbuf;
|
||||
void **tsd;
|
||||
struct {
|
||||
volatile void *volatile head;
|
||||
long off;
|
||||
volatile void *volatile pending;
|
||||
} robust_list;
|
||||
int h_errno_val;
|
||||
volatile int timer_id;
|
||||
locale_t locale;
|
||||
volatile int killlock[1];
|
||||
char *dlerror_buf;
|
||||
void *stdio_locks;
|
||||
#else
|
||||
#define __CCGO_SIZEOF_GO_MUTEX 8
|
||||
/* Part 2 -- implementation details, non-ABI. */
|
||||
int tid;
|
||||
int errno_val;
|
||||
volatile int detach_state;
|
||||
volatile int cancel;
|
||||
volatile unsigned char canceldisable, cancelasync;
|
||||
unsigned char tsd_used:1;
|
||||
unsigned char dlerror_flag:1;
|
||||
unsigned char *map_base;
|
||||
size_t map_size;
|
||||
void *stack;
|
||||
size_t stack_size;
|
||||
size_t guard_size;
|
||||
void *result;
|
||||
struct __ptcb *cancelbuf;
|
||||
void **tsd;
|
||||
struct {
|
||||
volatile void *volatile head;
|
||||
long off;
|
||||
volatile void *volatile pending;
|
||||
} robust_list;
|
||||
int h_errno_val;
|
||||
volatile int timer_id;
|
||||
locale_t locale;
|
||||
volatile int killlock[1];
|
||||
char *dlerror_buf;
|
||||
void *stdio_locks;
|
||||
|
||||
long long __ccgo_join_mutex[(__CCGO_SIZEOF_GO_MUTEX+7)/8];
|
||||
#endif
|
||||
|
||||
/* Part 3 -- the positions of these fields relative to
|
||||
* the end of the structure is external and internal ABI. */
|
||||
#ifdef TLS_ABOVE_TP
|
||||
uintptr_t canary;
|
||||
uintptr_t *dtv;
|
||||
#endif
|
||||
};
|
||||
|
||||
enum {
|
||||
DT_EXITED = 0,
|
||||
DT_EXITING,
|
||||
DT_JOINABLE,
|
||||
DT_DETACHED,
|
||||
};
|
||||
|
||||
#define __SU (sizeof(size_t)/sizeof(int))
|
||||
|
||||
#define _a_stacksize __u.__s[0]
|
||||
#define _a_guardsize __u.__s[1]
|
||||
#define _a_stackaddr __u.__s[2]
|
||||
#define _a_detach __u.__i[3*__SU+0]
|
||||
#define _a_sched __u.__i[3*__SU+1]
|
||||
#define _a_policy __u.__i[3*__SU+2]
|
||||
#define _a_prio __u.__i[3*__SU+3]
|
||||
#define _m_type __u.__i[0]
|
||||
#define _m_lock __u.__vi[1]
|
||||
#define _m_waiters __u.__vi[2]
|
||||
#define _m_prev __u.__p[3]
|
||||
#define _m_next __u.__p[4]
|
||||
#define _m_count __u.__i[5]
|
||||
#define _c_shared __u.__p[0]
|
||||
#define _c_seq __u.__vi[2]
|
||||
#define _c_waiters __u.__vi[3]
|
||||
#define _c_clock __u.__i[4]
|
||||
#define _c_lock __u.__vi[8]
|
||||
#define _c_head __u.__p[1]
|
||||
#define _c_tail __u.__p[5]
|
||||
#define _rw_lock __u.__vi[0]
|
||||
#define _rw_waiters __u.__vi[1]
|
||||
#define _rw_shared __u.__i[2]
|
||||
#define _b_lock __u.__vi[0]
|
||||
#define _b_waiters __u.__vi[1]
|
||||
#define _b_limit __u.__i[2]
|
||||
#define _b_count __u.__vi[3]
|
||||
#define _b_waiters2 __u.__vi[4]
|
||||
#define _b_inst __u.__p[3]
|
||||
|
||||
#ifndef TP_OFFSET
|
||||
#define TP_OFFSET 0
|
||||
#endif
|
||||
|
||||
#ifndef DTP_OFFSET
|
||||
#define DTP_OFFSET 0
|
||||
#endif
|
||||
|
||||
// #ifdef TLS_ABOVE_TP
|
||||
// #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + TP_OFFSET)
|
||||
// #define __pthread_self() ((pthread_t)(__get_tp() - sizeof(struct __pthread) - TP_OFFSET))
|
||||
// #else
|
||||
#define TP_ADJ(p) (p)
|
||||
#define __pthread_self() ((pthread_t)__get_tp())
|
||||
// #endif
|
||||
|
||||
#ifndef tls_mod_off_t
|
||||
#define tls_mod_off_t size_t
|
||||
#endif
|
||||
|
||||
#define SIGTIMER 32
|
||||
#define SIGCANCEL 33
|
||||
#define SIGSYNCCALL 34
|
||||
|
||||
#define SIGALL_SET ((sigset_t *)(const unsigned long long [2]){ -1,-1 })
|
||||
#define SIGPT_SET \
|
||||
((sigset_t *)(const unsigned long [_NSIG/8/sizeof(long)]){ \
|
||||
[sizeof(long)==4] = 3UL<<(32*(sizeof(long)>4)) })
|
||||
#define SIGTIMER_SET \
|
||||
((sigset_t *)(const unsigned long [_NSIG/8/sizeof(long)]){ \
|
||||
0x80000000 })
|
||||
|
||||
void *__tls_get_addr(tls_mod_off_t *);
|
||||
hidden int __init_tp(void *);
|
||||
hidden void *__copy_tls(unsigned char *);
|
||||
hidden void __reset_tls();
|
||||
|
||||
hidden void __membarrier_init(void);
|
||||
hidden void __dl_thread_cleanup(void);
|
||||
hidden void __testcancel();
|
||||
hidden void __do_cleanup_push(struct __ptcb *);
|
||||
hidden void __do_cleanup_pop(struct __ptcb *);
|
||||
hidden void __pthread_tsd_run_dtors();
|
||||
|
||||
hidden void __pthread_key_delete_synccall(void (*)(void *), void *);
|
||||
hidden int __pthread_key_delete_impl(pthread_key_t);
|
||||
|
||||
extern hidden volatile size_t __pthread_tsd_size;
|
||||
extern hidden void *__pthread_tsd_main[];
|
||||
extern hidden volatile int __eintr_valid_flag;
|
||||
|
||||
hidden int __clone(int (*)(void *), void *, int, void *, ...);
|
||||
hidden int __set_thread_area(void *);
|
||||
hidden int __libc_sigaction(int, const struct sigaction *, struct sigaction *);
|
||||
hidden void __unmapself(void *, size_t);
|
||||
|
||||
hidden int __timedwait(volatile int *, int, clockid_t, const struct timespec *, int);
|
||||
hidden int __timedwait_cp(volatile int *, int, clockid_t, const struct timespec *, int);
|
||||
hidden void __wait(volatile int *, volatile int *, int, int);
|
||||
static inline void __wake(volatile void *addr, int cnt, int priv)
|
||||
{
|
||||
if (priv) priv = FUTEX_PRIVATE;
|
||||
if (cnt<0) cnt = INT_MAX;
|
||||
__syscall(SYS_futex, addr, FUTEX_WAKE|priv, cnt) != -ENOSYS ||
|
||||
__syscall(SYS_futex, addr, FUTEX_WAKE, cnt);
|
||||
}
|
||||
static inline void __futexwait(volatile void *addr, int val, int priv)
|
||||
{
|
||||
if (priv) priv = FUTEX_PRIVATE;
|
||||
__syscall(SYS_futex, addr, FUTEX_WAIT|priv, val, 0) != -ENOSYS ||
|
||||
__syscall(SYS_futex, addr, FUTEX_WAIT, val, 0);
|
||||
}
|
||||
|
||||
hidden void __acquire_ptc(void);
|
||||
hidden void __release_ptc(void);
|
||||
hidden void __inhibit_ptc(void);
|
||||
|
||||
hidden void __tl_lock(void);
|
||||
hidden void __tl_unlock(void);
|
||||
hidden void __tl_sync(pthread_t);
|
||||
|
||||
extern hidden volatile int __thread_list_lock;
|
||||
|
||||
extern hidden volatile int __abort_lock[1];
|
||||
|
||||
extern hidden unsigned __default_stacksize;
|
||||
extern hidden unsigned __default_guardsize;
|
||||
|
||||
#define DEFAULT_STACK_SIZE 131072
|
||||
#define DEFAULT_GUARD_SIZE 8192
|
||||
|
||||
#define DEFAULT_STACK_MAX (8<<20)
|
||||
#define DEFAULT_GUARD_MAX (1<<20)
|
||||
|
||||
#define __ATTRP_C11_THREAD ((void*)(uintptr_t)-1)
|
||||
|
||||
#endif
|
13
internal/overlay/musl/src/malloc/reallocarray.c
Normal file
13
internal/overlay/musl/src/malloc/reallocarray.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
#define _BSD_SOURCE
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void *reallocarray(void *ptr, size_t m, size_t n)
|
||||
{
|
||||
if (n && m > -1 / n) {
|
||||
errno = ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return realloc(ptr, m * n);
|
||||
}
|
94
internal/overlay/musl/src/process/fork.c
Normal file
94
internal/overlay/musl/src/process/fork.c
Normal file
|
@ -0,0 +1,94 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "libc.h"
|
||||
#include "lock.h"
|
||||
#include "pthread_impl.h"
|
||||
#include "fork_impl.h"
|
||||
|
||||
static volatile int *const dummy_lockptr = 0;
|
||||
|
||||
weak_alias(dummy_lockptr, __at_quick_exit_lockptr);
|
||||
weak_alias(dummy_lockptr, __atexit_lockptr);
|
||||
weak_alias(dummy_lockptr, __gettext_lockptr);
|
||||
weak_alias(dummy_lockptr, __locale_lockptr);
|
||||
weak_alias(dummy_lockptr, __random_lockptr);
|
||||
weak_alias(dummy_lockptr, __sem_open_lockptr);
|
||||
weak_alias(dummy_lockptr, __stdio_ofl_lockptr);
|
||||
weak_alias(dummy_lockptr, __syslog_lockptr);
|
||||
weak_alias(dummy_lockptr, __timezone_lockptr);
|
||||
weak_alias(dummy_lockptr, __bump_lockptr);
|
||||
|
||||
weak_alias(dummy_lockptr, __vmlock_lockptr);
|
||||
|
||||
static volatile int *const *const atfork_locks[] = {
|
||||
&__at_quick_exit_lockptr,
|
||||
&__atexit_lockptr,
|
||||
&__gettext_lockptr,
|
||||
&__locale_lockptr,
|
||||
&__random_lockptr,
|
||||
&__sem_open_lockptr,
|
||||
&__stdio_ofl_lockptr,
|
||||
&__syslog_lockptr,
|
||||
&__timezone_lockptr,
|
||||
&__bump_lockptr,
|
||||
};
|
||||
|
||||
static void dummy(int x) { }
|
||||
weak_alias(dummy, __fork_handler);
|
||||
weak_alias(dummy, __malloc_atfork);
|
||||
weak_alias(dummy, __aio_atfork);
|
||||
weak_alias(dummy, __pthread_key_atfork);
|
||||
weak_alias(dummy, __ldso_atfork);
|
||||
|
||||
static void dummy_0(void) { }
|
||||
weak_alias(dummy_0, __tl_lock);
|
||||
weak_alias(dummy_0, __tl_unlock);
|
||||
|
||||
pid_t fork(void);
|
||||
|
||||
#ifndef __CCGO__
|
||||
pid_t fork(void)
|
||||
{
|
||||
sigset_t set;
|
||||
__fork_handler(-1);
|
||||
__block_app_sigs(&set);
|
||||
int need_locks = libc.need_locks > 0;
|
||||
if (need_locks) {
|
||||
__ldso_atfork(-1);
|
||||
__pthread_key_atfork(-1);
|
||||
__aio_atfork(-1);
|
||||
__inhibit_ptc();
|
||||
for (int i=0; i<sizeof atfork_locks/sizeof *atfork_locks; i++)
|
||||
if (*atfork_locks[i]) LOCK(*atfork_locks[i]);
|
||||
__malloc_atfork(-1);
|
||||
__tl_lock();
|
||||
}
|
||||
pthread_t self=__pthread_self(), next=self->next;
|
||||
pid_t ret = _Fork();
|
||||
int errno_save = errno;
|
||||
if (need_locks) {
|
||||
if (!ret) {
|
||||
for (pthread_t td=next; td!=self; td=td->next)
|
||||
td->tid = -1;
|
||||
if (__vmlock_lockptr) {
|
||||
__vmlock_lockptr[0] = 0;
|
||||
__vmlock_lockptr[1] = 0;
|
||||
}
|
||||
}
|
||||
__tl_unlock();
|
||||
__malloc_atfork(!ret);
|
||||
for (int i=0; i<sizeof atfork_locks/sizeof *atfork_locks; i++)
|
||||
if (*atfork_locks[i])
|
||||
if (ret) UNLOCK(*atfork_locks[i]);
|
||||
else **atfork_locks[i] = 0;
|
||||
__release_ptc();
|
||||
if (ret) __aio_atfork(0);
|
||||
__pthread_key_atfork(!ret);
|
||||
__ldso_atfork(!ret);
|
||||
}
|
||||
__restore_sigs(&set);
|
||||
__fork_handler(!ret);
|
||||
if (ret<0) errno = errno_save;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
61
internal/overlay/musl/src/stdio/ext.c
Normal file
61
internal/overlay/musl/src/stdio/ext.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
#define _GNU_SOURCE
|
||||
#include "stdio_impl.h"
|
||||
#include <stdio_ext.h>
|
||||
|
||||
void _flushlbf(void)
|
||||
{
|
||||
fflush(0);
|
||||
}
|
||||
|
||||
int __fsetlocking(FILE *f, int type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __fwriting(FILE *f)
|
||||
{
|
||||
return (f->flags & F_NORD) || f->wend;
|
||||
}
|
||||
|
||||
int __freading(FILE *f)
|
||||
{
|
||||
return (f->flags & F_NOWR) || f->rend;
|
||||
}
|
||||
|
||||
int __freadable(FILE *f)
|
||||
{
|
||||
return !(f->flags & F_NORD);
|
||||
}
|
||||
|
||||
int __fwritable(FILE *f)
|
||||
{
|
||||
return !(f->flags & F_NOWR);
|
||||
}
|
||||
|
||||
int __flbf(FILE *f)
|
||||
{
|
||||
return f->lbf >= 0;
|
||||
}
|
||||
|
||||
size_t __fbufsize(FILE *f)
|
||||
{
|
||||
return f->buf_size;
|
||||
}
|
||||
|
||||
size_t __fpending(FILE *f)
|
||||
{
|
||||
return f->wend ? f->wpos - f->wbase : 0;
|
||||
}
|
||||
|
||||
int __fpurge(FILE *f)
|
||||
{
|
||||
if (!f) { // libbsd fpurge test fails w/o this.
|
||||
return 1;
|
||||
}
|
||||
|
||||
f->wpos = f->wbase = f->wend = 0;
|
||||
f->rpos = f->rend = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
weak_alias(__fpurge, fpurge);
|
10
internal/overlay/musl/src/string/explicit_bzero.c
Normal file
10
internal/overlay/musl/src/string/explicit_bzero.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
#define _BSD_SOURCE
|
||||
#include <string.h>
|
||||
|
||||
void explicit_bzero(void *d, size_t n)
|
||||
{
|
||||
d = memset(d, 0, n);
|
||||
#ifndef __CCGO__
|
||||
__asm__ __volatile__ ("" : : "r"(d) : "memory");
|
||||
#endif
|
||||
}
|
301
internal/overlay/musl/src/time/strftime.c
Normal file
301
internal/overlay/musl/src/time/strftime.c
Normal file
|
@ -0,0 +1,301 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <langinfo.h>
|
||||
#include <locale.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
#include "locale_impl.h"
|
||||
#include "time_impl.h"
|
||||
|
||||
static int is_leap(int y)
|
||||
{
|
||||
/* Avoid overflow */
|
||||
if (y>INT_MAX-1900) y -= 2000;
|
||||
y += 1900;
|
||||
return !(y%4) && ((y%100) || !(y%400));
|
||||
}
|
||||
|
||||
static int week_num(const struct tm *tm)
|
||||
{
|
||||
int val = (tm->tm_yday + 7U - (tm->tm_wday+6U)%7) / 7;
|
||||
/* If 1 Jan is just 1-3 days past Monday,
|
||||
* the previous week is also in this year. */
|
||||
if ((tm->tm_wday + 371U - tm->tm_yday - 2) % 7 <= 2)
|
||||
val++;
|
||||
if (!val) {
|
||||
val = 52;
|
||||
/* If 31 December of prev year a Thursday,
|
||||
* or Friday of a leap year, then the
|
||||
* prev year has 53 weeks. */
|
||||
int dec31 = (tm->tm_wday + 7U - tm->tm_yday - 1) % 7;
|
||||
if (dec31 == 4 || (dec31 == 5 && is_leap(tm->tm_year%400-1)))
|
||||
val++;
|
||||
} else if (val == 53) {
|
||||
/* If 1 January is not a Thursday, and not
|
||||
* a Wednesday of a leap year, then this
|
||||
* year has only 52 weeks. */
|
||||
int jan1 = (tm->tm_wday + 371U - tm->tm_yday) % 7;
|
||||
if (jan1 != 4 && (jan1 != 3 || !is_leap(tm->tm_year)))
|
||||
val = 1;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *tm, locale_t loc, int pad)
|
||||
{
|
||||
nl_item item;
|
||||
long long val;
|
||||
const char *fmt = "-";
|
||||
int width = 2, def_pad = '0';
|
||||
|
||||
switch (f) {
|
||||
case 'a':
|
||||
if (tm->tm_wday > 6U) goto string;
|
||||
item = ABDAY_1 + tm->tm_wday;
|
||||
goto nl_strcat;
|
||||
case 'A':
|
||||
if (tm->tm_wday > 6U) goto string;
|
||||
item = DAY_1 + tm->tm_wday;
|
||||
goto nl_strcat;
|
||||
case 'h':
|
||||
case 'b':
|
||||
if (tm->tm_mon > 11U) goto string;
|
||||
item = ABMON_1 + tm->tm_mon;
|
||||
goto nl_strcat;
|
||||
case 'B':
|
||||
if (tm->tm_mon > 11U) goto string;
|
||||
item = MON_1 + tm->tm_mon;
|
||||
goto nl_strcat;
|
||||
case 'c':
|
||||
item = D_T_FMT;
|
||||
goto nl_strftime;
|
||||
case 'C':
|
||||
val = (1900LL+tm->tm_year) / 100;
|
||||
goto number;
|
||||
case 'e':
|
||||
def_pad = '_';
|
||||
case 'd':
|
||||
val = tm->tm_mday;
|
||||
goto number;
|
||||
case 'D':
|
||||
fmt = "%m/%d/%y";
|
||||
goto recu_strftime;
|
||||
case 'F':
|
||||
fmt = "%Y-%m-%d";
|
||||
goto recu_strftime;
|
||||
case 'g':
|
||||
case 'G':
|
||||
val = tm->tm_year + 1900LL;
|
||||
if (tm->tm_yday < 3 && week_num(tm) != 1) val--;
|
||||
else if (tm->tm_yday > 360 && week_num(tm) == 1) val++;
|
||||
if (f=='g') val %= 100;
|
||||
else width = 4;
|
||||
goto number;
|
||||
case 'H':
|
||||
val = tm->tm_hour;
|
||||
goto number;
|
||||
case 'l':
|
||||
def_pad = '_';
|
||||
case 'I':
|
||||
val = tm->tm_hour;
|
||||
if (!val) val = 12;
|
||||
else if (val > 12) val -= 12;
|
||||
goto number;
|
||||
case 'j':
|
||||
val = tm->tm_yday+1;
|
||||
width = 3;
|
||||
goto number;
|
||||
case 'k':
|
||||
val = tm->tm_hour;
|
||||
def_pad = '_';
|
||||
goto number;
|
||||
case 'm':
|
||||
val = tm->tm_mon+1;
|
||||
goto number;
|
||||
case 'M':
|
||||
val = tm->tm_min;
|
||||
goto number;
|
||||
case 'n':
|
||||
*l = 1;
|
||||
return "\n";
|
||||
case 'p':
|
||||
item = tm->tm_hour >= 12 ? PM_STR : AM_STR;
|
||||
goto nl_strcat;
|
||||
case 'P':
|
||||
item = tm->tm_hour >= 12 ? PM_STR : AM_STR;
|
||||
fmt = __nl_langinfo_l(item, loc);
|
||||
char *d = *s;
|
||||
for (*l = 0; *fmt; (*l)++) {
|
||||
*d++ = tolower(*fmt++);
|
||||
}
|
||||
return *s;
|
||||
case 'r':
|
||||
item = T_FMT_AMPM;
|
||||
goto nl_strftime;
|
||||
case 'R':
|
||||
fmt = "%H:%M";
|
||||
goto recu_strftime;
|
||||
case 's':
|
||||
val = __tm_to_secs(tm) - tm->__tm_gmtoff;
|
||||
width = 1;
|
||||
goto number;
|
||||
case 'S':
|
||||
val = tm->tm_sec;
|
||||
goto number;
|
||||
case 't':
|
||||
*l = 1;
|
||||
return "\t";
|
||||
case 'T':
|
||||
fmt = "%H:%M:%S";
|
||||
goto recu_strftime;
|
||||
case 'u':
|
||||
val = tm->tm_wday ? tm->tm_wday : 7;
|
||||
width = 1;
|
||||
goto number;
|
||||
case 'U':
|
||||
val = (tm->tm_yday + 7U - tm->tm_wday) / 7;
|
||||
goto number;
|
||||
case 'W':
|
||||
val = (tm->tm_yday + 7U - (tm->tm_wday+6U)%7) / 7;
|
||||
goto number;
|
||||
case 'V':
|
||||
val = week_num(tm);
|
||||
goto number;
|
||||
case 'w':
|
||||
val = tm->tm_wday;
|
||||
width = 1;
|
||||
goto number;
|
||||
case 'x':
|
||||
item = D_FMT;
|
||||
goto nl_strftime;
|
||||
case 'X':
|
||||
item = T_FMT;
|
||||
goto nl_strftime;
|
||||
case 'y':
|
||||
val = (tm->tm_year + 1900LL) % 100;
|
||||
if (val < 0) val = -val;
|
||||
goto number;
|
||||
case 'Y':
|
||||
val = tm->tm_year + 1900LL;
|
||||
if (val >= 10000) {
|
||||
*l = snprintf(*s, sizeof *s, "+%lld", val);
|
||||
return *s;
|
||||
}
|
||||
width = 4;
|
||||
goto number;
|
||||
case 'z':
|
||||
if (tm->tm_isdst < 0) {
|
||||
*l = 0;
|
||||
return "";
|
||||
}
|
||||
*l = snprintf(*s, sizeof *s, "%+.4ld",
|
||||
tm->__tm_gmtoff/3600*100 + tm->__tm_gmtoff%3600/60);
|
||||
return *s;
|
||||
case 'Z':
|
||||
if (tm->tm_isdst < 0) {
|
||||
*l = 0;
|
||||
return "";
|
||||
}
|
||||
fmt = __tm_to_tzname(tm);
|
||||
goto string;
|
||||
case '%':
|
||||
*l = 1;
|
||||
return "%";
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
number:
|
||||
switch (pad ? pad : def_pad) {
|
||||
case '-': *l = snprintf(*s, sizeof *s, "%lld", val); break;
|
||||
case '_': *l = snprintf(*s, sizeof *s, "%*lld", width, val); break;
|
||||
case '0':
|
||||
default: *l = snprintf(*s, sizeof *s, "%0*lld", width, val); break;
|
||||
}
|
||||
return *s;
|
||||
nl_strcat:
|
||||
fmt = __nl_langinfo_l(item, loc);
|
||||
string:
|
||||
*l = strlen(fmt);
|
||||
return fmt;
|
||||
nl_strftime:
|
||||
fmt = __nl_langinfo_l(item, loc);
|
||||
recu_strftime:
|
||||
*l = __strftime_l(*s, sizeof *s, fmt, tm, loc);
|
||||
if (!*l) return 0;
|
||||
return *s;
|
||||
}
|
||||
|
||||
size_t __strftime_l(char *restrict s, size_t n, const char *restrict f, const struct tm *restrict tm, locale_t loc)
|
||||
{
|
||||
size_t l, k;
|
||||
char buf[100];
|
||||
char *p;
|
||||
const char *t;
|
||||
int pad, plus;
|
||||
unsigned long width;
|
||||
for (l=0; l<n; f++) {
|
||||
if (!*f) {
|
||||
s[l] = 0;
|
||||
return l;
|
||||
}
|
||||
if (*f != '%') {
|
||||
s[l++] = *f;
|
||||
continue;
|
||||
}
|
||||
f++;
|
||||
pad = 0;
|
||||
if (*f == '-' || *f == '_' || *f == '0') pad = *f++;
|
||||
if ((plus = (*f == '+'))) f++;
|
||||
if (isdigit(*f)) {
|
||||
width = strtoul(f, &p, 10);
|
||||
} else {
|
||||
width = 0;
|
||||
p = (void *)f;
|
||||
}
|
||||
if (*p == 'C' || *p == 'F' || *p == 'G' || *p == 'Y') {
|
||||
if (!width && p!=f) width = 1;
|
||||
} else {
|
||||
width = 0;
|
||||
}
|
||||
f = p;
|
||||
if (*f == 'E' || *f == 'O') f++;
|
||||
t = __strftime_fmt_1(&buf, &k, *f, tm, loc, pad);
|
||||
if (!t) break;
|
||||
if (width) {
|
||||
/* Trim off any sign and leading zeros, then
|
||||
* count remaining digits to determine behavior
|
||||
* for the + flag. */
|
||||
if (*t=='+' || *t=='-') t++, k--;
|
||||
for (; *t=='0' && t[1]-'0'<10U; t++, k--);
|
||||
if (width < k) width = k;
|
||||
size_t d;
|
||||
for (d=0; t[d]-'0'<10U; d++);
|
||||
if (tm->tm_year < -1900) {
|
||||
s[l++] = '-';
|
||||
width--;
|
||||
} else if (plus && d+(width-k) >= (*p=='C'?3:5)) {
|
||||
s[l++] = '+';
|
||||
width--;
|
||||
}
|
||||
for (; width > k && l < n; width--)
|
||||
s[l++] = '0';
|
||||
}
|
||||
if (k > n-l) k = n-l;
|
||||
memcpy(s+l, t, k);
|
||||
l += k;
|
||||
}
|
||||
if (n) {
|
||||
if (l==n) l=n-1;
|
||||
s[l] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t strftime(char *restrict s, size_t n, const char *restrict f, const struct tm *restrict tm)
|
||||
{
|
||||
return __strftime_l(s, n, f, tm, CURRENT_LOCALE);
|
||||
}
|
||||
|
||||
weak_alias(__strftime_l, strftime_l);
|
65
internal/overlay/musl/src/unistd/faccessat.c
Normal file
65
internal/overlay/musl/src/unistd/faccessat.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/wait.h>
|
||||
#include "syscall.h"
|
||||
#include "pthread_impl.h"
|
||||
|
||||
struct ctx {
|
||||
int fd;
|
||||
const char *filename;
|
||||
int amode;
|
||||
int p;
|
||||
};
|
||||
|
||||
static int checker(void *p)
|
||||
{
|
||||
struct ctx *c = p;
|
||||
int ret;
|
||||
if (__syscall(SYS_setregid, __syscall(SYS_getegid), -1)
|
||||
|| __syscall(SYS_setreuid, __syscall(SYS_geteuid), -1))
|
||||
__syscall(SYS_exit, 1);
|
||||
ret = __syscall(SYS_faccessat, c->fd, c->filename, c->amode, 0);
|
||||
__syscall(SYS_write, c->p, &ret, sizeof ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int faccessat(int fd, const char *filename, int amode, int flag)
|
||||
{
|
||||
if (flag) {
|
||||
int ret = __syscall(SYS_faccessat2, fd, filename, amode, flag);
|
||||
if (ret != -ENOSYS) return __syscall_ret(ret);
|
||||
}
|
||||
|
||||
if (flag & ~AT_EACCESS)
|
||||
return __syscall_ret(-EINVAL);
|
||||
|
||||
#ifndef __CCGO__
|
||||
if (!flag || (getuid()==geteuid() && getgid()==getegid()))
|
||||
return syscall(SYS_faccessat, fd, filename, amode);
|
||||
|
||||
char stack[1024];
|
||||
sigset_t set;
|
||||
pid_t pid;
|
||||
int status;
|
||||
int ret, p[2];
|
||||
|
||||
if (pipe2(p, O_CLOEXEC)) return __syscall_ret(-EBUSY);
|
||||
struct ctx c = { .fd = fd, .filename = filename, .amode = amode, .p = p[1] };
|
||||
|
||||
__block_all_sigs(&set);
|
||||
|
||||
pid = __clone(checker, stack+sizeof stack, 0, &c);
|
||||
__syscall(SYS_close, p[1]);
|
||||
|
||||
if (pid<0 || __syscall(SYS_read, p[0], &ret, sizeof ret) != sizeof(ret))
|
||||
ret = -EBUSY;
|
||||
__syscall(SYS_close, p[0]);
|
||||
__sys_wait4(pid, &status, __WCLONE, 0);
|
||||
|
||||
__restore_sigs(&set);
|
||||
|
||||
return __syscall_ret(ret);
|
||||
#else
|
||||
return syscall(SYS_faccessat, fd, filename, amode);
|
||||
#endif
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue