This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] sparc* misc fixes, 2.3.3x LFS fixes


Hi!

This patch fixes a few issues on sparc32 and sparc64, adds LFS support on
Sparc which is in kernel 2.3.35 and fixes it for other platforms as well.

BTW: Anyone knows what's the reason behind not implementing INLINE_SYSCALL
on sparc*-linux? IMHO it could help because there could be more leaf
routines (the syscall does a save/restore for error handling anyway).

Last, but not least, I wish you all Merry Christmas.

1999-12-22  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/sparc/fpu/ftestexcept.c (fetestexcept): Use proper type
	for __fenv_stfsr argument.
	* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Add
	truncate64, ftruncate64, fstat64, lstat64, stat64 and mmap2.
	Remove ugetrlimit.
	* sysdeps/unix/sysv/linux/sparc/sparc32/mmap64.c: New file.
	* sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
	(XSTAT_IS_XSTAT64): Define.
	* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Add
	__libc_lseek64, __libc_pread, __libc_pread64, __libc_pwrite
	and __libc_pwrite64.
	Remove oldgetrlimit and oldsetrlimit.
	* sysdeps/unix/sysv/linux/sparc/sparc64/fxstat64.c: New file.
	* sysdeps/unix/sysv/linux/sparc/sparc64/lxstat64.c: New file.
	* sysdeps/unix/sysv/linux/sparc/sparc64/xstat64.c: New file.

	* sysdeps/unix/sysv/linux/fxstat64.c (__fxstat64): Pass the buf
	pointer to the syscall, not address of that pointer.
	* sysdeps/unix/sysv/linux/lxstat64.c (__lxstat64): Likewise.
	* sysdeps/unix/sysv/linux/xstat64.c (__xstat64): Likewise.
	(__syscall_stat64): Provide proper prototype.

	* sysdeps/unix/sysv/linux/ftruncate64.c (ftruncate64): Share
	has_no_truncate64 between truncate64 and ftruncate64.
	* sysdeps/unix/sysv/linux/truncate64.c (truncate64): Likewise.

	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_TRUNCATE64_SYSCALL, __ASSUME_MMAP2_SYSCALL,
	__ASSUME_STAT64_SYSCALL): Define on Sparc for kernels >= 2.3.35.

--- libc/sysdeps/sparc/fpu/ftestexcept.c.jj	Thu Aug 14 03:44:56 1997
+++ libc/sysdeps/sparc/fpu/ftestexcept.c	Thu Dec 23 14:43:26 1999
@@ -22,7 +22,7 @@
 int
 fetestexcept (int excepts)
 {
-  int tmp;
+  fenv_t tmp;
 
   __fenv_stfsr (tmp);
 
--- libc/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list.jj	Wed Dec  8 17:00:09 1999
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list	Thu Dec 23 10:24:25 1999
@@ -23,12 +23,16 @@ rt_sigqueueinfo	-	rt_sigqueueinfo	3	__sy
 rt_sigsuspend	-	rt_sigsuspend	2	__syscall_rt_sigsuspend
 rt_sigtimedwait	-	rt_sigtimedwait	4	__syscall_rt_sigtimedwait
 s_execve	execve	execve		3	__syscall_execve
+s_fstat64	fxstat64 fstat64	2	__syscall_fstat64
+s_ftruncate64	ftruncate64 ftruncate64	3	__syscall_ftruncate64
 s_getcwd	getcwd	getcwd		2	__syscall_getcwd
 s_getdents	getdents getdents	3	__syscall_getdents
 s_getpriority	getpriority getpriority	2	__syscall_getpriority
 s_getresgid	getresgid getresgid	3	__syscall_getresgid
 s_getresuid	getresuid getresuid	3	__syscall_getresuid
 s_getrlimit	getrlimit getrlimit	2	__syscall_getrlimit
+s_lstat64	lxstat64 lstat64	2	__syscall_lstat64
+s_mmap2		mmap64	mmap2		6	__syscall_mmap2
 s_poll		poll	poll		3	__syscall_poll
 s_pread64	pread64	pread		5	__syscall_pread
 s_ptrace	ptrace	ptrace		4	__syscall_ptrace
@@ -38,8 +42,9 @@ s_sigaction	sigaction sigaction	3	__sysc
 s_sigpending	sigpending sigpending	1	__syscall_sigpending
 s_sigprocmask	sigprocmask sigprocmask	3	__syscall_sigprocmask
 s_sigsuspend	sigsuspend sigsuspend	3	__syscall_sigsuspend
+s_stat64	xstat64 stat64		2	__syscall_stat64
 s_sysctl	sysctl	_sysctl		1	__syscall__sysctl
-s_ugetrlimit	getrlimit ugetrlimit	2	__syscall_ugetrlimit
+s_truncate64	truncate64 truncate64	3	__syscall_truncate64
 s_ustat		ustat	ustat		2	__syscall_ustat
 sys_fstat	fxstat	fstat		2	__syscall_fstat
 sys_lstat	lxstat	lstat		2	__syscall_lstat
--- libc/sysdeps/unix/sysv/linux/sparc/sparc32/mmap64.c.jj	Thu Dec 23 09:50:15 1999
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/mmap64.c	Thu Dec 23 10:18:45 1999
@@ -0,0 +1,74 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#include <sys/mman.h>
+
+#include "kernel-features.h"
+
+#ifdef __NR_mmap2
+extern int __syscall_mmap2(__ptr_t, size_t, int, int, int, off_t);
+#ifndef __ASSUME_MMAP2_SYSCALL
+static int have_no_mmap2;
+#endif
+#endif
+
+__ptr_t
+__mmap64 (__ptr_t addr, size_t len, int prot, int flags, int fd, off64_t offset)
+{
+#ifdef __NR_mmap2
+  if (
+#ifndef __ASSUME_MMAP2_SYSCALL
+      ! have_no_mmap2 &&
+#endif
+      ! (offset & 4095))
+    {
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+      int saved_errno = errno;
+#endif
+      /* This will be always 12, no matter what page size is.  */
+      int result = INLINE_SYSCALL (mmap2, 6, addr, len, prot, flags,
+				   fd, (off_t) (offset >> 12));
+
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+      if (result != -1 || errno != ENOSYS)
+#endif
+	return result;
+
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+      __set_errno (saved_errno);
+      have_no_mmap2 = 1;
+#endif
+    }
+#endif
+  if (offset != (off_t) offset || (offset + len) != (off_t) (offset + len))
+    {
+      __set_errno (EINVAL);
+      return MAP_FAILED;
+    }
+
+  return __mmap (addr, len, prot, flags, fd, (off_t) offset);
+}
+
+weak_alias (__mmap64, mmap64)
--- libc/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h.jj	Sun Oct 12 06:03:08 1997
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h	Thu Dec 23 10:39:55 1999
@@ -20,3 +20,5 @@ struct kernel_stat
 
 #define _HAVE___UNUSED1
 #define _HAVE___UNUSED2
+
+#define XSTAT_IS_XSTAT64 1
--- libc/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list.jj	Wed Dec  8 17:00:09 1999
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list	Thu Dec 23 09:25:08 1999
@@ -1,15 +1,13 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # Whee! 64-bit systems naturally implement llseek.
-llseek		EXTRA	lseek		3	__llseek	llseek __lseek64 lseek64
-pread		-	pread		4	__pread		pread __pread64 pread64
-pwrite		-	pwrite		4	__pwrite	pwrite __pwrite64 pwrite64
+llseek		EXTRA	lseek		3	__llseek	llseek	__libc_lseek64 __lseek64 lseek64
+pread		-	pread		4	__libc_pread	__libc_pread64 __pread pread __pread64 pread64
+pwrite		-	pwrite		4	__libc_pwrite	__libc_pwrite64 __pwrite pwrite __pwrite64 pwrite64
 fstatfs		-	fstatfs		2	__fstatfs	fstatfs fstatfs64
 statfs		-	statfs		2	__statfs	statfs statfs64
 getrlimit	-	getrlimit	2	__getrlimit	getrlimit getrlimit64
 setrlimit	-	setrlimit	2	setrlimit	setrlimit64
-oldgetrlimit	EXTRA	getrlimit	2	__old_getrlimit	getrlimit@GLIBC_2.0 getrlimit64@GLIBC_2.1
-oldsetrlimit	EXTRA	setrlimit	2	__old_setrlimit	setrlimit@GLIBC_2.0 setrlimit64@GLIBC_2.1
 ftruncate	-	ftruncate	2	__ftruncate	ftruncate ftruncate64
 truncate	-	truncate	2	truncate	truncate64
 mmap		-	mmap		6	__mmap		mmap __mmap64 mmap64
--- libc/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat64.c.jj	Thu Dec 23 10:41:22 1999
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat64.c	Fri Oct 31 23:51:57 1997
@@ -0,0 +1 @@
+/* fxstat64 is in fxstat.c */
--- libc/sysdeps/unix/sysv/linux/sparc/sparc64/lxstat64.c.jj	Thu Dec 23 10:41:22 1999
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/lxstat64.c	Fri Oct 31 23:51:57 1997
@@ -0,0 +1 @@
+/* lxstat64 is in lxstat.c */
--- libc/sysdeps/unix/sysv/linux/sparc/sparc64/xstat64.c.jj	Thu Dec 23 10:41:22 1999
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/xstat64.c	Fri Oct 31 23:51:57 1997
@@ -0,0 +1 @@
+/* xstat64 is in xstat.c */
--- libc/sysdeps/unix/sysv/linux/xstat64.c.jj	Tue Dec 21 11:08:05 1999
+++ libc/sysdeps/unix/sysv/linux/xstat64.c	Thu Dec 23 14:19:10 1999
@@ -33,7 +33,7 @@
 extern int __syscall_stat (const char *, struct kernel_stat *);
 
 #ifdef __NR_stat64
-extern int __syscall_fstat64 (int, struct stat64 *);
+extern int __syscall_stat64 (const char *, struct stat64 *);
 # if  __ASSUME_STAT64_SYSCALL == 0
 /* The variable is shared between all wrappers around *stat64 calls.
    This is the definition.  */
@@ -47,7 +47,7 @@ int
 __xstat64 (int vers, const char *name, struct stat64 *buf)
 {
 #if __ASSUME_STAT64_SYSCALL > 0
-  return INLINE_SYSCALL (stat64, 2, name, &buf);
+  return INLINE_SYSCALL (stat64, 2, name, buf);
 #else
   struct kernel_stat kbuf;
   int result;
@@ -55,7 +55,7 @@ __xstat64 (int vers, const char *name, s
   if (! have_no_stat64)
     {
       int saved_errno = errno;
-      result = INLINE_SYSCALL (stat64, 2, name, &buf);
+      result = INLINE_SYSCALL (stat64, 2, name, buf);
 
       if (result != -1 || errno != ENOSYS)
 	return result;
--- libc/sysdeps/unix/sysv/linux/kernel-features.h.jj	Tue Dec 21 11:08:05 1999
+++ libc/sysdeps/unix/sysv/linux/kernel-features.h	Thu Dec 23 09:41:43 1999
@@ -94,3 +94,11 @@
 #if __LINUX_KERNEL_VERSION >= 131874 && defined __i386__
 # define __ASSUME_STAT64_SYSCALL	1
 #endif
+
+/* On sparc the truncate64/ftruncate64/mmap2/stat64/lstat64/fstat64
+   syscalls were introduced in 2.3.35.  */
+#if __LINUX_KERNEL_VERSION >= 131875 && defined __sparc__
+# define __ASSUME_TRUNCATE64_SYSCALL	1
+# define __ASSUME_MMAP2_SYSCALL		1
+# define __ASSUME_STAT64_SYSCALL	1
+#endif
--- libc/sysdeps/unix/sysv/linux/ftruncate64.c.jj	Tue Dec 21 11:08:05 1999
+++ libc/sysdeps/unix/sysv/linux/ftruncate64.c	Thu Dec 23 10:28:01 1999
@@ -26,7 +26,10 @@
 #include "kernel-features.h"
 
 #ifdef __NR_ftruncate64
-static int have_no_ftruncate64;
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+/* The variable is shared between all wrappers around *truncate64 calls.  */
+extern int have_no_truncate64;
+#endif
 
 extern int __syscall_ftruncate64 (int fd, int high_length, int low_length);
 
@@ -38,7 +41,7 @@ ftruncate64 (fd, length)
      off64_t length;
 {
 #ifndef __ASSUME_TRUNCATE64_SYSCALL
-  if (! have_no_ftruncate64)
+  if (! have_no_truncate64)
 #endif
     {
       unsigned int low = length & 0xffffffff;
@@ -55,7 +58,7 @@ ftruncate64 (fd, length)
 
 #ifndef __ASSUME_TRUNCATE64_SYSCALL
       __set_errno (saved_errno);
-      have_no_ftruncate64 = 1;
+      have_no_truncate64 = 1;
 #endif
     }
 
--- libc/sysdeps/unix/sysv/linux/truncate64.c.jj	Tue Dec 21 11:08:05 1999
+++ libc/sysdeps/unix/sysv/linux/truncate64.c	Thu Dec 23 10:28:47 1999
@@ -26,7 +26,10 @@
 #include "kernel-features.h"
 
 #ifdef __NR_truncate64
-static int have_no_truncate64;
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+/* The variable is shared between all wrappers around *truncate64 calls.  */
+int have_no_truncate64;
+#endif
 
 extern int __syscall_truncate64 (int fd, int high_length, int low_length);
 
--- libc/sysdeps/unix/sysv/linux/lxstat64.c.jj	Tue Dec 21 11:08:05 1999
+++ libc/sysdeps/unix/sysv/linux/lxstat64.c	Thu Dec 23 14:19:59 1999
@@ -45,7 +45,7 @@ int
 __lxstat64 (int vers, const char *name, struct stat64 *buf)
 {
 #ifdef __ASSUME_STAT64_SYSCALL
-  return INLINE_SYSCALL (lstat64, 2, name, &buf);
+  return INLINE_SYSCALL (lstat64, 2, name, buf);
 #else
   struct kernel_stat kbuf;
   int result;
@@ -53,7 +53,7 @@ __lxstat64 (int vers, const char *name, 
   if (! have_no_stat64)
     {
       int saved_errno = errno;
-      result = INLINE_SYSCALL (lstat64, 2, name, &kbuf);
+      result = INLINE_SYSCALL (lstat64, 2, name, buf);
 
       if (result != -1 || errno != ENOSYS)
 	return result;
--- libc/sysdeps/unix/sysv/linux/fxstat64.c.jj	Tue Dec 21 11:08:05 1999
+++ libc/sysdeps/unix/sysv/linux/fxstat64.c	Thu Dec 23 14:20:22 1999
@@ -45,7 +45,7 @@ int
 __fxstat64 (int vers, int fd, struct stat64 *buf)
 {
 #if __ASSUME_STAT64_SYSCALL > 0
-  return INLINE_SYSCALL (fstat64, 2, fd, &buf);
+  return INLINE_SYSCALL (fstat64, 2, fd, buf);
 #else
   int result;
   struct kernel_stat kbuf;
@@ -53,7 +53,7 @@ __fxstat64 (int vers, int fd, struct sta
   if (! have_no_stat64)
     {
       int saved_errno = errno;
-      result = INLINE_SYSCALL (fstat64, 2, fd, &buf);
+      result = INLINE_SYSCALL (fstat64, 2, fd, buf);
 
       if (result != -1 || errno != ENOSYS)
 	return result;

Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.34 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]