Compare commits
No commits in common. "master" and "master" have entirely different histories.
43
Makefile
43
Makefile
|
@ -17,13 +17,9 @@ ifeq ($(ARCH),$(filter $(ARCH),arm64))
|
||||||
override ARCH = aarch64
|
override ARCH = aarch64
|
||||||
endif
|
endif
|
||||||
|
|
||||||
prefix = /usr
|
LIBDIR := /lib
|
||||||
libdir = ${prefix}/lib
|
INCLUDEDIR := /usr/include
|
||||||
shared_libdir = ${libdir}
|
PKGCONFIGDIR := /usr/lib/pkgconfig
|
||||||
static_libdir = ${libdir}
|
|
||||||
includedir = ${prefix}/include
|
|
||||||
pkgconfigdir = ${prefix}/lib/pkgconfig
|
|
||||||
|
|
||||||
CFLAGS ?= -ggdb3 -O2 -Wall
|
CFLAGS ?= -ggdb3 -O2 -Wall
|
||||||
CPPFLAGS := -Iinclude -Iarch/${ARCH} -Iarch/common
|
CPPFLAGS := -Iinclude -Iarch/${ARCH} -Iarch/common
|
||||||
ifneq ($(shell uname),Darwin)
|
ifneq ($(shell uname),Darwin)
|
||||||
|
@ -39,18 +35,6 @@ ifeq ($(FREESTANDING),yes)
|
||||||
EXPORT_UNPREFIXED = no
|
EXPORT_UNPREFIXED = no
|
||||||
endif
|
endif
|
||||||
|
|
||||||
FORCE_SOFT_FLOAT := no
|
|
||||||
|
|
||||||
ifeq ($(FORCE_SOFT_FLOAT),yes)
|
|
||||||
CPPFLAGS += -DFORCE_SOFT_FLOAT
|
|
||||||
endif
|
|
||||||
|
|
||||||
FORCE_HARD_FLOAT := no
|
|
||||||
|
|
||||||
ifeq ($(FORCE_HARD_FLOAT),yes)
|
|
||||||
CPPFLAGS += -DFORCE_HARD_FLOAT
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(EXPORT_UNPREFIXED),yes)
|
ifeq ($(EXPORT_UNPREFIXED),yes)
|
||||||
CPPFLAGS += -DEXPORT_UNPREFIXED
|
CPPFLAGS += -DEXPORT_UNPREFIXED
|
||||||
endif
|
endif
|
||||||
|
@ -83,8 +67,8 @@ else
|
||||||
endif
|
endif
|
||||||
LIBUCONTEXT_STATIC_NAME = libucontext.a
|
LIBUCONTEXT_STATIC_NAME = libucontext.a
|
||||||
LIBUCONTEXT_PC = libucontext.pc
|
LIBUCONTEXT_PC = libucontext.pc
|
||||||
LIBUCONTEXT_PATH = ${shared_libdir}/${LIBUCONTEXT_SONAME}
|
LIBUCONTEXT_PATH = ${LIBDIR}/${LIBUCONTEXT_SONAME}
|
||||||
LIBUCONTEXT_STATIC_PATH = ${static_libdir}/${LIBUCONTEXT_STATIC_NAME}
|
LIBUCONTEXT_STATIC_PATH = ${LIBDIR}/${LIBUCONTEXT_STATIC_NAME}
|
||||||
LIBUCONTEXT_HEADERS = \
|
LIBUCONTEXT_HEADERS = \
|
||||||
include/libucontext/libucontext.h \
|
include/libucontext/libucontext.h \
|
||||||
include/libucontext/bits.h
|
include/libucontext/bits.h
|
||||||
|
@ -93,8 +77,8 @@ LIBUCONTEXT_EXAMPLES = \
|
||||||
LIBUCONTEXT_POSIX_STATIC_NAME = libucontext_posix.a
|
LIBUCONTEXT_POSIX_STATIC_NAME = libucontext_posix.a
|
||||||
LIBUCONTEXT_POSIX_C_SRC = libucontext_posix.c
|
LIBUCONTEXT_POSIX_C_SRC = libucontext_posix.c
|
||||||
LIBUCONTEXT_POSIX_OBJ = ${LIBUCONTEXT_POSIX_C_SRC:.c=.o}
|
LIBUCONTEXT_POSIX_OBJ = ${LIBUCONTEXT_POSIX_C_SRC:.c=.o}
|
||||||
LIBUCONTEXT_POSIX_PATH = ${shared_libdir}/${LIBUCONTEXT_POSIX_SONAME}
|
LIBUCONTEXT_POSIX_PATH = ${LIBDIR}/${LIBUCONTEXT_POSIX_SONAME}
|
||||||
LIBUCONTEXT_POSIX_STATIC_PATH = ${static_libdir}/${LIBUCONTEXT_POSIX_STATIC_NAME}
|
LIBUCONTEXT_POSIX_STATIC_PATH = ${LIBDIR}/${LIBUCONTEXT_POSIX_STATIC_NAME}
|
||||||
|
|
||||||
ifeq ($(FREESTANDING),yes)
|
ifeq ($(FREESTANDING),yes)
|
||||||
LIBUCONTEXT_POSIX_NAME =
|
LIBUCONTEXT_POSIX_NAME =
|
||||||
|
@ -123,9 +107,8 @@ ${LIBUCONTEXT_SONAME}: ${LIBUCONTEXT_NAME}
|
||||||
|
|
||||||
${LIBUCONTEXT_PC}: libucontext.pc.in
|
${LIBUCONTEXT_PC}: libucontext.pc.in
|
||||||
sed -e s:@LIBUCONTEXT_VERSION@:${LIBUCONTEXT_VERSION}:g \
|
sed -e s:@LIBUCONTEXT_VERSION@:${LIBUCONTEXT_VERSION}:g \
|
||||||
-e s:@LIBUCONTEXT_SHARED_LIBDIR@:${shared_libdir}:g \
|
-e s:@LIBUCONTEXT_LIBDIR@:${LIBDIR}:g \
|
||||||
-e s:@LIBUCONTEXT_STATIC_LIBDIR@:${static_libdir}:g \
|
-e s:@LIBUCONTEXT_INCLUDEDIR@:${INCLUDEDIR}:g $< > $@
|
||||||
-e s:@LIBUCONTEXT_INCLUDEDIR@:${includedir}:g $< > $@
|
|
||||||
|
|
||||||
MANPAGES_SYMLINKS_3 = \
|
MANPAGES_SYMLINKS_3 = \
|
||||||
libucontext_getcontext.3 \
|
libucontext_getcontext.3 \
|
||||||
|
@ -209,13 +192,13 @@ clean: docs_clean
|
||||||
install: all
|
install: all
|
||||||
install -D -m755 ${LIBUCONTEXT_NAME} ${DESTDIR}${LIBUCONTEXT_PATH}
|
install -D -m755 ${LIBUCONTEXT_NAME} ${DESTDIR}${LIBUCONTEXT_PATH}
|
||||||
install -D -m664 ${LIBUCONTEXT_STATIC_NAME} ${DESTDIR}${LIBUCONTEXT_STATIC_PATH}
|
install -D -m664 ${LIBUCONTEXT_STATIC_NAME} ${DESTDIR}${LIBUCONTEXT_STATIC_PATH}
|
||||||
ln -sf ${LIBUCONTEXT_SONAME} ${DESTDIR}${shared_libdir}/${LIBUCONTEXT_NAME}
|
ln -sf ${LIBUCONTEXT_SONAME} ${DESTDIR}${LIBDIR}/${LIBUCONTEXT_NAME}
|
||||||
for i in ${LIBUCONTEXT_HEADERS}; do \
|
for i in ${LIBUCONTEXT_HEADERS}; do \
|
||||||
destfn=$$(echo $$i | sed s:include/::g); \
|
destfn=$$(echo $$i | sed s:include/::g); \
|
||||||
install -D -m644 $$i ${DESTDIR}${includedir}/$$destfn; \
|
install -D -m644 $$i ${DESTDIR}${INCLUDEDIR}/$$destfn; \
|
||||||
done
|
done
|
||||||
install -D -m644 ${LIBUCONTEXT_PC} ${DESTDIR}${pkgconfigdir}/${LIBUCONTEXT_PC}
|
install -D -m644 ${LIBUCONTEXT_PC} ${DESTDIR}${PKGCONFIGDIR}/${LIBUCONTEXT_PC}
|
||||||
if [ -n "${LIBUCONTEXT_POSIX_NAME}" ]; then \
|
if [ -n ${LIBUCONTEXT_POSIX_NAME} ]; then \
|
||||||
install -D -m755 ${LIBUCONTEXT_POSIX_NAME} ${DESTDIR}${LIBUCONTEXT_POSIX_PATH}; \
|
install -D -m755 ${LIBUCONTEXT_POSIX_NAME} ${DESTDIR}${LIBUCONTEXT_POSIX_PATH}; \
|
||||||
install -D -m644 ${LIBUCONTEXT_POSIX_STATIC_NAME} ${DESTDIR}${LIBUCONTEXT_POSIX_STATIC_PATH}; \
|
install -D -m644 ${LIBUCONTEXT_POSIX_STATIC_NAME} ${DESTDIR}${LIBUCONTEXT_POSIX_STATIC_PATH}; \
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -101,5 +101,4 @@ ucontext functions:
|
||||||
save/restore FPU registers or vector registers may be added in a later release as a build-time
|
save/restore FPU registers or vector registers may be added in a later release as a build-time
|
||||||
setting -- for now, we assume a soft-float ABI with no optional processor features. In practice, this
|
setting -- for now, we assume a soft-float ABI with no optional processor features. In practice, this
|
||||||
does not really matter, code using these functions are unlikely to be impacted by this design
|
does not really matter, code using these functions are unlikely to be impacted by this design
|
||||||
assumption. This is a work in progress, as newer compilers will spill even non-floating-point state
|
assumption.
|
||||||
through floating point registers when allowed to do so.
|
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
#define REG_SZ (4)
|
#define REG_SZ (4)
|
||||||
#define MCONTEXT_GREGS (32)
|
#define MCONTEXT_GREGS (32)
|
||||||
#define VFP_MAGIC_OFFSET (232)
|
|
||||||
#define VFP_D8_OFFSET (304)
|
|
||||||
|
|
||||||
#define TYPE(__proc) .type __proc, %function;
|
#define TYPE(__proc)
|
||||||
|
|
||||||
#define FETCH_LINKPTR(dest) \
|
#define FETCH_LINKPTR(dest) \
|
||||||
asm("movs %0, r4" : "=r" ((dest)))
|
asm("movs %0, r4" : "=r" ((dest)))
|
||||||
|
|
|
@ -22,27 +22,6 @@ FUNC(libucontext_getcontext)
|
||||||
str r13, [r0, #REG_OFFSET(13)]
|
str r13, [r0, #REG_OFFSET(13)]
|
||||||
str r14, [r0, #REG_OFFSET(15)]
|
str r14, [r0, #REG_OFFSET(15)]
|
||||||
|
|
||||||
#ifndef FORCE_SOFT_FLOAT
|
|
||||||
#ifndef FORCE_HARD_FLOAT
|
|
||||||
/* test for vfp, set kernel-defined magic number in uc_regspace */
|
|
||||||
push {r0-r1,fp,lr}
|
|
||||||
mov r0, #16
|
|
||||||
bl getauxval
|
|
||||||
tst r0, #64
|
|
||||||
pop {r0-r1,fp,lr}
|
|
||||||
moveq r2, #0
|
|
||||||
ldrne r2, =#0x56465001
|
|
||||||
str r2, [r0, #VFP_MAGIC_OFFSET]
|
|
||||||
beq 1f
|
|
||||||
#endif
|
|
||||||
/* if vfp detected, save d8-d15 */
|
|
||||||
.fpu vfp
|
|
||||||
add r1, r0, #VFP_D8_OFFSET
|
|
||||||
vstmia r1, {d8-d15}
|
|
||||||
.fpu softvfp
|
|
||||||
1:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* return 0 */
|
/* return 0 */
|
||||||
mov r0, #0
|
mov r0, #0
|
||||||
mov pc, lr
|
mov pc, lr
|
||||||
|
|
|
@ -23,8 +23,6 @@ typedef struct libucontext_ucontext {
|
||||||
struct libucontext_ucontext *uc_link;
|
struct libucontext_ucontext *uc_link;
|
||||||
libucontext_stack_t uc_stack;
|
libucontext_stack_t uc_stack;
|
||||||
libucontext_mcontext_t uc_mcontext;
|
libucontext_mcontext_t uc_mcontext;
|
||||||
unsigned long uc_sigmask[128 / sizeof(long)];
|
|
||||||
unsigned long long uc_regspace[64];
|
|
||||||
} libucontext_ucontext_t;
|
} libucontext_ucontext_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,22 +16,6 @@ ALIAS(setcontext, libucontext_setcontext)
|
||||||
ALIAS(__setcontext, libucontext_setcontext)
|
ALIAS(__setcontext, libucontext_setcontext)
|
||||||
|
|
||||||
FUNC(libucontext_setcontext)
|
FUNC(libucontext_setcontext)
|
||||||
#ifndef FORCE_SOFT_FLOAT
|
|
||||||
#ifndef FORCE_HARD_FLOAT
|
|
||||||
/* test for vfp magic number set by getcontext */
|
|
||||||
ldr r2, [r0, #VFP_MAGIC_OFFSET]
|
|
||||||
ldr r3, =#0x56465001
|
|
||||||
cmp r2, r3
|
|
||||||
bne 1f
|
|
||||||
#endif
|
|
||||||
/* if vfp in use, restore d8-d15 from uc_regspace */
|
|
||||||
.fpu vfp
|
|
||||||
add r14, r0, #VFP_D8_OFFSET
|
|
||||||
vldmia r14, {d8-d15}
|
|
||||||
.fpu softvfp
|
|
||||||
1:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* copy all of the current registers into the ucontext structure */
|
/* copy all of the current registers into the ucontext structure */
|
||||||
add r14, r0, #REG_OFFSET(0)
|
add r14, r0, #REG_OFFSET(0)
|
||||||
ldmia r14, {r0-r12}
|
ldmia r14, {r0-r12}
|
||||||
|
|
|
@ -22,26 +22,6 @@ FUNC(libucontext_swapcontext)
|
||||||
str r13, [r0,#REG_OFFSET(13)]
|
str r13, [r0,#REG_OFFSET(13)]
|
||||||
str r14, [r0,#REG_OFFSET(15)]
|
str r14, [r0,#REG_OFFSET(15)]
|
||||||
|
|
||||||
#ifndef FORCE_SOFT_FLOAT
|
|
||||||
#ifndef FORCE_HARD_FLOAT
|
|
||||||
/* test for vfp magic number, copy to other ucontext */
|
|
||||||
ldr r3, [r1, #VFP_MAGIC_OFFSET]
|
|
||||||
ldr r4, =#0x56465001
|
|
||||||
str r3, [r0, #VFP_MAGIC_OFFSET]
|
|
||||||
cmp r3, r4
|
|
||||||
bne 1f
|
|
||||||
#endif
|
|
||||||
/* if vfp in use, save and restore d8-d15 */
|
|
||||||
.fpu vfp
|
|
||||||
add r2, r0, #VFP_D8_OFFSET
|
|
||||||
vstmia r2, {d8-d15}
|
|
||||||
|
|
||||||
add r14, r1, #VFP_D8_OFFSET
|
|
||||||
vldmia r14, {d8-d15}
|
|
||||||
.fpu softvfp
|
|
||||||
1:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* load new registers from the second ucontext structure */
|
/* load new registers from the second ucontext structure */
|
||||||
add r14, r1, #REG_OFFSET(0)
|
add r14, r1, #REG_OFFSET(0)
|
||||||
ldmia r14, {r0-r12}
|
ldmia r14, {r0-r12}
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
scdoc = find_program('scdoc', required: true)
|
|
||||||
|
|
||||||
custom_target(
|
|
||||||
'libucontext.3',
|
|
||||||
output: 'libucontext.3',
|
|
||||||
input: 'libucontext.scd',
|
|
||||||
command: [ scdoc ],
|
|
||||||
feed: true,
|
|
||||||
capture: true,
|
|
||||||
install: true,
|
|
||||||
install_dir: get_option('mandir') / 'man3'
|
|
||||||
)
|
|
||||||
|
|
||||||
if meson.version().version_compare('>=0.61.0')
|
|
||||||
foreach link : [ 'get', 'make', 'set', 'swap' ]
|
|
||||||
install_symlink('libucontext_' + link + 'context.3',
|
|
||||||
pointing_to: 'libucontext.3',
|
|
||||||
install_dir: get_option('mandir') / 'man3'
|
|
||||||
)
|
|
||||||
endforeach
|
|
||||||
endif
|
|
|
@ -4,17 +4,9 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <libucontext/bits.h>
|
#include <libucontext/bits.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int libucontext_getcontext(libucontext_ucontext_t *);
|
int libucontext_getcontext(libucontext_ucontext_t *);
|
||||||
void libucontext_makecontext(libucontext_ucontext_t *, void (*)(), int, ...);
|
void libucontext_makecontext(libucontext_ucontext_t *, void (*)(), int, ...);
|
||||||
int libucontext_setcontext(const libucontext_ucontext_t *);
|
int libucontext_setcontext(const libucontext_ucontext_t *);
|
||||||
int libucontext_swapcontext(libucontext_ucontext_t *, const libucontext_ucontext_t *);
|
int libucontext_swapcontext(libucontext_ucontext_t *, const libucontext_ucontext_t *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
libdir=@LIBUCONTEXT_SHARED_LIBDIR@
|
libdir=@LIBUCONTEXT_LIBDIR@
|
||||||
static_libdir=@LIBUCONTEXT_STATIC_LIBDIR@
|
|
||||||
includedir=@LIBUCONTEXT_INCLUDEDIR@
|
includedir=@LIBUCONTEXT_INCLUDEDIR@
|
||||||
|
|
||||||
Name: libucontext
|
Name: libucontext
|
||||||
Version: @LIBUCONTEXT_VERSION@
|
Version: @LIBUCONTEXT_VERSION@
|
||||||
Description: ucontext library implementation (standalone)
|
Description: ucontext library implementation (standalone)
|
||||||
Libs: -L${libdir} -L${static_libdir} -lucontext
|
Libs: -L${libdir} -lucontext
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
project(
|
project(
|
||||||
'libucontext',
|
'libucontext',
|
||||||
'c',
|
'c',
|
||||||
meson_version : '>=0.59.0',
|
meson_version : '>=0.55.0',
|
||||||
default_options: ['c_std=gnu11', 'default_library=both'],
|
default_options: ['c_std=gnu11', 'default_library=both'],
|
||||||
version : run_command('head', files('VERSION')).stdout()
|
version : run_command('head', files('VERSION')).stdout()
|
||||||
)
|
)
|
||||||
|
@ -144,8 +144,9 @@ endif
|
||||||
# Docs
|
# Docs
|
||||||
# ====
|
# ====
|
||||||
|
|
||||||
if not meson.is_subproject() and get_option('docs')
|
# TODO: meson.build for docs
|
||||||
subdir('doc')
|
if not meson.is_subproject()
|
||||||
|
#subdir('docs')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# ==========
|
# ==========
|
||||||
|
|
|
@ -4,5 +4,3 @@ option('export_unprefixed', type : 'boolean', value : true,
|
||||||
description: 'Export POSIX 2004 ucontext names as alises')
|
description: 'Export POSIX 2004 ucontext names as alises')
|
||||||
option('cpu', type : 'string', value : '',
|
option('cpu', type : 'string', value : '',
|
||||||
description: 'Target CPU architecture for cross compile')
|
description: 'Target CPU architecture for cross compile')
|
||||||
option('docs', type : 'boolean', value : false,
|
|
||||||
description: 'Build and install man pages')
|
|
||||||
|
|
Loading…
Reference in New Issue