Creating libruntime, moving jerry-libc and pretty-printer to libruntime, creating platform-dependent handlers of failed assertions.

This commit is contained in:
Ruben Ayrapetyan
2014-07-10 15:39:43 +04:00
parent 8641b79ed5
commit c132f6aa3c
9 changed files with 85 additions and 14 deletions
+11 -5
View File
@@ -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
SOURCES = \
$(sort \
$(wildcard ./src/jerry-libc.c ./src/pretty-printer.c) \
$(wildcard ./src/libruntime/*.c) \
$(wildcard ./src/libperipherals/actuators.c) \
$(wildcard ./src/libjsparser/*.c) \
$(wildcard ./src/libecmaobjects/*.c) \
@@ -40,11 +40,16 @@ SOURCES = \
$(wildcard ./src/libcoreint/*.c) )
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 = \
$(sort \
$(wildcard ./src/*.h) \
$(wildcard ./src/libruntime/*.h) \
$(wildcard ./src/libperipherals/*.h) \
$(wildcard ./src/libjsparser/*.h) \
$(wildcard ./src/libecmaobjects/*.h) \
@@ -54,6 +59,7 @@ HEADERS = \
INCLUDES = \
-I src \
-I src/libruntime \
-I src/libperipherals \
-I src/libjsparser \
-I src/libecmaobjects \
@@ -129,12 +135,12 @@ debug.stdm32f4.bin: debug.stdm32f4.elf
debug: clean
mkdir -p $(OUT_DIR)/debug.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
mkdir -p $(OUT_DIR)/release.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)
tests:
@@ -142,7 +148,7 @@ tests:
for unit_test in $(UNITTESTS); \
do \
$(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
clean:
+4 -2
View File
@@ -16,7 +16,6 @@
#ifndef JERRY_GLOBALS_H
#define JERRY_GLOBALS_H
#include <assert.h>
#include <stddef.h>
#include <stdbool.h>
@@ -38,6 +37,7 @@ typedef signed int int32_t;
*/
#define __unused __attribute__((unused))
#define __packed __attribute__((packed))
#define __noreturn __attribute__((noreturn))
/**
* Constants
@@ -68,8 +68,10 @@ typedef signed int int32_t;
*/
extern uint32_t jerry_UnreferencedExpression;
extern void __noreturn jerry_AssertFail( const char *assertion, const char *file, const uint32_t line);
#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 */
#define JERRY_ASSERT( x ) (void) (x)
#endif /* !JERRY_NDEBUG */
+1 -1
View File
@@ -17,7 +17,7 @@
#define MAPPINGS_H
#ifndef __HOST
#include "../jerry-libc.h"
#include "jerry-libc.h"
#include "allocator.h"
#include <stdarg.h>
@@ -22,6 +22,7 @@
#include <stdarg.h>
extern int vprintf (__const char *__restrict __format, __builtin_va_list __arg);
extern void __noreturn exit(int status);
/**
* memset
@@ -115,12 +116,11 @@ __putchar (int c)
return __printf ("%c", c);
}
/** exit - cause normal process termination. Infinite loop. */
void
__exit (int status __unused)
/** exit - cause normal process termination */
void __noreturn
__exit (int status)
{
for (;;)
;
exit( status);
}
/** 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 int __printf (const char *format, ...);
extern int __putchar (int);
extern void __exit (int);
extern void __noreturn __exit (int);
extern int __strcmp (const char *, const char *);
extern int __strncmp (const char *, const char *, size_t);
+31
View File
@@ -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 */
+32
View File
@@ -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 */