Skip to content

Commit 2e828a5

Browse files
committed
cm: LibCM headers now can determine build options
Before this change, libcm headers were not able to determine the build definitions libcm/kernel was build with. Thus it was not possible enable/disable options in the headers for applications. After this change, libcm headers will be enable/disable features based on the way Kernel was built.
1 parent 13582f1 commit 2e828a5

File tree

8 files changed

+25
-9
lines changed

8 files changed

+25
-9
lines changed

include/cm/cm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <types.h>
1212
#include <stdarg.h>
13-
#if defined(KERNEL) || defined(UNITTEST)
13+
#if defined(LIBCM) || defined(UNITTEST)
1414
#include <cm/osif.h>
1515
#include <cm/syscall.h>
1616
#else

include/cm/debug.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#pragma once
88

99
#include <types.h>
10+
#ifndef LIBCM
11+
#include <cmbuild.h>
12+
#endif
1013

1114
#if defined(DEBUG) && defined(PORT_E9_ENABLED)
1215
typedef enum CM_DebugLogType {

include/cm/err.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
#include <stdint.h>
8-
#if defined(KERNEL) || defined (UNITTEST)
8+
#if defined(LIBCM) || defined (UNITTEST)
99
#include <cm/debug.h>
1010
#include <cm/syscall.h>
1111
#include <cm/osif.h>

include/cm/graphics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#pragma once
88

99
#include <types.h>
10-
#if defined(KERNEL) || defined (UNITTEST)
10+
#if defined(LIBCM) || defined (UNITTEST)
1111
#include <cm/osif.h>
1212
#else
1313
#include <osif.h>

include/cm/syscall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#pragma once
88

99
#include <types.h>
10-
#if defined(KERNEL) || defined (UNITTEST)
10+
#if defined(LIBCM) || defined (UNITTEST)
1111
#include <cm/osif.h>
1212
#else
1313
#include <osif.h>

src/apps/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ compile_lib(
77
NAME proc1
88
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/proc1.c
99
FLAGS ${MOS_USER_GCC_FLAGS}
10+
DEPENDS cm
1011
DEFINITIONS ${MOS_USER_GCC_DEFINITIONS}
1112
INCLUDE_DIRECTORIES ${MOS_USER_GCC_INCLUDE_DIRS}
1213
)
@@ -27,6 +28,7 @@ compile_lib(
2728
NAME mpdemo
2829
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mpdemo.c
2930
FLAGS ${MOS_USER_GCC_FLAGS}
31+
DEPENDS cm
3032
DEFINITIONS ${MOS_USER_GCC_DEFINITIONS}
3133
INCLUDE_DIRECTORIES ${MOS_USER_GCC_INCLUDE_DIRS}
3234
)
@@ -47,6 +49,7 @@ compile_lib(
4749
NAME gui0
4850
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/gui0.c
4951
FLAGS ${MOS_USER_GCC_FLAGS}
52+
DEPENDS cm
5053
DEFINITIONS ${MOS_USER_GCC_DEFINITIONS}
5154
INCLUDE_DIRECTORIES ${MOS_USER_GCC_INCLUDE_DIRS}
5255
)
@@ -71,6 +74,7 @@ compile_lib(
7174
NAME init
7275
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/init.c
7376
FLAGS ${MOS_USER_GCC_FLAGS}
77+
DEPENDS cm
7478
DEFINITIONS ${MOS_USER_GCC_DEFINITIONS} INIT_PROG=${MOS_INIT_PROGRAM}
7579
INCLUDE_DIRECTORIES ${MOS_USER_GCC_INCLUDE_DIRS}
7680
)

src/apps/init.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66

77
#include <cm.h>
88
#include <debug.h>
9+
#include <err.h>
910

1011
static void init_child_killed (OSIF_ProcessEvent const* const e)
1112
{
12-
#if defined(DEBUG) && defined(PORT_E9_ENABLED)
1313
CM_DBG_INFO ("Child process exited. Code: %x", e->data);
14-
#else
1514
(void)e;
16-
#endif
1715
}
1816

1917
void proc_main()

src/cm/CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
include(${PROJECT_SOURCE_DIR}/cmake/${ARCH}/kernelflags.cmake)
22

3+
#---------------------------------------------------------------------------
4+
# LIBCM macro is only present when building libcm, and absent when building applications. Thus this
5+
# macro can be used by a libcm header to determine if its being included by an application or by CM
6+
# library.
7+
#---------------------------------------------------------------------------
8+
set(MOS_LIBCM_GCC_DEFINITIONS
9+
${MOS_KERNEL_GCC_DEFINITIONS}
10+
LIBCM
11+
)
12+
313
#---------------------------------------------------------------------------
414
# Generate header file
515
#---------------------------------------------------------------------------
@@ -29,13 +39,14 @@ compile_lib(
2939
NAME crta
3040
SOURCES ${APPS_CRT_SOURCES}
3141
FLAGS ${MOS_KERNEL_GCC_FLAGS}
32-
DEFINITIONS ${MOS_KERNEL_GCC_DEFINITIONS}
42+
DEFINITIONS ${MOS_LIBCM_GCC_DEFINITIONS}
3343
INCLUDE_DIRECTORIES ${MOS_KERNEL_GCC_INCLUDE_DIRS}
3444
)
3545
# ------------------------------------------------------------------------
3646
# MOS C Library
3747
# C library to talk to the OS and helpful/common functions for use by application programs.
3848
# ------------------------------------------------------------------------
49+
3950
set(APPLIB_SOURCES
4051
${CMAKE_CURRENT_SOURCE_DIR}/process.c
4152
${CMAKE_CURRENT_SOURCE_DIR}/syscalls.c
@@ -54,7 +65,7 @@ compile_lib(
5465
NAME cm
5566
SOURCES ${APPLIB_SOURCES}
5667
FLAGS ${MOS_KERNEL_GCC_FLAGS}
57-
DEFINITIONS ${MOS_KERNEL_GCC_DEFINITIONS}
68+
DEFINITIONS ${MOS_LIBCM_GCC_DEFINITIONS}
5869
DEPENDS gen-build-config-header
5970
INCLUDE_DIRECTORIES ${MOS_KERNEL_GCC_INCLUDE_DIRS}
6071
STATIC_LIB

0 commit comments

Comments
 (0)