diff mbox series

[Ada] VxWorks inconsistent use of return type (vx_freq_t)

Message ID 20210922151538.GA1907679@adacore.com
State New
Headers show
Series [Ada] VxWorks inconsistent use of return type (vx_freq_t) | expand

Commit Message

Pierre-Marie de Rodat Sept. 22, 2021, 3:15 p.m. UTC
Several inconsistencies were found. They will be submitted as separate
proposed fixes. The approach is to make them "types" rather than
"subtypes" in order to catch inconsistencies in their usage, and to
declare them in a central package. System.VxWorks.Ext was chosen, the
only difficulty with this choice is that there's a version for each
runtime and that it's a libgnarl package which leaves a few outliers
in libgnat. System.VxWorks was also considered but here the difficulty
is the fact it's architecture/libgnarl specific. Leaving the only other
alternative a new package, which seemed like overkill.

This change is for vx_freq_t a friendlier type name for _Vx_freq_t. This
type was changed to C type unsigned in the VxWorks headers, but wasn't
changed in our code, and was incorrectly specified as an int.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnarl/s-osinte__vxworks.ads (SVE): New package renaming
	(vx_freq_t): New subtype.
	(sysClkRateGet): Return vx_freq_t.
	* libgnarl/s-vxwext.ads (vx_freq_t): New type.
	* libgnarl/s-vxwext__kernel.ads: Likewise.
	* libgnarl/s-vxwext__rtp.ads: Likewise.
diff mbox series

Patch

diff --git a/gcc/ada/libgnarl/s-osinte__vxworks.ads b/gcc/ada/libgnarl/s-osinte__vxworks.ads
--- a/gcc/ada/libgnarl/s-osinte__vxworks.ads
+++ b/gcc/ada/libgnarl/s-osinte__vxworks.ads
@@ -57,6 +57,8 @@  package System.OS_Interface is
    type unsigned_long_long is mod 2 ** long_long'Size;
    type size_t             is mod 2 ** Standard'Address_Size;
 
+   subtype vx_freq_t       is System.VxWorks.Ext.vx_freq_t;
+
    -----------
    -- Errno --
    -----------
@@ -312,7 +314,7 @@  package System.OS_Interface is
    function taskDelay (ticks : int) return int;
    pragma Import (C, taskDelay, "taskDelay");
 
-   function sysClkRateGet return int;
+   function sysClkRateGet return vx_freq_t;
    pragma Import (C, sysClkRateGet, "sysClkRateGet");
 
    --  VxWorks 5.x specific functions


diff --git a/gcc/ada/libgnarl/s-vxwext.ads b/gcc/ada/libgnarl/s-vxwext.ads
--- a/gcc/ada/libgnarl/s-vxwext.ads
+++ b/gcc/ada/libgnarl/s-vxwext.ads
@@ -46,6 +46,9 @@  package System.VxWorks.Ext is
    subtype int is Interfaces.C.int;
    subtype unsigned is Interfaces.C.unsigned;
 
+   type vx_freq_t is new unsigned;
+   --  Equivalent of the C type _Vx_freq_t
+
    type Interrupt_Handler is access procedure (parameter : System.Address);
    pragma Convention (C, Interrupt_Handler);
 


diff --git a/gcc/ada/libgnarl/s-vxwext__kernel.ads b/gcc/ada/libgnarl/s-vxwext__kernel.ads
--- a/gcc/ada/libgnarl/s-vxwext__kernel.ads
+++ b/gcc/ada/libgnarl/s-vxwext__kernel.ads
@@ -45,6 +45,9 @@  package System.VxWorks.Ext is
    subtype int is Interfaces.C.int;
    subtype unsigned is Interfaces.C.unsigned;
 
+   type vx_freq_t is new unsigned;
+   --  Equivalent of the C type _Vx_freq_t
+
    type Interrupt_Handler is access procedure (parameter : System.Address);
    pragma Convention (C, Interrupt_Handler);
 


diff --git a/gcc/ada/libgnarl/s-vxwext__rtp.ads b/gcc/ada/libgnarl/s-vxwext__rtp.ads
--- a/gcc/ada/libgnarl/s-vxwext__rtp.ads
+++ b/gcc/ada/libgnarl/s-vxwext__rtp.ads
@@ -45,6 +45,9 @@  package System.VxWorks.Ext is
    subtype int is Interfaces.C.int;
    subtype unsigned is Interfaces.C.unsigned;
 
+   type vx_freq_t is new unsigned;
+   --  Equivalent of the C type _Vx_freq_t
+
    type Interrupt_Handler is access procedure (parameter : System.Address);
    pragma Convention (C, Interrupt_Handler);