about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/shmat.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-03-16 19:28:51 -0700
committerDavid S. Miller <davem@davemloft.net>2012-03-16 19:28:51 -0700
commit374976dd138bd4d74608d5658c84c0e257716d0b (patch)
treefe923ac3e59dcc6ef45922b00a894beaa52c3481 /sysdeps/unix/sysv/linux/shmat.c
parentedc218041ef05fde20a7f7e6b24033a72deedce1 (diff)
downloadglibc-374976dd138bd4d74608d5658c84c0e257716d0b.tar.gz
glibc-374976dd138bd4d74608d5658c84c0e257716d0b.tar.xz
glibc-374976dd138bd4d74608d5658c84c0e257716d0b.zip
Fix SHMLBA on sparc.
	[BZ #6471]
	* sysdeps/unix/sysv/linux/shmat.c (shmat): Test for syscall errors
	properly.
	* sysdeps/unix/sysv/linux/sparc/getshmlba.c: New file.
	* sysdeps/unix/sysv/linux/sparc/Makefile: Add getshmlba to
	sysdep_routines when subdir is sysvipc.
	* sysdeps/unix/sysv/linux/sparc/bits/shm.h (SHMLBA): Use new
	__getshmlba helper.
Diffstat (limited to 'sysdeps/unix/sysv/linux/shmat.c')
-rw-r--r--sysdeps/unix/sysv/linux/shmat.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c
index 2eec6a6e62..dd75491ce4 100644
--- a/sysdeps/unix/sysv/linux/shmat.c
+++ b/sysdeps/unix/sysv/linux/shmat.c
@@ -35,7 +35,8 @@ shmat (shmid, shmaddr, shmflg)
      const void *shmaddr;
      int shmflg;
 {
-  void *__unbounded result;
+  INTERNAL_SYSCALL_DECL(err);
+  unsigned long resultvar;
   void *__unbounded raddr;
 
 #if __BOUNDED_POINTERS__
@@ -47,12 +48,15 @@ shmat (shmid, shmaddr, shmflg)
     length = shmds.shm_segsz;
 #endif
 
-  result = (void *__unbounded) INLINE_SYSCALL (ipc, 5, IPCOP_shmat,
-					       shmid, shmflg,
-					       (long int) __ptrvalue (&raddr),
-					       __ptrvalue ((void *) shmaddr));
-  if ((unsigned long) result <= -(unsigned long) SHMLBA)
-    result = raddr;
-
-  return BOUNDED_N (result, length);
+  resultvar = INTERNAL_SYSCALL (ipc, err, 5, IPCOP_shmat,
+				shmid, shmflg,
+				(long int) __ptrvalue (&raddr),
+				__ptrvalue ((void *) shmaddr));
+  if (INTERNAL_SYSCALL_ERROR_P (resultvar, err))
+    {
+      __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err));
+      return (void *) -1;
+    }
+
+  return BOUNDED_N (raddr, length);
 }