mirror of
https://github.com/google/pebble.git
synced 2025-07-14 21:55:57 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
45
third_party/jerryscript/jerry-core/jrt/jrt-bit-fields.h
vendored
Normal file
45
third_party/jerryscript/jerry-core/jrt/jrt-bit-fields.h
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef JRT_BIT_FIELDS_H
|
||||
#define JRT_BIT_FIELDS_H
|
||||
|
||||
/**
|
||||
* Extract a bit-field.
|
||||
*
|
||||
* @param type type of container
|
||||
* @param container container to extract bit-field from
|
||||
* @param lsb least significant bit of the value to be extracted
|
||||
* @param width width of the bit-field to be extracted
|
||||
* @return bit-field's value
|
||||
*/
|
||||
#define JRT_EXTRACT_BIT_FIELD(type, container, lsb, width) \
|
||||
(((container) >> lsb) & ((((type) 1) << (width)) - 1))
|
||||
|
||||
/**
|
||||
* Set a bit-field.
|
||||
*
|
||||
* @param type type of container
|
||||
* @param container container to insert bit-field to
|
||||
* @param new_bit_field_value value of bit-field to insert
|
||||
* @param lsb least significant bit of the value to be inserted
|
||||
* @param width width of the bit-field to be inserted
|
||||
* @return bit-field's value
|
||||
*/
|
||||
#define JRT_SET_BIT_FIELD_VALUE(type, container, new_bit_field_value, lsb, width) \
|
||||
(((container) & ~(((((type) 1) << (width)) - 1) << (lsb))) | (((type) new_bit_field_value) << (lsb)))
|
||||
|
||||
#endif /* !JRT_BIT_FIELDS_H */
|
112
third_party/jerryscript/jerry-core/jrt/jrt-fatals.c
vendored
Normal file
112
third_party/jerryscript/jerry-core/jrt/jrt-fatals.c
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of exit with specified status code.
|
||||
*/
|
||||
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
#define JERRY_INTERNAL
|
||||
#include "jerry-internal.h"
|
||||
|
||||
static void __noreturn
|
||||
jerry_fatal_with_lr (jerry_fatal_code_t code, /**< status code */
|
||||
void *lr) /**< return address at time the failure occurred */
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
switch (code)
|
||||
{
|
||||
case ERR_OUT_OF_MEMORY:
|
||||
{
|
||||
JERRY_ERROR_MSG ("Error: ERR_OUT_OF_MEMORY\n");
|
||||
break;
|
||||
}
|
||||
case ERR_SYSCALL:
|
||||
{
|
||||
/* print nothing as it may invoke syscall recursively */
|
||||
break;
|
||||
}
|
||||
case ERR_REF_COUNT_LIMIT:
|
||||
{
|
||||
JERRY_ERROR_MSG ("Error: ERR_REF_COUNT_LIMIT\n");
|
||||
break;
|
||||
}
|
||||
case ERR_FAILED_INTERNAL_ASSERTION:
|
||||
{
|
||||
JERRY_ERROR_MSG ("Error: ERR_FAILED_INTERNAL_ASSERTION\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
jerry_port_fatal (code, lr);
|
||||
|
||||
/* to make compiler happy for some RTOS: 'control reaches end of non-void function' */
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
} /* jerry_fatal_with_lr */
|
||||
|
||||
|
||||
/*
|
||||
* Exit with specified status code.
|
||||
*
|
||||
* If !JERRY_NDEBUG and code != 0, print status code with description
|
||||
* and call assertion fail handler.
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_fatal (jerry_fatal_code_t code) /**< status code */
|
||||
{
|
||||
jerry_fatal_with_lr(code, JERRY_RETURN_ADDRESS);
|
||||
} /* jerry_fatal */
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
/**
|
||||
* Handle failed assertion
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_assert_fail (const char *assertion, /**< assertion condition string */
|
||||
const char *file, /**< file name */
|
||||
const char *function, /**< function name */
|
||||
const uint32_t line) /**< line */
|
||||
{
|
||||
JERRY_ERROR_MSG ("ICE: Assertion '%s' failed at %s(%s):%lu.\n",
|
||||
assertion,
|
||||
file,
|
||||
function,
|
||||
(unsigned long) line);
|
||||
|
||||
jerry_fatal_with_lr (ERR_FAILED_INTERNAL_ASSERTION, JERRY_RETURN_ADDRESS);
|
||||
} /* jerry_assert_fail */
|
||||
|
||||
/**
|
||||
* Handle execution of control path that should be unreachable
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_unreachable (const char *file, /**< file name */
|
||||
const char *function, /**< function name */
|
||||
const uint32_t line) /**< line */
|
||||
{
|
||||
JERRY_ERROR_MSG ("ICE: Unreachable control path at %s(%s):%lu was executed.\n",
|
||||
file,
|
||||
function,
|
||||
(unsigned long) line);
|
||||
|
||||
jerry_fatal_with_lr (ERR_FAILED_INTERNAL_ASSERTION, JERRY_RETURN_ADDRESS);
|
||||
} /* jerry_unreachable */
|
||||
#endif /* !JERRY_NDEBUG */
|
26
third_party/jerryscript/jerry-core/jrt/jrt-libc-includes.h
vendored
Normal file
26
third_party/jerryscript/jerry-core/jrt/jrt-libc-includes.h
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
#ifndef JRT_LIBC_INCLUDES_H
|
||||
#define JRT_LIBC_INCLUDES_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#endif /* !JRT_LIBC_INCLUDES_H */
|
25
third_party/jerryscript/jerry-core/jrt/jrt-types.h
vendored
Normal file
25
third_party/jerryscript/jerry-core/jrt/jrt-types.h
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
#ifndef JRT_TYPES_H
|
||||
#define JRT_TYPES_H
|
||||
|
||||
#include <float.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#endif /* !JRT_TYPES_H */
|
153
third_party/jerryscript/jerry-core/jrt/jrt.h
vendored
Normal file
153
third_party/jerryscript/jerry-core/jrt/jrt.h
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef JRT_H
|
||||
#define JRT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "jerry-api.h"
|
||||
#include "jerry-port.h"
|
||||
#include "jrt-types.h"
|
||||
|
||||
/*
|
||||
* Attributes
|
||||
*/
|
||||
#define __noreturn __attribute__((noreturn))
|
||||
#define __attr_noinline___ __attribute__((noinline))
|
||||
#define __attr_return_value_should_be_checked___ __attribute__((warn_unused_result))
|
||||
#define __attr_hot___ __attribute__((hot))
|
||||
#ifndef __attr_always_inline___
|
||||
# define __attr_always_inline___ __attribute__((always_inline))
|
||||
#endif /* !__attr_always_inline___ */
|
||||
#ifndef __attr_const___
|
||||
# define __attr_const___ __attribute__((const))
|
||||
#endif /* !__attr_const___ */
|
||||
#ifndef __attr_pure___
|
||||
# define __attr_pure___ __attribute__((pure))
|
||||
#endif /* !__attr_pure___ */
|
||||
|
||||
/*
|
||||
* Conditions' likeliness, unlikeliness.
|
||||
*/
|
||||
#define likely(x) __builtin_expect (!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect (!!(x) , 0)
|
||||
|
||||
/*
|
||||
* Normally compilers store const(ant)s in ROM. Thus saving RAM.
|
||||
* But if your compiler does not support it then the directive below can force it.
|
||||
*
|
||||
* For the moment it is mainly meant for the following targets:
|
||||
* - ESP8266
|
||||
*/
|
||||
#ifndef JERRY_CONST_DATA
|
||||
# define JERRY_CONST_DATA
|
||||
#endif /* JERRY_CONST_DATA */
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
#define JERRY_BITSINBYTE 8
|
||||
|
||||
/*
|
||||
* Make sure unused parameters, variables, or expressions trigger no compiler warning.
|
||||
*/
|
||||
#define JERRY_UNUSED(x) ((void) (x))
|
||||
|
||||
/*
|
||||
* Asserts
|
||||
*
|
||||
* Warning:
|
||||
* Don't use JERRY_STATIC_ASSERT in headers, because
|
||||
* __LINE__ may be the same for asserts in a header
|
||||
* and in an implementation file.
|
||||
*/
|
||||
#define JERRY_STATIC_ASSERT_GLUE_(a, b, c) a ## b ## _ ## c
|
||||
#define JERRY_STATIC_ASSERT_GLUE(a, b, c) JERRY_STATIC_ASSERT_GLUE_ (a, b, c)
|
||||
#define JERRY_STATIC_ASSERT(x, msg) \
|
||||
enum { JERRY_STATIC_ASSERT_GLUE (static_assertion_failed_, __LINE__, msg) = 1 / (!!(x)) }
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
extern void __noreturn jerry_assert_fail (const char *, const char *, const char *, const uint32_t);
|
||||
extern void __noreturn jerry_unreachable (const char *, const char *, const uint32_t);
|
||||
|
||||
#define JERRY_ASSERT(x) \
|
||||
do \
|
||||
{ \
|
||||
if (unlikely (!(x))) \
|
||||
{ \
|
||||
jerry_assert_fail (#x, __FILE__, __func__, __LINE__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define JERRY_UNREACHABLE() \
|
||||
do \
|
||||
{ \
|
||||
jerry_unreachable (__FILE__, __func__, __LINE__); \
|
||||
} while (0)
|
||||
#else /* JERRY_NDEBUG */
|
||||
#define JERRY_ASSERT(x) \
|
||||
do \
|
||||
{ \
|
||||
if (false) \
|
||||
{ \
|
||||
JERRY_UNUSED (x); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define JERRY_UNREACHABLE() __builtin_unreachable ()
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
/**
|
||||
* Return address / LR, passed to jerry_port_fatal() calls, to aid with debugging.
|
||||
*/
|
||||
#ifndef JERRY_RETURN_ADDRESS
|
||||
#define JERRY_RETURN_ADDRESS __builtin_return_address(0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Exit on fatal error
|
||||
*/
|
||||
extern void __noreturn jerry_fatal (jerry_fatal_code_t);
|
||||
|
||||
/*
|
||||
* Logging
|
||||
*/
|
||||
#define JERRY_ERROR_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_ERROR, __VA_ARGS__)
|
||||
#define JERRY_WARNING_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_WARNING, __VA_ARGS__)
|
||||
#define JERRY_DEBUG_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_DEBUG, __VA_ARGS__)
|
||||
#define JERRY_TRACE_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_TRACE, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Size of struct member
|
||||
*/
|
||||
#define JERRY_SIZE_OF_STRUCT_MEMBER(struct_name, member_name) sizeof (((struct_name *) NULL)->member_name)
|
||||
|
||||
/**
|
||||
* Aligns @a value to @a alignment. @a must be the power of 2.
|
||||
*
|
||||
* Returns minimum positive value, that divides @a alignment and is more than or equal to @a value
|
||||
*/
|
||||
#define JERRY_ALIGNUP(value, alignment) (((value) + (((uintptr_t)alignment) - 1)) & ~(((uintptr_t)alignment) - 1))
|
||||
|
||||
/*
|
||||
* min, max
|
||||
*/
|
||||
#define JERRY_MIN(v1, v2) (((v1) < (v2)) ? (v1) : (v2))
|
||||
#define JERRY_MAX(v1, v2) (((v1) < (v2)) ? (v2) : (v1))
|
||||
|
||||
#endif /* !JRT_H */
|
Loading…
Add table
Add a link
Reference in a new issue