diff --git a/lib/atomic.h b/lib/atomic.h index 5fc04fc6..1afd15b8 100644 --- a/lib/atomic.h +++ b/lib/atomic.h @@ -107,7 +107,11 @@ using std::atomic_signal_fence; #elif defined(__GNUC__) # include #else +#if defined(HAVE_PROCESSOR_ATOMIC_H) # include +#else +# include +#endif /* defined(HAVE_PROCESSOR_ATOMIC_H) */ #endif #endif /* __METAL_ATOMIC__H__ */ diff --git a/lib/config.h b/lib/config.h index 7661a132..3b64a26e 100644 --- a/lib/config.h +++ b/lib/config.h @@ -42,6 +42,8 @@ extern "C" { #cmakedefine HAVE_STDATOMIC_H #cmakedefine HAVE_FUTEX_H +#cmakedefine HAVE_PROCESSOR_ATOMIC_H +#cmakedefine HAVE_PROCESSOR_CPU_H #ifdef __cplusplus } diff --git a/lib/cpu.h b/lib/cpu.h index 9deade61..5f9343bc 100644 --- a/lib/cpu.h +++ b/lib/cpu.h @@ -12,6 +12,10 @@ #ifndef __METAL_CPU__H__ #define __METAL_CPU__H__ +#if defined(HAVE_PROCESSOR_CPU_H) # include +#else +# include +#endif #endif /* __METAL_CPU__H__ */ diff --git a/lib/processor/CMakeLists.txt b/lib/processor/CMakeLists.txt index d542b56a..90200ff7 100644 --- a/lib/processor/CMakeLists.txt +++ b/lib/processor/CMakeLists.txt @@ -1,2 +1,14 @@ -add_subdirectory (${PROJECT_PROCESSOR}) +if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_PROCESSOR}/cpu.h") + collect (PROJECT_LIB_HEADERS ${PROJECT_PROCESSOR}/cpu.h) + set(HAVE_PROCESSOR_CPU_H 1 CACHE INTERNAL "Have include ${PROJECT_PROCESSOR}/cpu.h") +else() + collect (PROJECT_LIB_HEADERS generic/cpu.h) +endif() + +if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_PROCESSOR}/atomic.h") + collect (PROJECT_LIB_HEADERS ${PROJECT_PROCESSOR}/atomic.h) + set(HAVE_PROCESSOR_ATOMIC_H 1 CACHE INTERNAL "Have include ${PROJECT_PROCESSOR}/atomic.h") +else() + collect (PROJECT_LIB_HEADERS generic/atomic.h) +endif() diff --git a/lib/processor/aarch64/CMakeLists.txt b/lib/processor/aarch64/CMakeLists.txt deleted file mode 100644 index a20967bf..00000000 --- a/lib/processor/aarch64/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -collect (PROJECT_LIB_HEADERS atomic.h) -collect (PROJECT_LIB_HEADERS cpu.h) - diff --git a/lib/processor/aarch64/atomic.h b/lib/processor/aarch64/atomic.h deleted file mode 100644 index 410346c1..00000000 --- a/lib/processor/aarch64/atomic.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file gcc/atomic.h - * @brief GCC specific atomic primitives for libmetal. - */ - -#ifndef __METAL_AARCH64_ATOMIC__H__ -#define __METAL_AARCH64_ATOMIC__H__ - -#endif /* __METAL_ARM_ATOMIC__H__ */ diff --git a/lib/processor/arm/CMakeLists.txt b/lib/processor/arm/CMakeLists.txt deleted file mode 100644 index a20967bf..00000000 --- a/lib/processor/arm/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -collect (PROJECT_LIB_HEADERS atomic.h) -collect (PROJECT_LIB_HEADERS cpu.h) - diff --git a/lib/processor/arm/atomic.h b/lib/processor/arm/atomic.h deleted file mode 100644 index ab5ee406..00000000 --- a/lib/processor/arm/atomic.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file arm/atomic.h - * @brief Arm specific atomic primitives for libmetal. - */ - -#ifndef __METAL_ARM_ATOMIC__H__ -#define __METAL_ARM_ATOMIC__H__ - -#endif /* __METAL_ARM_ATOMIC__H__ */ diff --git a/lib/processor/arm/cpu.h b/lib/processor/arm/cpu.h deleted file mode 100644 index 0ea96102..00000000 --- a/lib/processor/arm/cpu.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file cpu.h - * @brief CPU specific primitives - */ - -#ifndef __METAL_ARM_CPU__H__ -#define __METAL_ARM_CPU__H__ - -#define metal_cpu_yield() - -#endif /* __METAL_ARM_CPU__H__ */ diff --git a/lib/processor/ceva/CMakeLists.txt b/lib/processor/ceva/CMakeLists.txt deleted file mode 100644 index 11b0f7d5..00000000 --- a/lib/processor/ceva/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -collect (PROJECT_LIB_HEADERS cpu.h) - diff --git a/lib/processor/csky/CMakeLists.txt b/lib/processor/csky/CMakeLists.txt deleted file mode 100644 index 11b0f7d5..00000000 --- a/lib/processor/csky/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -collect (PROJECT_LIB_HEADERS cpu.h) - diff --git a/lib/processor/csky/cpu.h b/lib/processor/csky/cpu.h deleted file mode 100644 index a3938488..00000000 --- a/lib/processor/csky/cpu.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2018, Pinecone Inc. and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file cpu.h - * @brief CPU specific primitives - */ - -#ifndef __METAL_CSKY_CPU__H__ -#define __METAL_CSKY_CPU__H__ - -#define metal_cpu_yield() - -#endif /* __METAL_CSKY_CPU__H__ */ diff --git a/lib/processor/generic/atomic.h b/lib/processor/generic/atomic.h new file mode 100644 index 00000000..9a2b252c --- /dev/null +++ b/lib/processor/generic/atomic.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * @file generic/atomic.h + * @brief Generic environment atomic primitives for libmetal. + */ + +#ifndef __METAL_GENERIC_ATOMIC__H__ +#define __METAL_GENERIC_ATOMIC__H__ + +#endif /* __METAL_GENERIC_ATOMIC__H__ */ diff --git a/lib/processor/generic/cpu.h b/lib/processor/generic/cpu.h new file mode 100644 index 00000000..60a72576 --- /dev/null +++ b/lib/processor/generic/cpu.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * @file generic/cpu.h + * @brief Generic CPU specific primitives + */ + +#ifndef __METAL_GENERIC_CPU__H__ +#define __METAL_GENERIC_CPU__H__ + +#define metal_cpu_yield() + +#endif /* __METAL_GENERIC_CPU__H__ */ diff --git a/lib/processor/hosted/CMakeLists.txt b/lib/processor/hosted/CMakeLists.txt deleted file mode 100644 index 13ce0230..00000000 --- a/lib/processor/hosted/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -collect (PROJECT_LIB_HEADERS atomic.h) -collect (PROJECT_LIB_HEADERS cpu.h) diff --git a/lib/processor/hosted/atomic.h b/lib/processor/hosted/atomic.h deleted file mode 100644 index ed153c30..00000000 --- a/lib/processor/hosted/atomic.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2023 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file hosted/atomic.h - * @brief Hosted environment atomic primitives for libmetal. - */ - -#ifndef __METAL_HOSTED_ATOMIC__H__ -#define __METAL_HOSTED_ATOMIC__H__ - -#endif /* __METAL_HOSTED_ATOMIC__H__ */ diff --git a/lib/processor/microblaze/CMakeLists.txt b/lib/processor/microblaze/CMakeLists.txt deleted file mode 100644 index a20967bf..00000000 --- a/lib/processor/microblaze/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -collect (PROJECT_LIB_HEADERS atomic.h) -collect (PROJECT_LIB_HEADERS cpu.h) - diff --git a/lib/processor/microblaze/atomic.h b/lib/processor/microblaze/atomic.h deleted file mode 100644 index d576662f..00000000 --- a/lib/processor/microblaze/atomic.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2017, Xilinx Inc. and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file microblaze/atomic.h - * @brief Microblaze specific atomic primitives for libmetal - */ - -#ifndef __METAL_MICROBLAZE_ATOMIC__H__ -#define __METAL_MICROBLAZE_ATOMIC__H__ - -#endif /* __METAL_MICROBLAZE_ATOMIC__H__ */ diff --git a/lib/processor/microblaze/cpu.h b/lib/processor/microblaze/cpu.h deleted file mode 100644 index 012df465..00000000 --- a/lib/processor/microblaze/cpu.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2017, Xilinx Inc. and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file cpu.h - * @brief CPU specific primitives on microblaze platform. - */ - -#ifndef __METAL_MICROBLAZE__H__ -#define __METAL_MICROBLAZE__H__ - -#include -#include - -#define metal_cpu_yield() - -#endif /* __METAL_MICROBLAZE__H__ */ diff --git a/lib/processor/riscv/CMakeLists.txt b/lib/processor/riscv/CMakeLists.txt deleted file mode 100644 index 11b0f7d5..00000000 --- a/lib/processor/riscv/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -collect (PROJECT_LIB_HEADERS cpu.h) - diff --git a/lib/processor/riscv/cpu.h b/lib/processor/riscv/cpu.h deleted file mode 100644 index ff02d9f8..00000000 --- a/lib/processor/riscv/cpu.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2018, Pinecone Inc. and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file cpu.h - * @brief CPU specific primitives - */ - -#ifndef __METAL_RISCV_CPU__H__ -#define __METAL_RISCV_CPU__H__ - -#define metal_cpu_yield() - -#endif /* __METAL_RISCV_CPU__H__ */ diff --git a/lib/processor/x86/CMakeLists.txt b/lib/processor/x86/CMakeLists.txt deleted file mode 100644 index a20967bf..00000000 --- a/lib/processor/x86/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -collect (PROJECT_LIB_HEADERS atomic.h) -collect (PROJECT_LIB_HEADERS cpu.h) - diff --git a/lib/processor/x86/atomic.h b/lib/processor/x86/atomic.h deleted file mode 100644 index bf98a9d1..00000000 --- a/lib/processor/x86/atomic.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file gcc/atomic.h - * @brief GCC specific atomic primitives for libmetal. - */ - -#ifndef __METAL_X86_ATOMIC__H__ -#define __METAL_X86_ATOMIC__H__ - - -#endif /* __METAL_X86_ATOMIC__H__ */ diff --git a/lib/processor/x86_64/CMakeLists.txt b/lib/processor/x86_64/CMakeLists.txt deleted file mode 100644 index a20967bf..00000000 --- a/lib/processor/x86_64/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -collect (PROJECT_LIB_HEADERS atomic.h) -collect (PROJECT_LIB_HEADERS cpu.h) - diff --git a/lib/processor/x86_64/atomic.h b/lib/processor/x86_64/atomic.h deleted file mode 100644 index ee773997..00000000 --- a/lib/processor/x86_64/atomic.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file gcc/atomic.h - * @brief GCC specific atomic primitives for libmetal. - */ - -#ifndef __METAL_X86_64_ATOMIC__H__ -#define __METAL_X86_64_ATOMIC__H__ - - -#endif /* __METAL_X86_64_ATOMIC__H__ */ diff --git a/lib/processor/xtensa/CMakeLists.txt b/lib/processor/xtensa/CMakeLists.txt deleted file mode 100644 index 13ce0230..00000000 --- a/lib/processor/xtensa/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -collect (PROJECT_LIB_HEADERS atomic.h) -collect (PROJECT_LIB_HEADERS cpu.h) diff --git a/lib/processor/xtensa/atomic.h b/lib/processor/xtensa/atomic.h deleted file mode 100644 index 6f87ea92..00000000 --- a/lib/processor/xtensa/atomic.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2021, Xiaomi Inc. and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file xtensa/atomic.h - * @brief Xtensa specific atomic primitives for libmetal. - */ - -#ifndef __METAL_XTENSA_ATOMIC__H__ -#define __METAL_XTENSA_ATOMIC__H__ - -#endif /* __METAL_XTENSA_ATOMIC__H__ */