diff mbox

[v3] librt: fix mq_timed{send,receive} return instructions

Message ID 415b8a900c65f0ca9a3441847635d85d79ef60bc.1383817616.git.baruch@tkos.co.il
State Superseded
Headers show

Commit Message

Baruch Siach Nov. 7, 2013, 9:52 a.m. UTC
Not all architectures use 'ret' as function return instruction. For example,
xtensa usually uses 'retw'. Use the ret_ERRVAL arch dependant macro instead.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
v3: Add a common ret_ERRVAL, and redefine for special archs (Bernhard
	Reutner-Fischer)

v2: Add ret_ERRVAL to architectures missing it as noted by Bernhard
	Reutner-Fischer.
---
 libc/sysdeps/linux/arm/sysdep.h               | 1 +
 libc/sysdeps/linux/common/sysdep.h            | 4 ++++
 libc/sysdeps/linux/i386/sysdep.h              | 2 --
 libc/sysdeps/linux/ia64/sysdep.h              | 1 -
 libc/sysdeps/linux/mips/sysdep.h              | 2 --
 libc/sysdeps/linux/powerpc/powerpc32/sysdep.h | 1 +
 libc/sysdeps/linux/powerpc/powerpc64/sysdep.h | 1 +
 libc/sysdeps/linux/sh/sysdep.h                | 2 --
 libc/sysdeps/linux/x86_64/sysdep.h            | 2 --
 librt/mq_timedreceive.S                       | 2 +-
 librt/mq_timedsend.S                          | 2 +-
 11 files changed, 9 insertions(+), 11 deletions(-)

Comments

Bernhard Reutner-Fischer Nov. 7, 2013, 11:32 a.m. UTC | #1
On 7 November 2013 10:52, Baruch Siach <baruch@tkos.co.il> wrote:
> Not all architectures use 'ret' as function return instruction. For example,
> xtensa usually uses 'retw'. Use the ret_ERRVAL arch dependant macro instead.
>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> v3: Add a common ret_ERRVAL, and redefine for special archs (Bernhard
>         Reutner-Fischer)
>
> v2: Add ret_ERRVAL to architectures missing it as noted by Bernhard
>         Reutner-Fischer.
> ---
>  libc/sysdeps/linux/arm/sysdep.h               | 1 +
>  libc/sysdeps/linux/common/sysdep.h            | 4 ++++
>  libc/sysdeps/linux/i386/sysdep.h              | 2 --
>  libc/sysdeps/linux/ia64/sysdep.h              | 1 -
>  libc/sysdeps/linux/mips/sysdep.h              | 2 --
>  libc/sysdeps/linux/powerpc/powerpc32/sysdep.h | 1 +
>  libc/sysdeps/linux/powerpc/powerpc64/sysdep.h | 1 +
>  libc/sysdeps/linux/sh/sysdep.h                | 2 --
>  libc/sysdeps/linux/x86_64/sysdep.h            | 2 --
>  librt/mq_timedreceive.S                       | 2 +-
>  librt/mq_timedsend.S                          | 2 +-
>  11 files changed, 9 insertions(+), 11 deletions(-)

And where does e.g. xtensa pick that up?
Can you commonize these, i.e. make sure that common/sysdep.h is
included first, #defining unconditional the defaults, arches
redefining stuff where they diverge.
Then, as a second, follow-up fix librt to make use of the new ret_ERRVAL.
Bonus points if you don't break any arch :)

thanks..
Baruch Siach Nov. 7, 2013, 11:43 a.m. UTC | #2
Hi Bernhard,

On Thu, Nov 07, 2013 at 12:32:49PM +0100, Bernhard Reutner-Fischer wrote:
> On 7 November 2013 10:52, Baruch Siach <baruch@tkos.co.il> wrote:
> > Not all architectures use 'ret' as function return instruction. For example,
> > xtensa usually uses 'retw'. Use the ret_ERRVAL arch dependant macro instead.
> >
> > Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> > ---
> > v3: Add a common ret_ERRVAL, and redefine for special archs (Bernhard
> >         Reutner-Fischer)
> >
> > v2: Add ret_ERRVAL to architectures missing it as noted by Bernhard
> >         Reutner-Fischer.
> > ---
> >  libc/sysdeps/linux/arm/sysdep.h               | 1 +
> >  libc/sysdeps/linux/common/sysdep.h            | 4 ++++
> >  libc/sysdeps/linux/i386/sysdep.h              | 2 --
> >  libc/sysdeps/linux/ia64/sysdep.h              | 1 -
> >  libc/sysdeps/linux/mips/sysdep.h              | 2 --
> >  libc/sysdeps/linux/powerpc/powerpc32/sysdep.h | 1 +
> >  libc/sysdeps/linux/powerpc/powerpc64/sysdep.h | 1 +
> >  libc/sysdeps/linux/sh/sysdep.h                | 2 --
> >  libc/sysdeps/linux/x86_64/sysdep.h            | 2 --
> >  librt/mq_timedreceive.S                       | 2 +-
> >  librt/mq_timedsend.S                          | 2 +-
> >  11 files changed, 9 insertions(+), 11 deletions(-)
> 
> And where does e.g. xtensa pick that up?

xtensa defines ret_ERRVAL as 'retw' already, but the 'undef' is missing. I'll 
add it in my next version of this patch.

> Can you commonize these, i.e. make sure that common/sysdep.h is
> included first, #defining unconditional the defaults, arches
> redefining stuff where they diverge.
> Then, as a second, follow-up fix librt to make use of the new ret_ERRVAL.
> Bonus points if you don't break any arch :)

OK. I can't promise anything about not breaking other archs, though, but I'll 
try.

baruch
diff mbox

Patch

diff --git a/libc/sysdeps/linux/arm/sysdep.h b/libc/sysdeps/linux/arm/sysdep.h
index d4a86d3..5c751f5 100644
--- a/libc/sysdeps/linux/arm/sysdep.h
+++ b/libc/sysdeps/linux/arm/sysdep.h
@@ -156,6 +156,7 @@ 
 #define	PSEUDO_END_ERRVAL(name) \
   END (name)
 
+#undef ret_ERRVAL
 #define ret_ERRVAL PSEUDO_RET_NOERRNO
 
 #if defined NOT_IN_libc
diff --git a/libc/sysdeps/linux/common/sysdep.h b/libc/sysdeps/linux/common/sysdep.h
index 8e39b5b..9c9b69a 100644
--- a/libc/sysdeps/linux/common/sysdep.h
+++ b/libc/sysdeps/linux/common/sysdep.h
@@ -48,6 +48,10 @@ 
 #define JUMPTARGET(sym)		sym
 #endif
 
+#ifndef ret_ERRVAL
+#define ret_ERRVAL ret
+#endif
+
 /* Macros to generate eh_frame unwind information.  */
 # ifdef HAVE_ASM_CFI_DIRECTIVES
 #  define cfi_sections(sect...) 	.cfi_sections sect
diff --git a/libc/sysdeps/linux/i386/sysdep.h b/libc/sysdeps/linux/i386/sysdep.h
index 7a8d2e2..40088ad 100644
--- a/libc/sysdeps/linux/i386/sysdep.h
+++ b/libc/sysdeps/linux/i386/sysdep.h
@@ -195,8 +195,6 @@  __x86.get_pc_thunk.reg:						      \
 #define	PSEUDO_END_ERRVAL(name) \
   END (name)
 
-#define ret_ERRVAL ret
-
 #ifndef __PIC__
 # define SYSCALL_ERROR_HANDLER	/* Nothing here; code in sysdep.S is used.  */
 #else
diff --git a/libc/sysdeps/linux/ia64/sysdep.h b/libc/sysdeps/linux/ia64/sysdep.h
index eacc22b..7cbd77e 100644
--- a/libc/sysdeps/linux/ia64/sysdep.h
+++ b/libc/sysdeps/linux/ia64/sysdep.h
@@ -169,7 +169,6 @@ 
 
 #define ret			br.ret.sptk.few b0
 #define ret_NOERRNO		ret
-#define ret_ERRVAL		ret
 
 #endif /* not __ASSEMBLER__ */
 
diff --git a/libc/sysdeps/linux/mips/sysdep.h b/libc/sysdeps/linux/mips/sysdep.h
index 04e0da5..6dba1fb 100644
--- a/libc/sysdeps/linux/mips/sysdep.h
+++ b/libc/sysdeps/linux/mips/sysdep.h
@@ -77,8 +77,6 @@ 
 #undef PSEUDO_END_ERRVAL
 #define PSEUDO_END_ERRVAL(sym) .end sym; .size sym,.-sym
 
-#define ret_ERRVAL ret
-
 #define r0	v0
 #define r1	v1
 /* The mips move insn is d,s.  */
diff --git a/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h b/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h
index 6d641dc..d9a4704 100644
--- a/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h
+++ b/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h
@@ -132,6 +132,7 @@ 
 
 #define PSEUDO_RET_ERRVAL						      \
     blr
+#undef ret_ERRVAL
 #define ret_ERRVAL PSEUDO_RET_ERRVAL
 
 #undef	PSEUDO_END_ERRVAL
diff --git a/libc/sysdeps/linux/powerpc/powerpc64/sysdep.h b/libc/sysdeps/linux/powerpc/powerpc64/sysdep.h
index 701fad8..902b63b 100644
--- a/libc/sysdeps/linux/powerpc/powerpc64/sysdep.h
+++ b/libc/sysdeps/linux/powerpc/powerpc64/sysdep.h
@@ -227,6 +227,7 @@  LT_LABELSUFFIX(name,_name_end): ; \
 #define PSEUDO_RET_ERRVAL \
     blr
 
+#undef ret_ERRVAL
 #define ret_ERRVAL PSEUDO_RET_ERRVAL
 
 #undef	PSEUDO_END_ERRVAL
diff --git a/libc/sysdeps/linux/sh/sysdep.h b/libc/sysdeps/linux/sh/sysdep.h
index c692617..69bcbe1 100644
--- a/libc/sysdeps/linux/sh/sysdep.h
+++ b/libc/sysdeps/linux/sh/sysdep.h
@@ -141,8 +141,6 @@ 
 #define	PSEUDO_END_ERRVAL(name) \
   END (name)
 
-#define ret_ERRVAL ret
-
 #ifndef __PIC__
 # define SYSCALL_ERROR_HANDLER	\
 	mov.l 0f,r1; \
diff --git a/libc/sysdeps/linux/x86_64/sysdep.h b/libc/sysdeps/linux/x86_64/sysdep.h
index fdf7de1..ed7e26e 100644
--- a/libc/sysdeps/linux/x86_64/sysdep.h
+++ b/libc/sysdeps/linux/x86_64/sysdep.h
@@ -182,8 +182,6 @@  lose:									      \
 # define PSEUDO_END_ERRVAL(name) \
   END (name)
 
-# define ret_ERRVAL ret
-
 # ifndef __PIC__
 #  define SYSCALL_ERROR_HANDLER	/* Nothing here; code in sysdep.S is used.  */
 # elif defined(RTLD_PRIVATE_ERRNO)
diff --git a/librt/mq_timedreceive.S b/librt/mq_timedreceive.S
index 43a5fda..00fecac 100644
--- a/librt/mq_timedreceive.S
+++ b/librt/mq_timedreceive.S
@@ -3,6 +3,6 @@ 
 #error Missing definition of NR_timedreceive needed for cancellation.
 #endif
 PSEUDO(mq_timedreceive, mq_timedreceive, 5)
-ret
+ret_ERRVAL
 PSEUDO_END(mq_timedreceive)
 librt_hidden_def(mq_timedreceive)
diff --git a/librt/mq_timedsend.S b/librt/mq_timedsend.S
index 13d91da..ee8d483 100644
--- a/librt/mq_timedsend.S
+++ b/librt/mq_timedsend.S
@@ -3,6 +3,6 @@ 
 #error Missing definition of NR_timedsend needed for cancellation.
 #endif
 PSEUDO(mq_timedsend, mq_timedsend, 5)
-ret
+ret_ERRVAL
 PSEUDO_END(mq_timedsend)
 librt_hidden_def(mq_timedsend)