Skip to content

Commit

Permalink
lib: 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 03140d7 commit 6b7fd32
Show file tree
Hide file tree
Showing 27 changed files with 55 additions and 212 deletions.
4 changes: 4 additions & 0 deletions libmetal/lib/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,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 libmetal/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 libmetal/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 libmetal/lib/processor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
add_subdirectory (${PROJECT_PROCESSOR})
if (EXISTS "${PROJECT_PROCESSOR}/cpu.h")
collect (PROJECT_LIB_HEADERS ${PROJECT_PROCESSOR}/cpu.h)
set(HAVE_PROCESSOR_CPU_H 1 INTERNAL CACHE "")
else()
collect (PROJECT_LIB_HEADERS generic/cpu.h)
endif()

if (EXISTS "${PROJECT_PROCESSOR}/atomic.h")
collect (PROJECT_LIB_HEADERS ${PROJECT_PROCESSOR}/atomic.h)
set(HAVE_PROCESSOR_ATOMIC_H 1 INTERNAL CACHE "")
else()
collect (PROJECT_LIB_HEADERS generic/atomic.h)
endif()

# vim: expandtab:ts=2:sw=2:smartindent
4 changes: 0 additions & 4 deletions libmetal/lib/processor/aarch64/CMakeLists.txt

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

15 changes: 15 additions & 0 deletions libmetal/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 libmetal/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 libmetal/lib/processor/hosted/CMakeLists.txt

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

0 comments on commit 6b7fd32

Please sign in to comment.