Creating libruntime, moving jerry-libc and pretty-printer to libruntime, creating platform-dependent handlers of failed assertions.
This commit is contained in:
@@ -31,7 +31,7 @@ SUP_STM32F4 = ./third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32
|
|||||||
# Add common-io.c and sensors.c
|
# Add common-io.c and sensors.c
|
||||||
SOURCES = \
|
SOURCES = \
|
||||||
$(sort \
|
$(sort \
|
||||||
$(wildcard ./src/jerry-libc.c ./src/pretty-printer.c) \
|
$(wildcard ./src/libruntime/*.c) \
|
||||||
$(wildcard ./src/libperipherals/actuators.c) \
|
$(wildcard ./src/libperipherals/actuators.c) \
|
||||||
$(wildcard ./src/libjsparser/*.c) \
|
$(wildcard ./src/libjsparser/*.c) \
|
||||||
$(wildcard ./src/libecmaobjects/*.c) \
|
$(wildcard ./src/libecmaobjects/*.c) \
|
||||||
@@ -40,11 +40,16 @@ SOURCES = \
|
|||||||
$(wildcard ./src/libcoreint/*.c) )
|
$(wildcard ./src/libcoreint/*.c) )
|
||||||
|
|
||||||
SOURCES_STM32F4 = \
|
SOURCES_STM32F4 = \
|
||||||
third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
|
third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c \
|
||||||
|
$(wildcard src/libruntime/stm32f4/*)
|
||||||
|
|
||||||
|
SOURCES_LINUX = \
|
||||||
|
$(wildcard src/libruntime/linux/*)
|
||||||
|
|
||||||
HEADERS = \
|
HEADERS = \
|
||||||
$(sort \
|
$(sort \
|
||||||
$(wildcard ./src/*.h) \
|
$(wildcard ./src/*.h) \
|
||||||
|
$(wildcard ./src/libruntime/*.h) \
|
||||||
$(wildcard ./src/libperipherals/*.h) \
|
$(wildcard ./src/libperipherals/*.h) \
|
||||||
$(wildcard ./src/libjsparser/*.h) \
|
$(wildcard ./src/libjsparser/*.h) \
|
||||||
$(wildcard ./src/libecmaobjects/*.h) \
|
$(wildcard ./src/libecmaobjects/*.h) \
|
||||||
@@ -54,6 +59,7 @@ HEADERS = \
|
|||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I src \
|
-I src \
|
||||||
|
-I src/libruntime \
|
||||||
-I src/libperipherals \
|
-I src/libperipherals \
|
||||||
-I src/libjsparser \
|
-I src/libjsparser \
|
||||||
-I src/libecmaobjects \
|
-I src/libecmaobjects \
|
||||||
@@ -129,12 +135,12 @@ debug.stdm32f4.bin: debug.stdm32f4.elf
|
|||||||
debug: clean
|
debug: clean
|
||||||
mkdir -p $(OUT_DIR)/debug.host/
|
mkdir -p $(OUT_DIR)/debug.host/
|
||||||
$(CC) $(CFLAGS) $(DEBUG_OPTIONS) $(DEFINES) $(TARGET_HOST) \
|
$(CC) $(CFLAGS) $(DEBUG_OPTIONS) $(DEFINES) $(TARGET_HOST) \
|
||||||
$(SOURCES) $(MAIN_MODULE_SRC) -o $(OUT_DIR)/debug.host/$(TARGET)
|
$(SOURCES) $(SOURCES_LINUX) $(MAIN_MODULE_SRC) -o $(OUT_DIR)/debug.host/$(TARGET)
|
||||||
|
|
||||||
release: clean
|
release: clean
|
||||||
mkdir -p $(OUT_DIR)/release.host/
|
mkdir -p $(OUT_DIR)/release.host/
|
||||||
$(CC) $(CFLAGS) $(RELEASE_OPTIONS) $(DEFINES) $(TARGET_HOST) \
|
$(CC) $(CFLAGS) $(RELEASE_OPTIONS) $(DEFINES) $(TARGET_HOST) \
|
||||||
$(SOURCES) $(MAIN_MODULE_SRC) -o $(OUT_DIR)/release.host/$(TARGET)
|
$(SOURCES) $(SOURCES_LINUX) $(MAIN_MODULE_SRC) -o $(OUT_DIR)/release.host/$(TARGET)
|
||||||
$(STRIP) $(OUT_DIR)/release.host/$(TARGET)
|
$(STRIP) $(OUT_DIR)/release.host/$(TARGET)
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
@@ -142,7 +148,7 @@ tests:
|
|||||||
for unit_test in $(UNITTESTS); \
|
for unit_test in $(UNITTESTS); \
|
||||||
do \
|
do \
|
||||||
$(CC) -O3 $(CFLAGS) $(DEBUG_OPTIONS) $(DEFINES) $(TARGET_HOST) \
|
$(CC) -O3 $(CFLAGS) $(DEBUG_OPTIONS) $(DEFINES) $(TARGET_HOST) \
|
||||||
$(SOURCES) $(UNITTESTS_SRC_DIR)/"$$unit_test".c -o $(OUT_DIR)/tests.host/"$$unit_test"; \
|
$(SOURCES) $(SOURCES_LINUX) $(UNITTESTS_SRC_DIR)/"$$unit_test".c -o $(OUT_DIR)/tests.host/"$$unit_test"; \
|
||||||
done
|
done
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
+4
-2
@@ -16,7 +16,6 @@
|
|||||||
#ifndef JERRY_GLOBALS_H
|
#ifndef JERRY_GLOBALS_H
|
||||||
#define JERRY_GLOBALS_H
|
#define JERRY_GLOBALS_H
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -38,6 +37,7 @@ typedef signed int int32_t;
|
|||||||
*/
|
*/
|
||||||
#define __unused __attribute__((unused))
|
#define __unused __attribute__((unused))
|
||||||
#define __packed __attribute__((packed))
|
#define __packed __attribute__((packed))
|
||||||
|
#define __noreturn __attribute__((noreturn))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
@@ -68,8 +68,10 @@ typedef signed int int32_t;
|
|||||||
*/
|
*/
|
||||||
extern uint32_t jerry_UnreferencedExpression;
|
extern uint32_t jerry_UnreferencedExpression;
|
||||||
|
|
||||||
|
extern void __noreturn jerry_AssertFail( const char *assertion, const char *file, const uint32_t line);
|
||||||
|
|
||||||
#ifndef JERRY_NDEBUG
|
#ifndef JERRY_NDEBUG
|
||||||
#define JERRY_ASSERT( x ) assert( x )
|
#define JERRY_ASSERT( x ) do { if ( __builtin_expect( !( x ), 0 ) ) { jerry_AssertFail( #x, __FILE__, __LINE__); } } while(0)
|
||||||
#else /* !JERRY_NDEBUG */
|
#else /* !JERRY_NDEBUG */
|
||||||
#define JERRY_ASSERT( x ) (void) (x)
|
#define JERRY_ASSERT( x ) (void) (x)
|
||||||
#endif /* !JERRY_NDEBUG */
|
#endif /* !JERRY_NDEBUG */
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
#define MAPPINGS_H
|
#define MAPPINGS_H
|
||||||
|
|
||||||
#ifndef __HOST
|
#ifndef __HOST
|
||||||
#include "../jerry-libc.h"
|
#include "jerry-libc.h"
|
||||||
#include "allocator.h"
|
#include "allocator.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
extern int vprintf (__const char *__restrict __format, __builtin_va_list __arg);
|
extern int vprintf (__const char *__restrict __format, __builtin_va_list __arg);
|
||||||
|
extern void __noreturn exit(int status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* memset
|
* memset
|
||||||
@@ -115,12 +116,11 @@ __putchar (int c)
|
|||||||
return __printf ("%c", c);
|
return __printf ("%c", c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** exit - cause normal process termination. Infinite loop. */
|
/** exit - cause normal process termination */
|
||||||
void
|
void __noreturn
|
||||||
__exit (int status __unused)
|
__exit (int status)
|
||||||
{
|
{
|
||||||
for (;;)
|
exit( status);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compare two strings. return an integer less than, equal to, or greater than zero
|
/** Compare two strings. return an integer less than, equal to, or greater than zero
|
||||||
@@ -26,7 +26,7 @@ extern int __memcmp (const void *s1, const void *s2, size_t n);
|
|||||||
extern void *__memcpy (void *s1, const void *s2, size_t n);
|
extern void *__memcpy (void *s1, const void *s2, size_t n);
|
||||||
extern int __printf (const char *format, ...);
|
extern int __printf (const char *format, ...);
|
||||||
extern int __putchar (int);
|
extern int __putchar (int);
|
||||||
extern void __exit (int);
|
extern void __noreturn __exit (int);
|
||||||
|
|
||||||
extern int __strcmp (const char *, const char *);
|
extern int __strcmp (const char *, const char *);
|
||||||
extern int __strncmp (const char *, const char *, size_t);
|
extern int __strncmp (const char *, const char *, size_t);
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/* Copyright 2014 Samsung Electronics Co., Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "globals.h"
|
||||||
|
#include "jerry-libc.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle failed assertion
|
||||||
|
*/
|
||||||
|
void __noreturn
|
||||||
|
jerry_AssertFail( const char *assertion, /**< assertion condition string */
|
||||||
|
const char *file, /**< file name */
|
||||||
|
const uint32_t line) /** line */
|
||||||
|
{
|
||||||
|
__printf("Assertion '%s' failed at %s:%u\n",
|
||||||
|
assertion, file, line);
|
||||||
|
|
||||||
|
__exit( 1);
|
||||||
|
} /* jerry_AssertFail */
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/* Copyright 2014 Samsung Electronics Co., Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "globals.h"
|
||||||
|
#include "jerry-libc.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle failed assertion
|
||||||
|
*/
|
||||||
|
void __noreturn
|
||||||
|
jerry_AssertFail( const char *assertion, /**< assertion condition string */
|
||||||
|
const char *file, /**< file name */
|
||||||
|
const uint32_t line) /** line */
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* TODO: Blink with LEDs.
|
||||||
|
* Save call stack?
|
||||||
|
*/
|
||||||
|
while( true );
|
||||||
|
} /* jerry_AssertFail */
|
||||||
Reference in New Issue
Block a user