diff --git a/build_rts.py b/build_rts.py index 5879df00..02b89d1d 100755 --- a/build_rts.py +++ b/build_rts.py @@ -49,7 +49,8 @@ from x86_64 import X8664Generic # native -from native import Aarch64Native, X86Native, X8664Native +from linux import Aarch64Linux, X86Linux, X8664Linux +from windows import X86Windows, X8664Windows # vx7r2cert from vx7r2cert import AArch64Vx7r2Cert, ArmVx7r2Cert, \ @@ -224,12 +225,16 @@ def build_configs(target): elif target == 'x86_64': t = X8664Generic() # native platforms - elif target in ('x86-linux', 'x86-windows'): - t = X86Native() - elif target in ('x86_64-linux', 'x86_64-windows', 'x86_64-windows64'): - t = X8664Native() - elif target in ('aarch64-linux',): - t = Aarch64Native() + elif target == "aarch64-linux": + t = Aarch64Linux() + elif target == "x86-linux": + t = X86Linux() + elif target == "x86_64-linux": + t = X8664Linux() + elif target == "x86-windows": + t = X86Windows() + elif target in ("x86_64-windows", "x86_64-windows64"): + t = X8664Windows() # vx7r2cert elif target == "aarch64-vx7r2cert": t = AArch64Vx7r2Cert() diff --git a/gen_rts_sources.py b/gen_rts_sources.py index 8242ae31..30a179b8 100755 --- a/gen_rts_sources.py +++ b/gen_rts_sources.py @@ -44,7 +44,8 @@ def main(): '--rts-profile', choices=['light', 'light-tasking', 'embedded', 'cert'], required=True, help='supported profiles') parser.add_argument( - '--source-profile', choices=['bb', 'deos', 'pikeos', 'vx7r2cert', 'qnx'], + '--source-profile', + choices=['bb', 'deos', 'linux', 'pikeos', 'vx7r2cert', 'qnx'], default='bb', help='platform specific source selections') args = parser.parse_args() diff --git a/native/__init__.py b/linux/__init__.py similarity index 65% rename from native/__init__.py rename to linux/__init__.py index 8470acf2..968de20c 100644 --- a/native/__init__.py +++ b/linux/__init__.py @@ -1,20 +1,19 @@ from support.bsp_sources.target import DFBBTarget -class Native(DFBBTarget): +class Linux(DFBBTarget): def __init__(self): super().__init__() - self.add_gnat_sources( - 'src/s-macres__native.adb', - 'src/s-textio__stdio.adb') - - @property - def target(self): - return None + self.add_gnat_sources("src/s-macres__native.adb") + self.add_gnarl_sources("linux/adaint.c") def has_libc(self, profile): return True + @property + def name(self): + return self.target + def dump_runtime_xml(self, rts_name, rts): return ('\n' '\n' @@ -22,24 +21,25 @@ def dump_runtime_xml(self, rts_name, rts): ' \n' '\n') - def amend_rts(self, rts_profile, cfg): - super().amend_rts(rts_profile, cfg) + @property + def is_legacy_format(self): + return True -class X86Native(Native): +class X86Linux(Linux): @property - def name(self): - return 'native-x86' + def target(self): + return "x86-linux" @property def system_ads(self): return {'light': 'system-xi-x86.ads'} -class X8664Native(Native): +class X8664Linux(Linux): @property - def name(self): - return 'native-x86_64' + def target(self): + return "x86_64-linux" @property def is_64bit(self): @@ -50,10 +50,10 @@ def system_ads(self): return {'light': 'system-xi-x86_64.ads'} -class Aarch64Native(Native): +class Aarch64Linux(Linux): @property - def name(self): - return 'native-aarch64' + def target(self): + return "aarch64-linux" @property def is_64bit(self): diff --git a/linux/adaint.c b/linux/adaint.c new file mode 100644 index 00000000..3e431e05 --- /dev/null +++ b/linux/adaint.c @@ -0,0 +1,44 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include + +void * +__gnat_lwp_self (void) +{ + return (void *) syscall (__NR_gettid); +} + +cpu_set_t * +__gnat_cpu_alloc (size_t count) +{ + return CPU_ALLOC (count); +} + +size_t +__gnat_cpu_alloc_size (size_t count) +{ + return CPU_ALLOC_SIZE (count); +} + +void +__gnat_cpu_free (cpu_set_t *set) +{ + CPU_FREE (set); +} + +void +__gnat_cpu_zero (size_t count, cpu_set_t *set) +{ + CPU_ZERO_S (count, set); +} + +void +__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set) +{ + /* Ada handles CPU numbers starting from 1, while C identifies the first + CPU by a 0, so we need to adjust. */ + CPU_SET_S (cpu - 1, count, set); +} diff --git a/support/data/target_options.gpr.in b/support/data/target_options.gpr.in index 1b29d4ce..9acf7fea 100644 --- a/support/data/target_options.gpr.in +++ b/support/data/target_options.gpr.in @@ -52,8 +52,8 @@ abstract project Target_Options is -- link against libgnat (itself). -- Since -nostdlib also removes libgcc -- from the linked libraries we have to - -- add -lgcc again. - LOPTIONS := LOPTIONS & ("-nostdlib", "-lgcc"); + -- add -lc and -lgcc again. + LOPTIONS := LOPTIONS & ("-nostdlib", "-lc", "-lgcc"); end case; -- Concatenate with common flags diff --git a/support/rts_sources/sources.py b/support/rts_sources/sources.py index 4d489259..a4953346 100644 --- a/support/rts_sources/sources.py +++ b/support/rts_sources/sources.py @@ -229,6 +229,16 @@ 'hie/a-textio__deos.ads', 'hie/a-textio__deos.adb', 'hie/s-macres.ads', ], + 'linux_srcs': [ + 'hie/a-textio.ads', + 'hie/a-textio__libc.adb', + 'hie/g-io__zfp.ads', + 'hie/g-io__zfp.adb', + 'hie/g-io-put.adb', + 'hie/s-macres.ads', + 'hie/s-textio__libc.ads', + 'hie/s-textio__libc.adb', + ], 'pikeos_srcs': [ 'hie/a-textio.ads', 'exit.c', @@ -246,11 +256,15 @@ 'vx_stack_info.c'], 'qnx_srcs': [ 'exit.c', - 'hie/g-io__zfp.ads', 'hie/g-io__zfp.adb', + 'hie/g-io__zfp.ads', + 'hie/g-io__zfp.adb', 'hie/g-io-put.adb', - 'hie/a-textio.ads', 'hie/a-textio__qnx.adb', + 'hie/a-textio.ads', + 'hie/a-textio__qnx.adb', 'hie/s-macres.ads', - 'hie/s-textio__qnx.ads', 'hie/s-textio__qnx.adb'] + 'hie/s-textio__qnx.ads', + 'hie/s-textio__qnx.adb' + ], }, 'common/32': { @@ -282,6 +296,7 @@ 'hie/s-assert__xi.adb', 'hie/s-memory__light.ads'], 'bb_srcs': ['hie/a-elchha__zfp.adb'], + 'linux_srcs': ['hie/a-elchha__zfp.adb'], 'pikeos_srcs': ['hie/a-elchha__zfp.adb'], 'qnx_srcs': [ 'hie/a-elchha__traceback.adb', @@ -307,6 +322,7 @@ 'hie/s-sssita.ads', 'hie/s-sssita.adb'], 'deos_srcs': [ 'hie/s-thread__cert.ads', 'hie/s-thread__cert.adb'], + 'linux_srcs': ['hie/s-sssita.ads', 'hie/s-sssita.adb'], 'pikeos_srcs': [ 'hie/a-textio__pikeos-light.adb', 'hie/s-sssita.ads', 'hie/s-sssita.adb'], @@ -1048,6 +1064,19 @@ 'hie/a-nalofl__light.ads', 'hie/a-nallfl__light.ads', 'libgnat/a-naliop__nolibm.ads'], + 'linux_srcs': [ + 'hie/a-ngelfu__cert.ads', + 'hie/a-ngelfu__cert.adb', + 'hie/a-nlelfu__cert.ads', + 'hie/a-nuelfu__cert.ads', + 'hie/s-gcmain__cert.ads', + 'hie/s-gcmain__cert.adb', + 'hie/a-nllefu__cert.ads', + 'hie/a-nuaufl__light.ads', + 'hie/a-nalofl__light.ads', + 'hie/a-nallfl__light.ads', + 'libgnat/a-naliop.ads', + ], 'pikeos_srcs': [ 'hie/a-ngelfu__ada.ads', 'hie/a-ngelfu__ada.adb', 'hie/a-nlelfu__ada.ads', @@ -1713,15 +1742,18 @@ }, 'gnat/parameters/light-small': { 'conditions': ['RTS_Profile:light', 'Memory_Profile:small'], - 'bb_srcs': ['hie/s-parame__zfp_small.ads'] + 'bb_srcs': ['hie/s-parame__zfp_small.ads'], + 'linux_srcs': ['hie/s-parame__zfp_small.ads'], }, 'gnat/parameters/light-large': { 'conditions': ['RTS_Profile:light', 'Memory_Profile:large'], - 'bb_srcs': ['hie/s-parame__zfp.ads'] + 'bb_srcs': ['hie/s-parame__zfp.ads'], + 'linux_srcs': ['hie/s-parame__zfp.ads'], }, 'gnat/parameters/light-huge': { 'conditions': ['RTS_Profile:light', 'Memory_Profile:huge'], - 'bb_srcs': ['hie/s-parame__zfp_huge.ads'] + 'bb_srcs': ['hie/s-parame__zfp_huge.ads'], + 'linux_srcs': ['hie/s-parame__zfp_huge.ads'], }, # Cert diff --git a/windows/__init__.py b/windows/__init__.py new file mode 100644 index 00000000..4e7ce7a1 --- /dev/null +++ b/windows/__init__.py @@ -0,0 +1,51 @@ +from support.bsp_sources.target import DFBBTarget + + +class Windows(DFBBTarget): + def __init__(self): + super().__init__() + self.add_gnat_sources("src/s-macres__native.adb", "src/s-textio__stdio.adb") + + @property + def name(self): + return self.target + + def has_libc(self, profile): + return True + + def dump_runtime_xml(self, rts_name, rts): + return ( + '\n' + "\n" + " \n" + " \n" + "\n" + ) + + @property + def is_legacy_format(self): + return True + + +class X86Windows(Windows): + @property + def target(self): + return "x86-windows" + + @property + def system_ads(self): + return {"light": "system-native-x86-light.ads"} + + +class X8664Windows(Windows): + @property + def target(self): + return "x86_64-windows" + + @property + def is_64bit(self): + return True + + @property + def system_ads(self): + return {"light": "system-native-x86-light.ads"}