From patchwork Thu Feb 29 16:35:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Chestnykh X-Patchwork-Id: 1906411 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=R3mNmaSC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TlxgZ1jh6z23fC for ; Fri, 1 Mar 2024 03:36:23 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 23C73352822D; Thu, 29 Feb 2024 17:36:09 +0100 (CET) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=R3mNmaSC; dkim-atps=neutral Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by helium.openadk.org (Postfix) with ESMTPS id 889553521164 for ; Thu, 29 Feb 2024 17:36:01 +0100 (CET) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5132444ac00so278408e87.1 for ; Thu, 29 Feb 2024 08:36:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709224560; x=1709829360; darn=uclibc-ng.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mS5BeoP2McRc7rftCduvtj9XO7OrBDRELIAqAYopy2I=; b=R3mNmaSCiw03nlt6YdidC2vqJZJymkdI7qjbsT+4FADJvVhPjJ/D0btbqsQv3Kn68F muiOD7YtsQ8kwhqHn7dJAHMc4a1Hhg9MYJCFrkc16uCMl14FiZtcPnQptnL5rpWKGAW0 cOlvdqRt+Sy59YhBPH8On41rZ0vyYwbFLb/Zs78yhC7Iew8Rn+xCnnLGAOZWQ/Cu4Q4m yje71knI9TjxAOKILZOeJltfyNdxDkf0v1glZndoFoQlUW0KFoVbIlKPEdc3m4vXCPAn Fttg71rhh4r2StW2Q0u8TANCI/zHj6hy5rubpps6boo3YJ6u8a7UKdLqOWM/TaMQ6G3g D6YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709224560; x=1709829360; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mS5BeoP2McRc7rftCduvtj9XO7OrBDRELIAqAYopy2I=; b=qXtNvZPmpHk44ICR6OHrahaZ7COEeN4fwfuUApiflk7YgzFnGIOJMRKQOakIP8Osyj e/6FTvhOm/B52pcT3vpSw4ckJM/rfKwbDguSHe3OvhcKYcf5tm1+dPpxT0tVUX3oe2GP jRTVy2vNR1StNSxJu5+BbB5HLp3TrFqQY0wnHl9NBe+J+0ppNzCwVqFYX9Yy3rCK9rVL Rt+4hQu7ewg/noOViML7vGu01F0LgNo3T1XeinyZYfyYDJq4lDjrsHPOZ2bnhWhjrQyI yowzwygva8xuGCxgp7nkBNlm57Sj4ENSI5rk90G4c+rgk83T55JWh2aFM1dGKv4uhbUV 7OvA== X-Gm-Message-State: AOJu0YxpJ8j0NDxMX9/fXeCEpvOz/Df34jQG+SotRY9STjqHjzK3rbzz BsCBp1FqEQiNUkJMefGpNS140anvwkwKszl5C6B45hC/7bTe93rObrm4SeFv X-Google-Smtp-Source: AGHT+IFP/XpejxaaUuqwpafYlstrcEw89/WhmrFRbtTBsXqMtdiTQgJjw95b6yvfg5xnkdc6hxQrYA== X-Received: by 2002:a05:6512:3703:b0:513:2ba9:4b0f with SMTP id z3-20020a056512370300b005132ba94b0fmr632533lfr.4.1709224559739; Thu, 29 Feb 2024 08:35:59 -0800 (PST) Received: from localhost.localdomain ([2a00:1370:817a:d2b8:e47e:b3b7:28ce:8ed9]) by smtp.gmail.com with ESMTPSA id k30-20020a192d1e000000b00513201a0e56sm306702lfj.78.2024.02.29.08.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 08:35:59 -0800 (PST) From: Dmitry Chestnykh To: devel@uclibc-ng.org Date: Thu, 29 Feb 2024 19:35:53 +0300 Message-ID: <20240229163553.2476623-1-dm.chestnykh@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Message-ID-Hash: RZMBMTOG7UPKF3QTUW4FMMSLTFAU6SDV X-Message-ID-Hash: RZMBMTOG7UPKF3QTUW4FMMSLTFAU6SDV X-MailFrom: dm.chestnykh@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Dmitry Chestnykh X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH] Add time64 support for sparc. List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: By some reason sparc ld.so cannot work properly with statx() system call, so fallback to regular stat() family in ld.so. Signed-off-by: Dmitry Chestnykh --- extra/Configs/Config.in | 1 + ldso/include/dl-syscall.h | 10 +++++----- libc/sysdeps/linux/sparc/bits/kernel_stat.h | 16 ++++++++++++++++ libc/sysdeps/linux/sparc/bits/sem.h | 18 ++++++++++++++++-- libc/sysdeps/linux/sparc/bits/typesizes.h | 12 ++++++++++++ .../linux/sparc/bits/uClibc_arch_features.h | 3 --- 6 files changed, 50 insertions(+), 10 deletions(-) diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index ded1f72c9..bae7b4885 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -1030,6 +1030,7 @@ config UCLIBC_USE_TIME64 (TARGET_mips && !CONFIG_MIPS_N64_ABI) || \ TARGET_or1k || \ TARGET_powerpc || \ + TARGET_sparc || \ TARGET_xtensa # TODO: add support for other architectures default n diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h index 666a7c693..b40f58b10 100644 --- a/ldso/include/dl-syscall.h +++ b/ldso/include/dl-syscall.h @@ -20,7 +20,7 @@ extern int _dl_errno; #define _SYS_MMAN_H 1 #include -#if defined(__ARCH_HAS_DEPRECATED_SYSCALLS__) && !defined(__UCLIBC_USE_TIME64__) +#if defined(__ARCH_HAS_DEPRECATED_SYSCALLS__) && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__)) /* Pull in whatever this particular arch's kernel thinks the kernel version of * struct stat should look like. It turns out that each arch has a different * opinion on the subject, and different kernel revs use different names... */ @@ -116,7 +116,7 @@ static __always_inline _syscall3(unsigned long, _dl_read, int, fd, static __always_inline _syscall3(int, _dl_mprotect, const void *, addr, unsigned long, len, int, prot) -#if defined __NR_fstatat64 && !defined __NR_stat && !defined(__UCLIBC_USE_TIME64__) +#if defined __NR_fstatat64 && !defined __NR_stat && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__)) # define __NR__dl_fstatat64 __NR_fstatat64 static __always_inline _syscall4(int, _dl_fstatat64, int, fd, const char *, fn, struct stat *, stat, int, flags) @@ -126,7 +126,7 @@ static __always_inline int _dl_stat(const char *file_name, { return _dl_fstatat64(AT_FDCWD, file_name, buf, 0); } -#elif defined __NR_newfstatat && !defined __NR_stat && !defined(__UCLIBC_USE_TIME64__) +#elif defined __NR_newfstatat && !defined __NR_stat && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__)) # define __NR__dl_newfstatat __NR_newfstatat static __always_inline _syscall4(int, _dl_newfstatat, int, fd, const char *, fn, struct stat *, stat, int, flags) @@ -136,7 +136,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__) +#elif defined __NR_stat && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__)) # define __NR__dl_stat __NR_stat static __always_inline _syscall2(int, _dl_stat, const char *, file_name, struct stat *, buf) @@ -160,7 +160,7 @@ static __always_inline int _dl_stat(const char *file_name, } #endif -#if defined __NR_fstat64 && !defined __NR_fstat && !defined(__UCLIBC_USE_TIME64__) +#if defined __NR_fstat64 && !defined __NR_fstat && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__)) # define __NR__dl_fstat __NR_fstat64 static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf) #elif defined __NR_fstat diff --git a/libc/sysdeps/linux/sparc/bits/kernel_stat.h b/libc/sysdeps/linux/sparc/bits/kernel_stat.h index e960857fe..5e214c72f 100644 --- a/libc/sysdeps/linux/sparc/bits/kernel_stat.h +++ b/libc/sysdeps/linux/sparc/bits/kernel_stat.h @@ -5,6 +5,10 @@ * struct kernel_stat should look like... It turns out each arch has a * different opinion on the subject... */ +#if defined(__UCLIBC_USE_TIME64__) +#include "internal/time64_helpers.h" +#endif + struct kernel_stat { unsigned short st_dev; unsigned long st_ino; @@ -14,9 +18,15 @@ struct kernel_stat { unsigned short st_gid; unsigned short st_rdev; long st_size; +#if defined(__UCLIBC_USE_TIME64__) + struct __ts32_struct __st_atim32; + struct __ts32_struct __st_mtim32; + struct __ts32_struct __st_ctim32; +#else struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; +#endif long st_blksize; long st_blocks; unsigned long __unused4[2]; @@ -35,9 +45,15 @@ struct kernel_stat64 { unsigned int st_blksize; unsigned char __pad4[8]; unsigned int st_blocks; +#if defined(__UCLIBC_USE_TIME64__) + struct __ts32_struct __st_atim32; + struct __ts32_struct __st_mtim32; + struct __ts32_struct __st_ctim32; +#else struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; +#endif unsigned int __unused4; unsigned int __unused5; }; diff --git a/libc/sysdeps/linux/sparc/bits/sem.h b/libc/sysdeps/linux/sparc/bits/sem.h index 04c579fc6..23fd7c2eb 100644 --- a/libc/sysdeps/linux/sparc/bits/sem.h +++ b/libc/sysdeps/linux/sparc/bits/sem.h @@ -38,10 +38,24 @@ struct semid_ds { struct ipc_perm sem_perm; /* operation permission struct */ unsigned int __pad1; - __time_t sem_otime; /* last semop() time */ +#if defined(__UCLIBC_USE_TIME64__) + unsigned long int __sem_otime_internal_1; /* last semop() time */ + unsigned long int __sem_otime_internal_2; +#else + __time_t sem_otime; /* last semop() time */ +#endif unsigned int __pad2; - __time_t sem_ctime; /* last time changed by semctl() */ +#if defined(__UCLIBC_USE_TIME64__) + unsigned long int __sem_ctime_internal_1; /* last time changed by semctl() */ + unsigned long int __sem_ctime_internal_2; +#else + __time_t sem_ctime; /* last time changed by semctl() */ +#endif unsigned long int sem_nsems; /* number of semaphores in set */ +#if defined(__UCLIBC_USE_TIME64__) + __time_t sem_otime; + __time_t sem_ctime; +#endif unsigned long int __uclibc_unused1; unsigned long int __uclibc_unused2; }; diff --git a/libc/sysdeps/linux/sparc/bits/typesizes.h b/libc/sysdeps/linux/sparc/bits/typesizes.h index 37b7656aa..c7b7f5576 100644 --- a/libc/sysdeps/linux/sparc/bits/typesizes.h +++ b/libc/sysdeps/linux/sparc/bits/typesizes.h @@ -46,9 +46,21 @@ #define __FSFILCNT64_T_TYPE __UQUAD_TYPE #define __ID_T_TYPE __U32_TYPE #define __CLOCK_T_TYPE __SLONGWORD_TYPE + +#ifdef __UCLIBC_USE_TIME64__ +#define __TIME_T_TYPE __S64_TYPE +#else #define __TIME_T_TYPE __SLONGWORD_TYPE +#endif + #define __USECONDS_T_TYPE __U32_TYPE + +#ifdef __UCLIBC_USE_TIME64__ +#define __SUSECONDS_T_TYPE __S64_TYPE +#else #define __SUSECONDS_T_TYPE __S32_TYPE +#endif + #define __DADDR_T_TYPE __S32_TYPE #define __SWBLK_T_TYPE __SLONGWORD_TYPE #define __KEY_T_TYPE __S32_TYPE diff --git a/libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h b/libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h index 76f5084ff..283a250bb 100644 --- a/libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h +++ b/libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h @@ -11,9 +11,6 @@ /* can your target use syscall6() for mmap ? */ #define __UCLIBC_MMAP_HAS_6_ARGS__ -/* does your target use statx */ -#undef __UCLIBC_HAVE_STATX__ - /* does your target align 64bit values in register pairs ? (32bit arches only) */ #undef __UCLIBC_SYSCALL_ALIGN_64BIT__