Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
matoro | be80075e95 | |
Ariadne Conill | 4c2cfc54ac | |
L. Pereira | 0f625a86ee | |
Ismael Luceno | 8e1397f5a2 | |
Ariadne Conill | 33ff253d52 | |
Richard Campbell | 3044c2b908 | |
Ariadne Conill | 128e4fdc4b | |
Richard Campbell | 5244775fb9 | |
Richard Campbell | 9abcd8afe0 | |
Richard Campbell | 7bc3e90984 |
43
Makefile
43
Makefile
|
@ -17,9 +17,13 @@ ifeq ($(ARCH),$(filter $(ARCH),arm64))
|
|||
override ARCH = aarch64
|
||||
endif
|
||||
|
||||
LIBDIR := /lib
|
||||
INCLUDEDIR := /usr/include
|
||||
PKGCONFIGDIR := /usr/lib/pkgconfig
|
||||
prefix = /usr
|
||||
libdir = ${prefix}/lib
|
||||
shared_libdir = ${libdir}
|
||||
static_libdir = ${libdir}
|
||||
includedir = ${prefix}/include
|
||||
pkgconfigdir = ${prefix}/lib/pkgconfig
|
||||
|
||||
CFLAGS ?= -ggdb3 -O2 -Wall
|
||||
CPPFLAGS := -Iinclude -Iarch/${ARCH} -Iarch/common
|
||||
ifneq ($(shell uname),Darwin)
|
||||
|
@ -35,6 +39,18 @@ ifeq ($(FREESTANDING),yes)
|
|||
EXPORT_UNPREFIXED = no
|
||||
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)
|
||||
CPPFLAGS += -DEXPORT_UNPREFIXED
|
||||
endif
|
||||
|
@ -67,8 +83,8 @@ else
|
|||
endif
|
||||
LIBUCONTEXT_STATIC_NAME = libucontext.a
|
||||
LIBUCONTEXT_PC = libucontext.pc
|
||||
LIBUCONTEXT_PATH = ${LIBDIR}/${LIBUCONTEXT_SONAME}
|
||||
LIBUCONTEXT_STATIC_PATH = ${LIBDIR}/${LIBUCONTEXT_STATIC_NAME}
|
||||
LIBUCONTEXT_PATH = ${shared_libdir}/${LIBUCONTEXT_SONAME}
|
||||
LIBUCONTEXT_STATIC_PATH = ${static_libdir}/${LIBUCONTEXT_STATIC_NAME}
|
||||
LIBUCONTEXT_HEADERS = \
|
||||
include/libucontext/libucontext.h \
|
||||
include/libucontext/bits.h
|
||||
|
@ -77,8 +93,8 @@ LIBUCONTEXT_EXAMPLES = \
|
|||
LIBUCONTEXT_POSIX_STATIC_NAME = libucontext_posix.a
|
||||
LIBUCONTEXT_POSIX_C_SRC = libucontext_posix.c
|
||||
LIBUCONTEXT_POSIX_OBJ = ${LIBUCONTEXT_POSIX_C_SRC:.c=.o}
|
||||
LIBUCONTEXT_POSIX_PATH = ${LIBDIR}/${LIBUCONTEXT_POSIX_SONAME}
|
||||
LIBUCONTEXT_POSIX_STATIC_PATH = ${LIBDIR}/${LIBUCONTEXT_POSIX_STATIC_NAME}
|
||||
LIBUCONTEXT_POSIX_PATH = ${shared_libdir}/${LIBUCONTEXT_POSIX_SONAME}
|
||||
LIBUCONTEXT_POSIX_STATIC_PATH = ${static_libdir}/${LIBUCONTEXT_POSIX_STATIC_NAME}
|
||||
|
||||
ifeq ($(FREESTANDING),yes)
|
||||
LIBUCONTEXT_POSIX_NAME =
|
||||
|
@ -107,8 +123,9 @@ ${LIBUCONTEXT_SONAME}: ${LIBUCONTEXT_NAME}
|
|||
|
||||
${LIBUCONTEXT_PC}: libucontext.pc.in
|
||||
sed -e s:@LIBUCONTEXT_VERSION@:${LIBUCONTEXT_VERSION}:g \
|
||||
-e s:@LIBUCONTEXT_LIBDIR@:${LIBDIR}:g \
|
||||
-e s:@LIBUCONTEXT_INCLUDEDIR@:${INCLUDEDIR}:g $< > $@
|
||||
-e s:@LIBUCONTEXT_SHARED_LIBDIR@:${shared_libdir}:g \
|
||||
-e s:@LIBUCONTEXT_STATIC_LIBDIR@:${static_libdir}:g \
|
||||
-e s:@LIBUCONTEXT_INCLUDEDIR@:${includedir}:g $< > $@
|
||||
|
||||
MANPAGES_SYMLINKS_3 = \
|
||||
libucontext_getcontext.3 \
|
||||
|
@ -192,13 +209,13 @@ clean: docs_clean
|
|||
install: all
|
||||
install -D -m755 ${LIBUCONTEXT_NAME} ${DESTDIR}${LIBUCONTEXT_PATH}
|
||||
install -D -m664 ${LIBUCONTEXT_STATIC_NAME} ${DESTDIR}${LIBUCONTEXT_STATIC_PATH}
|
||||
ln -sf ${LIBUCONTEXT_SONAME} ${DESTDIR}${LIBDIR}/${LIBUCONTEXT_NAME}
|
||||
ln -sf ${LIBUCONTEXT_SONAME} ${DESTDIR}${shared_libdir}/${LIBUCONTEXT_NAME}
|
||||
for i in ${LIBUCONTEXT_HEADERS}; do \
|
||||
destfn=$$(echo $$i | sed s:include/::g); \
|
||||
install -D -m644 $$i ${DESTDIR}${INCLUDEDIR}/$$destfn; \
|
||||
install -D -m644 $$i ${DESTDIR}${includedir}/$$destfn; \
|
||||
done
|
||||
install -D -m644 ${LIBUCONTEXT_PC} ${DESTDIR}${PKGCONFIGDIR}/${LIBUCONTEXT_PC}
|
||||
if [ -n ${LIBUCONTEXT_POSIX_NAME} ]; then \
|
||||
install -D -m644 ${LIBUCONTEXT_PC} ${DESTDIR}${pkgconfigdir}/${LIBUCONTEXT_PC}
|
||||
if [ -n "${LIBUCONTEXT_POSIX_NAME}" ]; then \
|
||||
install -D -m755 ${LIBUCONTEXT_POSIX_NAME} ${DESTDIR}${LIBUCONTEXT_POSIX_PATH}; \
|
||||
install -D -m644 ${LIBUCONTEXT_POSIX_STATIC_NAME} ${DESTDIR}${LIBUCONTEXT_POSIX_STATIC_PATH}; \
|
||||
fi
|
||||
|
|
|
@ -101,4 +101,5 @@ ucontext functions:
|
|||
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
|
||||
does not really matter, code using these functions are unlikely to be impacted by this design
|
||||
assumption.
|
||||
assumption. This is a work in progress, as newer compilers will spill even non-floating-point state
|
||||
through floating point registers when allowed to do so.
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
#define REG_SZ (4)
|
||||
#define MCONTEXT_GREGS (32)
|
||||
#define VFP_MAGIC_OFFSET (232)
|
||||
#define VFP_D8_OFFSET (304)
|
||||
|
||||
#define TYPE(__proc)
|
||||
#define TYPE(__proc) .type __proc, %function;
|
||||
|
||||
#define FETCH_LINKPTR(dest) \
|
||||
asm("movs %0, r4" : "=r" ((dest)))
|
||||
|
|
|
@ -22,6 +22,27 @@ FUNC(libucontext_getcontext)
|
|||
str r13, [r0, #REG_OFFSET(13)]
|
||||
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 */
|
||||
mov r0, #0
|
||||
mov pc, lr
|
||||
|
|
|
@ -23,6 +23,8 @@ typedef struct libucontext_ucontext {
|
|||
struct libucontext_ucontext *uc_link;
|
||||
libucontext_stack_t uc_stack;
|
||||
libucontext_mcontext_t uc_mcontext;
|
||||
unsigned long uc_sigmask[128 / sizeof(long)];
|
||||
unsigned long long uc_regspace[64];
|
||||
} libucontext_ucontext_t;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,6 +16,22 @@ ALIAS(setcontext, libucontext_setcontext)
|
|||
ALIAS(__setcontext, 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 */
|
||||
add r14, r0, #REG_OFFSET(0)
|
||||
ldmia r14, {r0-r12}
|
||||
|
|
|
@ -22,6 +22,26 @@ FUNC(libucontext_swapcontext)
|
|||
str r13, [r0,#REG_OFFSET(13)]
|
||||
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 */
|
||||
add r14, r1, #REG_OFFSET(0)
|
||||
ldmia r14, {r0-r12}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
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,9 +4,17 @@
|
|||
#include <stddef.h>
|
||||
#include <libucontext/bits.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int libucontext_getcontext(libucontext_ucontext_t *);
|
||||
void libucontext_makecontext(libucontext_ucontext_t *, void (*)(), int, ...);
|
||||
int libucontext_setcontext(const libucontext_ucontext_t *);
|
||||
int libucontext_swapcontext(libucontext_ucontext_t *, const libucontext_ucontext_t *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
libdir=@LIBUCONTEXT_LIBDIR@
|
||||
libdir=@LIBUCONTEXT_SHARED_LIBDIR@
|
||||
static_libdir=@LIBUCONTEXT_STATIC_LIBDIR@
|
||||
includedir=@LIBUCONTEXT_INCLUDEDIR@
|
||||
|
||||
Name: libucontext
|
||||
Version: @LIBUCONTEXT_VERSION@
|
||||
Description: ucontext library implementation (standalone)
|
||||
Libs: -L${libdir} -lucontext
|
||||
Libs: -L${libdir} -L${static_libdir} -lucontext
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
project(
|
||||
'libucontext',
|
||||
'c',
|
||||
meson_version : '>=0.55.0',
|
||||
meson_version : '>=0.59.0',
|
||||
default_options: ['c_std=gnu11', 'default_library=both'],
|
||||
version : run_command('head', files('VERSION')).stdout()
|
||||
)
|
||||
|
@ -144,9 +144,8 @@ endif
|
|||
# Docs
|
||||
# ====
|
||||
|
||||
# TODO: meson.build for docs
|
||||
if not meson.is_subproject()
|
||||
#subdir('docs')
|
||||
if not meson.is_subproject() and get_option('docs')
|
||||
subdir('doc')
|
||||
endif
|
||||
|
||||
# ==========
|
||||
|
|
|
@ -4,3 +4,5 @@ option('export_unprefixed', type : 'boolean', value : true,
|
|||
description: 'Export POSIX 2004 ucontext names as alises')
|
||||
option('cpu', type : 'string', value : '',
|
||||
description: 'Target CPU architecture for cross compile')
|
||||
option('docs', type : 'boolean', value : false,
|
||||
description: 'Build and install man pages')
|
||||
|
|
Loading…
Reference in New Issue