This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

PATCH: Add x32 fallocate/posix_fadvise/posix_fallocate


Hi,

By default, x32 system calls pass and return int32.  But
fallocate/posix_fadvise/posix_fallocate pass int64.  This patch adds
x32 fallocate/posix_fadvise/posix_fallocate by loading int64 arguments
with long long int.  Testd on Linux/x32.  OK to install?

Thanks.

H.J.
----
	* sysdeps/unix/sysv/linux/x86_64/x32/fallocate.c: New file.
	* sysdeps/unix/sysv/linux/x86_64/x32/posix_fadvise.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/posix_fallocate.c: Likewise.

diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/fallocate.c b/sysdeps/unix/sysv/linux/x86_64/x32/fallocate.c
new file mode 100644
index 0000000..b1768da
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/fallocate.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 2012 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 <errno.h>
+#include <fcntl.h>
+#include <sysdep.h>
+#include <sysdep-cancel.h>
+
+#undef LOAD_ARGS_3
+#define LOAD_ARGS_3(a1, a2, a3)				\
+  long long int __arg3 = (long long int) (a3);		\
+  LOAD_ARGS_2 (a1, a2)
+#undef LOAD_REGS_3
+#define LOAD_REGS_3					\
+  register long long int _a3 asm ("rdx") = __arg3;	\
+  LOAD_REGS_2
+
+#undef LOAD_ARGS_4
+#define LOAD_ARGS_4(a1, a2, a3, a4)			\
+  long long int __arg4 = (long long int) (a4);		\
+  LOAD_ARGS_3 (a1, a2, a3)
+#undef LOAD_REGS_4
+#define LOAD_REGS_4					\
+  register long long int _a4 asm ("r10") = __arg4;	\
+  LOAD_REGS_3
+
+/* Reserve storage for the data of the file associated with FD.  */
+int
+fallocate (int fd, int mode, __off_t offset, __off_t len)
+{
+  if (SINGLE_THREAD_P)
+    return INLINE_SYSCALL (fallocate, 4, fd, mode, offset, len);
+
+  int oldtype = LIBC_CANCEL_ASYNC ();
+  int result = INLINE_SYSCALL (fallocate, 4, fd, mode, offset, len);
+
+  LIBC_CANCEL_RESET (oldtype);
+
+  return result;
+}
+strong_alias (fallocate, fallocate64)
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/posix_fadvise.c b/sysdeps/unix/sysv/linux/x86_64/x32/posix_fadvise.c
new file mode 100644
index 0000000..6e69f17
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/posix_fadvise.c
@@ -0,0 +1,52 @@
+/* Copyright (C) 2012 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 <errno.h>
+#include <fcntl.h>
+#include <sysdep.h>
+
+#undef LOAD_ARGS_2
+#define LOAD_ARGS_2(a1, a2)				\
+  long long int __arg2 = (long long int) (a2);		\
+  LOAD_ARGS_1 (a1)
+#undef LOAD_REGS_2
+#define LOAD_REGS_2					\
+  register long long int _a2 asm ("rsi") = __arg2;	\
+  LOAD_REGS_1
+
+#undef LOAD_ARGS_3
+#define LOAD_ARGS_3(a1, a2, a3)				\
+  long long int __arg3 = (long long int) (a3);		\
+  LOAD_ARGS_2 (a1, a2)
+#undef LOAD_REGS_3
+#define LOAD_REGS_3					\
+  register long long int _a3 asm ("rdx") = __arg3;	\
+  LOAD_REGS_2
+
+/* Advice the system about the expected behaviour of the application with
+   respect to the file associated with FD.  */
+
+int
+posix_fadvise (int fd, off_t offset, off_t len, int advise)
+{
+  INTERNAL_SYSCALL_DECL (err);
+  int ret = INTERNAL_SYSCALL (fadvise64, err, 4, fd, offset, len, advise);
+  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+    return INTERNAL_SYSCALL_ERRNO (ret, err);
+  return 0;
+}
+strong_alias (posix_fadvise, posix_fadvise64)
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/posix_fallocate.c b/sysdeps/unix/sysv/linux/x86_64/x32/posix_fallocate.c
new file mode 100644
index 0000000..de57ce2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/posix_fallocate.c
@@ -0,0 +1,58 @@
+/* Copyright (C) 2012 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 <sysdep.h>
+
+#define posix_fallocate static internal_fallocate
+#include <sysdeps/posix/posix_fallocate.c>
+#undef posix_fallocate
+
+#undef LOAD_ARGS_2
+#define LOAD_ARGS_2(a1, a2)				\
+  long long int __arg2 = (long long int) (a2);		\
+  LOAD_ARGS_1 (a1)
+#undef LOAD_REGS_2
+#define LOAD_REGS_2					\
+  register long long int _a2 asm ("rsi") = __arg2;	\
+  LOAD_REGS_1
+
+#undef LOAD_ARGS_3
+#define LOAD_ARGS_3(a1, a2, a3)				\
+  long long int __arg3 = (long long int) (a3);		\
+  LOAD_ARGS_2 (a1, a2)
+#undef LOAD_REGS_3
+#define LOAD_REGS_3					\
+  register long long int _a3 asm ("rdx") = __arg3;	\
+  LOAD_REGS_2
+
+/* Reserve storage for the data of the file associated with FD.  */
+int
+posix_fallocate (int fd, __off_t offset, __off_t len)
+{
+  INTERNAL_SYSCALL_DECL (err);
+  int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, offset, len);
+
+  if (! INTERNAL_SYSCALL_ERROR_P (res, err))
+    return 0;
+
+  if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP)
+    return INTERNAL_SYSCALL_ERRNO (res, err);
+
+  return internal_fallocate (fd, offset, len);
+}
+strong_alias (posix_fallocate, posix_fallocate64)


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