diff mbox series

[uclibc-ng-devel,v2,sh4] Fix sh4 compilation with 4.x kernel headers

Message ID 20240720142345.773848-1-dm.chestnykh@gmail.com
State Accepted
Headers show
Series [uclibc-ng-devel,v2,sh4] Fix sh4 compilation with 4.x kernel headers | expand

Commit Message

Dmitry Chestnykh July 20, 2024, 2:23 p.m. UTC
- Fallback to __NR_stat syscall in ld.so if we use 4.x kernel headers.
4.x kernel doesn't support 64-bit time so we can use old syscall
- Add preprocessor conditions to have fstat64 and fstatat64 in libc
with old kernel headers

Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
---
 ldso/include/dl-syscall.h             | 4 +++-
 libc/sysdeps/linux/common/fstat64.c   | 3 ++-
 libc/sysdeps/linux/common/fstatat64.c | 3 ++-
 3 files changed, 7 insertions(+), 3 deletions(-)

Comments

Waldemar Brodkorb July 22, 2024, 11:43 a.m. UTC | #1
Hi Dmitry,

thanks, applied and pushed,
 best regards
  Waldemar

Dmitry Chestnykh wrote,

> - Fallback to __NR_stat syscall in ld.so if we use 4.x kernel headers.
> 4.x kernel doesn't support 64-bit time so we can use old syscall
> - Add preprocessor conditions to have fstat64 and fstatat64 in libc
> with old kernel headers
> 
> Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
> ---
>  ldso/include/dl-syscall.h             | 4 +++-
>  libc/sysdeps/linux/common/fstat64.c   | 3 ++-
>  libc/sysdeps/linux/common/fstatat64.c | 3 ++-
>  3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
> index 4f41034ad..9ec0eac60 100644
> --- a/ldso/include/dl-syscall.h
> +++ b/ldso/include/dl-syscall.h
> @@ -17,6 +17,8 @@ extern int _dl_errno;
>  #define __set_errno(X) {(_dl_errno) = (X);}
>  #endif
>  
> +#include <linux/version.h>
> +
>  /* Pull in the arch specific syscall implementation */
>  #include <dl-syscalls.h>
>  /*  For MAP_ANONYMOUS -- differs between platforms */
> @@ -139,7 +141,7 @@ static __always_inline int _dl_stat(const char *file_name,
>  {
>  	return _dl_newfstatat(AT_FDCWD, file_name, buf, 0);
>  }
> -#elif defined __NR_stat && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__))
> +#elif defined __NR_stat && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__)) || (LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))
>  # define __NR__dl_stat __NR_stat
>  static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
>                          struct stat *, buf)
> diff --git a/libc/sysdeps/linux/common/fstat64.c b/libc/sysdeps/linux/common/fstat64.c
> index 359c22af6..121b21fc8 100644
> --- a/libc/sysdeps/linux/common/fstat64.c
> +++ b/libc/sysdeps/linux/common/fstat64.c
> @@ -8,8 +8,9 @@
>  
>  #include <_lfs_64.h>
>  #include <sys/syscall.h>
> +#include <linux/version.h>
>  
> -#if defined(__NR_fstat64) && !defined(__UCLIBC_USE_TIME64__)
> +#if defined(__NR_fstat64) && (!defined(__UCLIBC_USE_TIME64__) || LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))
>  # include <unistd.h>
>  # include <sys/stat.h>
>  # include "xstatconv.h"
> diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c
> index 16dbf9215..739e84081 100644
> --- a/libc/sysdeps/linux/common/fstatat64.c
> +++ b/libc/sysdeps/linux/common/fstatat64.c
> @@ -9,6 +9,7 @@
>  #include <_lfs_64.h>
>  #include <bits/wordsize.h>
>  #include <sys/syscall.h>
> +#include <linux/version.h>
>  
>  #if defined __mips__
>  # include <sgidefs.h>
> @@ -23,7 +24,7 @@
>  # define __NR_fstatat64 __NR_newfstatat
>  #endif
>  
> -#if defined(__NR_fstatat64) && !defined(__UCLIBC_USE_TIME64__)
> +#if defined(__NR_fstatat64) && (!defined(__UCLIBC_USE_TIME64__)  || LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))
>  # include <sys/stat.h>
>  # include "xstatconv.h"
>  int fstatat64(int fd, const char *file, struct stat64 *buf, int flag)
> -- 
> 2.45.2
> 
> _______________________________________________
> devel mailing list -- devel@uclibc-ng.org
> To unsubscribe send an email to devel-leave@uclibc-ng.org
>
diff mbox series

Patch

diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
index 4f41034ad..9ec0eac60 100644
--- a/ldso/include/dl-syscall.h
+++ b/ldso/include/dl-syscall.h
@@ -17,6 +17,8 @@  extern int _dl_errno;
 #define __set_errno(X) {(_dl_errno) = (X);}
 #endif
 
+#include <linux/version.h>
+
 /* Pull in the arch specific syscall implementation */
 #include <dl-syscalls.h>
 /*  For MAP_ANONYMOUS -- differs between platforms */
@@ -139,7 +141,7 @@  static __always_inline int _dl_stat(const char *file_name,
 {
 	return _dl_newfstatat(AT_FDCWD, file_name, buf, 0);
 }
-#elif defined __NR_stat && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__))
+#elif defined __NR_stat && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__)) || (LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))
 # define __NR__dl_stat __NR_stat
 static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
                         struct stat *, buf)
diff --git a/libc/sysdeps/linux/common/fstat64.c b/libc/sysdeps/linux/common/fstat64.c
index 359c22af6..121b21fc8 100644
--- a/libc/sysdeps/linux/common/fstat64.c
+++ b/libc/sysdeps/linux/common/fstat64.c
@@ -8,8 +8,9 @@ 
 
 #include <_lfs_64.h>
 #include <sys/syscall.h>
+#include <linux/version.h>
 
-#if defined(__NR_fstat64) && !defined(__UCLIBC_USE_TIME64__)
+#if defined(__NR_fstat64) && (!defined(__UCLIBC_USE_TIME64__) || LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))
 # include <unistd.h>
 # include <sys/stat.h>
 # include "xstatconv.h"
diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c
index 16dbf9215..739e84081 100644
--- a/libc/sysdeps/linux/common/fstatat64.c
+++ b/libc/sysdeps/linux/common/fstatat64.c
@@ -9,6 +9,7 @@ 
 #include <_lfs_64.h>
 #include <bits/wordsize.h>
 #include <sys/syscall.h>
+#include <linux/version.h>
 
 #if defined __mips__
 # include <sgidefs.h>
@@ -23,7 +24,7 @@ 
 # define __NR_fstatat64 __NR_newfstatat
 #endif
 
-#if defined(__NR_fstatat64) && !defined(__UCLIBC_USE_TIME64__)
+#if defined(__NR_fstatat64) && (!defined(__UCLIBC_USE_TIME64__)  || LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))
 # include <sys/stat.h>
 # include "xstatconv.h"
 int fstatat64(int fd, const char *file, struct stat64 *buf, int flag)