This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libgo patch committed: Add mount flags, fallocate, statfs.


This patch to libgo adds the mount flags, the GNU/Linux specific
fallocate function, and the GNU/Linux version of the statfs function.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r 2b6e531380f6 libgo/configure.ac
--- a/libgo/configure.ac	Fri Feb 17 16:42:08 2012 -0800
+++ b/libgo/configure.ac	Fri Feb 17 17:12:38 2012 -0800
@@ -453,7 +453,7 @@
   ;;
 esac
 
-AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h sys/prctl.h)
+AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h)
 
 AC_CHECK_HEADERS([linux/filter.h linux/netlink.h linux/rtnetlink.h], [], [],
 [#ifdef HAVE_SYS_SOCKET_H
@@ -467,7 +467,8 @@
 AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
 AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
 
-AC_CHECK_FUNCS(epoll_create1 faccessat fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_rm_watch mkdirat mknodat openat renameat splice tee unlinkat unshare)
+AC_CHECK_FUNCS(epoll_create1 faccessat fallocate fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_rm_watch mkdirat mknodat openat renameat splice tee unlinkat unshare)
+AC_TYPE_OFF_T
 AC_CHECK_TYPES([loff_t])
 
 CFLAGS_hold="$CFLAGS"
diff -r 2b6e531380f6 libgo/go/syscall/libcall_linux.go
--- a/libgo/go/syscall/libcall_linux.go	Fri Feb 17 16:42:08 2012 -0800
+++ b/libgo/go/syscall/libcall_linux.go	Fri Feb 17 17:12:38 2012 -0800
@@ -178,9 +178,8 @@
 //sys	Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
 //faccessat(dirfd int, pathname *byte, mode int, flags int) int
 
-// FIXME: Only in glibc 2.10 and later.
-// //sys	Fallocate(fd int, mode uint32, off int64, len int64) (err error)
-// //fallocate(fd int, mode int, offset Offset_t, len Offset_t) int
+//sys	Fallocate(fd int, mode uint32, off int64, len int64) (err error)
+//fallocate(fd int, mode int, offset Offset_t, len Offset_t) int
 
 //sys	Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
 //fchmodat(dirfd int, pathname *byte, mode Mode_t, flags int) int
@@ -191,9 +190,8 @@
 //sys	Flock(fd int, how int) (err error)
 //flock(fd int, how int) int
 
-// FIXME: mksysinfo statfs
-// //sys	Fstatfs(fd int, buf *Statfs_t) (err error)
-// //fstatfs(fd int, buf *Statfs_t) int
+//sys	Fstatfs(fd int, buf *Statfs_t) (err error)
+//fstatfs(fd int, buf *Statfs_t) int
 
 func Gettid() (tid int) {
 	r1, _, _ := Syscall(SYS_GETTID, 0, 0, 0)
@@ -283,9 +281,8 @@
 	return
 }
 
-// FIXME: mksysinfo statfs
-// //sys	Statfs(path string, buf *Statfs_t) (err error)
-// //statfs(path *byte, buf *Statfs_t) int
+//sys	Statfs(path string, buf *Statfs_t) (err error)
+//statfs(path *byte, buf *Statfs_t) int
 
 // FIXME: Only in glibc 2.6 and later.
 // //sys	SyncFileRange(fd int, off int64, n int64, flags int) (err error)
diff -r 2b6e531380f6 libgo/mksysinfo.sh
--- a/libgo/mksysinfo.sh	Fri Feb 17 16:42:08 2012 -0800
+++ b/libgo/mksysinfo.sh	Fri Feb 17 17:12:38 2012 -0800
@@ -93,6 +93,15 @@
 #if defined(HAVE_NET_IF_H)
 #include <net/if.h>
 #endif
+#if defined(HAVE_SYS_MOUNT_H)
+#include <sys/mount.h>
+#endif
+#if defined(HAVE_SYS_VFS_H)
+#include <sys/vfs.h>
+#endif
+#if defined(HAVE_STATFS_H)
+#include <sys/statfs.h>
+#endif
 
 /* Constants that may only be defined as expressions on some systems,
    expressions too complex for -fdump-go-spec to handle.  These are
@@ -766,4 +775,35 @@
 	sed -e 's/^\(const \)_\([^=]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 done
 
+# The mount flags
+grep '^const _MS_' gen-sysinfo.go |
+    sed -e 's/^\(const \)_\(MS_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+
+# The fallocate flags.
+grep '^const _FALLOC_' gen-sysinfo.go |
+    sed -e 's/^\(const \)_\(FALLOC_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+
+# The statfs struct.
+# Prefer largefile variant if available.
+statfs=`grep '^type _statfs64 ' gen-sysinfo.go || true`
+if test "$statfs" != ""; then
+  grep '^type _statfs64 ' gen-sysinfo.go
+else
+  grep '^type _statfs ' gen-sysinfo.go
+fi | sed -e 's/type _statfs64/type Statfs_t/' \
+	 -e 's/type _statfs/type Statfs_t/' \
+	 -e 's/f_type/Type/' \
+	 -e 's/f_bsize/Bsize/' \
+	 -e 's/f_blocks/Blocks/' \
+	 -e 's/f_bfree/Bfree/' \
+	 -e 's/f_bavail/Bavail/' \
+	 -e 's/f_files/Files/' \
+	 -e 's/f_ffree/Ffree/' \
+	 -e 's/f_fsid/Fsid/' \
+	 -e 's/f_namelen/Namelen/' \
+	 -e 's/f_frsize/Frsize/' \
+	 -e 's/f_flags/Flags/' \
+	 -e 's/f_spare/Spare/' \
+    >> ${OUT}
+
 exit $?
diff -r 2b6e531380f6 libgo/runtime/go-nosys.c
--- a/libgo/runtime/go-nosys.c	Fri Feb 17 16:42:08 2012 -0800
+++ b/libgo/runtime/go-nosys.c	Fri Feb 17 17:12:38 2012 -0800
@@ -48,6 +48,18 @@
 }
 #endif
 
+#ifndef HAVE_FALLOCATE
+int
+fallocate (int fd __attribute__ ((unused)),
+	   int mode __attribute__ ((unused)),
+	   off_t offset __attribute __ ((unused)),
+	   off_t len __attribute__ ((unused)))
+{
+  errno = ENOSYS;
+  return -1;
+}
+#endif
+
 #ifndef HAVE_FCHMODAT
 int
 fchmodat (int dirfd __attribute__ ((unused)),

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