2023-05-29 16:47:58 +00:00
|
|
|
From 5bc3deb9bc2679ad4f6f189a65e3643b550587a1 Mon Sep 17 00:00:00 2001
|
2020-08-21 10:18:02 +00:00
|
|
|
From: Ariadne Conill <ariadne@dereferenced.org>
|
|
|
|
Date: Fri, 21 Aug 2020 07:06:30 +0000
|
2023-05-29 16:47:58 +00:00
|
|
|
Subject: [PATCH 25/33] ada: libgnarl compatibility for musl
|
2020-08-21 10:18:02 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
gcc/ada/libgnarl/s-osinte__linux.ads | 11 ------
|
|
|
|
gcc/ada/libgnarl/s-taprop__linux.adb | 53 ++--------------------------
|
|
|
|
2 files changed, 3 insertions(+), 61 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/gcc/ada/libgnarl/s-osinte__linux.ads b/gcc/ada/libgnarl/s-osinte__linux.ads
|
2023-05-15 08:15:31 +00:00
|
|
|
index a5e645d334d..32165347071 100644
|
2020-08-21 10:18:02 +00:00
|
|
|
--- a/gcc/ada/libgnarl/s-osinte__linux.ads
|
|
|
|
+++ b/gcc/ada/libgnarl/s-osinte__linux.ads
|
2022-08-13 15:17:36 +00:00
|
|
|
@@ -403,12 +403,6 @@ package System.OS_Interface is
|
2018-12-12 17:14:55 +00:00
|
|
|
PTHREAD_RWLOCK_PREFER_WRITER_NP : constant := 1;
|
|
|
|
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
|
|
|
|
|
|
|
|
- function pthread_rwlockattr_setkind_np
|
|
|
|
- (attr : access pthread_rwlockattr_t;
|
|
|
|
- pref : int) return int;
|
|
|
|
- pragma Import
|
|
|
|
- (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
|
|
|
|
-
|
|
|
|
function pthread_rwlock_init
|
|
|
|
(mutex : access pthread_rwlock_t;
|
|
|
|
attr : access pthread_rwlockattr_t) return int;
|
2022-08-13 15:17:36 +00:00
|
|
|
@@ -470,11 +464,6 @@ package System.OS_Interface is
|
2018-12-12 17:14:55 +00:00
|
|
|
protocol : int) return int;
|
|
|
|
pragma Import (C, pthread_mutexattr_setprotocol);
|
|
|
|
|
|
|
|
- function pthread_mutexattr_setprioceiling
|
|
|
|
- (attr : access pthread_mutexattr_t;
|
|
|
|
- prioceiling : int) return int;
|
|
|
|
- pragma Import (C, pthread_mutexattr_setprioceiling);
|
|
|
|
-
|
|
|
|
type struct_sched_param is record
|
|
|
|
sched_priority : int; -- scheduling priority
|
|
|
|
end record;
|
2020-08-21 10:18:02 +00:00
|
|
|
diff --git a/gcc/ada/libgnarl/s-taprop__linux.adb b/gcc/ada/libgnarl/s-taprop__linux.adb
|
2023-05-15 08:15:31 +00:00
|
|
|
index 821ceef30e4..ae95b58e01e 100644
|
2020-08-21 10:18:02 +00:00
|
|
|
--- a/gcc/ada/libgnarl/s-taprop__linux.adb
|
|
|
|
+++ b/gcc/ada/libgnarl/s-taprop__linux.adb
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -198,9 +198,6 @@ package body System.Task_Primitives.Operations is
|
2018-12-12 17:14:55 +00:00
|
|
|
pragma Import
|
|
|
|
(C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
|
|
|
|
|
|
|
|
- function GNAT_has_cap_sys_nice return C.int;
|
|
|
|
- pragma Import
|
|
|
|
- (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
|
|
|
|
-- We do not have pragma Linker_Options ("-lcap"); here, because this
|
|
|
|
-- library is not present on many Linux systems. 'libcap' is the Linux
|
|
|
|
-- "capabilities" library, called by __gnat_has_cap_sys_nice.
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -210,38 +207,6 @@ package body System.Task_Primitives.Operations is
|
2018-12-12 17:14:55 +00:00
|
|
|
-- Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
|
|
|
|
-- GNU/Linux, so we map 0 .. 98 to 1 .. 99.
|
|
|
|
|
|
|
|
- function Get_Ceiling_Support return Boolean;
|
|
|
|
- -- Get the value of the Ceiling_Support constant (see below).
|
|
|
|
- -- Note well: If this function or related code is modified, it should be
|
|
|
|
- -- tested by hand, because automated testing doesn't exercise it.
|
|
|
|
-
|
|
|
|
- -------------------------
|
|
|
|
- -- Get_Ceiling_Support --
|
|
|
|
- -------------------------
|
|
|
|
-
|
|
|
|
- function Get_Ceiling_Support return Boolean is
|
|
|
|
- Ceiling_Support : Boolean := False;
|
|
|
|
- begin
|
|
|
|
- if Locking_Policy /= 'C' then
|
|
|
|
- return False;
|
|
|
|
- end if;
|
|
|
|
-
|
|
|
|
- declare
|
|
|
|
- function geteuid return Integer;
|
|
|
|
- pragma Import (C, geteuid, "geteuid");
|
|
|
|
- Superuser : constant Boolean := geteuid = 0;
|
|
|
|
- Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
|
|
|
|
- pragma Assert (Has_Cap in 0 | 1);
|
|
|
|
- begin
|
|
|
|
- Ceiling_Support := Superuser or else Has_Cap = 1;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- return Ceiling_Support;
|
|
|
|
- end Get_Ceiling_Support;
|
|
|
|
-
|
2021-11-25 09:09:10 +00:00
|
|
|
- pragma Warnings (Off, "non-preelaborable call not allowed*");
|
2018-12-12 17:14:55 +00:00
|
|
|
- Ceiling_Support : constant Boolean := Get_Ceiling_Support;
|
2021-11-25 09:09:10 +00:00
|
|
|
- pragma Warnings (On, "non-preelaborable call not allowed*");
|
2018-12-12 17:14:55 +00:00
|
|
|
-- True if the locking policy is Ceiling_Locking, and the current process
|
|
|
|
-- has permission to use this policy. The process has permission if it is
|
|
|
|
-- running as 'root', or if the capability was set by the setcap command,
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -344,7 +309,9 @@ package body System.Task_Primitives.Operations is
|
2018-12-12 17:14:55 +00:00
|
|
|
-- Init_Mutex --
|
|
|
|
----------------
|
|
|
|
|
|
|
|
+ pragma Warnings (Off, "formal parameter * is not referenced");
|
|
|
|
function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
|
|
|
|
+ pragma Warnings (On, "formal parameter * is not referenced");
|
|
|
|
Mutex_Attr : aliased pthread_mutexattr_t;
|
|
|
|
Result, Result_2 : C.int;
|
|
|
|
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -356,16 +323,7 @@ package body System.Task_Primitives.Operations is
|
2018-12-12 17:14:55 +00:00
|
|
|
return Result;
|
|
|
|
end if;
|
|
|
|
|
|
|
|
- if Ceiling_Support then
|
|
|
|
- Result := pthread_mutexattr_setprotocol
|
|
|
|
- (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
|
|
|
|
- pragma Assert (Result = 0);
|
|
|
|
-
|
|
|
|
- Result := pthread_mutexattr_setprioceiling
|
|
|
|
- (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
|
|
|
|
- pragma Assert (Result = 0);
|
|
|
|
-
|
|
|
|
- elsif Locking_Policy = 'I' then
|
|
|
|
+ if Locking_Policy = 'I' then
|
|
|
|
Result := pthread_mutexattr_setprotocol
|
|
|
|
(Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
|
|
|
|
pragma Assert (Result = 0);
|
2021-11-25 09:09:10 +00:00
|
|
|
@@ -405,11 +363,6 @@ package body System.Task_Primitives.Operations is
|
2018-12-12 17:14:55 +00:00
|
|
|
Result := pthread_rwlockattr_init (RWlock_Attr'Access);
|
|
|
|
pragma Assert (Result = 0);
|
|
|
|
|
|
|
|
- Result := pthread_rwlockattr_setkind_np
|
|
|
|
- (RWlock_Attr'Access,
|
|
|
|
- PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
|
|
|
|
- pragma Assert (Result = 0);
|
|
|
|
-
|
|
|
|
Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
|
|
|
|
|
|
|
|
pragma Assert (Result in 0 | ENOMEM);
|
2023-05-15 08:15:31 +00:00
|
|
|
--
|
|
|
|
2.40.1
|
|
|
|
|