From 7f48e8a8b3e241579f57d0b5b91db1449ba96fe8 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 17 Jul 2008 19:04:26 +0000 Subject: [PATCH] 2008-07-17 Ken Werner * spu/syscalls.c: Check and set the errno value. --- libgloss/ChangeLog | 4 ++++ libgloss/spu/syscalls.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index 255f7a42c..8811889cb 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,3 +1,7 @@ +2008-07-17 Ken Werner + + * spu/syscalls.c: Check and set the errno value. + 2008-06-17 Ken Werner * spu/Makefile.in: Add new file. diff --git a/libgloss/spu/syscalls.c b/libgloss/spu/syscalls.c index f2f292853..7e85fa502 100644 --- a/libgloss/spu/syscalls.c +++ b/libgloss/spu/syscalls.c @@ -29,6 +29,7 @@ POSSIBILITY OF SUCH DAMAGE. Author: Andreas Neukoetter (ti95neuk@de.ibm.com) */ +#include #include #include "jsre.h" @@ -36,6 +37,7 @@ int __send_to_ppe (unsigned int signalcode, unsigned int opcode, void *data) { + int newerrno; unsigned int combined = ( ( opcode<<24 )&0xff000000 ) | ( ( unsigned int )data & 0x00ffffff ); __vector unsigned int stopfunc = { @@ -48,7 +50,13 @@ __send_to_ppe (unsigned int signalcode, unsigned int opcode, void *data) void (*f) (void) = (void *) &stopfunc; asm ("sync"); f (); - errno = ((unsigned int *) data)[3]; + newerrno = ((unsigned int *) data)[3]; + /* + * Note: branchless code to conditionally set errno using + * spu_cmpeq and spu_sel used more space than the following. + */ + if (newerrno) + errno = newerrno; /* * Return the rc code stored in slot 0.