# rts sources
-.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/sys-minix
+HERE=${.CURDIR}/arch/${MACHINE_ARCH}/sys-minix
+.PATH: ${HERE}
+
+TMP=ucontextoffsets.h.tmp
+INCLS=../../include
+ARCHINCLS=$(INCLS)/arch/i386/include/
+CF=ucontextoffsets.cf
+
+INCS+=ucontextoffsets.h
+
+ucontext.d: ucontextoffsets.h
SRCS+= \
__sigreturn.S \
_senda.S \
brksize.S \
ucontext.S
+
+ucontextoffsets.h: $(CF) $(ARCHINCLS)/stackframe.h $(INCLS)/sys/ucontext.h
+ ${_MKTARGET_CREATE}
+ cat ${HERE}/$(CF) | \
+ ${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} >$TMP && \
+ mv -f $TMP $@
+
#include <machine/asm.h>
+#include <ucontextoffsets.h>
#ifdef __ACK__
.text
IMPORT(resumecontext)
-/* Offsets into ucontext_t structure. Keep in sync with <sys/ucontext.h>! */
-#define UC_FLAGS 0
-#define UC_LINK UC_FLAGS + 4
-#define MCTX UC_LINK + 4
-#define MAGIC MCTX
-#define GS MAGIC+4
-#define FS GS+2
-#define ES FS+2
-#define DS ES+2
-#define DI DS+2
-#define SI DI+4
-#define BP SI+4
-#define ST BP+4 /* Hole for another SP */
-#define BX ST+4
-#define DX BX+4
-#define CX DX+4
-#define AX CX+4
-#define RETADR AX+4
-#define PC RETADR+4
-#define CS PC+4
-#define PSW CS+4
-#define SP PSW+4
-#define SS SP+4
-
-
/* MCF_MAGIC value from <mcontext.h> */
#define MCF_MAGIC 0xc0ffee
--- /dev/null
+
+include <minix/type.h>
+include <sys/ucontext.h>
+
+struct __ucontext
+member UC_FLAGS uc_flags
+member UC_LINK uc_link
+member MAGIC uc_mcontext.mc_magic
+member DI uc_mcontext.mc_p_reg.di
+member SI uc_mcontext.mc_p_reg.si
+member BP uc_mcontext.mc_p_reg.fp
+member AX uc_mcontext.mc_p_reg.retreg
+member BX uc_mcontext.mc_p_reg.bx
+member CX uc_mcontext.mc_p_reg.cx
+member DX uc_mcontext.mc_p_reg.dx
+member PC uc_mcontext.mc_p_reg.pc
+member SP uc_mcontext.mc_p_reg.sp
+