public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@wdc.com>
To: libc-alpha@sourceware.org
Cc: alistair.francis@wdc.com, alistair23@gmail.com
Subject: [PATCH v3 07/19] RISC-V: Add path of library directories for the 32-bit
Date: Sun, 12 Jul 2020 08:47:39 -0700	[thread overview]
Message-ID: <5cf15612abb2f89e7cf7b76b1546b558751ce261.1594568655.git.alistair.francis@wdc.com> (raw)
In-Reply-To: <cover.1594568655.git.alistair.francis@wdc.com>

With RV32 support the list of possible RISC-V system directories
increases to:
     - /lib64/lp64d
     - /lib64/lp64
     - /lib32/ilp32d
     - /lib32/ilp32
     - /lib (only ld.so)

This patch changes the add_system_di () macro to support the new ilp32d
and ilp32 directories for RV32. While refactoring this code let's split
out the confusing if statements into a loop to make it easier to
understand and extend.
---
 sysdeps/unix/sysv/linux/riscv/dl-cache.h | 39 +++++++++++++++++-------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/riscv/dl-cache.h b/sysdeps/unix/sysv/linux/riscv/dl-cache.h
index b3cda4ef9f..7317406036 100644
--- a/sysdeps/unix/sysv/linux/riscv/dl-cache.h
+++ b/sysdeps/unix/sysv/linux/riscv/dl-cache.h
@@ -30,10 +30,12 @@
   ((flags) == _DL_CACHE_DEFAULT_ID)
 
 /* If given a path to one of our library directories, adds every library
-   directory via add_dir (), otherwise just adds the giver directory.  On
+   directory via add_dir (), otherwise just adds the given directory.  On
    RISC-V, libraries can be found in paths ending in:
      - /lib64/lp64d
      - /lib64/lp64
+     - /lib32/ilp32d
+     - /lib32/ilp32
      - /lib (only ld.so)
    so this will add all of those paths.
 
@@ -45,25 +47,40 @@
 	 architectures and have that automatically imply /usr/local/lib64/lp64d
 	 etc. so that libraries can be found that come from software that does
 	 use the ABI-specific directories.  */
+
 #define add_system_dir(dir) 									\
   do							    					\
     {												\
+	static const char* lib_dirs[] = {							\
+		"/lib64/lp64d",									\
+		"/lib64/lp64",									\
+		"/lib32/ilp32d",								\
+		"/lib32/ilp32",									\
+		NULL,										\
+	};											\
 	size_t len = strlen (dir);								\
-	char path[len + 9];									\
+	char path[len + 10];									\
 	memcpy (path, dir, len + 1);								\
-	if (len >= 12 && ! memcmp(path + len - 12, "/lib64/lp64d", 12))				\
-	{											\
-	  len -= 8;										\
-	  path[len] = '\0';									\
-	}											\
-	if (len >= 11 && ! memcmp(path + len - 11, "/lib64/lp64", 11))				\
-	{											\
-	  len -= 7;										\
-	  path[len] = '\0';									\
+	int i = 0;										\
+	const char* lib_dir = lib_dirs[0];								\
+												\
+	while (lib_dir != NULL) {								\
+		size_t dir_len = strlen (lib_dir);						\
+		if (len >= dir_len && ! memcmp(path + len - dir_len, lib_dir, dir_len)) {	\
+			len -= dir_len + 4;							\
+			path[len] = '\0';							\
+			break;									\
+		}										\
+		i++;										\
+		lib_dir = lib_dirs[i];								\
 	}											\
 	add_dir (path);										\
 	if (len >= 4 && ! memcmp(path + len - 4, "/lib", 4))					\
 	{											\
+	  memcpy (path + len, "32/ilp32d", 10);							\
+	  add_dir (path);									\
+	  memcpy (path + len, "32/ilp32", 9);							\
+	  add_dir (path);									\
 	  memcpy (path + len, "64/lp64d", 9);							\
 	  add_dir (path);									\
 	  memcpy (path + len, "64/lp64", 8);							\
-- 
2.27.0


  parent reply	other threads:[~2020-07-12 15:57 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-12 15:47 [PATCH v3 00/19] glibc port for 32-bit RISC-V (RV32) Alistair Francis
2020-07-12 15:47 ` [PATCH v3 01/19] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64 Alistair Francis
2020-07-15 17:29   ` Maciej W. Rozycki
2020-07-12 15:47 ` [PATCH v3 02/19] RISC-V: Cleanup some of the sysdep.h code Alistair Francis
2020-07-16  1:07   ` Maciej W. Rozycki
2020-08-10 15:16     ` Alistair Francis
2020-07-12 15:47 ` [PATCH v3 03/19] RISC-V: Use 64-bit-time syscall numbers with the 32-bit port Alistair Francis
2020-07-16  1:58   ` Maciej W. Rozycki
2020-08-10 15:15     ` Alistair Francis
2020-07-12 15:47 ` [PATCH v3 04/19] RISC-V: Add support for 32-bit vDSO calls Alistair Francis
2020-07-16  0:12   ` Maciej W. Rozycki
2020-07-12 15:47 ` [PATCH v3 05/19] RISC-V: Support dynamic loader for the 32-bit Alistair Francis
2020-07-12 15:47 ` [PATCH v3 06/19] sysv/linux: riscv: Fix dl-cache.h indentation Alistair Francis
2020-07-16  6:31   ` Maciej W. Rozycki
2020-07-12 15:47 ` Alistair Francis [this message]
2020-07-16  7:03   ` [PATCH v3 07/19] RISC-V: Add path of library directories for the 32-bit Maciej W. Rozycki
2020-07-12 15:47 ` [PATCH v3 08/19] RISC-V: Add arch-syscall.h for RV32 Alistair Francis
2020-07-12 15:47 ` [PATCH v3 09/19] RISC-V: nptl: update default pthread-offsets.h Alistair Francis
2020-07-12 15:47 ` [PATCH v3 10/19] RISC-V: Support the 32-bit ABI implementation Alistair Francis
2020-07-16  8:23   ` Maciej W. Rozycki
2020-07-12 15:47 ` [PATCH v3 11/19] RISC-V: Hard float support for 32-bit Alistair Francis
2020-07-16  8:27   ` Maciej W. Rozycki
2020-07-12 15:47 ` [PATCH v3 12/19] RISC-V: Add ABI lists Alistair Francis
2020-07-12 15:47 ` [PATCH v3 13/19] RISC-V: Add the RV32 libm-test-ulps Alistair Francis
2020-07-13 17:14   ` Maciej W. Rozycki
2020-07-13 17:32     ` Alistair Francis
2020-07-13 19:19       ` Maciej W. Rozycki
2020-07-13 19:38         ` Carlos O'Donell
2020-07-30 23:11           ` [PATCH] RISC-V: Update lp64d libm-test-ulps according to HiFive Unleashed Maciej W. Rozycki
2020-08-03 17:52             ` Carlos O'Donell
2020-08-04 12:01               ` Maciej W. Rozycki
2020-07-13 21:26     ` [PATCH v3 13/19] RISC-V: Add the RV32 libm-test-ulps Joseph Myers
2020-07-13 21:30       ` Carlos O'Donell
2020-07-13 21:59         ` Joseph Myers
2020-07-13 22:26           ` Andrew Waterman
2020-07-14  0:00             ` Maciej W. Rozycki
2020-07-14 17:24               ` Joseph Myers
2020-07-12 15:47 ` [PATCH v3 14/19] RISC-V: Fix llrint and llround missing exceptions on RV32 Alistair Francis
2020-07-14 22:13   ` Maciej W. Rozycki
2020-07-22 16:30     ` Alistair Francis
2020-07-12 15:48 ` [PATCH v3 15/19] RISC-V: Build Infastructure for 32-bit Alistair Francis
2020-07-14 23:55   ` Maciej W. Rozycki
2020-08-10 15:45     ` Alistair Francis
2020-07-12 15:48 ` [PATCH v3 16/19] riscv32: Specify the arch_minimum_kernel as 5.4 Alistair Francis
2020-07-15  0:06   ` Maciej W. Rozycki
2020-07-16  1:34     ` Maciej W. Rozycki
2020-07-12 15:48 ` [PATCH v3 17/19] RISC-V: Add rv32 path to RTLDLIST in ldd Alistair Francis
2020-07-15  0:32   ` Maciej W. Rozycki
2020-08-10 20:04     ` Alistair Francis
2020-07-12 15:48 ` [PATCH v3 18/19] Documentation for the RISC-V 32-bit port Alistair Francis
2020-07-13 17:17   ` Adhemerval Zanella
2020-07-14 13:28     ` Alistair Francis
2020-07-15  0:53   ` Maciej W. Rozycki
2020-07-22 16:33     ` Alistair Francis
2020-07-12 15:48 ` [PATCH v3 19/19] Add RISC-V 32-bit target to build-many-glibcs.py Alistair Francis
2020-07-15  1:16   ` Maciej W. Rozycki
2020-07-13 21:15 ` [PATCH v3 00/19] glibc port for 32-bit RISC-V (RV32) Joseph Myers
2020-07-14 13:18   ` Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5cf15612abb2f89e7cf7b76b1546b558751ce261.1594568655.git.alistair.francis@wdc.com \
    --to=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).