-- Errno - Provide direct access from Ada to that asinine C language integer value of the same name. -- Written in 2023 by Prince Trippy . -- To the extent possible under law, the author(s) have dedicated all copyright and related and -- neighboring rights to this software to the public domain worldwide. -- This software is distributed without any warranty. -- You should have received a copy of the CC0 Public Domain Dedication along with this software. -- If not, see . -- This program does so little that it can't help but adhere to the requirements of Ada 1995, alone. with Interfaces.C; -- That errno is exposed only to the C language, since it's implemented as a text replacement macro. -- I'm wholly unwilling to write any C language code to expose it, however, as its scope would grow. -- I skulked, to find an identical function used in its implementations, using only different names. -- For GNU, and one compatible system library, the function is appropriately named __errno_location. -- For other systems I've found the name used to be either __errno or __error and so note such here. -- I'm not certain how the C convention interacts with the access return value type, but I care not. -- I could've used the System package and its address type, but that's overkill, and always will be. -- This code will be changed whenever porting, so anything greater is wasted effort and naught more. function Errno return Interfaces.C.Int is function True_Errno return access Interfaces.C.Int; pragma Import(Convention => C, Entity => True_Errno, External_Name => "__errno_location"); begin return True_Errno.all; end Errno; .