[Glibc-bsd-commits] r2529 - in trunk/glibc-ports/kfreebsd: . i386

Aurelien Jarno aurel32 at alioth.debian.org
Sun May 24 10:40:59 UTC 2009


Author: aurel32
Date: 2009-05-24 10:40:58 +0000 (Sun, 24 May 2009)
New Revision: 2529

Added:
   trunk/glibc-ports/kfreebsd/i386/sys_freebsd6_lseek.S
Modified:
   trunk/glibc-ports/kfreebsd/Makefile
   trunk/glibc-ports/kfreebsd/Versions
   trunk/glibc-ports/kfreebsd/ftruncate.c
   trunk/glibc-ports/kfreebsd/i386/sys_lseek.S
   trunk/glibc-ports/kfreebsd/kernel-features.h
   trunk/glibc-ports/kfreebsd/lseek.c
   trunk/glibc-ports/kfreebsd/mmap.c
   trunk/glibc-ports/kfreebsd/pread.c
   trunk/glibc-ports/kfreebsd/pwrite.c
   trunk/glibc-ports/kfreebsd/syscalls.list
   trunk/glibc-ports/kfreebsd/truncate.c
Log:
Use syscalls from FreeBSD 7.0 if available


Modified: trunk/glibc-ports/kfreebsd/Makefile
===================================================================
--- trunk/glibc-ports/kfreebsd/Makefile	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/Makefile	2009-05-24 10:40:58 UTC (rev 2529)
@@ -31,7 +31,7 @@
 
 ifeq ($(subdir),io)
 # For <unistd.h>.
-sysdep_routines += sys_getcwd sys_lseek
+sysdep_routines += sys_getcwd sys_lseek sys_freebsd6_lseek
 # For <fcntl.h>.
 sysdep_routines += sys_open open_2
 # For <sys/stat.h>.
@@ -51,7 +51,7 @@
 # For <sched.h>.
 sysdep_routines += clone start_thread
 # For <unistd.h>.
-sysdep_routines += sys_ftruncate sys_truncate
+sysdep_routines += sys_ftruncate sys_freebsd6_ftruncate sys_truncate sys_freebsd6_truncate
 # For <sys/acl.h>.
 sysdep_routines += acl_aclcheck_fd acl_aclcheck_file acl_delete_fd acl_delete_file acl_get_fd acl_get_file acl_set_fd acl_set_file
 # For <sys/extattr.h>.
@@ -63,7 +63,7 @@
 # For <sys/linker.h>.
 sysdep_routines += kldfind kldfirstmod kldload kldnext kldstat kldsym kldunload kldunloadf
 # For <sys/mman.h>.
-sysdep_routines += minherit sys_mmap sys_munmap
+sysdep_routines += minherit sys_mmap sys_freebsd6_mmap sys_munmap
 # For <sys/mount.h>.
 sysdep_routines += fhopen sys_fhstat sys_fhstatfs fhstat fhstat64 fhstatfs fhstatfs64 getfh getfsstat getfsstat64 sys_getfsstat getmntinfo getmntinfo64 mount nmount unmount
 # For <sys/ptrace.h>.
@@ -87,7 +87,7 @@
 
 ifeq ($(subdir),posix)
 # For <unistd.h>.
-sysdep_routines += sys_getlogin sys_pread sys_pwrite sys_setlogin sys_read sys_write
+sysdep_routines += sys_getlogin sys_pread sys_freebsd6_pread sys_pwrite sys_freebsd6_pwrite sys_setlogin sys_read sys_write
 # for <sched.h>
 sysdep_routines += sys_cpuset_getaffinity sys_cpuset_setaffinity
 endif

Modified: trunk/glibc-ports/kfreebsd/Versions
===================================================================
--- trunk/glibc-ports/kfreebsd/Versions	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/Versions	2009-05-24 10:40:58 UTC (rev 2529)
@@ -93,6 +93,7 @@
     __syscall_clock_getres; __syscall_clock_gettime; __syscall_clock_settime;
      # misc fixes for FreeBSD:
     __syscall_freebsd6_lseek; __syscall_freebsd6_pread; __syscall_freebsd6_pwrite;
+    __syscall_lseek; __syscall_pread; __syscall_pwrite;
     __syscall_connect; __syscall_sendto;
     __syscall_cpuset_getaffinity ; __syscall_cpuset_setaffinity;
     __sigprocmask; __ioctl;

Modified: trunk/glibc-ports/kfreebsd/ftruncate.c
===================================================================
--- trunk/glibc-ports/kfreebsd/ftruncate.c	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/ftruncate.c	2009-05-24 10:40:58 UTC (rev 2529)
@@ -20,9 +20,10 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sysdep.h>
+#include <errno.h>
 
-/* The real system call has a word of padding before the 64-bit off_t
-   argument.  */
+extern int __syscall_ftruncate (int __fd, __off_t __length) __THROW;
+libc_hidden_proto (__syscall_ftruncate)
 extern int __syscall_freebsd6_ftruncate (int __fd, int __unused1,
 				__off_t __length) __THROW;
 libc_hidden_proto (__syscall_freebsd6_ftruncate)
@@ -30,8 +31,18 @@
 int
 __ftruncate (int fd, __off_t length)
 {
-  /* We pass 2 arguments in 4 words.  */
-  return INLINE_SYSCALL (freebsd6_ftruncate, 2, fd, 0, length);
+  int result;
+
+  /* First try the new syscall. */
+  result = INLINE_SYSCALL (ftruncate, 2, fd, length);
+
+#ifndef __ASSUME_FTRUNCATE_SYSCALL
+  if (result == -1 && errno == ENOSYS)
+    /* New syscall not available, us the old one. */
+    result = INLINE_SYSCALL (freebsd6_ftruncate, 3, fd, 0, length);
+#endif
+
+  return result;
 }
 
 weak_alias (__ftruncate, ftruncate)

Added: trunk/glibc-ports/kfreebsd/i386/sys_freebsd6_lseek.S
===================================================================
--- trunk/glibc-ports/kfreebsd/i386/sys_freebsd6_lseek.S	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/i386/sys_freebsd6_lseek.S	2009-05-24 10:40:58 UTC (rev 2529)
@@ -0,0 +1,32 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sysdep.h>
+
+/* lseek returns a 64-bit result in %eax, %edx.  This means that in the
+   error case we have to set both %eax and %edx to -1.  */
+
+PSEUDO_NOERRNO(__syscall_freebsd6_lseek, freebsd6_lseek, 3)
+        jnb L(no_error)
+	call SYSCALL_ERROR_LABEL;
+	orl $-1, %edx;
+L(pseudo_end):
+L(no_error):
+	ret
+PSEUDO_END(__syscall_freebsd6_lseek)
+libc_hidden_def (__syscall_freebsd6_lseek)

Modified: trunk/glibc-ports/kfreebsd/i386/sys_lseek.S
===================================================================
--- trunk/glibc-ports/kfreebsd/i386/sys_lseek.S	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/i386/sys_lseek.S	2009-05-24 10:40:58 UTC (rev 2529)
@@ -21,12 +21,12 @@
 /* lseek returns a 64-bit result in %eax, %edx.  This means that in the
    error case we have to set both %eax and %edx to -1.  */
 
-PSEUDO_NOERRNO(__syscall_freebsd6_lseek, freebsd6_lseek, 4)
+PSEUDO_NOERRNO(__syscall_lseek, lseek, 4)
         jnb L(no_error)
 	call SYSCALL_ERROR_LABEL;
 	orl $-1, %edx;
 L(pseudo_end):
 L(no_error):
 	ret
-PSEUDO_END(__syscall_freebsd6_lseek)
-libc_hidden_def (__syscall_freebsd6_lseek)
+PSEUDO_END(__syscall_lseek)
+libc_hidden_def (__syscall_lseek)

Modified: trunk/glibc-ports/kfreebsd/kernel-features.h
===================================================================
--- trunk/glibc-ports/kfreebsd/kernel-features.h	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/kernel-features.h	2009-05-24 10:40:58 UTC (rev 2529)
@@ -41,3 +41,33 @@
 /* Use signals #32, #33, #34 for internal linuxthreads communication */
 #define PTHREAD_SIGBASE 32
 
+/* The `ftruncate' syscall was introduced in kFreeBSD 7.0. */
+#if __KFREEBSD_KERNEL_VERSION >= 0x70000
+# define __ASSUME_FTRUNCATE_SYSCALL	1
+#endif
+
+/* The `lseek' syscall was introduced in kFreeBSD 7.0. */
+#if __KFREEBSD_KERNEL_VERSION >= 0x70000
+# define __ASSUME_LSEEK_SYSCALL		1
+#endif
+
+/* The `mmap' syscall was introduced in kFreeBSD 7.0. */
+#if __KFREEBSD_KERNEL_VERSION >= 0x70000
+# define __ASSUME_MMAP_SYSCALL		1
+#endif
+
+/* The `pread' syscall was introduced in kFreeBSD 7.0. */
+#if __KFREEBSD_KERNEL_VERSION >= 0x70000
+# define __ASSUME_PREAD_SYSCALL		1
+#endif
+
+/* The `pwrite' syscall was introduced in kFreeBSD 7.0. */
+#if __KFREEBSD_KERNEL_VERSION >= 0x70000
+# define __ASSUME_PWRITE_SYSCALL	1
+#endif
+
+/* The `truncate' syscall was introduced in kFreeBSD 7.0. */
+#if __KFREEBSD_KERNEL_VERSION >= 0x70000
+# define __ASSUME_TRUNCATE_SYSCALL	1
+#endif
+

Modified: trunk/glibc-ports/kfreebsd/lseek.c
===================================================================
--- trunk/glibc-ports/kfreebsd/lseek.c	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/lseek.c	2009-05-24 10:40:58 UTC (rev 2529)
@@ -22,8 +22,8 @@
 #include <sysdep.h>
 #include <errno.h>
 
-/* The real system call has a word of padding before the 64-bit off_t
-   argument.  */
+extern __off_t __syscall_lseek (int __fd, __off_t __offset, int __whence) __THROW;
+libc_hidden_proto (__syscall_lseek)
 extern __off_t __syscall_freebsd6_lseek (int __fd, int __unused1, __off_t __offset,
 				int __whence) __THROW;
 libc_hidden_proto (__syscall_freebsd6_lseek)
@@ -31,8 +31,18 @@
 __off_t
 __libc_lseek (int fd, __off_t offset, int whence)
 {
-  /* We pass 3 arguments in 5 words.  */
-  return INLINE_SYSCALL (freebsd6_lseek, 3, fd, 0, offset, whence);
+  __off_t result;
+
+  /* First try the new syscall. */
+  result = INLINE_SYSCALL (lseek, 3, fd, offset, whence);
+
+#ifndef __ASSUME_LSEEK_SYSCALL
+  if (result == -1 && errno == ENOSYS)
+    /* New syscall not available, us the old one. */
+    result = INLINE_SYSCALL (freebsd6_lseek, 4, fd, 0, offset, whence);
+#endif
+
+  return result;
 }
 
 weak_alias (__libc_lseek, __lseek)

Modified: trunk/glibc-ports/kfreebsd/mmap.c
===================================================================
--- trunk/glibc-ports/kfreebsd/mmap.c	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/mmap.c	2009-05-24 10:40:58 UTC (rev 2529)
@@ -23,56 +23,58 @@
 #include <errno.h>
 #include <sysdep.h>
 
-/* The real system call has a word of padding before the 64-bit off_t
-   argument.  */
+extern void *__syscall_mmap (void *__addr, size_t __len, int __prot,
+			     int __flags, int __fd, __off_t __offset) __THROW;
+libc_hidden_proto (__syscall_mmap)
 extern void *__syscall_freebsd6_mmap (void *__addr, size_t __len, int __prot,
 			     int __flags, int __fd, int __unused1,
 			     __off_t __offset) __THROW;
 libc_hidden_proto (__syscall_freebsd6_mmap)
-
 extern ssize_t __syscall_freebsd6_pread (int __fd, void *__buf, size_t __nbytes,
                                 int __unused1, __off_t __offset) __THROW;
+libc_hidden_proto (__syscall_freebsd6_pread)
 
-libc_hidden_proto (__syscall_freebsd6_pread)
 void *
 __mmap (void *addr, size_t len, int prot, int flags, int fd, __off_t offset)
 {
   void *result;
 
   /* Validity checks not done by the kernel.  */
-  if ((flags & MAP_FIXED) || (offset != 0))
+  if (offset != 0)
     {
       int pagesize = __getpagesize ();
-
-      if (((flags & MAP_FIXED)
-	   && (__builtin_expect (pagesize & (pagesize - 1), 0)
-	       ? (unsigned long) addr % pagesize
-	       : (unsigned long) addr & (pagesize - 1)))
-	  || (__builtin_expect (pagesize & (pagesize - 1), 0)
-	      ? offset % pagesize
-	      : offset & (pagesize - 1)))
+      if ((__builtin_expect (pagesize & (pagesize - 1), 0)
+        ? offset % pagesize
+	: offset & (pagesize - 1)))
 	{
 	  __set_errno (EINVAL);
 	  return (void *) (-1);
 	}
     }
 
-  /* We pass 7 arguments in 8 words.  */
   /* for ANON mapping we must pass -1 in place of fd */
   if (flags & MAP_ANON)
-    return INLINE_SYSCALL (freebsd6_mmap, 7, addr, len, prot, flags, -1, 0, offset);
-  result = INLINE_SYSCALL (freebsd6_mmap, 7, addr, len, prot, flags, fd, 0, offset);
+    fd = -1;
 
-  if (result != (void *) (-1) && fd >= 0 && len > 0)
+  /* First try the new syscall. */
+  result = INLINE_SYSCALL (mmap, 6, addr, len, prot, flags, fd, offset);
+
+#ifndef __ASSUME_MMAP_SYSCALL
+  if (result == (void *) (-1) && errno == ENOSYS)
     {
-      /* Force an update of the atime.  POSIX:2001 mandates that this happens
-	 at some time between the mmap() call and the first page-in.  Since
-	 the FreeBSD 4.0 kernel doesn't update the atime upon a page-in, we
-	 do it here.  */
-      char dummy;
-
-      INLINE_SYSCALL (freebsd6_pread, 5, fd, &dummy, 1, 0, offset);
+      /* New syscall not available, us the old one. */
+      result = INLINE_SYSCALL (freebsd6_mmap, 7, addr, len, prot, flags, fd, 0, offset);
+      if (result != (void *) (-1) && fd >= 0 && len > 0)
+	{
+	  /* Force an update of the atime.  POSIX:2001 mandates that this happens
+	  at some time between the mmap() call and the first page-in.  Since
+	  the FreeBSD 6.0 kernel doesn't update the atime upon a page-in, we
+	  do it here.  */
+	  char dummy;
+	  INLINE_SYSCALL (freebsd6_pread, 5, fd, &dummy, 1, 0, offset);
+	}
     }
+#endif
 
   return result;
 }

Modified: trunk/glibc-ports/kfreebsd/pread.c
===================================================================
--- trunk/glibc-ports/kfreebsd/pread.c	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/pread.c	2009-05-24 10:40:58 UTC (rev 2529)
@@ -21,9 +21,11 @@
 #include <sys/types.h>
 #include <sysdep.h>
 #include <sysdep-cancel.h>
+#include <errno.h>
 
-/* The real system call has a word of padding before the 64-bit off_t
-   argument.  */
+extern ssize_t __syscall_pread (int __fd, void *__buf, size_t __nbytes,
+				__off_t __offset) __THROW;
+libc_hidden_proto(__syscall_pread)
 extern ssize_t __syscall_freebsd6_pread (int __fd, void *__buf, size_t __nbytes,
 				int __unused1, __off_t __offset) __THROW;
 libc_hidden_proto(__syscall_freebsd6_pread)
@@ -31,13 +33,26 @@
 ssize_t
 __libc_pread (int fd, void *buf, size_t nbytes, __off_t offset)
 {
-  /* We pass 5 arguments in 6 words.  */
-  if (SINGLE_THREAD_P)
-    return INLINE_SYSCALL (freebsd6_pread, 5, fd, buf, nbytes, 0, offset);
+  ssize_t result;
+  int oldtype;
 
-  int oldtype = LIBC_CANCEL_ASYNC ();
-  ssize_t result = INLINE_SYSCALL (freebsd6_pread, 5, fd, buf, nbytes, 0, offset);
-  LIBC_CANCEL_RESET (oldtype);
+  if (!SINGLE_THREAD_P)
+    {
+      oldtype = LIBC_CANCEL_ASYNC ();
+    }
+
+  /* First try the new syscall. */
+  result = INLINE_SYSCALL (pread, 4, fd, buf, nbytes, offset);
+#ifndef __ASSUME_PREAD_SYSCALL
+  if (result == -1 && errno == ENOSYS)
+    /* New syscall not available, us the old one. */
+    result = INLINE_SYSCALL (freebsd6_pread, 5, fd, buf, nbytes, 0, offset);
+#endif
+
+  if (!SINGLE_THREAD_P)
+    {
+      LIBC_CANCEL_RESET (oldtype);
+    }
   return result;
 }
 

Modified: trunk/glibc-ports/kfreebsd/pwrite.c
===================================================================
--- trunk/glibc-ports/kfreebsd/pwrite.c	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/pwrite.c	2009-05-24 10:40:58 UTC (rev 2529)
@@ -21,9 +21,11 @@
 #include <sys/types.h>
 #include <sysdep.h>
 #include <sysdep-cancel.h>
+#include <errno.h>
 
-/* The real system call has a word of padding before the 64-bit off_t
-   argument.  */
+extern ssize_t __syscall_pwrite (int __fd, const void *__buf, size_t __nbytes,
+				 __off_t __offset) __THROW;
+libc_hidden_proto(__syscall_pwrite)
 extern ssize_t __syscall_freebsd6_pwrite (int __fd, const void *__buf, size_t __nbytes,
 				 int __unused1, __off_t __offset) __THROW;
 libc_hidden_proto(__syscall_freebsd6_pwrite)
@@ -31,12 +33,28 @@
 ssize_t
 __libc_pwrite (int fd, const void *buf, size_t nbytes, __off_t offset)
 {
-  /* We pass 5 arguments in 6 words.  */
+  ssize_t result;
+
   if (SINGLE_THREAD_P)
-    return INLINE_SYSCALL (freebsd6_pwrite, 5, fd, buf, nbytes, 0, offset);
+    {
+      /* First try the new syscall. */
+      result = INLINE_SYSCALL (pwrite, 4, fd, buf, nbytes, offset);
+#ifndef __ASSUME_PREAD_SYSCALL
+      if (result == -1 && errno == ENOSYS)
+        /* New syscall not available, us the old one. */
+        result = INLINE_SYSCALL (freebsd6_pwrite, 5, fd, buf, nbytes, 0, offset);
+#endif
+      return result;
+    }
 
   int oldtype = LIBC_CANCEL_ASYNC ();
-  ssize_t result = INLINE_SYSCALL (freebsd6_pwrite, 5, fd, buf, nbytes, 0, offset);
+  /* First try the new syscall. */
+  result = INLINE_SYSCALL (pwrite, 4, fd, buf, nbytes, offset);
+#ifndef __ASSUME_PREAD_SYSCALL
+  if (result == -1 && errno == ENOSYS)
+    /* New syscall not available, us the old one. */
+    result = INLINE_SYSCALL (freebsd6_pwrite, 5, fd, buf, nbytes, 0, offset);
+#endif
   LIBC_CANCEL_RESET (oldtype);
   return result;
 }

Modified: trunk/glibc-ports/kfreebsd/syscalls.list
===================================================================
--- trunk/glibc-ports/kfreebsd/syscalls.list	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/syscalls.list	2009-05-24 10:40:58 UTC (rev 2529)
@@ -30,7 +30,8 @@
 sys_fstatfs		-	fstatfs			i:ip		__syscall_fstatfs
 sys_fhstatfs		-	fhstatfs		i:pp		__syscall_fhstatfs
 sys_fstat		-	fstat			i:ip		__syscall_fstat
-sys_ftruncate		-	freebsd6_ftruncate	i:iii		__syscall_freebsd6_ftruncate
+sys_ftruncate		-	ftruncate		i:ii		__syscall_ftruncate
+sys_freebsd6_ftruncate	-	freebsd6_ftruncate	i:iii		__syscall_freebsd6_ftruncate
 futimes			-	futimes			i:ip		__futimes futimes
 sys_getcwd		-	getcwd			i:bn		__syscall_getcwd
 sys_getdents		-	getdents		i:ibn		__syscall_getdents
@@ -57,7 +58,8 @@
 lchmod			-	lchmod			i:si		lchmod
 lchown			-	lchown			i:sii		__lchown lchown
 sys_lio_listio		-	lio_listio		i:ibnP		__syscall_lio_listio
-sys_lseek		-	freebsd6_lseek		i:iiii		__syscall_freebsd6_lseek
+sys_lseek		-	lseek			i:iii		__syscall_lseek
+sys_freebsd6_lseek	-	freebsd6_lseek		i:iiii		__syscall_freebsd6_lseek
 sys_lstat		-	lstat			i:sp		__syscall_lstat
 lutimes			-	lutimes			i:sp		__lutimes lutimes
 posix_madvise		-	madvise			i:pii		posix_madvise
@@ -67,7 +69,8 @@
 mlockall		-	mlockall		i:i		mlockall
 mkfifo			-	mkfifo			i:si		__mkfifo mkfifo
 sys_mknod		-	mknod			i:sii		__syscall_mknod
-sys_mmap		-	freebsd6_mmap		b:aniiiii	__syscall_freebsd6_mmap
+sys_mmap		-	mmap			b:aniiii	__syscall_mmap
+sys_freebsd6_mmap	-	freebsd6_mmap		b:aniiiii	__syscall_freebsd6_mmap
 sys_munmap		-	munmap			i:pi		__syscall_munmap
 modfind			-	modfind			i:s		modfind
 modfnext		-	modfnext		i:i		modfnext
@@ -89,9 +92,11 @@
 obreak			-	obreak			i:a		__syscall_obreak
 sys_open		-	open			i:siv		__syscall_open
 poll			-	poll			Ci:pii		__poll poll
-sys_pread		-	freebsd6_pread		i:ibnii		__syscall_freebsd6_pread
+sys_pread		-	pread			i:ibni		__syscall_pread
+sys_freebsd6_pread	-	freebsd6_pread		i:ibnii		__syscall_freebsd6_pread
 sys_ptrace		-	ptrace			i:iipi		__syscall_ptrace
-sys_pwrite		-	freebsd6_pwrite		i:ibnii		__syscall_freebsd6_pwrite
+sys_pwrite		-	pwrite			i:ibni		__syscall_pwrite
+sys_freebsd6_pwrite	-	freebsd6_pwrite		i:ibnii		__syscall_freebsd6_pwrite
 quotactl		-	quotactl		i:siip		quotactl
 sys_readv		-	readv			i:ipi		__syscall_readv
 rfork			-	rfork			i:i		__rfork rfork
@@ -129,7 +134,8 @@
 sys_stat		-	stat			i:sp		__syscall_stat
 sysarch			-	sysarch			i:ip		__sysarch sysarch
 sysctl			-	sysctl			i:pibNbn	__sysctl sysctl
-sys_truncate		-	freebsd6_truncate	i:sii		__syscall_freebsd6_truncate
+sys_truncate		-	truncate		i:sii		__syscall_truncate
+sys_freebsd6_truncate	-	freebsd6_truncate	i:si		__syscall_freebsd6_truncate
 undelete		-	undelete		i:s		undelete
 unmount			-	unmount			i:si		unmount
 utrace			-	utrace			i:bn		utrace

Modified: trunk/glibc-ports/kfreebsd/truncate.c
===================================================================
--- trunk/glibc-ports/kfreebsd/truncate.c	2009-05-24 00:55:23 UTC (rev 2528)
+++ trunk/glibc-ports/kfreebsd/truncate.c	2009-05-24 10:40:58 UTC (rev 2529)
@@ -20,9 +20,10 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sysdep.h>
+#include <errno.h>
 
-/* The real system call has a word of padding before the 64-bit off_t
-   argument.  */
+extern int __syscall_truncate (const char *__file, __off_t __length) __THROW;
+libc_hidden_proto (__syscall_truncate)
 extern int __syscall_freebsd6_truncate (const char *__file, int __unused1,
 			       __off_t __length) __THROW;
 libc_hidden_proto (__syscall_freebsd6_truncate)
@@ -30,8 +31,18 @@
 int
 __truncate (const char *file, __off_t length)
 {
-  /* We pass 2 arguments in 4 words.  */
-  return INLINE_SYSCALL (freebsd6_truncate, 2, file, 0, length);
+  int result;
+
+  /* First try the new syscall. */
+  result = INLINE_SYSCALL (truncate, 2, file, length);
+
+#ifndef __ASSUME_TRUNCATE_SYSCALL
+  if (result == -1 && errno == ENOSYS)
+    /* New syscall not available, us the old one. */
+    result = INLINE_SYSCALL (freebsd6_truncate, 3, file, 0, length);
+#endif
+
+  return result;
 }
 
 weak_alias (__truncate, truncate)




More information about the Glibc-bsd-commits mailing list