First commit XiUOS

This commit is contained in:
xuetest
2021-04-28 17:49:18 +08:00
commit 6001051eb7
1331 changed files with 433955 additions and 0 deletions

7
lib/libcpp/Kconfig Executable file
View File

@@ -0,0 +1,7 @@
menu "C++ features"
config LIB_CPLUSPLUS
bool "Support C++ features"
default n
endmenu

5
lib/libcpp/Makefile Executable file
View File

@@ -0,0 +1,5 @@
SRC_FILES := cppinit.c crt.cpp
include $(KERNEL_ROOT)/compiler.mk

46
lib/libcpp/cppinit.c Executable file
View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2014-12-03 Bernard Add copyright header.
* 2014-12-29 Bernard Add cplusplus initialization for ARMCC.
* 2016-06-28 Bernard Add _init/_fini routines for GCC.
* 2016-10-02 Bernard Add WEAK for cplusplus_system_init routine.
*/
/**
* @file: cppinit.c
* @brief: cplusplus initialzation
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021/4/25
*/
/*************************************************
File name: cppinit.c
Description: support cppinit function
Others: take RT-Thread v4.0.2/components/cplusplus/crt_init.c for references
https://github.com/RT-Thread/rt-thread/tree/v4.0.2
History:
1. Date: 2021-04-25
Author: AIIT XUOS Lab
Modification:
1. support cppinit function
*************************************************/
int cplusplus_system_init(void)
{
typedef void(*pfunc)();
extern pfunc __ctors_start__[];
extern pfunc __ctors_end__[];
pfunc *p;
for (p = __ctors_start__; p < __ctors_end__; p++)
(*p)();
return 0;
}

42
lib/libcpp/crt.cpp Executable file
View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: crt.c
* @brief: cplusplus initialzation
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/15
*
*/
#include <xiuos.h>
#include "crt.h"
void *operator new(size_t size)
{
return x_malloc(size);
}
void *operator new[](size_t size)
{
return x_malloc(size);
}
void operator delete(void *ptr)
{
x_free(ptr);
}
void operator delete[](void *ptr)
{
return x_free(ptr);
}

30
lib/libcpp/crt.h Executable file
View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: crt.h
* @brief: head file for crt.c
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/15
*
*/
#ifndef CRT_H_
#define CRT_H_
void *operator new(size_t size);
void *operator new[](size_t size);
void operator delete(void * ptr);
void operator delete[](void *ptr);
#endif