Skip to content

Commit

Permalink
Refactor equal processor headers into new generic ones
Browse files Browse the repository at this point in the history
Refactor all processor headers which had the same content
into a generic set, to reduce the number of duplicates.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
  • Loading branch information
aescolar committed Nov 1, 2023
1 parent dafb784 commit b19688f
Show file tree
Hide file tree
Showing 27 changed files with 55 additions and 204 deletions.
4 changes: 4 additions & 0 deletions lib/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ using std::atomic_signal_fence;
#elif defined(__GNUC__)
# include <metal/compiler/gcc/atomic.h>
#else
#if defined(HAVE_PROCESSOR_ATOMIC_H)
# include <metal/processor/@PROJECT_PROCESSOR@/atomic.h>
#else
# include <metal/processor/generic/atomic.h>
#endif /* defined(HAVE_PROCESSOR_ATOMIC_H) */
#endif

#endif /* __METAL_ATOMIC__H__ */
2 changes: 2 additions & 0 deletions lib/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions lib/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#ifndef __METAL_CPU__H__
#define __METAL_CPU__H__

#if defined(HAVE_PROCESSOR_CPU_H)
# include <metal/processor/@PROJECT_PROCESSOR@/cpu.h>
#else
# include <metal/processor/generic/cpu.h>
#endif

#endif /* __METAL_CPU__H__ */
14 changes: 13 additions & 1 deletion lib/processor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()

3 changes: 0 additions & 3 deletions lib/processor/aarch64/CMakeLists.txt

This file was deleted.

15 changes: 0 additions & 15 deletions lib/processor/aarch64/atomic.h

This file was deleted.

3 changes: 0 additions & 3 deletions lib/processor/arm/CMakeLists.txt

This file was deleted.

15 changes: 0 additions & 15 deletions lib/processor/arm/atomic.h

This file was deleted.

17 changes: 0 additions & 17 deletions lib/processor/arm/cpu.h

This file was deleted.

2 changes: 0 additions & 2 deletions lib/processor/ceva/CMakeLists.txt

This file was deleted.

2 changes: 0 additions & 2 deletions lib/processor/csky/CMakeLists.txt

This file was deleted.

17 changes: 0 additions & 17 deletions lib/processor/csky/cpu.h

This file was deleted.

15 changes: 15 additions & 0 deletions lib/processor/generic/atomic.h
Original file line number Diff line number Diff line change
@@ -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__ */
17 changes: 17 additions & 0 deletions lib/processor/generic/cpu.h
Original file line number Diff line number Diff line change
@@ -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__ */
2 changes: 0 additions & 2 deletions lib/processor/hosted/CMakeLists.txt

This file was deleted.

15 changes: 0 additions & 15 deletions lib/processor/hosted/atomic.h

This file was deleted.

3 changes: 0 additions & 3 deletions lib/processor/microblaze/CMakeLists.txt

This file was deleted.

15 changes: 0 additions & 15 deletions lib/processor/microblaze/atomic.h

This file was deleted.

20 changes: 0 additions & 20 deletions lib/processor/microblaze/cpu.h

This file was deleted.

2 changes: 0 additions & 2 deletions lib/processor/riscv/CMakeLists.txt

This file was deleted.

17 changes: 0 additions & 17 deletions lib/processor/riscv/cpu.h

This file was deleted.

3 changes: 0 additions & 3 deletions lib/processor/x86/CMakeLists.txt

This file was deleted.

16 changes: 0 additions & 16 deletions lib/processor/x86/atomic.h

This file was deleted.

3 changes: 0 additions & 3 deletions lib/processor/x86_64/CMakeLists.txt

This file was deleted.

16 changes: 0 additions & 16 deletions lib/processor/x86_64/atomic.h

This file was deleted.

2 changes: 0 additions & 2 deletions lib/processor/xtensa/CMakeLists.txt

This file was deleted.

15 changes: 0 additions & 15 deletions lib/processor/xtensa/atomic.h

This file was deleted.

0 comments on commit b19688f

Please sign in to comment.