Ada Runtime Library: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m Bot: Replace deprecated source tag with syntaxhighlight |
|||
Line 52: | Line 52: | ||
For more information regarding GNAT project configuration refer to the AdaCore documentation: [https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html] |
For more information regarding GNAT project configuration refer to the AdaCore documentation: [https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html] |
||
< |
<syntaxhighlight lang="ada"> |
||
library project Runtime is |
library project Runtime is |
||
-- Tells Gprbuild to create any missing directories in the build process. |
-- Tells Gprbuild to create any missing directories in the build process. |
||
Line 123: | Line 123: | ||
for Target use "i686-elf"; |
for Target use "i686-elf"; |
||
end Runtime; |
end Runtime; |
||
</syntaxhighlight> |
|||
</source> |
|||
As noted in the source code comments above, in this setup the run-time sources are used as a run-time library during the build process. One method to implement this is to include a pre-requisite step in your makefile to copy the sources to the final build destination <tt>adainclude</tt> directory, then to specify this build directory as the run-time for the project. An example makefile for facilitating this can be seen below. |
As noted in the source code comments above, in this setup the run-time sources are used as a run-time library during the build process. One method to implement this is to include a pre-requisite step in your makefile to copy the sources to the final build destination <tt>adainclude</tt> directory, then to specify this build directory as the run-time for the project. An example makefile for facilitating this can be seen below. |
||
Line 129: | Line 129: | ||
''Please note that this makefile may not be fit for all projects and purposes.'' |
''Please note that this makefile may not be fit for all projects and purposes.'' |
||
< |
<syntaxhighlight lang="make"> |
||
RUNTIME_BINARY := ${LIB_DIR}/libgnat.a |
RUNTIME_BINARY := ${LIB_DIR}/libgnat.a |
||
RUNTIME_PROJ := runtime |
RUNTIME_PROJ := runtime |
||
Line 176: | Line 176: | ||
${LIB_DIR}: |
${LIB_DIR}: |
||
mkdir -p ${LIB_DIR} |
mkdir -p ${LIB_DIR} |
||
</syntaxhighlight> |
|||
</source> |
|||
Line 249: | Line 249: | ||
Also, add the following line in the private part of the package: |
Also, add the following line in the private part of the package: |
||
< |
<syntaxhighlight lang="ada"> |
||
private |
private |
||
Run_Time_Name : constant String := "Bare Bones Run Time"; |
Run_Time_Name : constant String := "Bare Bones Run Time"; |
||
</syntaxhighlight> |
|||
</source> |
|||
According to <tt>targparm.ads</tt>, this directive should be the first thing after the private keyword. |
According to <tt>targparm.ads</tt>, this directive should be the first thing after the private keyword. |
||
Line 266: | Line 266: | ||
'''x86.ads''' |
'''x86.ads''' |
||
< |
<syntaxhighlight lang="ada"> |
||
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
||
-- X86 |
-- X86 |
||
Line 276: | Line 276: | ||
pragma Preelaborate (x86); |
pragma Preelaborate (x86); |
||
end x86; |
end x86; |
||
</syntaxhighlight> |
|||
</source> |
|||
'''x86-port_io.ads''' |
'''x86-port_io.ads''' |
||
< |
<syntaxhighlight lang="ada"> |
||
with Interfaces; |
with Interfaces; |
||
with System; |
with System; |
||
Line 321: | Line 321: | ||
); |
); |
||
end x86.Port_IO; |
end x86.Port_IO; |
||
</syntaxhighlight> |
|||
</source> |
|||
'''x86-port_io.adb''' |
'''x86-port_io.adb''' |
||
< |
<syntaxhighlight lang="ada"> |
||
with System.Machine_Code; |
with System.Machine_Code; |
||
Line 367: | Line 367: | ||
end Outb; |
end Outb; |
||
end x86.Port_IO; |
end x86.Port_IO; |
||
</syntaxhighlight> |
|||
</source> |
|||
Fundamentally, the role of the runtime library is to implement the features defined in the Ada language standard for the particular target platform. This requires the creation of target-specific packages to interface with platform features such as internal clocks, [[UART|UARTs]] and [[PIT|timers]], among other things. These packages can then be used by language-defined packages in the runtime library to expose this functionality to the linked application. |
Fundamentally, the role of the runtime library is to implement the features defined in the Ada language standard for the particular target platform. This requires the creation of target-specific packages to interface with platform features such as internal clocks, [[UART|UARTs]] and [[PIT|timers]], among other things. These packages can then be used by language-defined packages in the runtime library to expose this functionality to the linked application. |
||
Line 423: | Line 423: | ||
'''s-imguns.ads''' |
'''s-imguns.ads''' |
||
< |
<syntaxhighlight lang="ada"> |
||
with System.Unsigned_Types; |
with System.Unsigned_Types; |
||
Line 468: | Line 468: | ||
end System.Img_Uns; |
end System.Img_Uns; |
||
</syntaxhighlight> |
|||
</source> |
|||
'''s-imguns.adb''' |
'''s-imguns.adb''' |
||
< |
<syntaxhighlight lang="ada"> |
||
with System.Unsigned_Types; use System.Unsigned_Types; |
with System.Unsigned_Types; use System.Unsigned_Types; |
||
Line 539: | Line 539: | ||
end System.Img_Uns; |
end System.Img_Uns; |
||
</syntaxhighlight> |
|||
</source> |
|||
User-defined images for a given type can be implemented by overriding the default implementation of the <tt>Put_Image</tt> attribute. |
User-defined images for a given type can be implemented by overriding the default implementation of the <tt>Put_Image</tt> attribute. |