From 81a3e2b46db5474df3633b850805e5e981a6cbb4 Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 29 Apr 2012 11:04:31 +0000 Subject: Add a convenience macro for the returns_twice attribute, and apply it to the prototypes of the appropriate functions (getcontext, savectx, setjmp, sigsetjmp and vfork). MFC after: 2 weeks --- include/setjmp.h | 6 +++--- include/unistd.h | 2 +- sys/amd64/include/pcb.h | 2 +- sys/arm/include/pcb.h | 2 +- sys/i386/include/pcb.h | 2 +- sys/ia64/include/pcb.h | 4 ++-- sys/mips/include/pcb.h | 2 +- sys/powerpc/include/cpu.h | 2 +- sys/sparc64/include/pcb.h | 2 +- sys/sys/cdefs.h | 6 ++++++ sys/sys/systm.h | 2 +- sys/sys/ucontext.h | 2 +- 12 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/setjmp.h b/include/setjmp.h index 49d4ed5..bf03f6f 100644 --- a/include/setjmp.h +++ b/include/setjmp.h @@ -46,16 +46,16 @@ __BEGIN_DECLS #if __BSD_VISIBLE || __XSI_VISIBLE >= 600 void _longjmp(jmp_buf, int) __dead2; -int _setjmp(jmp_buf); +int _setjmp(jmp_buf) __returns_twice; #endif void longjmp(jmp_buf, int) __dead2; #if __BSD_VISIBLE void longjmperror(void); #endif -int setjmp(jmp_buf); +int setjmp(jmp_buf) __returns_twice; #if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE void siglongjmp(sigjmp_buf, int) __dead2; -int sigsetjmp(sigjmp_buf, int); +int sigsetjmp(sigjmp_buf, int) __returns_twice; #endif __END_DECLS diff --git a/include/unistd.h b/include/unistd.h index 90694ed..9b2f2ec 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -479,7 +479,7 @@ char *getwd(char *); /* obsoleted by getcwd() */ useconds_t ualarm(useconds_t, useconds_t); int usleep(useconds_t); -pid_t vfork(void); +pid_t vfork(void) __returns_twice; #endif #if __BSD_VISIBLE diff --git a/sys/amd64/include/pcb.h b/sys/amd64/include/pcb.h index 61f651bb..70b2e62 100644 --- a/sys/amd64/include/pcb.h +++ b/sys/amd64/include/pcb.h @@ -130,7 +130,7 @@ clear_pcb_flags(struct pcb *pcb, const u_int flags) } void makectx(struct trapframe *, struct pcb *); -int savectx(struct pcb *); +int savectx(struct pcb *) __returns_twice; #endif diff --git a/sys/arm/include/pcb.h b/sys/arm/include/pcb.h index 4a5f330..ce9ab97 100644 --- a/sys/arm/include/pcb.h +++ b/sys/arm/include/pcb.h @@ -94,7 +94,7 @@ void makectx(struct trapframe *tf, struct pcb *pcb); #ifdef _KERNEL -void savectx(struct pcb *); +void savectx(struct pcb *) __returns_twice; #endif /* _KERNEL */ #endif /* !_MACHINE_PCB_H_ */ diff --git a/sys/i386/include/pcb.h b/sys/i386/include/pcb.h index 1311ab1..4c227df 100644 --- a/sys/i386/include/pcb.h +++ b/sys/i386/include/pcb.h @@ -84,7 +84,7 @@ struct pcb { struct trapframe; void makectx(struct trapframe *, struct pcb *); -void savectx(struct pcb *); +void savectx(struct pcb *) __returns_twice; #endif #endif /* _I386_PCB_H_ */ diff --git a/sys/ia64/include/pcb.h b/sys/ia64/include/pcb.h index 59334bf..dac7169 100644 --- a/sys/ia64/include/pcb.h +++ b/sys/ia64/include/pcb.h @@ -65,10 +65,10 @@ struct trapframe; void makectx(struct trapframe *, struct pcb *); void restorectx(struct pcb *) __dead2; -int swapctx(struct pcb *old, struct pcb *new); +int swapctx(struct pcb *old, struct pcb *new) __returns_twice; void ia32_restorectx(struct pcb *); -void ia32_savectx(struct pcb *); +void ia32_savectx(struct pcb *) __returns_twice; #endif diff --git a/sys/mips/include/pcb.h b/sys/mips/include/pcb.h index 9911339..52589f5 100644 --- a/sys/mips/include/pcb.h +++ b/sys/mips/include/pcb.h @@ -78,7 +78,7 @@ struct pcb extern struct pcb *curpcb; /* the current running pcb */ void makectx(struct trapframe *, struct pcb *); -int savectx(struct pcb *); +int savectx(struct pcb *) __returns_twice; #endif #endif /* !_MACHINE_PCB_H_ */ diff --git a/sys/powerpc/include/cpu.h b/sys/powerpc/include/cpu.h index 73b1f50..66d21eb 100644 --- a/sys/powerpc/include/cpu.h +++ b/sys/powerpc/include/cpu.h @@ -99,6 +99,6 @@ void fork_trampoline(void); void swi_vm(void *); /* XXX the following should not be here. */ -void savectx(struct pcb *); +void savectx(struct pcb *) __returns_twice; #endif /* _MACHINE_CPU_H_ */ diff --git a/sys/sparc64/include/pcb.h b/sys/sparc64/include/pcb.h index f23c1f2..25a41cc 100644 --- a/sys/sparc64/include/pcb.h +++ b/sys/sparc64/include/pcb.h @@ -55,7 +55,7 @@ struct pcb { #ifdef _KERNEL void makectx(struct trapframe *tf, struct pcb *pcb); -int savectx(struct pcb *pcb); +int savectx(struct pcb *pcb) __returns_twice; #endif #endif /* !LOCORE */ diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 076842d..80f7b8e 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -293,6 +293,12 @@ #define __nonnull(x) #endif +#if __GNUC_PREREQ__(4, 1) +#define __returns_twice __attribute__((__returns_twice__)) +#else +#define __returns_twice +#endif + /* XXX: should use `#if __STDC_VERSION__ < 199901'. */ #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) #define __func__ NULL diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 5375ec4..fec77d2 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -153,7 +153,7 @@ struct uio; struct _jmp_buf; struct trapframe; -int setjmp(struct _jmp_buf *); +int setjmp(struct _jmp_buf *) __returns_twice; void longjmp(struct _jmp_buf *, int) __dead2; int dumpstatus(vm_offset_t addr, off_t count); int nullop(void); diff --git a/sys/sys/ucontext.h b/sys/sys/ucontext.h index 609cdd3..1e504c9 100644 --- a/sys/sys/ucontext.h +++ b/sys/sys/ucontext.h @@ -71,7 +71,7 @@ struct ucontext4 { __BEGIN_DECLS -int getcontext(ucontext_t *); +int getcontext(ucontext_t *) __returns_twice; ucontext_t *getcontextx(void); int setcontext(const ucontext_t *); void makecontext(ucontext_t *, void (*)(void), int, ...); -- cgit v1.1