preadv/pwritev don't provide separate version for 64-bit wide off_t,
and default to 32-bit wide off_t, which results in a mismatch between
declaration and definition for user programs built with
-D_FILE_OFFSET_BITS=64.
Make offset argument of both functions __off64_t.
This fixes test misc/tst-preadvwritev on xtensa.
Signed-off-by: Max Filippov <jcmvbkbc(a)gmail.com>
---
include/sys/uio.h | 4 ++--
libc/sysdeps/linux/common/preadv.c | 2 +-
libc/sysdeps/linux/common/pwritev.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/sys/uio.h b/include/sys/uio.h
index aa766f9b1187..330426fec492 100644
--- a/include/sys/uio.h
+++ b/include/sys/uio.h
@@ -59,7 +59,7 @@ extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count);
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count,
- off_t __offset) __wur;
+ __off64_t __offset) __wur;
/* Write data pointed by the buffers described by IOVEC, which is a
vector of COUNT 'struct iovec's, to file descriptor FD at the given
@@ -71,7 +71,7 @@ extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count,
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t pwritev (int __fd, const struct iovec *__iovec, int __count,
- off_t __offset) __wur;
+ __off64_t __offset) __wur;
#endif /* Use misc. */
__END_DECLS
diff --git a/libc/sysdeps/linux/common/preadv.c b/libc/sysdeps/linux/common/preadv.c
index fd9dde4b999c..6a07d5df87e0 100644
--- a/libc/sysdeps/linux/common/preadv.c
+++ b/libc/sysdeps/linux/common/preadv.c
@@ -21,7 +21,7 @@
#ifdef __NR_preadv
ssize_t
-preadv (int fd, const struct iovec *vector, int count, off_t offset)
+preadv (int fd, const struct iovec *vector, int count, __off64_t offset)
{
unsigned long pos_l, pos_h;
diff --git a/libc/sysdeps/linux/common/pwritev.c b/libc/sysdeps/linux/common/pwritev.c
index bef5bcf69b46..f07c40e6de3c 100644
--- a/libc/sysdeps/linux/common/pwritev.c
+++ b/libc/sysdeps/linux/common/pwritev.c
@@ -21,7 +21,7 @@
#ifdef __NR_pwritev
ssize_t
-pwritev (int fd, const struct iovec *vector, int count, off_t offset)
+pwritev (int fd, const struct iovec *vector, int count, __off64_t offset)
{
unsigned long pos_l, pos_h;
--
2.11.0
Add description for _LARGEFILE_SOURCE, _LARGEFILE64_SOURCE,
_FILE_OFFSET_BITS and __USE_LARGEFILE, __USE_LARGEFILE64 and
__USE_FILE_OFFSET64 macros.
Signed-off-by: Max Filippov <jcmvbkbc(a)gmail.com>
---
Changes v1->v2:
- fix subject line
docs/defines.txt | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/docs/defines.txt b/docs/defines.txt
index b23fac9c0036..6af44bdd809f 100644
--- a/docs/defines.txt
+++ b/docs/defines.txt
@@ -10,11 +10,28 @@ __USE_GNU, __USE_BSD, __USE_XOPEN[2K], __USE_SVID, __USE_POSIX...
If defined, user program which included us requests compat additions
from relevant standard or Unix flavor. See features.h for full list.
-__USE_FILE_OFFSET64
+_LARGEFILE_SOURCE
+ If defined, headers will provide functions fseeko and ftello.
+_LARGEFILE64_SOURCE
+ If defined, headers will in addition to data types, constants and
+ functions named xxx (e.g. off_t, struct stat, F_SETLK, ftruncate())
+ supply data types, constants and functions named xxx64 (e.g. off64_t,
+ struct stat64, F_SETLK64, ftruncate64()) known as an interface for
+ 64-bit file offsets.
__USE_LARGEFILE[64]
-_LARGEFILE[64]_SOURCE
+ Defined to 1 and used internally when built with _LARGEFILE[64]_SOURCE.
+ Undefined otherwise.
+
_FILE_OFFSET_BITS
- ???
+ Select default filesystem interface. When defined as 64 the data types,
+ constants and functions mentioned in _LARGEFILE64_SOURCE as xxx are
+ aliased to the corresponding xxx64 data types, constants and functions.
+ _FILE_OFFSET_BITS=64 enables both __USE_LARGEFILE and __USE_LARGEFILE64.
+ This flag does not affect the way libc itself is built, it only affects
+ what declarations are provided to library user.
+__USE_FILE_OFFSET64
+ Defined to 1 and used internally when built with _FILE_OFFSET_BITS=64.
+ Undefined otherwise.
__THROW
Function annotation "I do not throw anything".
--
2.11.0
Add description for _LARGEFILE_SOURCE, _LARGEFILE64_SOURCE,
_FILE_OFFSET_BITS and __USE_LARGEFILE, __USE_LARGEFILE64 and
__USE_FILE_OFFSET64 macros.
Signed-off-by: Max Filippov <jcmvbkbc(a)gmail.com>
---
docs/defines.txt | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/docs/defines.txt b/docs/defines.txt
index b23fac9c0036..6af44bdd809f 100644
--- a/docs/defines.txt
+++ b/docs/defines.txt
@@ -10,11 +10,28 @@ __USE_GNU, __USE_BSD, __USE_XOPEN[2K], __USE_SVID, __USE_POSIX...
If defined, user program which included us requests compat additions
from relevant standard or Unix flavor. See features.h for full list.
-__USE_FILE_OFFSET64
+_LARGEFILE_SOURCE
+ If defined, headers will provide functions fseeko and ftello.
+_LARGEFILE64_SOURCE
+ If defined, headers will in addition to data types, constants and
+ functions named xxx (e.g. off_t, struct stat, F_SETLK, ftruncate())
+ supply data types, constants and functions named xxx64 (e.g. off64_t,
+ struct stat64, F_SETLK64, ftruncate64()) known as an interface for
+ 64-bit file offsets.
__USE_LARGEFILE[64]
-_LARGEFILE[64]_SOURCE
+ Defined to 1 and used internally when built with _LARGEFILE[64]_SOURCE.
+ Undefined otherwise.
+
_FILE_OFFSET_BITS
- ???
+ Select default filesystem interface. When defined as 64 the data types,
+ constants and functions mentioned in _LARGEFILE64_SOURCE as xxx are
+ aliased to the corresponding xxx64 data types, constants and functions.
+ _FILE_OFFSET_BITS=64 enables both __USE_LARGEFILE and __USE_LARGEFILE64.
+ This flag does not affect the way libc itself is built, it only affects
+ what declarations are provided to library user.
+__USE_FILE_OFFSET64
+ Defined to 1 and used internally when built with _FILE_OFFSET_BITS=64.
+ Undefined otherwise.
__THROW
Function annotation "I do not throw anything".
--
2.11.0
On Thu, May 9, 2019 at 11:34 AM Max Filippov <jcmvbkbc(a)gmail.com> wrote:
> I've tried to run uclibc-ng tests on xtensa in a buildroot-built rootfs
> and found misc/tst-preadvwritev failing with the following message:
>
> first buffer from first preadv different than expected
>
> Digging deeper into it I've found that the test is built with the following
> definition in the command line: -D_FILE_OFFSET_BITS=64,
> due to the following line in the uclibc-ng-test.mk:
>
> UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)"
>
> but uclibc-ng itself does not have -D_FILE_OFFSET_BITS=64,
> because of the following definition in the uclibc-ng.mk:
>
> UCLIBC_EXTRA_CFLAGS="$(TARGET_ABI)"
>
> uclibc-ng defaults to 32-bit off_t type then.
> I'm not sure what's broken here, buildroot or uclibc-ng. Ideas?
Ok, I see something definitely strange in the uclibc-ng:
ublibc-ng does not honor -D_FILE_OFFSET_BITS=64
when it's passed to it in the make command, because
the following fragment of the include/features.h that defines
__USE_FILE_OFFSET64 based on the value of
_FILE_OFFSET_BITS
#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
# define __USE_FILE_OFFSET64 1
#endif
is neutralized by the following fragment at the end of the same file:
#ifdef _LIBC
# undef _FILE_OFFSET_BITS
# undef __USE_FILE_OFFSET64
# include <libc-internal.h>
#endif
--
Thanks.
-- Max
On 4/29/19 6:18 PM, Arnaldo Carvalho de Melo wrote:
>>> Auto-detecting system features:
>>> ... dwarf: [ OFF ]
>>> ... dwarf_getlocations: [ OFF ]
>>> ... glibc: [ on ]
>> Not related to current issue, this run uses a uClibc toolchain and yet it is
>> detecting glibc - doesn't seem right to me.
> Ok, I'll improve that, I think it just tries to detect a libc, yeah,
> see:
>
> [acme@quaco linux]$ cat tools/build/feature/test-glibc.c
> // SPDX-License-Identifier: GPL-2.0
> #include <stdlib.h>
>
> #if !defined(__UCLIBC__)
> #include <gnu/libc-version.h>
> #else
> #define XSTR(s) STR(s)
> #define STR(s) #s
> #endif
>
> int main(void)
> {
> #if !defined(__UCLIBC__)
> const char *version = gnu_get_libc_version();
> #else
> const char *version = XSTR(__GLIBC__) "." XSTR(__GLIBC_MINOR__);
> #endif
>
> return (long)version;
> }
> [acme@quaco linux]$
>
> [perfbuilder@59ca4b424ded /]$ grep __GLIBC__ /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/*.h
> /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/features.h: The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
> /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/features.h:#define __GLIBC__ 2
> /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/features.h: ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
> [perfbuilder@59ca4b424ded /]$
>
> Isn't that part of uClibc?
Right you are. Per the big fat comment right above that code, this gross hack in
uclibc is unavoidable as applications tend to rely on that define.
So a better fix would be to check for various !GLIBC libs explicitly.
#ifdef __UCLIBC__
#elseif defined __MUSL__
...
Not pretty from app usage pov, but that seems to be the only sane way of doing it.
-Vineet
Hi Volodymyr, all,
> -----Original Message-----
> From: Volodymyr Boyko <boyko.cxx(a)gmail.com>
> Sent: Monday, April 22, 2019 4:24 PM
> To: Alexey Brodkin <abrodkin(a)synopsys.com>
> Subject: Re: [uclibc-ng-devel] https://uclibc-ng.org/ is not available
>
> Can confirm that the site is available from Ukraine (16:23 22.04).
Looks like it was a short glitch and since then no other failures
have been observed, so sorry for the noise.
-Alexey
Hello,
I am wondering if libpthread/nptl/sysdeps/generic/dl-tls.c could be
cleaned up a little bit to improve code readability.
Especially I can see in the first lines that "#if SHARED => #error":
https://elixir.bootlin.com/uclibc-ng/latest/source/libpthread/nptl/sysdeps/…
And then the file contains some #ifdef SHARED (5 of them actually)
I wonder why this code is still guarded by ifdefs.
I am guessing that this is for maintainability purposes so that this
file does not diverge too much from its friend at ./ldso/ldso/dl-tls.c
and to ease maintaining both in sync.
If this guess is right, I believe removing code between "#ifdef SHARED"
is a no-go?
In this case, I would propose changing "#ifdef SHARED" by "#if 0".
So that it is very obvious for readers that the code is never included.
That would also keep it easy to maintain both files in sync.
If previous guesses are wrong maybe we can just strip the code altogether.
Based on the feedbacks I would propose a patch accordingly.
Thank's for your feedback on that!
Regards,
--
Yann