Creating libruntime, moving jerry-libc and pretty-printer to libruntime, creating platform-dependent handlers of failed assertions.
This commit is contained in:
+4
-2
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
@@ -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