From 69ddf2d5e99049bd91f49785e6267e57ec76bae3 Mon Sep 17 00:00:00 2001 From: Vincent Jicquel Date: Fri, 26 Jan 2024 17:16:00 +0100 Subject: [PATCH] Adapt Read_Symbolic_Link for 32-bit architectures This function was failing on the ppc-linux architecture. Replace 64-bit type size with more generic ssize_t and size_t types. Issue: eng/toolchain/gnatcoll-core#27 Co-author: Nicolas Roche Change-Id: Ia92850d3765d38430dede1defc930057b420bb63 --- src/os/gnatcoll-os-fsutil-read_symbolic_link__unix.adb | 4 ++-- src/os/unix/gnatcoll-os-libc.ads | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/os/gnatcoll-os-fsutil-read_symbolic_link__unix.adb b/src/os/gnatcoll-os-fsutil-read_symbolic_link__unix.adb index a9429327..5e5858cf 100644 --- a/src/os/gnatcoll-os-fsutil-read_symbolic_link__unix.adb +++ b/src/os/gnatcoll-os-fsutil-read_symbolic_link__unix.adb @@ -22,6 +22,7 @@ ------------------------------------------------------------------------------ with Interfaces.C; +with GNATCOLL.Memory; use GNATCOLL.Memory; with GNATCOLL.OS.Libc; use GNATCOLL.OS.Libc; with GNATCOLL.String_Builders; with Ada.Strings.Unbounded; @@ -38,13 +39,12 @@ is use all type SB.Static_String_Builder; Link_C_Path : SB.Static_String_Builder (Link_Path'Length + 1); - Bytes_Read : Sint_64; + Bytes_Read : GNATCOLL.Memory.ssize_t; C_Buf : C.char_array (1 .. 4096) := (others => C.nul); -- PATH_MAX is usually set to 4096 bytes, so we set the maximum -- target path length to this value. begin - Append (Link_C_Path, Link_Path); Bytes_Read := diff --git a/src/os/unix/gnatcoll-os-libc.ads b/src/os/unix/gnatcoll-os-libc.ads index 31e1423d..55dbb147 100644 --- a/src/os/unix/gnatcoll-os-libc.ads +++ b/src/os/unix/gnatcoll-os-libc.ads @@ -267,8 +267,10 @@ package GNATCOLL.OS.Libc is Import => True, Convention => C, External_Name => "symlinkat"; function ReadLink - (Path_Name : C_String; Buf : out char_array; Buf_Size : Uint_64) - return Sint_64 with + (Path_Name : C_String; + Buf : out char_array; + Buf_Size : GNATCOLL.Memory.size_t) + return GNATCOLL.Memory.ssize_t with Import => True, Convention => C, External_Name => "readlink"; end GNATCOLL.OS.Libc;