Re: [PATCH,CFT] libc: add posix_fallocate()

2012-06-19 Thread Natanael Copa
On Mon, Jun 18, 2012 at 5:27 PM, Bernhard Reutner-Fischer
rep.dot@gmail.com wrote:
 On 18 April 2012 14:45, Bernhard Reutner-Fischer rep.dot@gmail.com 
 wrote:
 On 17 April 2012 23:18, Khem Raj raj.k...@gmail.com wrote:
 On Tue, Apr 17, 2012 at 12:30 AM, Bernhard Reutner-Fischer
 rep.dot@gmail.com wrote:
 Signed-off-by: Bernhard Reutner-Fischer rep.dot@gmail.com
 ---
  include/fcntl.h                                  |    4 +-
  libc/sysdeps/linux/common/Makefile.in            |    3 +-
  libc/sysdeps/linux/common/bits/kernel-features.h |    8 ++
  libc/sysdeps/linux/common/posix_fallocate.c      |   43 
  libc/sysdeps/linux/common/posix_fallocate64.c    |   39 +++
  libc/sysdeps/linux/common/stubs.c                |    4 +
  test/.gitignore                                  |    1 +
  test/unistd/Makefile.in                          |    3 +
  test/unistd/tst-posix_fallocate.c                |  121 
 ++
  9 files changed, 222 insertions(+), 4 deletions(-)
  create mode 100644 libc/sysdeps/linux/common/posix_fallocate.c
  create mode 100644 libc/sysdeps/linux/common/posix_fallocate64.c
  create mode 100644 test/unistd/tst-posix_fallocate.c


 Looks ok to me. Did you test it on a 32bit and a 64 bit arch ?

 I compiled it on x86 and x86_64 where it generated reasonably looking code.
 No runtime-tests performed yet, thus Call For Testers..

 mips would be interesting.

 mips and e.g. ppc* variants of bitness and endianess would indeed be
 interresting, yes.

 Anyone? :)

(resending since I forgot CC uclibc list)

I have it backported to 0.9.33.2.


Works on x86_64 (the test case passes)


on x86:

The output of failed test is:
1st posix_fallocate call failed

The error code appears to be no such file or directory

I have a vauge memory about syscalls with N args (6?) beeing broken.

Appears that posix_fallocate is the only syscall that uses all 6 args.


I wonder if it might be due to our syscalls.h patch for stack
unwinding, but I doubt that.
http://git.alpinelinux.org/cgit/aports/plain/main/libc0.9.32/0007-libc-x86-fix-stack-unwinding-and-backtrace-informati.patch

-- 
Natanael Copa
___
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc


Re: [PATCH,CFT] libc: add posix_fallocate()

2012-04-18 Thread Bernhard Reutner-Fischer
On 17 April 2012 23:18, Khem Raj raj.k...@gmail.com wrote:
 On Tue, Apr 17, 2012 at 12:30 AM, Bernhard Reutner-Fischer
 rep.dot@gmail.com wrote:
 Signed-off-by: Bernhard Reutner-Fischer rep.dot@gmail.com
 ---
  include/fcntl.h                                  |    4 +-
  libc/sysdeps/linux/common/Makefile.in            |    3 +-
  libc/sysdeps/linux/common/bits/kernel-features.h |    8 ++
  libc/sysdeps/linux/common/posix_fallocate.c      |   43 
  libc/sysdeps/linux/common/posix_fallocate64.c    |   39 +++
  libc/sysdeps/linux/common/stubs.c                |    4 +
  test/.gitignore                                  |    1 +
  test/unistd/Makefile.in                          |    3 +
  test/unistd/tst-posix_fallocate.c                |  121 
 ++
  9 files changed, 222 insertions(+), 4 deletions(-)
  create mode 100644 libc/sysdeps/linux/common/posix_fallocate.c
  create mode 100644 libc/sysdeps/linux/common/posix_fallocate64.c
  create mode 100644 test/unistd/tst-posix_fallocate.c


 Looks ok to me. Did you test it on a 32bit and a 64 bit arch ?

I compiled it on x86 and x86_64 where it generated reasonably looking code.
No runtime-tests performed yet, thus Call For Testers..

 mips would be interesting.

mips and e.g. ppc* variants of bitness and endianess would indeed be
interresting, yes.

cheers,
___
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc


Re: [PATCH,CFT] libc: add posix_fallocate()

2012-04-17 Thread Khem Raj
On Tue, Apr 17, 2012 at 12:30 AM, Bernhard Reutner-Fischer
rep.dot@gmail.com wrote:
 Signed-off-by: Bernhard Reutner-Fischer rep.dot@gmail.com
 ---
  include/fcntl.h                                  |    4 +-
  libc/sysdeps/linux/common/Makefile.in            |    3 +-
  libc/sysdeps/linux/common/bits/kernel-features.h |    8 ++
  libc/sysdeps/linux/common/posix_fallocate.c      |   43 
  libc/sysdeps/linux/common/posix_fallocate64.c    |   39 +++
  libc/sysdeps/linux/common/stubs.c                |    4 +
  test/.gitignore                                  |    1 +
  test/unistd/Makefile.in                          |    3 +
  test/unistd/tst-posix_fallocate.c                |  121 
 ++
  9 files changed, 222 insertions(+), 4 deletions(-)
  create mode 100644 libc/sysdeps/linux/common/posix_fallocate.c
  create mode 100644 libc/sysdeps/linux/common/posix_fallocate64.c
  create mode 100644 test/unistd/tst-posix_fallocate.c


Looks ok to me. Did you test it on a 32bit and a 64 bit arch ?
mips would be interesting.

 diff --git a/include/fcntl.h b/include/fcntl.h
 index 26ad1fe..c4a47af 100644
 --- a/include/fcntl.h
 +++ b/include/fcntl.h
 @@ -210,9 +210,7 @@ extern int posix_fadvise64 (int __fd, __off64_t __offset, 
 __off64_t __len,

  #endif

 -#if 0 /*  defined __UCLIBC_HAS_ADVANCED_REALTIME__ */
 -
 -/* FIXME -- uClibc should probably implement these... */
 +#if defined __UCLIBC_HAS_ADVANCED_REALTIME__

  /* Reserve storage for the data of the file associated with FD.

 diff --git a/libc/sysdeps/linux/common/Makefile.in 
 b/libc/sysdeps/linux/common/Makefile.in
 index 3b5763c..cddcd74 100644
 --- a/libc/sysdeps/linux/common/Makefile.in
 +++ b/libc/sysdeps/linux/common/Makefile.in
 @@ -81,7 +81,8 @@ CSRC-$(UCLIBC_HAS_REALTIME) += clock_getres.c 
 clock_gettime.c clock_settime.c \
        sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c 
 \
        sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c 
 sigqueue.c
  # 
 clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typ
  ed_mem_get_info|pthread_mutex_timedlock|sem_timedwait
 -CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c
 +CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c \
 +       posix_fallocate.c posix_fallocate64.c
  CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c
  CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c
  CSRC-$(UCLIBC_HAS_XATTR) += xattr.c
 diff --git a/libc/sysdeps/linux/common/bits/kernel-features.h 
 b/libc/sysdeps/linux/common/bits/kernel-features.h
 index 5ea85d2..be00dda 100644
 --- a/libc/sysdeps/linux/common/bits/kernel-features.h
 +++ b/libc/sysdeps/linux/common/bits/kernel-features.h
 @@ -494,6 +494,14 @@
  # define __ASSUME_PRIVATE_FUTEX        1
  #endif

 +/* Support for fallocate was added in 2.6.23,
 +   on s390 only after 2.6.23-rc1, on alpha only after 2.6.33-rc1.  */
 +#if __LINUX_KERNEL_VERSION = 0x020617 \
 +     (!defined __s390__ || __LINUX_KERNEL_VERSION = 0x020618) \
 +     (!defined __alpha__ || __LINUX_KERNEL_VERSION = 0x020621)
 +# define __ASSUME_FALLOCATE 1
 +#endif
 +
  /* getcpu is a syscall for x86-64 since 3.1.  */
  #if defined __x86_64__  __LINUX_KERNEL_VERSION = 0x030100
  # define __ASSUME_GETCPU_SYSCALL        1
 diff --git a/libc/sysdeps/linux/common/posix_fallocate.c 
 b/libc/sysdeps/linux/common/posix_fallocate.c
 new file mode 100644
 index 000..9aaa6ce
 --- /dev/null
 +++ b/libc/sysdeps/linux/common/posix_fallocate.c
 @@ -0,0 +1,43 @@
 +/* vi: set sw=4 ts=4: */
 +/*
 + * posix_fallocate() for uClibc
 + * 
 http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
 + *
 + * Copyright (C) 2000-2006 Erik Andersen ander...@uclibc.org
 + *
 + * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this 
 tarball.
 + */
 +
 +#include sys/syscall.h
 +#include fcntl.h
 +#include bits/kernel-features.h
 +#include stdint.h
 +
 +#if defined __NR_fallocate
 +int posix_fallocate(int fd, __off_t offset, __off_t len)
 +{
 +       int ret;
 +
 +# if