Ensure that tlib headers are not included in kernel

This commit is contained in:
Baptiste Wicht 2016-08-25 21:50:11 +02:00
parent 1884649766
commit 47266f5ed9
9 changed files with 61 additions and 7 deletions

10
cpp.mk
View File

@ -36,10 +36,10 @@ COMMON_LINK_FLAGS=-lgcc
KERNEL_LINK_FLAGS=$(COMMON_LINK_FLAGS) -T linker.ld
LIB_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -ffunction-sections -fdata-sections
LIB_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -Wl,-gc-sections
TLIB_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -ffunction-sections -fdata-sections -DTHOR_TLIB=yes
TLIB_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -Wl,-gc-sections
PROGRAM_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -I../../tlib/include/ -I../../printf/include/ -static -L../../tlib/debug/ -ltlib -mcmodel=small -fPIC -DTHOR_PROGRAM
PROGRAM_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -I../../tlib/include/ -I../../printf/include/ -static -L../../tlib/debug/ -ltlib -mcmodel=small -fPIC -DTHOR_PROGRAM=yes
PROGRAM_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) $(COMMON_LINK_FLAGS) -static -L../../tlib/debug/ -mcmodel=small -fPIC -z max-page-size=0x1000 -T ../linker.ld
NO_COLOR=\x1b[0m
@ -133,12 +133,12 @@ define tlib_compile_cpp_folder
debug/$(1)/%.cpp.d: $(1)/%.cpp
@ mkdir -p debug/$(1)/
@ $(CXX) $(LIB_FLAGS) -MM -MT debug/$(1)/$$*.cpp.o $(1)/$$*.cpp | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $$@
@ $(CXX) $(TLIB_FLAGS) -MM -MT debug/$(1)/$$*.cpp.o $(1)/$$*.cpp | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $$@
debug/$(1)/%.cpp.o: $(1)/%.cpp
@ mkdir -p debug/$(1)/
@ echo -e "$(MODE_COLOR)[debug]$(NO_COLOR) Compile (tlib) $(FILE_COLOR)$(1)/$$*.cpp$(NO_COLOR)"
@ $(CXX) $(LIB_FLAGS) -c $$< -o $$@
@ $(CXX) $(TLIB_FLAGS) -c $$< -o $$@
folder_cpp_files := $(wildcard $(1)/*.cpp)
folder_d_files := $$(folder_cpp_files:%.cpp=debug/%.cpp.d)

View File

@ -0,0 +1,33 @@
//=======================================================================
// Copyright Baptiste Wicht 2013-2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
#ifndef TLIB_CONFIG_HPP
#define TLIB_CONFIG_HPP
namespace tlib {
constexpr bool is_thor_program(){
#ifdef THOR_PROGRAM
return true;
#else
return false;
#endif
}
constexpr bool is_thor_lib(){
#ifdef THOR_TLIB
return true;
#else
return false;
#endif
}
} // end of namespace tlib
#define ASSERT_ONLY_THOR_PROGRAM static_assert(tlib::is_thor_program() || tlib::is_thor_lib(), __FILE__ " can only be used in Thor programs");
#endif

View File

@ -14,6 +14,9 @@
#include "tlib/stat_info.hpp"
#include "tlib/statfs_info.hpp"
#include "tlib/config.hpp"
ASSERT_ONLY_THOR_PROGRAM
namespace tlib {

View File

@ -10,6 +10,10 @@
#include <types.hpp>
#include "tlib/config.hpp"
ASSERT_ONLY_THOR_PROGRAM
namespace tlib {
namespace graphics {

View File

@ -12,6 +12,9 @@
#include <expected.hpp>
#include "tlib/ioctl_codes.hpp"
#include "tlib/config.hpp"
ASSERT_ONLY_THOR_PROGRAM
namespace tlib {

View File

@ -9,6 +9,9 @@
#define USERLIB_MALLOC_H
#include "types.hpp"
#include "tlib/config.hpp"
ASSERT_ONLY_THOR_PROGRAM
void* operator new(uint64_t size);
void operator delete(void* p);

View File

@ -10,7 +10,10 @@
#include <expected.hpp>
#include "net_constants.hpp"
#include "tlib/net_constants.hpp"
#include "tlib/config.hpp"
ASSERT_ONLY_THOR_PROGRAM
namespace tlib {

View File

@ -8,7 +8,9 @@
#ifndef USER_PRINT_HPP
#define USER_PRINT_HPP
//TODO Rename in console
#include "tlib/config.hpp"
ASSERT_ONLY_THOR_PROGRAM
#include <stdarg.h>

View File

@ -14,6 +14,9 @@
#include <string.hpp>
#include "tlib/datetime.hpp"
#include "tlib/config.hpp"
ASSERT_ONLY_THOR_PROGRAM
namespace tlib {