提交 22972409 编写于 作者: Z zhkag 提交者: mysterywolf

[simulator] 修复 linux simulator 编译运行失败

上级 0a7b08d0
......@@ -56,7 +56,6 @@ CONFIG_RT_USING_MESSAGEQUEUE=y
#
# Memory Management
#
CONFIG_RT_PAGE_MAX_ORDER=11
CONFIG_RT_USING_MEMPOOL=y
CONFIG_RT_USING_SMALL_MEM=y
# CONFIG_RT_USING_SLAB is not set
......@@ -80,7 +79,7 @@ CONFIG_RT_USING_DEVICE=y
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="console"
CONFIG_RT_VER_NUM=0x50000
CONFIG_RT_VER_NUM=0x50001
# CONFIG_RT_USING_STDC_ATOMIC is not set
# CONFIG_RT_USING_CACHE is not set
# CONFIG_RT_USING_HW_ATOMIC is not set
......@@ -111,13 +110,19 @@ CONFIG_FINSH_USING_DESCRIPTION=y
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
# CONFIG_FINSH_USING_AUTH is not set
CONFIG_FINSH_ARG_MAX=10
#
# DFS: device virtual file system
#
CONFIG_RT_USING_DFS=y
CONFIG_DFS_USING_POSIX=y
CONFIG_DFS_USING_WORKDIR=y
# CONFIG_RT_USING_DFS_MNTTABLE is not set
CONFIG_DFS_FD_MAX=32
CONFIG_RT_USING_DFS_V1=y
# CONFIG_RT_USING_DFS_V2 is not set
CONFIG_DFS_FILESYSTEMS_MAX=8
CONFIG_DFS_FILESYSTEM_TYPES_MAX=8
CONFIG_DFS_FD_MAX=32
# CONFIG_RT_USING_DFS_MNTTABLE is not set
CONFIG_RT_USING_DFS_ELMFAT=y
#
......@@ -567,6 +572,7 @@ CONFIG_NETDEV_IPV6=0
# CONFIG_PKG_USING_QPC is not set
# CONFIG_PKG_USING_AGILE_UPGRADE is not set
# CONFIG_PKG_USING_FLASH_BLOB is not set
# CONFIG_PKG_USING_MLIBC is not set
#
# peripheral libraries and drivers
......@@ -663,7 +669,6 @@ CONFIG_NETDEV_IPV6=0
# CONFIG_PKG_USING_LKDGUI is not set
# CONFIG_PKG_USING_NRF5X_SDK is not set
# CONFIG_PKG_USING_NRFX is not set
# CONFIG_PKG_USING_WM_LIBRARIES is not set
#
# Kendryte SDK
......@@ -721,14 +726,15 @@ CONFIG_NETDEV_IPV6=0
# CONFIG_PKG_USING_MISAKA_AT24CXX is not set
# CONFIG_PKG_USING_MISAKA_RGB_BLING is not set
# CONFIG_PKG_USING_LORA_MODEM_DRIVER is not set
# CONFIG_PKG_USING_BL_MCU_SDK is not set
# CONFIG_PKG_USING_SOFT_SERIAL is not set
# CONFIG_PKG_USING_MB85RS16 is not set
# CONFIG_PKG_USING_RFM300 is not set
# CONFIG_PKG_USING_IO_INPUT_FILTER is not set
# CONFIG_PKG_USING_RASPBERRYPI_PICO_SDK is not set
# CONFIG_PKG_USING_LRF_NV7LIDAR is not set
# CONFIG_PKG_USING_AIP650 is not set
# CONFIG_PKG_USING_FINGERPRINT is not set
# CONFIG_PKG_USING_SPI_TOOLS is not set
#
# AI packages
......@@ -967,6 +973,7 @@ CONFIG_NETDEV_IPV6=0
#
# Display
#
# CONFIG_PKG_USING_ARDUINO_TFT_ESPI is not set
# CONFIG_PKG_USING_ARDUINO_U8G2 is not set
# CONFIG_PKG_USING_ARDUINO_U8GLIB_ARDUINO is not set
# CONFIG_PKG_USING_SEEED_TM1637 is not set
......@@ -1025,13 +1032,72 @@ CONFIG_NETDEV_IPV6=0
#
# Uncategorized
#
#
# Privated Packages of RealThread
#
# CONFIG_PKG_USING_CODEC is not set
# CONFIG_PKG_USING_PLAYER is not set
# CONFIG_PKG_USING_MPLAYER is not set
# CONFIG_PKG_USING_PERSIMMON_SRC is not set
# CONFIG_PKG_USING_JS_PERSIMMON is not set
# CONFIG_PKG_USING_JERRYSCRIPT_WIN32 is not set
#
# Network Utilities
#
# CONFIG_PKG_USING_WICED is not set
# CONFIG_PKG_USING_CLOUDSDK is not set
# CONFIG_PKG_USING_POWER_MANAGER is not set
# CONFIG_PKG_USING_RT_OTA is not set
# CONFIG_PKG_USING_RTINSIGHT is not set
# CONFIG_PKG_USING_SMARTCONFIG is not set
# CONFIG_PKG_USING_RTX is not set
# CONFIG_RT_USING_TESTCASE is not set
# CONFIG_PKG_USING_NGHTTP2 is not set
# CONFIG_PKG_USING_AVS is not set
# CONFIG_PKG_USING_ALI_LINKKIT is not set
# CONFIG_PKG_USING_STS is not set
# CONFIG_PKG_USING_DLMS is not set
# CONFIG_PKG_USING_AUDIO_FRAMEWORK is not set
# CONFIG_PKG_USING_ZBAR is not set
# CONFIG_PKG_USING_MCF is not set
# CONFIG_PKG_USING_URPC is not set
# CONFIG_PKG_USING_DCM is not set
# CONFIG_PKG_USING_EMQ is not set
# CONFIG_PKG_USING_CFGM is not set
# CONFIG_PKG_USING_RT_CMSIS_DAP is not set
# CONFIG_PKG_USING_SMODULE is not set
# CONFIG_PKG_USING_SNFD is not set
# CONFIG_PKG_USING_UDBD is not set
# CONFIG_PKG_USING_BENCHMARK is not set
# CONFIG_PKG_USING_UBJSON is not set
# CONFIG_PKG_USING_DATATYPE is not set
# CONFIG_PKG_USING_FASTFS is not set
# CONFIG_PKG_USING_RIL is not set
# CONFIG_PKG_USING_WATCH_DCM_SVC is not set
# CONFIG_PKG_USING_WATCH_APP_FWK is not set
# CONFIG_PKG_USING_GUI_TEST is not set
# CONFIG_PKG_USING_PMEM is not set
# CONFIG_PKG_USING_LWRDP is not set
# CONFIG_PKG_USING_MASAN is not set
# CONFIG_PKG_USING_BSDIFF_LIB is not set
# CONFIG_PKG_USING_PRC_DIFF is not set
#
# RT-Thread Smart
#
# CONFIG_PKG_USING_UKERNEL is not set
# CONFIG_PKG_USING_TRACE_AGENT is not set
# CONFIG_PKG_USING_DLOG is not set
# CONFIG_PKG_USING_EXT4 is not set
CONFIG_SOC_SIMULATOR=y
#
# Peripheral Drivers
#
CONFIG_RT_USING_DFS_WINSHAREDIR=y
# CONFIG_RT_USING_DFS_WINSHAREDIR is not set
CONFIG_BSP_USING_RTC=y
# CONFIG_BSP_USING_ALARM is not set
CONFIG_BSP_USING_SOCKET=y
# CONFIG_BSP_USING_SOCKET is not set
# CONFIG_BSP_USING_LVGL is not set
from building import *
import rtconfig
cwd = GetCurrentDir()
objs = []
......@@ -9,4 +10,9 @@ for d in list:
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
if rtconfig.ASAN == True:
LIBS = ['asan', 'ubsan']
group = DefineGroup('asan', [], depend = [''], LIBS=LIBS)
objs += group
Return('objs')
......@@ -73,7 +73,8 @@ else:
env['CC']=rtconfig.CC
env.Append(CFLAGS=rtconfig.CFLAGS)
env.Append(LINKFLAGS=rtconfig.LFLAGS)
env.Append(LIBS=['winmm'])
if sys.platform == 'win32':
env.Append(LIBS=['winmm'])
# prepare building environment
......@@ -96,8 +97,9 @@ def ProjectRemove(group, remove):
item['src'].remove(src)
return
ObjRemove(objs, ['components.obj', 'components.o', 'components.c'])
ProjectRemove('Kernel', ['components.obj', 'components.o', 'components.c'])
if rtconfig.CPU != 'posix':
ObjRemove(objs, ['components.obj', 'components.o', 'components.c'])
ProjectRemove('Kernel', ['components.obj', 'components.o', 'components.c'])
# build program -shared
if GetDepend('RT_USING_MODULE'):
......
......@@ -42,6 +42,7 @@ static void soft_rtc_alarm_update(struct rt_rtc_wkalarm *palarm)
static void get_rtc_timeval(struct timeval *tv)
{
#ifdef _WIN32
struct tm newtime = { 0 };
SYSTEMTIME sys_time;
......@@ -56,6 +57,10 @@ static void get_rtc_timeval(struct timeval *tv)
tv->tv_sec = timegm(&newtime);
tv->tv_usec = sys_time.wMilliseconds * 1000UL;
#else
tv->tv_sec = 0;
tv->tv_usec = 0;
#endif
}
static rt_err_t pc_rtc_control(rt_device_t dev, int cmd, void *args)
......
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
"elf64-x86-64")
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x08048000)); . = SEGMENT_START("text-segment", 0x08048000) + SIZEOF_HEADERS;
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.dyn :
{
*(.rel.init)
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
*(.rel.fini)
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
*(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
*(.rel.ctors)
*(.rel.dtors)
*(.rel.got)
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
*(.rel.ifunc)
}
.rel.plt :
{
*(.rel.plt)
PROVIDE_HIDDEN (__rel_iplt_start = .);
*(.rel.iplt)
PROVIDE_HIDDEN (__rel_iplt_end = .);
}
.init :
{
KEEP (*(.init))
} =0x90909090
.plt : { *(.plt) *(.iplt) }
.text :
{
*(.text.unlikely .text.*_unlikely)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
} =0x90909090
.fini :
{
KEEP (*(.fini))
} =0x90909090
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
/* setction information for finsh shell begin */
. = ALIGN(8);
FSymTab : {
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
}
. = ALIGN(8);
VSymTab : {
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
}
. = ALIGN(8);
rti_fn : {
__rt_init_start = .;
KEEP(*(SORT(.rti_fn*)))
__rt_init_end = .;
}
. = ALIGN(8);
/* setction information for finsh shell end */
.eh_frame_hdr : { *(.eh_frame_hdr) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
.gcc_except_table.*) }
/* These sections are generated by the Sun/Oracle C++ compiler. */
.exception_ranges : ONLY_IF_RO { *(.exception_ranges
.exception_ranges*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
.exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
/* Thread Local Storage sections */
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array))
KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array))
KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
.dynamic : { *(.dynamic) }
.got : { *(.got) *(.igot) }
. = DATA_SEGMENT_RELRO_END (12, .);
.got.plt : { *(.got.plt) *(.igot.plt) }
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
_edata = .; PROVIDE (edata = .);
__bss_start = .;
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we don't
pad the .data section. */
. = ALIGN(. != 0 ? 32 / 8 : 1);
}
. = ALIGN(32 / 8);
. = ALIGN(32 / 8);
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* DWARF 3 */
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
}
......@@ -33,7 +33,6 @@
/* Memory Management */
#define RT_PAGE_MAX_ORDER 11
#define RT_USING_MEMPOOL
#define RT_USING_SMALL_MEM
#define RT_USING_SMALL_MEM_AS_HEAP
......@@ -45,7 +44,7 @@
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "console"
#define RT_VER_NUM 0x50000
#define RT_VER_NUM 0x50001
/* RT-Thread Components */
......@@ -66,12 +65,16 @@
#define MSH_USING_BUILT_IN_COMMANDS
#define FINSH_USING_DESCRIPTION
#define FINSH_ARG_MAX 10
/* DFS: device virtual file system */
#define RT_USING_DFS
#define DFS_USING_POSIX
#define DFS_USING_WORKDIR
#define DFS_FD_MAX 32
#define RT_USING_DFS_V1
#define DFS_FILESYSTEMS_MAX 8
#define DFS_FILESYSTEM_TYPES_MAX 8
#define DFS_FD_MAX 32
#define RT_USING_DFS_ELMFAT
/* elm-chan's FatFs, Generic FAT Filesystem Module */
......@@ -257,13 +260,19 @@
/* Uncategorized */
/* Privated Packages of RealThread */
/* Network Utilities */
/* RT-Thread Smart */
#define SOC_SIMULATOR
/* Peripheral Drivers */
#define RT_USING_DFS_WINSHAREDIR
#define BSP_USING_RTC
#define BSP_USING_SOCKET
#include "rtconfig_project.h"
#endif
import os
import sys
import SCons.Tool.MSCommon.vc
# toolchains options
ARCH='sim'
ASAN = False
#CROSS_TOOL='msvc' or 'gcc' or 'mingw'
#'msvc' and 'mingw' are both for windows
# 'gcc' is for linux
CROSS_TOOL='msvc'
if sys.platform == 'win32':
CROSS_TOOL='msvc'
else:
CROSS_TOOL='gcc'
ASAN = True
if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC')
......@@ -16,7 +22,7 @@ if os.getenv('RTT_CC'):
if CROSS_TOOL == 'gcc' or CROSS_TOOL == 'clang-analyze':
CPU = 'posix'
PLATFORM = 'gcc'
EXEC_PATH = ''
EXEC_PATH = '/usr/bin'
elif CROSS_TOOL == 'mingw':
CPU = 'win32'
......@@ -67,11 +73,11 @@ if PLATFORM == 'gcc':
OBJCPY = PREFIX + 'objcopy'
DEVICE = ' -ffunction-sections -fdata-sections'
DEVICE = ' '
# DEVICE = ' -m32 ' # open this when build 32bit target on 64bit PC
CFLAGS = DEVICE + ' -I/usr/include -w -D_REENTRANT -D_LINUX -DHAVE_SYS_SIGNALS'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
#LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-linux.map -lpthread'
LFLAGS = DEVICE + ' -Wl,-Map=rtthread-linux.map -pthread -T gcc.ld'
# LFLAGS = DEVICE + ' -Wl,-Map=rtthread-linux.map -pthread -T gcc.ld' # open this when build 32bit target
LFLAGS = DEVICE + ' -Wl,-Map=rtthread-linux.map -pthread -T gcc_elf64.ld' # open this when build 64bit target
CPATH = ''
LPATH = ''
......@@ -82,6 +88,8 @@ if PLATFORM == 'gcc':
else:
CFLAGS += ' -O2'
if ASAN == True:
CFLAGS += ' -Wall -g -O0 -fsanitize=address -fsanitize-recover=address,all -fno-omit-frame-pointer -fsanitize=leak -fsanitize=undefined -fdiagnostics-color'
POST_ACTION = ''
elif PLATFORM == 'mingw':
......
......@@ -11,6 +11,8 @@ if rtconfig.PLATFORM in ['armcc', 'armclang']:
CPPDEFINES += ['__CLK_TCK=RT_TICK_PER_SECOND']
elif rtconfig.PLATFORM in ['iccarm']:
CPPDEFINES += ['CLOCKS_PER_SEC=RT_TICK_PER_SECOND'] # forcly revert to 1 by IAR
elif rtconfig.PLATFORM in ['gcc'] and rtconfig.CPU in ['posix']:
CPPDEFINES += ['_GNU_SOURCE'] # linux x86 platform gcc use!
src += Glob('*.c')
......
......@@ -66,6 +66,7 @@ static const short __spm[13] =
rt_align(4) static const char *days = "Sun Mon Tue Wed Thu Fri Sat ";
rt_align(4) static const char *months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ";
#ifndef __isleap
static int __isleap(int year)
{
/* every fourth year is a leap year except for century years that are
......@@ -73,6 +74,7 @@ static int __isleap(int year)
/* return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); */
return (!(year % 4) && ((year % 100) || !(year % 400)));
}
#endif
static void num2str(char *c, int i)
{
......
......@@ -48,6 +48,33 @@ struct timezone
int tz_dsttime; /* type of dst correction */
};
#if defined(_GNU_SOURCE) && (defined(__x86_64__) || defined(__i386__))
/* linux x86 platform gcc use! */
#define _TIMEVAL_DEFINED
/* Values for the first argument to `getitimer' and `setitimer'. */
enum __itimer_which
{
/* Timers run in real time. */
ITIMER_REAL = 0,
#define ITIMER_REAL ITIMER_REAL
/* Timers run only when the process is executing. */
ITIMER_VIRTUAL = 1,
#define ITIMER_VIRTUAL ITIMER_VIRTUAL
/* Timers run when the process is executing and when
the system is executing on behalf of the process. */
ITIMER_PROF = 2
#define ITIMER_PROF ITIMER_PROF
};
struct itimerval
{
/* Value to put into `it_value' when the timer expires. */
struct timeval it_interval;
/* Time to the next timer expiration. */
struct timeval it_value;
};
#endif /* defined(_GNU_SOURCE) && (defined(__x86_64__) || defined(__i386__)) */
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
struct timeval
......
......@@ -49,8 +49,8 @@ static long interrupt_disable_flag;
//static int systick_signal_flag;
/* flag in interrupt handling */
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
rt_ubase_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_ubase_t rt_thread_switch_interrupt_flag;
/* interrupt event mutex */
static pthread_mutex_t *ptr_int_mutex;
......@@ -363,8 +363,8 @@ void rt_hw_interrupt_enable(rt_base_t level)
/*TODO: It may need to unmask the signal */
}
void rt_hw_context_switch(rt_uint32_t from,
rt_uint32_t to)
void rt_hw_context_switch(rt_ubase_t from,
rt_ubase_t to)
{
struct rt_thread * tid;
pthread_t pid;
......@@ -380,12 +380,12 @@ void rt_hw_context_switch(rt_uint32_t from,
rt_thread_switch_interrupt_flag = 1;
// set rt_interrupt_from_thread
rt_interrupt_from_thread = *((rt_uint32_t *)from);
rt_interrupt_from_thread = *((rt_ubase_t *)from);
}
#endif
pthread_mutex_lock(ptr_int_mutex);
rt_interrupt_from_thread = *((rt_uint32_t *)from);
rt_interrupt_to_thread = *((rt_uint32_t *)to);
rt_interrupt_from_thread = *((rt_ubase_t *)from);
rt_interrupt_to_thread = *((rt_ubase_t *)to);
/* 这个函数只是并不会真正执行中断处理函数,而只是简单的
* 设置一下中断挂起标志位
......@@ -394,16 +394,16 @@ void rt_hw_context_switch(rt_uint32_t from,
pthread_mutex_unlock(ptr_int_mutex);
}
void rt_hw_context_switch_interrupt(rt_uint32_t from,
rt_uint32_t to)
void rt_hw_context_switch_interrupt(rt_ubase_t from,
rt_ubase_t to)
{
rt_hw_context_switch(from, to);
}
void rt_hw_context_switch_to(rt_uint32_t to)
void rt_hw_context_switch_to(rt_ubase_t to)
{
//set to thread
rt_interrupt_to_thread = *((rt_uint32_t *)(to));
rt_interrupt_to_thread = *((rt_ubase_t *)(to));
//clear from thread
rt_interrupt_from_thread = 0;
......
#include <rtthread.h>
#if defined(__GNUC__)
int rtthread_startup(void);
static int start(void)
{
rtthread_startup();
return 0;
}
__attribute__((section(".init_array"))) typeof(start) *__init = start;
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册