[Glibc-bsd-commits] r4471 - in trunk/glibc-ports/kfreebsd: . bits sys
Petr Salinger
ps-guest at alioth.debian.org
Sat May 25 18:23:27 UTC 2013
Author: ps-guest
Date: 2013-05-25 18:23:27 +0000 (Sat, 25 May 2013)
New Revision: 4471
Added:
trunk/glibc-ports/kfreebsd/posix_fadvise.c
trunk/glibc-ports/kfreebsd/posix_fadvise64.c
Modified:
trunk/glibc-ports/kfreebsd/bits/fcntl.h
trunk/glibc-ports/kfreebsd/sys/syscall.h
trunk/glibc-ports/kfreebsd/syscalls.list
Log:
partially update fcntl.h, syscalls.list, provide real posix_fadvise() instead of previous stub
Modified: trunk/glibc-ports/kfreebsd/bits/fcntl.h
===================================================================
--- trunk/glibc-ports/kfreebsd/bits/fcntl.h 2013-05-23 16:42:08 UTC (rev 4470)
+++ trunk/glibc-ports/kfreebsd/bits/fcntl.h 2013-05-25 18:23:27 UTC (rev 4471)
@@ -1,5 +1,5 @@
/* O_*, F_*, FD_* bit values for FreeBSD.
- Copyright (C) 1991-1992, 1997, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1991-1992, 1997-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
@@ -27,36 +27,66 @@
# include <bits/uio.h>
#endif
+/*
+ * File status flags: these are used by open(2), fcntl(2).
+ * They are also used (indirectly) in the kernel file structure f_flags,
+ * which is a superset of the open/fcntl flags. Open flags and f_flags
+ * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
+ * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
+ */
+/* open-only flags */
+#define O_RDONLY 0x0000 /* open for reading only */
+#define O_WRONLY 0x0001 /* open for writing only */
+#define O_RDWR 0x0002 /* open for reading and writing */
+#define O_ACCMODE 0x0003 /* mask for above modes */
-/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
- located on an ext2 file system */
-#define O_ACCMODE 0003
-#define O_RDONLY 00
-#define O_WRONLY 01
-#define O_RDWR 02
-#define O_CREAT 01000 /* not fcntl */
-#define O_EXCL 04000 /* not fcntl */
-#define O_NOCTTY 0100000 /* not fcntl */
-#define O_TRUNC 02000 /* not fcntl */
-#define O_APPEND 010
-#define O_NONBLOCK 04
-#define O_NDELAY O_NONBLOCK
-#define O_SYNC 0200
-#define O_FSYNC O_SYNC
-#define O_ASYNC 0100
+/*
+ * Kernel encoding of open mode; separate read and write bits that are
+ * independently testable: 1 greater than the above.
+ */
+
+#define O_NONBLOCK 0x0004 /* no delay */
+#define O_NDELAY O_NONBLOCK /* compat */
+#define O_APPEND 0x0008 /* set append mode */
-#ifdef __USE_GNU
-# define O_DIRECT 0200000 /* Direct disk access. */
-enum { O_DIRECTORY = 0 }; /* Must be a directory. */
+#if __USE_BSD
+#define O_SHLOCK 0x0010 /* open with shared file lock */
+#define O_EXLOCK 0x0020 /* open with exclusive file lock */
+#endif
+
+#define O_ASYNC 0x0040 /* signal pgrp when data ready */
+#define O_FSYNC 0x0080 /* synchronous writes */
+#define O_SYNC O_FSYNC /* POSIX synonym for O_FSYNC */
+
+#if defined (__USE_XOPEN2K8) || defined (__USE_BSD)
+#define O_NOFOLLOW 0x0100 /* don't follow symlinks */
+#endif
+
+#define O_CREAT 0x0200 /* create if nonexistent */
+#define O_TRUNC 0x0400 /* truncate to zero length */
+#define O_EXCL 0x0800 /* error if already exists */
+/* Defined by POSIX 1003.1; BSD default, but must be distinct from O_RDONLY. */
+#define O_NOCTTY 0x8000 /* don't assign controlling terminal */
+
+#if __USE_BSD
+/* Attempt to bypass buffer cache */
+#define O_DIRECT 0x00010000
enum { O_NOATIME = 0}; /* Do not set atime. */
-# define O_NOFOLLOW 0400 /* Do not follow links. */
#endif
-#ifdef __USE_BSD
-#define O_SHLOCK 020 /* Open with shared file lock. */
-#define O_EXLOCK 040 /* Open with shared exclusive lock. */
+/* Defined by POSIX Extended API Set Part 2 */
+#if defined (__USE_XOPEN2K8) || defined (__USE_BSD)
+#define O_DIRECTORY 0x00020000 /* Fail if not directory */
+#define O_EXEC 0x00040000 /* Open for execute only */
#endif
+#if defined (__USE_XOPEN2K8) || defined (__USE_BSD)
+/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */
+#define O_TTY_INIT 0x00080000 /* Restore default termios attributes */
+/* Defining O_CLOEXEC would break kfreebsd 8.1, see #635192 */
+/* #define O_CLOEXEC 0x00100000 */
+#endif
+
/* For now FreeBSD has synchronisity options for data and read operations.
We define the symbols here but let them do the same as O_SYNC since
this is a superset. */
@@ -65,12 +95,6 @@
# define O_RSYNC O_SYNC /* Synchronize read operations. */
#endif
-#if _POSIX_C_SOURCE >= 200809L
-#define O_TTY_INIT 0x00080000 /* Restore default termios attributes */
-/* Defining O_CLOEXEC would break kfreebsd 8.1, see #635192 */
-/* #define O_CLOEXEC 0x00100000 */
-#endif
-
/* Since 'off_t' is 64-bit, O_LARGEFILE is a no-op. */
#define O_LARGEFILE 0
@@ -107,6 +131,7 @@
* for POSIX shared memory objects (which are otherwise
* implemented as plain files).
*/
+#define FRDAHEAD O_CREAT
#define FPOSIXSHM O_NOFOLLOW
#endif
@@ -116,13 +141,13 @@
#define F_SETFD 2 /* Set file descriptor flags. */
#define F_GETFL 3 /* Get file status flags. */
#define F_SETFL 4 /* Set file status flags. */
-#define F_GETLK 7 /* Get record locking info. */
-#define F_SETLK 8 /* Set record locking info (non-blocking). */
-#define F_SETLKW 9 /* Set record locking info (blocking). */
+#define F_GETLK 11 /* Get record locking info. */
+#define F_SETLK 12 /* Set record locking info (non-blocking). */
+#define F_SETLKW 13 /* Set record locking info (blocking). */
/* Not necessary, we always have 64-bit offsets. */
-#define F_GETLK64 7 /* Get record locking info. */
-#define F_SETLK64 8 /* Set record locking info (non-blocking). */
-#define F_SETLKW64 9 /* Set record locking info (blocking). */
+#define F_GETLK64 11 /* Get record locking info. */
+#define F_SETLK64 12 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 13 /* Set record locking info (blocking). */
#if defined __USE_BSD || defined __USE_UNIX98
# define F_SETOWN 5 /* Get owner of socket (receiver of SIGIO). */
@@ -132,10 +157,14 @@
/* For F_[GET|SET]FD. */
#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
-/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
-#define F_RDLCK 1 /* Read lock. */
-#define F_WRLCK 3 /* Write lock. */
-#define F_UNLCK 2 /* Remove lock. */
+/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
+#define F_RDLCK 1 /* shared or read lock */
+#define F_UNLCK 2 /* unlock */
+#define F_WRLCK 3 /* exclusive or write lock */
+#if __USE_BSD
+#define F_UNLCKSYS 4 /* purge locks for a given system ID */
+#define F_CANCEL 5 /* cancel an async lock request */
+#endif
#ifdef __USE_BSD
/* Operations for bsd flock(), also used by the kernel implementation. */
@@ -184,3 +213,15 @@
#define FSYNC O_SYNC
#endif /* Use BSD. */
+
+#ifdef __USE_XOPEN2K
+/*
+ * Advice to posix_fadvise
+ */
+#define POSIX_FADV_NORMAL 0 /* no special treatment */
+#define POSIX_FADV_RANDOM 1 /* expect random page references */
+#define POSIX_FADV_SEQUENTIAL 2 /* expect sequential page references */
+#define POSIX_FADV_WILLNEED 3 /* will need these pages */
+#define POSIX_FADV_DONTNEED 4 /* dont need these pages */
+#define POSIX_FADV_NOREUSE 5 /* access data only once */
+#endif
Added: trunk/glibc-ports/kfreebsd/posix_fadvise.c
===================================================================
--- trunk/glibc-ports/kfreebsd/posix_fadvise.c (rev 0)
+++ trunk/glibc-ports/kfreebsd/posix_fadvise.c 2013-05-25 18:23:27 UTC (rev 4471)
@@ -0,0 +1,52 @@
+/* Copyright (C) 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysdep.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+#include <kernel-features.h>
+
+extern int __syscall_posix_fadvise(int fd, off_t offset, off_t len, int advice);
+libc_hidden_proto (__syscall_posix_fadvise)
+
+/* the syscall is available in 8.x since 8.3 and in 9.1 and above */
+/* i.e. it is not supported in 9.0 kernel */
+
+int
+posix_fadvise(int fd, off_t offset, off_t len, int advice)
+{
+ int rv;
+ rv = INLINE_SYSCALL (posix_fadvise, 4, fd, offset, len, advice);
+ if (rv == -1)
+ {
+ if (errno == ENOSYS) /* cheat under old kernels as successfull */
+ return 0;
+ return errno;
+ }
+ return rv;
+}
+
+strong_alias (posix_fadvise, posix_fadvise64)
Added: trunk/glibc-ports/kfreebsd/posix_fadvise64.c
===================================================================
--- trunk/glibc-ports/kfreebsd/posix_fadvise64.c (rev 0)
+++ trunk/glibc-ports/kfreebsd/posix_fadvise64.c 2013-05-25 18:23:27 UTC (rev 4471)
@@ -0,0 +1 @@
+/* 'posix_fadvise64' is the same as 'posix_fadvise', because __off64_t == __off_t. */
Modified: trunk/glibc-ports/kfreebsd/sys/syscall.h
===================================================================
--- trunk/glibc-ports/kfreebsd/sys/syscall.h 2013-05-23 16:42:08 UTC (rev 4470)
+++ trunk/glibc-ports/kfreebsd/sys/syscall.h 2013-05-25 18:23:27 UTC (rev 4471)
@@ -6,7 +6,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/kern/syscalls.master 224987 2011-08-18 22:51:30Z jonathan
+ * created from FreeBSD: head/sys/kern/syscalls.master 250853 2013-05-21 11:40:16Z kib
*/
#define SYS_syscall 0
@@ -219,6 +219,10 @@
#define SYS_ktimer_gettime 238
#define SYS_ktimer_getoverrun 239
#define SYS_nanosleep 240
+#define SYS_ffclock_getcounter 241
+#define SYS_ffclock_setestimate 242
+#define SYS_ffclock_getestimate 243
+#define SYS_clock_getcpuclockid2 247
#define SYS_ntp_gettime 248
#define SYS_minherit 250
#define SYS_rfork 251
@@ -309,7 +313,6 @@
#define SYS_extattr_get_fd 372
#define SYS_extattr_delete_fd 373
#define SYS___setugid 374
-#define SYS_nfsclnt 375
#define SYS_eaccess 376
#define SYS_afs3_syscall 377
#define SYS_nmount 378
@@ -435,7 +438,7 @@
#define SYS_shmctl SYS_freebsd7_shmctl
#define SYS_lpathconf 513
#define SYS_cap_new 514
-#define SYS_cap_getrights 515
+#define SYS_cap_rights_get 515
#define SYS_cap_enter 516
#define SYS_cap_getmode 517
#define SYS_pdfork 518
@@ -449,9 +452,20 @@
#define SYS_rctl_get_limits 527
#define SYS_rctl_add_rule 528
#define SYS_rctl_remove_rule 529
-#define SYS_posix_fallocate 530
-#define SYS_posix_fadvise 531
-#define SYS_MAXSYSCALL 532
+#define SYS_posix_fallocate 530
+#define SYS_posix_fadvise 531
+#define SYS_wait6 532
+#define SYS_cap_rights_limit 533
+#define SYS_cap_ioctls_limit 534
+#define SYS_cap_ioctls_get 535
+#define SYS_cap_fcntls_limit 536
+#define SYS_cap_fcntls_get 537
+#define SYS_bindat 538
+#define SYS_connectat 539
+#define SYS_chflagsat 540
+#define SYS_accept4 541
+#define SYS_pipe2 542
+#define SYS_MAXSYSCALL 543
#define SYS_obreak SYS_break
#define SYS_sysctl SYS___sysctl
Modified: trunk/glibc-ports/kfreebsd/syscalls.list
===================================================================
--- trunk/glibc-ports/kfreebsd/syscalls.list 2013-05-23 16:42:08 UTC (rev 4470)
+++ trunk/glibc-ports/kfreebsd/syscalls.list 2013-05-25 18:23:27 UTC (rev 4471)
@@ -106,6 +106,7 @@
obreak - obreak i:a __syscall_obreak
sys_open - open i:siv __syscall_open
poll - poll Ci:pii __poll poll
+sys_posix_fadvise EXTRA posix_fadvise i:iiii __syscall_posix_fadvise
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