[Glibc-bsd-commits] r4483 - trunk/glibc-ports/kfreebsd

Petr Salinger ps-guest at alioth.debian.org
Tue May 28 15:45:23 UTC 2013


Author: ps-guest
Date: 2013-05-28 15:45:23 +0000 (Tue, 28 May 2013)
New Revision: 4483

Added:
   trunk/glibc-ports/kfreebsd/posix_fallocate.c
   trunk/glibc-ports/kfreebsd/posix_fallocate64.c
Modified:
   trunk/glibc-ports/kfreebsd/kernel-features.h
   trunk/glibc-ports/kfreebsd/syscalls.list
Log:
use kernel's posix_fallocate() when available


Modified: trunk/glibc-ports/kfreebsd/kernel-features.h
===================================================================
--- trunk/glibc-ports/kfreebsd/kernel-features.h	2013-05-27 14:30:30 UTC (rev 4482)
+++ trunk/glibc-ports/kfreebsd/kernel-features.h	2013-05-28 15:45:23 UTC (rev 4483)
@@ -79,3 +79,7 @@
 /* The pselect syscall was introduced in kFreeBSD 8.1. */
 # define __ASSUME_PSELECT		1
 
+/* The posix_fallocate syscall was introduced in kFreeBSD 8.3. */
+#if __KFREEBSD_KERNEL_VERSION >= 0x80300
+# define __ASSUME_FALLOCATE		1
+#endif

Added: trunk/glibc-ports/kfreebsd/posix_fallocate.c
===================================================================
--- trunk/glibc-ports/kfreebsd/posix_fallocate.c	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/posix_fallocate.c	2013-05-28 15:45:23 UTC (rev 4483)
@@ -0,0 +1,60 @@
+/* Copyright (C) 2007-2013 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <fcntl.h>
+#include <kernel-features.h>
+#include <sysdep.h>
+
+extern int __syscall_posix_fallocate(int fd, off_t offset, off_t len);
+libc_hidden_proto (__syscall_posix_fallocate)
+
+#define posix_fallocate static internal_fallocate
+#include <sysdeps/posix/posix_fallocate.c>
+#undef posix_fallocate
+
+#if !defined __ASSUME_FALLOCATE
+static int __have_fallocate;
+#endif
+
+
+/* Reserve storage for the data of the file associated with FD.  */
+int
+posix_fallocate (int fd, __off_t offset, __off_t len)
+{
+#ifndef __ASSUME_FALLOCATE
+    if (__have_fallocate >= 0)
+#endif
+    {
+        int res = INLINE_SYSCALL (posix_fallocate, 3, fd, offset, len);
+      
+        if (res == -1)
+            res = errno;
+#ifndef __ASSUME_FALLOCATE
+        if (res == ENOSYS)
+        {
+            __have_fallocate = -1;
+        }
+        else
+#endif
+        {
+            if (res != EOPNOTSUPP)
+                return res;
+        }
+    }      
+    return internal_fallocate (fd, offset, len);
+}
+strong_alias (posix_fallocate, posix_fallocate64)

Added: trunk/glibc-ports/kfreebsd/posix_fallocate64.c
===================================================================
--- trunk/glibc-ports/kfreebsd/posix_fallocate64.c	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/posix_fallocate64.c	2013-05-28 15:45:23 UTC (rev 4483)
@@ -0,0 +1 @@
+/* 'posix_fallocate64' is the same as 'posix_fallocate', because __off64_t == __off_t.  */

Modified: trunk/glibc-ports/kfreebsd/syscalls.list
===================================================================
--- trunk/glibc-ports/kfreebsd/syscalls.list	2013-05-27 14:30:30 UTC (rev 4482)
+++ trunk/glibc-ports/kfreebsd/syscalls.list	2013-05-28 15:45:23 UTC (rev 4483)
@@ -107,6 +107,8 @@
 sys_open		-	open			i:siv		__syscall_open
 poll			-	poll			Ci:pii		__poll poll
 sys_posix_fadvise	EXTRA	posix_fadvise		i:iiii		__syscall_posix_fadvise
+sys_posix_fallocate	EXTRA	posix_fallocate		i:iii		__syscall_posix_fallocate
+posix_openpt		getpt	posix_openpt		i:i		__syscall_posix_openpt
 pread			-	pread			Ci:ibni		__libc_pread !__pread pread !__libc_pread64 !__pread64 pread64
 pwrite			-	pwrite			Ci:ibni		__libc_pwrite !__pwrite pwrite !__libc_pwrite64 !__pwrite64 pwrite64
 preadv			-	preadv			Ci:ipii		__preadv  preadv  __preadv64  preadv64 




More information about the Glibc-bsd-commits mailing list