Jerry is now split to several components: core, libc, plugins.

The components are build independently and then are linked with main module corresponding to target platform.
Core is supposed to be platform-independent, while libc and plugins are dependent on specific architecture / platform.

The commit disables unit tests building and running during precommit.
That is supposed to be fixed in a subsequent commit.

Also, the commit disables building and running valgrind targets during precommit.
Build is supposed to be turned on by an option that should be introduced later.
Valgrind-checked runs are supposed to be performed in asynchronous mode.
This commit is contained in:
Ruben Ayrapetyan 2015-02-13 21:29:02 +03:00
parent 62a3ac93d9
commit 43ea53b1d7
84 changed files with 1345 additions and 1116 deletions

View File

@ -37,13 +37,37 @@ project (Jerry CXX C ASM)
set(CMAKE_AR ${DIRECTORY_GCC}/${CMAKE_AR}) set(CMAKE_AR ${DIRECTORY_GCC}/${CMAKE_AR})
set(CMAKE_RANLIB ${DIRECTORY_GCC}/${CMAKE_RANLIB}) set(CMAKE_RANLIB ${DIRECTORY_GCC}/${CMAKE_RANLIB})
# Disable _FORTIFY_SOURCE
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_FORTIFY_SOURCE")
# Architecture-specific compile/link flags
foreach(FLAG ${FLAGS_COMMON_ARCH})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}")
endforeach()
# Remove rdynamic option # Remove rdynamic option
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS ) set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS ) set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS )
# Options # Determining platform and defining options
option(STRIP_LINUX_RELEASE_BINARY "Strip symbols from Linux-targeted release binaries" ON) set(PLATFORM "${CMAKE_SYSTEM_NAME}")
string(TOUPPER "${PLATFORM}" PLATFORM)
if("${PLATFORM}" STREQUAL "LINUX")
set(PLATFORM_EXT "LINUX")
option(STRIP_RELEASE_BINARY "Strip symbols from release binaries" ON)
elseif("${PLATFORM}" STREQUAL "MCU")
set(PLATFORM_EXT "MCU_${CMAKE_SYSTEM_VERSION}")
option(STRIP_RELEASE_BINARY "Strip symbols from release binaries" OFF)
set(MCU_SCRIPT_FILE "tests/blinky.js" CACHE STRING "Script to run on MCU") set(MCU_SCRIPT_FILE "tests/blinky.js" CACHE STRING "Script to run on MCU")
else()
message(FATAL_ERROR "Platform is not supported")
endif()
# Intermediate files # Intermediate files
# Script to run on MCU # Script to run on MCU
@ -68,297 +92,105 @@ project (Jerry CXX C ASM)
# Profiles # Profiles
# Full profile (default, so - no suffix) # Full profile (default, so - no suffix)
set(MODIFIER_SUFFIX_FULL_PROFILE ) set(MODIFIER_SUFFIX_FULL_PROFILE "")
set(MODIFIER_DEFINES_FULL_PROFILE DEFINES_JERRY_FULL_PROFILE)
set(MODIFIER_INCLUDE_FULL_PROFILE )
# Compact profile # Compact profile
set(MODIFIER_SUFFIX_COMPACT_PROFILE -cp) set(MODIFIER_SUFFIX_COMPACT_PROFILE -cp)
set(MODIFIER_DEFINES_COMPACT_PROFILE DEFINES_JERRY_COMPACT_PROFILE)
set(MODIFIER_INCLUDE_COMPACT_PROFILE )
# Minimal compact profile # Minimal compact profile
set(MODIFIER_SUFFIX_COMPACT_PROFILE_MINIMAL -cp_minimal) set(MODIFIER_SUFFIX_COMPACT_PROFILE_MINIMAL -cp_minimal)
set(MODIFIER_DEFINES_COMPACT_PROFILE_MINIMAL DEFINES_JERRY_COMPACT_PROFILE_MINIMAL)
set(MODIFIER_INCLUDE_COMPACT_PROFILE_MINIMAL )
# Memory statistics # Memory statistics
set(MODIFIER_SUFFIX_MEMORY_STATISTICS -mem_stats) set(MODIFIER_SUFFIX_MEMORY_STATISTICS -mem_stats)
set(MODIFIER_DEFINES_MEMORY_STATISTICS DEFINES_JERRY_MEMORY_STATS)
set(MODIFIER_INCLUDE_MEMORY_STATISTICS )
# Valgrind # Valgrind (TODO: make option)
set(MODIFIER_SUFFIX_VALGRIND -valgrind) # set(MODIFIER_SUFFIX_VALGRIND -valgrind)
set(MODIFIER_DEFINES_VALGRIND DEFINES_JERRY_VALGRIND) # set(MODIFIER_DEFINES_VALGRIND DEFINES_JERRY_VALGRIND)
set(MODIFIER_INCLUDE_VALGRIND INCLUDE_THIRD_PARTY_VALGRIND) # set(MODIFIER_INCLUDE_VALGRIND INCLUDE_THIRD_PARTY_VALGRIND)
# Compiler flags # Modifier lists
set(CXX_FLAGS_JERRY -std=c++11 -fno-exceptions -fno-rtti) # Linux
set(MODIFIERS_LISTS_LINUX
"FULL_PROFILE"
"COMPACT_PROFILE"
"COMPACT_PROFILE_MINIMAL"
"FULL_PROFILE MEMORY_STATISTICS"
"COMPACT_PROFILE_MINIMAL MEMORY_STATISTICS")
# Turn off implicit template instantiation
set(CXX_FLAGS_JERRY ${CXX_FLAGS_JERRY} -fno-implicit-templates -fno-implicit-inline-templates)
# Turn off stack protector
set(CXX_FLAGS_JERRY ${CXX_FLAGS_JERRY} -fno-stack-protector)
# Debug information
set(CXX_FLAGS_JERRY ${CXX_FLAGS_JERRY} -g -gdwarf-4)
# Warnings
set(CXX_FLAGS_JERRY ${CXX_FLAGS_JERRY} -Wall -Wextra -Wpedantic -Wlogical-op)
set(CXX_FLAGS_JERRY ${CXX_FLAGS_JERRY} -Wformat-nonliteral -Winit-self -Wstack-protector)
set(CXX_FLAGS_JERRY ${CXX_FLAGS_JERRY} -Wconversion -Wsign-conversion -Wformat-security)
set(CXX_FLAGS_JERRY ${CXX_FLAGS_JERRY} -Wmissing-declarations -Wno-attributes)
set(CXX_FLAGS_JERRY ${CXX_FLAGS_JERRY} -Werror -Wfatal-errors)
# Architecture-specific
# x86_64
# Workaround for gcc bug 64905 (x86_64)
set(CXX_FLAGS_JERRY_X86_64 -ffixed-rbp)
# ARMv7
set(CXX_FLAGS_JERRY_ARMV7 -mlittle-endian -mthumb)
# Platform-specific
# MCU # MCU
# stm32f3 # stm32f3
set(CXX_FLAGS_COMMON_MCU_STM32F3 -mcpu=cortex-m4 -march=armv7e-m) set(MODIFIERS_LISTS_MCU_STM32F3
set(CXX_FLAGS_COMMON_MCU_STM32F3 ${CXX_FLAGS_COMMON_MCU_STM32F3} -mfpu=fpv4-sp-d16 -mfloat-abi=hard) "FULL_PROFILE"
"COMPACT_PROFILE"
"COMPACT_PROFILE_MINIMAL")
# stm32f4 # stm32f4
set(CXX_FLAGS_COMMON_MCU_STM32F4 -mcpu=cortex-m4 -march=armv7e-m) set(MODIFIERS_LISTS_MCU_STM32F4
set(CXX_FLAGS_COMMON_MCU_STM32F4 ${CXX_FLAGS_COMMON_MCU_STM32F4} -mfpu=fpv4-sp-d16 -mfloat-abi=hard) "FULL_PROFILE"
"COMPACT_PROFILE"
"COMPACT_PROFILE_MINIMAL")
# Debug # Compiler / Linker flags
set(CXX_FLAGS_COMMON_DEBUG ) set(COMPILE_FLAGS_JERRY "-fno-builtin")
set(LINKER_FLAGS_COMMON "-nostdlib")
# Release # Turn off stack protector
set(CXX_FLAGS_COMMON_RELEASE -Os -flto) set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -fno-stack-protector")
# Unit tests # Debug information
set(CXX_FLAGS_UNIT_TEST set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -g -gdwarf-4")
${CXX_FLAGS_COMMON_RELEASE})
# Linker flags (flags are passed through set_target_properties, # Warnings
# so they should be specified withstring constant, set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -Wall -Wextra -Wpedantic -Wlogical-op")
# not list) set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -Wformat-nonliteral -Winit-self -Wno-stack-protector")
set(LINKER_FLAGS_JERRY "-nostdlib -lgcc") set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -Wconversion -Wsign-conversion -Wformat-security")
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -Wmissing-declarations -Wno-attributes")
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -Werror -Wfatal-errors")
# Static build # Static build
set(LINKER_FLAGS_STATIC "-static") set(LINKER_FLAGS_STATIC "-static")
# Architecture-specific # C++
# x86_64 set(CXX_FLAGS_JERRY "-std=c++11 -fno-exceptions -fno-rtti")
# Workaround for gcc bug 64905 (x86_64)
string(REPLACE ";" " " LINKER_FLAGS_JERRY_X86_64 "${CXX_FLAGS_JERRY_X86_64}")
# ARMv7 # Turn off implicit template instantiation
string(REPLACE ";" " " LINKER_FLAGS_JERRY_ARMV7 "${CXX_FLAGS_JERRY_ARMV7}") set(CXX_FLAGS_JERRY "${CXX_FLAGS_JERRY} -fno-implicit-templates -fno-implicit-inline-templates")
# Platform-specific # C
# MCU set(C_FLAGS_JERRY "-std=c99")
# stm32f3
set(LINKER_FLAGS_JERRY_MCU_STM32F3 "-T${CMAKE_SOURCE_DIR}/third-party/stm32f3.ld")
# stm32f4
set(LINKER_FLAGS_JERRY_MCU_STM32F4 "-T${CMAKE_SOURCE_DIR}/third-party/stm32f4.ld")
# Debug
set(LINKER_FLAGS_COMMON_DEBUG "")
# Release
set(LINKER_FLAGS_COMMON_RELEASE "-Os -flto")
# Unit tests
set(LINKER_FLAGS_UNIT_TEST
"${LINKER_FLAGS_COMMON_RELEASE}")
# Definitions
# Common
# Get version information from git
execute_process(COMMAND git symbolic-ref -q HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE JERRY_GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE JERRY_GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Get build date
execute_process(COMMAND date +%d/%m/%Y
OUTPUT_VARIABLE JERRY_BUILD_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(DEFINES_JERRY
JERRY_BUILD_DATE="${JERRY_BUILD_DATE}"
JERRY_COMMIT_HASH="${JERRY_GIT_COMMIT}"
JERRY_BRANCH_NAME="${JERRY_GIT_BRANCH}")
# Debug
set(DEFINES_JERRY_DEBUG JERRY_ENABLE_PRETTY_PRINTER)
# Release
set(DEFINES_JERRY_RELEASE JERRY_NDEBUG)
# Full profile
set(DEFINES_JERRY_FULL_PROFILE CONFIG_ECMA_NUMBER_TYPE=CONFIG_ECMA_NUMBER_FLOAT64)
# Compact profile
set(DEFINES_JERRY_COMPACT_PROFILE
CONFIG_ECMA_COMPACT_PROFILE)
# Minimal compact profile
set(DEFINES_JERRY_COMPACT_PROFILE_MINIMAL
CONFIG_ECMA_COMPACT_PROFILE
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_STRING_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_MATH_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_JSON_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN)
# Memory statistics
set(DEFINES_JERRY_MEMORY_STATS MEM_STATS)
# Valgrind
set(DEFINES_JERRY_VALGRIND JERRY_VALGRIND)
# Architecture-specific
# x86_64
set(DEFINES_JERRY_X86_64 __TARGET_HOST_x64)
# ARMv7
set(DEFINES_JERRY_ARMV7 __TARGET_HOST_ARMv7)
# Platform-specific # Platform-specific
# Linux
set(DEFINES_JERRY_LINUX __TARGET_HOST JERRY_SOURCE_BUFFER_SIZE=1048576)
# MCU # MCU
math(EXPR MEM_HEAP_AREA_SIZE_16K "16 * 1024")
set(DEFINES_JERRY_MCU CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE_16K} __TARGET_MCU)
# stm32f3 # stm32f3
set(DEFINES_JERRY_MCU_STM32F3 __TARGET_MCU_STM32F3) set(LINKER_FLAGS_COMMON_MCU_STM32F3 "-T${CMAKE_SOURCE_DIR}/third-party/stm32f3.ld")
# stm32f4 # stm32f4
set(DEFINES_JERRY_MCU_STM32F4 __TARGET_MCU_STM32F4) set(LINKER_FLAGS_COMMON_MCU_STM32F4 "-T${CMAKE_SOURCE_DIR}/third-party/stm32f4.ld")
# Debug
set(FLAGS_COMMON_DEBUG "")
# Release
set(FLAGS_COMMON_RELEASE "-Os -flto")
# Unit tests # Unit tests
set(DEFINES_UNIT_TEST set(FLAGS_UNIT_TEST "${FLAGS_COMMON_RELEASE}")
${DEFINES_JERRY_FULL_PROFILE}
${DEFINES_JERRY_DEBUG}
${DEFINES_JERRY_VALGRIND})
# Include directories # Include directories
set(INCLUDE_CORE set(INCLUDE_CORE
src ${CMAKE_SOURCE_DIR}/src)
src/mem
src/vm
src/ecma/builtin-objects
src/ecma/base
src/ecma/operations
src/parser/collections
src/parser/js
src/jrt
jerry-libc
plugins/lib-device-stm)
# Platform-specific
# Linux
set(INCLUDE_CORE_LINUX
jerry-libc/target/linux)
# MCU
# STM32F3
set(INCLUDE_CORE_MCU_STM32F3
jerry-libc/target/stm32f3)
# STM32F4
set(INCLUDE_CORE_MCU_STM32F4
jerry-libc/target/stm32f4)
# Third-party
# Valgrind
set(INCLUDE_THIRD_PARTY_VALGRIND third-party/valgrind)
# Platform-specific
# MCU
# STM32F3
set(INCLUDE_THIRD_PARTY_MCU_STM32F3
third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Include
third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/inc
third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Include
third-party/STM32F3-Discovery_FW_V1.1.0)
# STM32F4
set(INCLUDE_THIRD_PARTY_MCU_STM32F4
third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Include
third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/inc
third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/Include
third-party/STM32F4-Discovery_FW_V1.1.0)
# Unit tests
set(INCLUDE_UNIT_TEST
tests/unit
${INCLUDE_THIRD_PARTY_VALGRIND})
# Sources # Sources
# Jerry core
file(GLOB SOURCE_CORE_MEM src/mem/*.cpp)
file(GLOB SOURCE_CORE_VM src/vm/*.cpp)
file(GLOB SOURCE_CORE_ECMA_BUILTINS src/ecma/builtin-objects/*.cpp)
file(GLOB SOURCE_CORE_ECMA_BASE src/ecma/base/*.cpp)
file(GLOB SOURCE_CORE_ECMA_OPERATIONS src/ecma/operations/*.cpp)
file(GLOB SOURCE_CORE_PARSER_COLLECTIONS src/parser/collections/*.cpp)
file(GLOB SOURCE_CORE_PARSER_JS src/parser/js/*.cpp)
file(GLOB SOURCE_CORE_JRT src/jrt/*.cpp)
# libc
file(GLOB SOURCE_JERRY_LIBC jerry-libc/*.cpp)
# Plugins
file(GLOB SOURCE_PLUGINS_LIB_DEVICE_STM plugins/lib-device-stm/*.cpp)
set(SOURCE_CORE
src/jerry.cpp
${SOURCE_CORE_MEM}
${SOURCE_CORE_VM}
${SOURCE_CORE_ECMA_BUILTINS}
${SOURCE_CORE_ECMA_BASE}
${SOURCE_CORE_ECMA_OPERATIONS}
${SOURCE_CORE_PARSER_COLLECTIONS}
${SOURCE_CORE_PARSER_JS}
${SOURCE_CORE_JRT}
${SOURCE_JERRY_LIBC}
${SOURCE_PLUGINS_LIB_DEVICE_STM})
# Platform-specific # Platform-specific
# Linux
# Jerry standalone # Jerry standalone
# Linux
set(SOURCE_JERRY_STANDALONE_MAIN_LINUX src/main_linux.cpp) set(SOURCE_JERRY_STANDALONE_MAIN_LINUX src/main_linux.cpp)
file(GLOB SOURCE_JERRY_LIBC_LINUX jerry-libc/target/linux/*.cpp jerry-libc/target/linux/*.S)
# MCU
# Jerry standalone
set(SOURCE_JERRY_STANDALONE_MAIN_MCU src/main_mcu.cpp)
# stm32f3
file(GLOB SOURCE_JERRY_LIBC_STM32F3 jerry-libc/target/stm32f3/*.cpp jerry-libc/target/stm32f3/*.S)
# stm32f4
file(GLOB SOURCE_JERRY_LIBC_STM32F4 jerry-libc/target/stm32f4/*.cpp jerry-libc/target/stm32f4/*.S)
# Third-party
# Platform-specific
# MCU # MCU
# stm32f3 # stm32f3
set(SOURCE_THIRD_PARTY_MCU_STM32F3 set(SOURCE_JERRY_STANDALONE_MAIN_MCU_STM32F3 src/main_mcu.cpp)
third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/gcc_ride7/startup_stm32f30x.s
third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/system_stm32f30x.c
third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_tim.c
third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_gpio.c
third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_rcc.c)
# stm32f4 # stm32f4
set(SOURCE_THIRD_PARTY_MCU_STM32F4 set(SOURCE_JERRY_STANDALONE_MAIN_MCU_STM32F4 src/main_mcu.cpp)
third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f4xx.s
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/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c
third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c)
# Unit tests main modules # Unit tests main modules
file(GLOB SOURCE_UNIT_TEST_MAIN_MODULES tests/unit/*.cpp) file(GLOB SOURCE_UNIT_TEST_MAIN_MODULES tests/unit/*.cpp)
@ -366,68 +198,82 @@ project (Jerry CXX C ASM)
# Imported libraries # Imported libraries
# libc # libc
add_library(imported_libc SHARED IMPORTED) add_library(imported_libc SHARED IMPORTED)
execute_process(COMMAND ${CMAKE_C_COMPILER} -print-file-name=libc.so execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_COMMON_ARCH} -print-file-name=libc.so
OUTPUT_VARIABLE IMPORTED_LIBC_LOCATION OUTPUT_VARIABLE IMPORTED_LIBC_LOCATION
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
set_property(TARGET imported_libc set_property(TARGET imported_libc
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBC_LOCATION}) PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBC_LOCATION})
# libgcc # libgcc
add_library(imported_libgcc STATIC IMPORTED) add_library(imported_libgcc STATIC IMPORTED)
execute_process(COMMAND ${CMAKE_C_COMPILER} -print-file-name=libgcc.a execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_COMMON_ARCH} -print-file-name=libgcc.a
OUTPUT_VARIABLE IMPORTED_LIBGCC_LOCATION OUTPUT_VARIABLE IMPORTED_LIBGCC_LOCATION
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
set_property(TARGET imported_libgcc set_property(TARGET imported_libgcc
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBGCC_LOCATION}) PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBGCC_LOCATION})
# Architecture-specific configuration
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(CXX_FLAGS_COMMON_ARCH ${CXX_FLAGS_JERRY_X86_64})
set(LINKER_FLAGS_JERRY "${LINKER_FLAGS_JERRY} ${LINKER_FLAGS_JERRY_X86_64}")
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_X86_64})
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
set(CXX_FLAGS_COMMON_ARCH ${CXX_FLAGS_JERRY_ARMV7})
set(LINKER_FLAGS_JERRY "${LINKER_FLAGS_JERRY} ${LINKER_FLAGS_JERRY_ARMV7}")
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_ARMV7})
else()
message(FATAL_ERROR "Unsupported machine architecture")
endif()
# Platform-specific configuration # Platform-specific configuration
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(MODIFIERS_LISTS ${MODIFIERS_LISTS_${PLATFORM_EXT}})
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_LINUX}) set(LINKER_FLAGS_COMMON "${LINKER_FLAGS_COMMON} ${LINKER_FLAGS_COMMON_${PLATFORM_EXT}}")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Generic") set(SOURCE_JERRY_STANDALONE_MAIN ${SOURCE_JERRY_STANDALONE_MAIN_${PLATFORM_EXT}})
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_MCU})
else() # Component targets
message(FATAL_ERROR "Platform is not supported") # Jerry's Core
endif() add_subdirectory(src)
# Jerry's libc
add_subdirectory(jerry-libc)
# Plugins
add_subdirectory(plugins)
# Targets declaration # Targets declaration
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") function(declare_targets_for_build_mode BUILD_MODE)
function(declare_targets_for_build_mode BUILD_MODE MODIFIERS_LISTS) string(TOLOWER "${PLATFORM_EXT}" PLATFORM_L)
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.linux) set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.${PLATFORM_L})
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_${BUILD_MODE}}) set(LIBC_TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.jerry-libc.${PLATFORM_L})
set(LINKER_FLAGS_JERRY "${LINKER_FLAGS_JERRY} ${LINKER_FLAGS_COMMON_${BUILD_MODE}}")
function(declare_target_with_modifiers ) # modifiers are passed in ARGN implicit argument function(declare_target_with_modifiers ) # modifiers are passed in ARGN implicit argument
foreach(MODIFIER ${ARGN}) set(CORE_TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}})
foreach(MODIFIER ${ARGN}) # FIXME
set(TARGET_NAME ${TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}}) set(TARGET_NAME ${TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}})
set(DEFINES_JERRY ${DEFINES_JERRY} ${${MODIFIER_DEFINES_${MODIFIER}}})
set(INCLUDE_CORE ${INCLUDE_CORE} ${${MODIFIER_INCLUDE_${MODIFIER}}}) set(LIBC_TARGET_NAME ${LIBC_TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}})
set(CORE_TARGET_NAME ${CORE_TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}})
endforeach() endforeach()
set(CORE_TARGET_NAME ${CORE_TARGET_NAME}.jerry-core)
set(LIBC_TARGET_NAME ${LIBC_TARGET_NAME}.lib)
add_library(${TARGET_NAME}.lib STATIC ${SOURCE_CORE} ${SOURCE_JERRY_LIBC_LINUX}) set(DEFINES_JERRY )
target_compile_options(${TARGET_NAME}.lib PRIVATE ${CXX_FLAGS_JERRY} ${CXX_FLAGS_COMMON_ARCH} ${CXX_FLAGS_COMMON_${BUILD_MODE}})
target_compile_definitions(${TARGET_NAME}.lib PRIVATE ${DEFINES_JERRY})
target_include_directories(${TARGET_NAME}.lib PRIVATE ${INCLUDE_CORE})
add_executable(${TARGET_NAME} ${SOURCE_JERRY_STANDALONE_MAIN_LINUX}) if("${PLATFORM}" STREQUAL "MCU")
target_compile_options(${TARGET_NAME} PRIVATE ${CXX_FLAGS_JERRY} ${CXX_FLAGS_COMMON_ARCH} ${CXX_FLAGS_COMMON_${BUILD_MODE}}) set(MCU_SCRIPT_GENERATED_HEADER ${MCU_SCRIPT_GENERATED_HEADER}.${TARGET_NAME})
set_property(TARGET ${TARGET_NAME} PROPERTY LINK_FLAGS "${LINKER_FLAGS_JERRY} ${LINKER_FLAGS_STATIC}") add_custom_command(OUTPUT ${MCU_SCRIPT_GENERATED_HEADER}
COMMAND ${CMAKE_SOURCE_DIR}/tools/generator.sh "${CMAKE_SOURCE_DIR}/${MCU_SCRIPT_FILE}" ${MCU_SCRIPT_GENERATED_HEADER}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_custom_target(mcu_header_with_script_to_run.${TARGET_NAME} DEPENDS ${MCU_SCRIPT_GENERATED_HEADER})
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_MCU_SCRIPT_HEADER="${MCU_SCRIPT_GENERATED_HEADER}")
endif()
add_executable(${TARGET_NAME} ${SOURCE_JERRY_STANDALONE_MAIN})
set_property(TARGET ${TARGET_NAME}
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}}")
set_property(TARGET ${TARGET_NAME}
PROPERTY LINK_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}} ${LINKER_FLAGS_COMMON} ${LINKER_FLAGS_STATIC}")
target_compile_definitions(${TARGET_NAME} PRIVATE ${DEFINES_JERRY}) target_compile_definitions(${TARGET_NAME} PRIVATE ${DEFINES_JERRY})
target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE}) target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE})
target_link_libraries(${TARGET_NAME} ${TARGET_NAME}.lib imported_libgcc) target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} imported_libgcc)
if(${STRIP_LINUX_RELEASE_BINARY} STREQUAL "ON") if("${PLATFORM}" STREQUAL "MCU")
add_dependencies(${TARGET_NAME} mcu_header_with_script_to_run.${TARGET_NAME})
add_custom_target(${TARGET_NAME}.bin
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${TARGET_NAME}> $<TARGET_FILE:${TARGET_NAME}>.bin
DEPENDS ${TARGET_NAME})
add_custom_target(${TARGET_NAME}.flash
COMMAND st-flash write $<TARGET_FILE:${TARGET_NAME}>.bin 0x08000000
DEPENDS ${TARGET_NAME}.bin)
endif()
if(${STRIP_RELEASE_BINARY} STREQUAL "ON")
add_custom_command(TARGET ${TARGET_NAME} add_custom_command(TARGET ${TARGET_NAME}
POST_BUILD POST_BUILD
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:${TARGET_NAME}>) COMMAND ${CMAKE_STRIP} $<TARGET_FILE:${TARGET_NAME}>)
@ -441,130 +287,31 @@ project (Jerry CXX C ASM)
endforeach() endforeach()
endfunction() endfunction()
set(DEBUG_AND_RELEASE_MODIFIERS_LISTS foreach(BUILD_MODE ${BUILD_MODES})
"FULL_PROFILE"
"COMPACT_PROFILE"
"COMPACT_PROFILE_MINIMAL"
"FULL_PROFILE MEMORY_STATISTICS"
"COMPACT_PROFILE_MINIMAL MEMORY_STATISTICS"
"FULL_PROFILE VALGRIND"
"COMPACT_PROFILE_MINIMAL VALGRIND"
"COMPACT_PROFILE VALGRIND")
declare_targets_for_build_mode(DEBUG "${DEBUG_AND_RELEASE_MODIFIERS_LISTS}")
declare_targets_for_build_mode(RELEASE "${DEBUG_AND_RELEASE_MODIFIERS_LISTS}")
# Unit tests declaration
add_custom_target(unittests)
add_library(unit_tests.lib STATIC ${SOURCE_CORE} ${SOURCE_JERRY_LIBC_LINUX})
target_compile_options(unit_tests.lib PRIVATE ${CXX_FLAGS_JERRY} ${CXX_FLAGS_COMMON_ARCH} ${CXX_FLAGS_UNIT_TEST})
target_compile_definitions(unit_tests.lib PRIVATE ${DEFINES_JERRY} ${DEFINES_UNIT_TEST})
target_include_directories(unit_tests.lib PRIVATE ${INCLUDE_CORE} ${INCLUDE_UNIT_TEST})
foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE)
set(TARGET_NAME unit_${TARGET_NAME})
add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN})
target_compile_options(${TARGET_NAME} PRIVATE
${CXX_FLAGS_JERRY}
${CXX_FLAGS_COMMON_ARCH}
${CXX_FLAGS_UNIT_TEST})
set_property(TARGET ${TARGET_NAME} PROPERTY LINK_FLAGS "${LINKER_FLAGS_JERRY} ${LINKER_FLAGS_UNIT_TEST}")
target_compile_definitions(${TARGET_NAME} PRIVATE ${DEFINES_JERRY} ${DEFINES_UNIT_TEST})
target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE} ${INCLUDE_UNIT_TEST})
target_link_libraries(${TARGET_NAME} unit_tests.lib imported_libc imported_libgcc)
add_dependencies(unittests ${TARGET_NAME})
endforeach()
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Generic")
function(declare_target_for_platform PLATFORM) # build modes are passed in ARGN
string(TOLOWER ${PLATFORM} PLATFORM_L)
set(TARGET_NAME ${PLATFORM_L})
set(BUILD_MODES_FOR_PLATFORM ${ARGN})
function(declare_targets_for_build_mode BUILD_MODE)
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.${TARGET_NAME})
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_${BUILD_MODE}})
set(LINKER_FLAGS_JERRY "${LINKER_FLAGS_JERRY} ${LINKER_FLAGS_COMMON_${BUILD_MODE}}")
function(declare_target_with_modifiers ) # modifiers are passed in ARGN
foreach(MODIFIER ${ARGN})
set(TARGET_NAME ${TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}})
set(DEFINES_JERRY ${DEFINES_JERRY} ${${MODIFIER_DEFINES_${MODIFIER}}})
set(INCLUDE_CORE ${INCLUDE_CORE} ${${MODIFIER_INCLUDE_${MODIFIER}}})
endforeach()
set(MCU_SCRIPT_GENERATED_HEADER ${MCU_SCRIPT_GENERATED_HEADER}.${TARGET_NAME})
add_custom_command(OUTPUT ${MCU_SCRIPT_GENERATED_HEADER}
COMMAND ${CMAKE_SOURCE_DIR}/tools/generator.sh "${CMAKE_SOURCE_DIR}/${MCU_SCRIPT_FILE}" ${MCU_SCRIPT_GENERATED_HEADER}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_custom_target(mcu_header_with_script_to_run.${TARGET_NAME} DEPENDS ${MCU_SCRIPT_GENERATED_HEADER})
set(DEFINES_JERRY_MCU_SCRIPT JERRY_MCU_SCRIPT_HEADER="${MCU_SCRIPT_GENERATED_HEADER}")
# Jerry library
add_library(${TARGET_NAME}.jerry.lib STATIC ${SOURCE_CORE} ${SOURCE_JERRY_LIBC_${PLATFORM}})
target_compile_options(${TARGET_NAME}.jerry.lib PRIVATE
${CXX_FLAGS_JERRY}
${CXX_FLAGS_COMMON_${BUILD_MODE}}
${CXX_FLAGS_COMMON_ARCH}
${CXX_FLAGS_COMMON_MCU_${PLATFORM}})
target_compile_definitions(${TARGET_NAME}.jerry.lib PRIVATE
${DEFINES_JERRY}
${DEFINES_JERRY_MCU_${PLATFORM}})
target_include_directories(${TARGET_NAME}.jerry.lib PRIVATE
${INCLUDE_CORE}
${INCLUDE_CORE_MCU_${PLATFORM}}
${INCLUDE_THIRD_PARTY_MCU_${PLATFORM}})
# Third-party MCU library
add_library(${TARGET_NAME}.third_party.lib STATIC
${SOURCE_THIRD_PARTY_MCU_${PLATFORM}})
target_compile_options(${TARGET_NAME}.third_party.lib PRIVATE
${CXX_FLAGS_COMMON_${BUILD_MODE}}
${CXX_FLAGS_COMMON_ARCH}
${CXX_FLAGS_COMMON_MCU_${PLATFORM}})
target_include_directories(${TARGET_NAME}.third_party.lib PRIVATE
${INCLUDE_THIRD_PARTY_MCU_${PLATFORM}})
add_executable(${TARGET_NAME} ${SOURCE_JERRY_STANDALONE_MAIN_MCU})
target_compile_options(${TARGET_NAME} PRIVATE
${CXX_FLAGS_JERRY}
${CXX_FLAGS_COMMON_${BUILD_MODE}}
${CXX_FLAGS_COMMON_ARCH}
${CXX_FLAGS_COMMON_MCU_${PLATFORM}})
set_property(TARGET ${TARGET_NAME} PROPERTY LINK_FLAGS
"${LINKER_FLAGS_JERRY} ${LINKER_FLAGS_STATIC} ${LINKER_FLAGS_JERRY_MCU_${PLATFORM}}")
target_compile_definitions(${TARGET_NAME} PRIVATE
${DEFINES_JERRY}
${DEFINES_JERRY_MCU_${PLATFORM}}
${DEFINES_JERRY_MCU_SCRIPT})
target_include_directories(${TARGET_NAME} PRIVATE
${INCLUDE_CORE}
${INCLUDE_CORE_MCU_${PLATFORM}}
${INCLUDE_THIRD_PARTY_MCU_${PLATFORM}})
target_link_libraries(${TARGET_NAME} ${TARGET_NAME}.jerry.lib ${TARGET_NAME}.third_party.lib imported_libgcc)
add_dependencies(${TARGET_NAME} mcu_header_with_script_to_run.${TARGET_NAME})
add_custom_target(${TARGET_NAME}.bin
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${TARGET_NAME}> $<TARGET_FILE:${TARGET_NAME}>.bin
DEPENDS ${TARGET_NAME})
add_custom_target(${TARGET_NAME}.flash
COMMAND st-flash write $<TARGET_FILE:${TARGET_NAME}>.bin 0x08000000
DEPENDS ${TARGET_NAME}.bin)
endfunction()
declare_target_with_modifiers(COMPACT_PROFILE)
declare_target_with_modifiers(COMPACT_PROFILE_MINIMAL)
endfunction()
foreach(BUILD_MODE ${BUILD_MODES_FOR_PLATFORM})
declare_targets_for_build_mode(${BUILD_MODE}) declare_targets_for_build_mode(${BUILD_MODE})
endforeach() endforeach()
endfunction()
declare_target_for_platform(STM32F3 RELEASE) # Unit tests declaration
declare_target_for_platform(STM32F4 DEBUG RELEASE) # --- add_custom_target(unittests)
else() # ---
message(FATAL_ERROR "Platform is not supported") # --- add_library(unit_tests.lib STATIC ${SOURCE_CORE} ${SOURCE_JERRY_LIBC_LINUX})
endif() # --- target_compile_options(unit_tests.lib PRIVATE ${CXX_FLAGS_JERRY} ${CXX_FLAGS_COMMON_ARCH} ${CXX_FLAGS_UNIT_TEST})
# --- target_compile_definitions(unit_tests.lib PRIVATE ${DEFINES_JERRY} ${DEFINES_UNIT_TEST})
# --- target_include_directories(unit_tests.lib PRIVATE ${INCLUDE_CORE} ${INCLUDE_UNIT_TEST})
# ---
# --- foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
# --- get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE)
# --- set(TARGET_NAME unit_${TARGET_NAME})
# ---
# --- add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN})
# --- target_compile_options(${TARGET_NAME} PRIVATE
# --- ${CXX_FLAGS_JERRY}
# --- ${CXX_FLAGS_COMMON_ARCH}
# --- ${CXX_FLAGS_UNIT_TEST})
# --- set_property(TARGET ${TARGET_NAME} PROPERTY LINK_FLAGS "${LINKER_FLAGS_COMMON} ${LINKER_FLAGS_UNIT_TEST}")
# --- target_compile_definitions(${TARGET_NAME} PRIVATE ${DEFINES_JERRY} ${DEFINES_UNIT_TEST})
# --- target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE} ${INCLUDE_UNIT_TEST})
# --- target_link_libraries(${TARGET_NAME} unit_tests.lib imported_libc imported_libgcc)
# ---
# --- add_dependencies(unittests ${TARGET_NAME})
# --- endforeach()

View File

@ -39,24 +39,29 @@
export TARGET_DEBUG_MODES = debug export TARGET_DEBUG_MODES = debug
export TARGET_RELEASE_MODES = release export TARGET_RELEASE_MODES = release
export TARGET_PC_SYSTEMS = linux export TARGET_PC_SYSTEMS = linux
export TARGET_MCU_SYSTEMS = $(addprefix stm32f,3 4)
export TARGET_PC_MODS = valgrind cp cp_minimal mem_stats cp-valgrind export TARGET_PC_MODS = cp cp_minimal mem_stats
export TARGET_MCU_MODS = cp cp_minimal export TARGET_MCU_MODS = cp cp_minimal
export TARGET_PC_SYSTEMS_MODS = $(TARGET_PC_SYSTEMS) \ export TARGET_PC_SYSTEMS_MODS = $(TARGET_PC_SYSTEMS) \
$(foreach __MOD,$(TARGET_PC_MODS),$(foreach __SYSTEM,$(TARGET_PC_SYSTEMS),$(__SYSTEM)-$(__MOD))) $(foreach __MOD,$(TARGET_PC_MODS),$(foreach __SYSTEM,$(TARGET_PC_SYSTEMS),$(__SYSTEM)-$(__MOD)))
export TARGET_MCU_SYSTEMS_MODS = $(foreach __MOD,$(TARGET_MCU_MODS),$(foreach __SYSTEM,$(TARGET_MCU_SYSTEMS),$(__SYSTEM)-$(__MOD))) export TARGET_STM32F3_MODS = $(foreach __MOD,$(TARGET_MCU_MODS),mcu_stm32f3-$(__MOD))
export TARGET_STM32F4_MODS = $(foreach __MOD,$(TARGET_MCU_MODS),mcu_stm32f4-$(__MOD))
# Target list # Target list
export JERRY_LINUX_TARGETS = $(foreach __MODE,$(TARGET_DEBUG_MODES),$(foreach __SYSTEM,$(TARGET_PC_SYSTEMS_MODS),$(__MODE).$(__SYSTEM))) \ export JERRY_LINUX_TARGETS = $(foreach __MODE,$(TARGET_DEBUG_MODES),$(foreach __SYSTEM,$(TARGET_PC_SYSTEMS_MODS),$(__MODE).$(__SYSTEM))) \
$(foreach __MODE,$(TARGET_RELEASE_MODES),$(foreach __SYSTEM,$(TARGET_PC_SYSTEMS_MODS),$(__MODE).$(__SYSTEM))) $(foreach __MODE,$(TARGET_RELEASE_MODES),$(foreach __SYSTEM,$(TARGET_PC_SYSTEMS_MODS),$(__MODE).$(__SYSTEM)))
export JERRY_MCU_TARGETS = $(foreach __MODE,$(TARGET_RELEASE_MODES),$(foreach __SYSTEM,$(TARGET_MCU_SYSTEMS_MODS),$(__MODE).$(__SYSTEM)))
export JERRY_TARGETS = $(JERRY_LINUX_TARGETS) $(JERRY_MCU_TARGETS)
export CHECK_TARGETS = $(foreach __TARGET,$(JERRY_TARGETS),$(__TARGET).check) export JERRY_STM32F3_TARGETS = $(foreach __MODE,$(TARGET_RELEASE_MODES),$(foreach __SYSTEM,$(TARGET_STM32F3_MODS),$(__MODE).$(__SYSTEM)))
export FLASH_TARGETS = $(foreach __TARGET,$(foreach __MODE,$(TARGET_RELEASE_MODES),$(foreach __SYSTEM,$(TARGET_MCU_SYSTEMS_MODS),$(__MODE).$(__SYSTEM))),$(__TARGET).flash)
export JERRY_STM32F4_TARGETS = $(foreach __MODE,$(TARGET_DEBUG_MODES),$(foreach __SYSTEM,$(TARGET_STM32F4_MODS),$(__MODE).$(__SYSTEM))) \
$(foreach __MODE,$(TARGET_RELEASE_MODES),$(foreach __SYSTEM,$(TARGET_STM32F4_MODS),$(__MODE).$(__SYSTEM)))
export JERRY_TARGETS = $(JERRY_LINUX_TARGETS) $(JERRY_STM32F3_TARGETS) $(JERRY_STM32F4_TARGETS)
export CHECK_TARGETS = $(foreach __TARGET,$(JERRY_LINUX_TARGETS),$(__TARGET).check)
export FLASH_TARGETS = $(foreach __TARGET,$(JERRY_STM32F3_TARGETS) $(JERRY_STM32F4_TARGETS),$(__TARGET).flash)
export OUT_DIR = ./build/bin export OUT_DIR = ./build/bin
export BUILD_DIR = ./build/obj export BUILD_DIR = ./build/obj
@ -66,12 +71,14 @@ export SHELL=/bin/bash
all: precommit all: precommit
$(BUILD_DIR)/native: $(BUILD_DIR)/native:
@ mkdir -p $(BUILD_DIR)/native @ arch=`uname -p`; if [ "$$arch" == "armv7l" ]; then readelf -A /proc/self/exe | grep Tag_ABI_VFP_args && arch=$$arch"-hf" || arch=$$arch"-el"; fi; \
@ cd $(BUILD_DIR)/native; cmake ../../.. &>cmake.log mkdir -p $(BUILD_DIR)/native && cd $(BUILD_DIR)/native && cmake -DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_linux_$$arch.cmake ../../.. &>cmake.log
$(BUILD_DIR)/mcu: $(BUILD_DIR)/stm32f3:
@ mkdir -p $(BUILD_DIR)/mcu @ mkdir -p $(BUILD_DIR)/stm32f3 && cd $(BUILD_DIR)/stm32f3 && cmake -DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_mcu_stm32f3.cmake ../../.. &>cmake.log
@ cd $(BUILD_DIR)/mcu; cmake -DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_mcu_armv7l.cmake ../../.. &>cmake.log
$(BUILD_DIR)/stm32f4:
@ mkdir -p $(BUILD_DIR)/stm32f4 && cd $(BUILD_DIR)/stm32f4 && cmake -DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_mcu_stm32f4.cmake ../../.. &>cmake.log
$(JERRY_LINUX_TARGETS): $(BUILD_DIR)/native $(JERRY_LINUX_TARGETS): $(BUILD_DIR)/native
@ mkdir -p $(OUT_DIR)/$@ @ mkdir -p $(OUT_DIR)/$@
@ -83,20 +90,27 @@ unittests: $(BUILD_DIR)/native
@ $(MAKE) -C $(BUILD_DIR)/native VERBOSE=1 $@ &>$(OUT_DIR)/$@/make.log @ $(MAKE) -C $(BUILD_DIR)/native VERBOSE=1 $@ &>$(OUT_DIR)/$@/make.log
@ cp $(BUILD_DIR)/native/unit_test_* $(OUT_DIR)/$@ @ cp $(BUILD_DIR)/native/unit_test_* $(OUT_DIR)/$@
$(JERRY_MCU_TARGETS): $(BUILD_DIR)/mcu $(JERRY_STM32F3_TARGETS): $(BUILD_DIR)/stm32f3
@ mkdir -p $(OUT_DIR)/$@ @ mkdir -p $(OUT_DIR)/$@
@ $(MAKE) -C $(BUILD_DIR)/mcu VERBOSE=1 $@.bin &>$(OUT_DIR)/$@/make.log @ $(MAKE) -C $(BUILD_DIR)/stm32f3 VERBOSE=1 $@.bin &>$(OUT_DIR)/$@/make.log
@ cp $(BUILD_DIR)/mcu/$@ $(OUT_DIR)/$@/jerry @ cp $(BUILD_DIR)/stm32f3/$@ $(OUT_DIR)/$@/jerry
@ cp $(BUILD_DIR)/mcu/$@.bin $(OUT_DIR)/$@/jerry.bin @ cp $(BUILD_DIR)/stm32f3/$@.bin $(OUT_DIR)/$@/jerry.bin
build: $(JERRY_TARGETS) unittests $(JERRY_STM32F4_TARGETS): $(BUILD_DIR)/stm32f4
@ mkdir -p $(OUT_DIR)/$@
@ $(MAKE) -C $(BUILD_DIR)/stm32f4 VERBOSE=1 $@.bin &>$(OUT_DIR)/$@/make.log
@ cp $(BUILD_DIR)/stm32f4/$@ $(OUT_DIR)/$@/jerry
@ cp $(BUILD_DIR)/stm32f4/$@.bin $(OUT_DIR)/$@/jerry.bin
build: $(JERRY_TARGETS) # unittests
$(FLASH_TARGETS): $(BUILD_DIR)/mcu $(FLASH_TARGETS): $(BUILD_DIR)/mcu
@$(MAKE) -C $(BUILD_DIR)/mcu VERBOSE=1 $@ 1>/dev/null @$(MAKE) -C $(BUILD_DIR)/mcu VERBOSE=1 $@ 1>/dev/null
PRECOMMIT_CHECK_TARGETS_NO_VALGRIND_LIST= debug.linux.check \ PRECOMMIT_CHECK_TARGETS_NO_VALGRIND_LIST= debug.linux.check \
release.linux.check release.linux.check
PRECOMMIT_CHECK_TARGETS_VALGRIND_LIST= debug.linux-valgrind.check \
PRECOMMIT_CHECK_TARGETS_VALGRIND_LIST= #debug.linux-valgrind.check \
release.linux-valgrind.check \ release.linux-valgrind.check \
release.linux-cp-valgrind.check release.linux-cp-valgrind.check
@ -113,9 +127,10 @@ precommit: clean
@ echo -e "\nBuilding...\n\n" @ echo -e "\nBuilding...\n\n"
@ $(MAKE) build @ $(MAKE) build
@ echo -e "\n================ Build completed successfully. Running precommit tests ================\n" @ echo -e "\n================ Build completed successfully. Running precommit tests ================\n"
@ echo -e "All targets were built successfully. Starting unit tests' run.\n" @ #echo -e "All targets were built successfully. Starting unit tests' run.\n"
@ $(MAKE) unittests_run TESTS_OPTS="--silent" @ #$(MAKE) unittests_run TESTS_OPTS="--silent"
@ echo -e "Unit tests completed successfully. Starting parse-only testing.\n" @ #echo -e "Unit tests completed successfully. Starting parse-only testing.\n"
@ #echo -e "All targets were built successfully. Starting parse-only testing.\n"
@ # Parse-only testing @ # Parse-only testing
@ for path in "./tests/jerry" "./tests/benchmarks/jerry"; \ @ for path in "./tests/jerry" "./tests/benchmarks/jerry"; \
do \ do \
@ -166,8 +181,8 @@ precommit: clean
done done
@ echo -e "Full testing completed successfully\n\n================\n\n" @ echo -e "Full testing completed successfully\n\n================\n\n"
unittests_run: unittests #unittests_run: unittests
@$(MAKE) -s -f Makefile.mk TARGET=$@ $@ # @$(MAKE) -s -f Makefile.mk TARGET=$@ $@
clean: clean:
@ rm -rf $(BUILD_DIR) $(OUT_DIR) @ rm -rf $(BUILD_DIR) $(OUT_DIR)

View File

@ -17,3 +17,5 @@ set(CMAKE_SYSTEM_PROCESSOR armv7l)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb)

View File

@ -17,3 +17,5 @@ set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER x86_64-linux-gnu-gcc) set(CMAKE_C_COMPILER x86_64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER x86_64-linux-gnu-g++) set(CMAKE_CXX_COMPILER x86_64-linux-gnu-g++)
set(FLAGS_COMMON_ARCH -ffixed-rbp)

View File

@ -14,8 +14,11 @@
include(CMakeForceCompiler) include(CMakeForceCompiler)
set(CMAKE_SYSTEM_NAME Generic) set(CMAKE_SYSTEM_NAME MCU)
set(CMAKE_SYSTEM_PROCESSOR armv7l) set(CMAKE_SYSTEM_PROCESSOR armv7l)
set(CMAKE_SYSTEM_VERSION STM32F3)
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)
CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU) CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU) CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)

View File

@ -0,0 +1,24 @@
# 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.
include(CMakeForceCompiler)
set(CMAKE_SYSTEM_NAME MCU)
set(CMAKE_SYSTEM_PROCESSOR armv7l)
set(CMAKE_SYSTEM_VERSION STM32F4)
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)
CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)

151
jerry-libc/CMakeLists.txt Normal file
View File

@ -0,0 +1,151 @@
# 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.
cmake_minimum_required (VERSION 2.8.12)
project (Jerry_LibC C ASM)
# Compiler / linker flags
set(COMPILE_FLAGS_LIBC "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY}")
# Definitions
set(DEFINES_LIBC )
# Debug
set(DEFINES_LIBC_DEBUG )
# Release
set(DEFINES_LIBC_RELEASE LIBC_NDEBUG)
# Architecture-specific
# x86_64
set(DEFINES_LIBC_X86_64 __TARGET_HOST_x64)
# ARMv7
set(DEFINES_LIBC_ARMV7 __TARGET_HOST_ARMv7)
# Platform-specific
# Linux
set(DEFINES_LIBC_LINUX __TARGET_HOST)
# MCU
set(DEFINES_LIBC_MCU __TARGET_MCU)
# stm32f3
set(DEFINES_LIBC_MCU_STM32F3 __TARGET_MCU_STM32F3)
# stm32f4
set(DEFINES_LIBC_MCU_STM32F4 __TARGET_MCU_STM32F4)
# Include directories
set(INCLUDE_LIBC .)
# Platform-specific
# Linux
set(INCLUDE_LIBC_LINUX target/linux)
# MCU
# STM32F3
set(INCLUDE_LIBC_MCU_STM32F3 target/stm32f3)
# STM32F4
set(INCLUDE_LIBC_MCU_STM32F4 target/stm32f4)
# Third-party
# Platform-specific
# Linux
set(INCLUDE_THIRD_PARTY_LINUX )
# MCU
# STM32F3
set(INCLUDE_THIRD_PARTY_MCU_STM32F3
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Include
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Include)
# STM32F4
set(INCLUDE_THIRD_PARTY_MCU_STM32F4
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Include
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/Include)
# Sources
file(GLOB SOURCE_LIBC *.c)
# Platform-specific
# Linux
file(GLOB SOURCE_LIBC_LINUX target/linux/*.c target/linux/*.S)
# MCU
# stm32f3
file(GLOB SOURCE_LIBC_MCU_STM32F3 target/mcu-stubs/*.c target/mcu-stubs/*.S)
# stm32f4
file(GLOB SOURCE_LIBC_MCU_STM32F4 target/mcu-stubs/*.c target/mcu-stubs/*.S)
# Third-party
# Platform-specific
# MCU
# stm32f3
set(SOURCE_THIRD_PARTY_MCU_STM32F3
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/system_stm32f30x.c
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/gcc_ride7/startup_stm32f30x.s)
# stm32f4
set(SOURCE_THIRD_PARTY_MCU_STM32F4
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f4xx.s)
# Architecture-specific configuration
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_X86_64})
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_ARMV7})
else()
message(FATAL_ERROR "Unsupported machine architecture")
endif()
# Platform-specific configuration
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_${PLATFORM}})
# Targets declaration
string(TOLOWER ${PLATFORM_EXT} PLATFORM_L)
set(TARGET_NAME jerry-libc.${PLATFORM_L})
function(declare_targets_for_build_mode BUILD_MODE)
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.${TARGET_NAME})
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_${BUILD_MODE}})
set(INCLUDE_LIBC ${INCLUDE_LIBC} ${INCLUDE_LIBC_${PLATFORM_EXT}})
function(declare_target_with_modifiers ) # modifiers are passed in ARGN implicit argument
foreach(MODIFIER ${ARGN})
set(TARGET_NAME ${TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}})
endforeach()
# Jerry
add_library(${TARGET_NAME}.lib STATIC ${SOURCE_LIBC} ${SOURCE_LIBC_${PLATFORM_EXT}})
set_property(TARGET ${TARGET_NAME}.lib
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_LIBC} ${FLAGS_COMMON_${BUILD_MODE}}")
target_compile_definitions(${TARGET_NAME}.lib PRIVATE ${DEFINES_LIBC})
target_include_directories(${TARGET_NAME}.lib PRIVATE ${INCLUDE_LIBC})
# Third-party MCU library
if(DEFINED SOURCE_THIRD_PARTY_${PLATFORM_EXT})
add_library(${TARGET_NAME}.third_party.lib STATIC ${SOURCE_THIRD_PARTY_${PLATFORM_EXT}})
set_property(TARGET ${TARGET_NAME}.third_party.lib
PROPERTY COMPILE_FLAGS "${FLAGS_COMMON_${BUILD_MODE}}")
target_include_directories(${TARGET_NAME}.third_party.lib PRIVATE ${INCLUDE_THIRD_PARTY_${PLATFORM_EXT}})
target_link_libraries(${TARGET_NAME}.lib ${TARGET_NAME}.third_party.lib)
endif()
endfunction()
foreach(MODIFIERS_LIST ${MODIFIERS_LISTS})
separate_arguments(MODIFIERS_LIST)
declare_target_with_modifiers(${MODIFIERS_LIST})
endforeach()
endfunction()
foreach(BUILD_MODE ${BUILD_MODES})
declare_targets_for_build_mode(${BUILD_MODE})
endforeach()

View File

@ -0,0 +1,117 @@
/* 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 DEFS_H
#define DEFS_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
/**
* Attributes
*/
#define __attr_unused___ __attribute__((unused))
#define __attr_used___ __attribute__((used))
#define __attr_noreturn___ __attribute__((noreturn))
#define __attr_noinline___ __attribute__((noinline))
/**
* Constants
*/
#define LIBC_FATAL_ERROR_EXIT_CODE (2)
/**
* Assertions
*/
extern void __attr_noreturn___
libc_fatal (const char *msg,
const char *file_name,
const char *function_name,
const int line_number);
#ifndef LIBC_NDEBUG
# define LIBC_ASSERT(x) do { if (__builtin_expect (!(x), 0)) { \
libc_fatal (#x, __FILE__, __FUNCTION__, __LINE__); } } while (0)
# define LIBC_UNREACHABLE() \
do \
{ \
libc_fatal ("Code is unreachable", __FILE__, __FUNCTION__, __LINE__); \
} while (0)
#else /* !LIBC_NDEBUG */
# define LIBC_ASSERT(x) do { if (false) { (void)(x); } } while (0)
# define LIBC_UNREACHABLE() \
do \
{ \
libc_fatal (NULL, NULL, NULL, 0); \
} while (0)
#endif /* !LIBC_NDEBUG */
/**
* Stubs declaration
*/
/**
* Unreachable stubs for routines that are never called,
* but referenced from third-party libraries.
*/
#define LIBC_UNREACHABLE_STUB_FOR(...) \
__attr_used___ __VA_ARGS__ \
{ \
LIBC_UNREACHABLE (); \
}
/**
* Libc redefinitions
*/
/* Ensuring no macro implementation of variables / functions are in effect */
#undef vfprintf
#undef fprintf
#undef printf
#undef isspace
#undef isalpha
#undef islower
#undef isupper
#undef isdigit
#undef isxdigit
#undef memset
#undef memcmp
#undef memcpy
#undef memmove
#undef strcmp
#undef strncmp
#undef strncpy
#undef strlen
#undef putchar
#undef puts
#undef exit
#undef fopen
#undef rewind
#undef fclose
#undef fseek
#undef ftell
#undef fread
#undef fwrite
#undef stdin
#undef stdout
#undef stderr
extern FILE* stdin;
extern FILE* stdout;
extern FILE* stderr;
#endif /* !DEFS_H */

View File

@ -0,0 +1,44 @@
/* 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.
*/
/**
* Jerry libc's fatal errors handlers
*/
#include <stdio.h>
#include "jerry-libc-defs.h"
/**
* Fatal error handler
*
* Arguments may be NULL. If so, they are ignored.
*/
void __attr_noreturn___
libc_fatal (const char *msg, /**< fatal error description */
const char *file_name, /**< file name */
const char *function_name, /**< function name */
const int line_number) /**< line number */
{
if (msg != NULL
&& file_name != NULL
&& function_name != NULL)
{
printf("Assertion '%s' failed at %s (%s:%u).\n",
msg, function_name, file_name, line_number);
}
exit (LIBC_FATAL_ERROR_EXIT_CODE);
} /* libc_fatal */

View File

@ -17,10 +17,11 @@
* Jerry printf implementation * Jerry printf implementation
*/ */
#include "jrt.h"
#include "jerry-libc.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "jerry-libc-defs.h"
/** /**
* printf's length type * printf's length type
@ -72,7 +73,7 @@ typedef uint8_t libc_printf_arg_flags_mask_t;
* printf helper function that outputs a char * printf helper function that outputs a char
*/ */
static void static void
libc_printf_putchar (_FILE *stream, /**< stream pointer */ libc_printf_putchar (FILE *stream, /**< stream pointer */
char character) /**< character */ char character) /**< character */
{ {
fwrite (&character, 1, sizeof (character), stream); fwrite (&character, 1, sizeof (character), stream);
@ -82,7 +83,7 @@ libc_printf_putchar (_FILE *stream, /**< stream pointer */
* printf helper function that outputs justified string * printf helper function that outputs justified string
*/ */
static void static void
libc_printf_justified_string_output (_FILE *stream, /**< stream pointer */ libc_printf_justified_string_output (FILE *stream, /**< stream pointer */
const char *string_p, /**< string */ const char *string_p, /**< string */
size_t width, /**< minimum field width */ size_t width, /**< minimum field width */
bool is_left_justify, /**< justify to left (true) or right (false) */ bool is_left_justify, /**< justify to left (true) or right (false) */
@ -130,20 +131,20 @@ libc_printf_uint_to_string (uintmax_t value, /**< integer value */
char *str_p = str_buffer_end; char *str_p = str_buffer_end;
*--str_p = '\0'; *--str_p = '\0';
JERRY_ASSERT(radix >= 2); LIBC_ASSERT(radix >= 2);
if ((radix & (radix - 1)) != 0) if ((radix & (radix - 1)) != 0)
{ {
/* /*
* Radix is not power of 2. Only 32-bit numbers are supported in this mode. * Radix is not power of 2. Only 32-bit numbers are supported in this mode.
*/ */
JERRY_ASSERT((value >> 32) == 0); LIBC_ASSERT((value >> 32) == 0);
uint32_t value_lo = (uint32_t) value; uint32_t value_lo = (uint32_t) value;
while (value_lo != 0) while (value_lo != 0)
{ {
JERRY_ASSERT (str_p != buffer_p); LIBC_ASSERT (str_p != buffer_p);
*--str_p = alphabet[ value_lo % radix ]; *--str_p = alphabet[ value_lo % radix ];
value_lo /= radix; value_lo /= radix;
@ -156,7 +157,7 @@ libc_printf_uint_to_string (uintmax_t value, /**< integer value */
{ {
shift++; shift++;
JERRY_ASSERT(shift <= 32); LIBC_ASSERT(shift <= 32);
} }
uint32_t value_lo = (uint32_t) value; uint32_t value_lo = (uint32_t) value;
@ -165,7 +166,7 @@ libc_printf_uint_to_string (uintmax_t value, /**< integer value */
while (value_lo != 0 while (value_lo != 0
|| value_hi != 0) || value_hi != 0)
{ {
JERRY_ASSERT (str_p != buffer_p); LIBC_ASSERT (str_p != buffer_p);
*--str_p = alphabet[ value_lo & (radix - 1) ]; *--str_p = alphabet[ value_lo & (radix - 1) ];
value_lo >>= shift; value_lo >>= shift;
@ -179,7 +180,7 @@ libc_printf_uint_to_string (uintmax_t value, /**< integer value */
*--str_p = '0'; *--str_p = '0';
} }
JERRY_ASSERT(str_p >= buffer_p && str_p < str_buffer_end); LIBC_ASSERT(str_p >= buffer_p && str_p < str_buffer_end);
return str_p; return str_p;
} /* libc_printf_uint_to_string */ } /* libc_printf_uint_to_string */
@ -190,20 +191,21 @@ libc_printf_uint_to_string (uintmax_t value, /**< integer value */
* @return updated va_list * @return updated va_list
*/ */
static void static void
libc_printf_write_d_i (_FILE *stream, /**< stream pointer */ libc_printf_write_d_i (FILE *stream, /**< stream pointer */
va_list* args_list_p, /**< args' list */ va_list* args_list_p, /**< args' list */
libc_printf_arg_flags_mask_t flags, /**< field's flags */ libc_printf_arg_flags_mask_t flags, /**< field's flags */
libc_printf_arg_length_type_t length, /**< field's length type */ libc_printf_arg_length_type_t length, /**< field's length type */
uint32_t width) /**< minimum field width to output */ uint32_t width) /**< minimum field width to output */
{ {
JERRY_ASSERT((flags & LIBC_PRINTF_ARG_FLAG_SHARP) == 0); LIBC_ASSERT((flags & LIBC_PRINTF_ARG_FLAG_SHARP) == 0);
bool is_signed = true; bool is_signed = true;
uintmax_t value = 0; uintmax_t value = 0;
/* true - positive, false - negative */ /* true - positive, false - negative */
bool sign = true; bool sign = true;
const uintmax_t value_sign_mask = ((uintmax_t)1) << (sizeof (value) * JERRY_BITSINBYTE - 1); const size_t bits_in_byte = 8;
const uintmax_t value_sign_mask = ((uintmax_t)1) << (sizeof (value) * bits_in_byte - 1);
switch (length) switch (length)
{ {
@ -259,7 +261,7 @@ libc_printf_write_d_i (_FILE *stream, /**< stream pointer */
case LIBC_PRINTF_ARG_LENGTH_TYPE_HIGHL: case LIBC_PRINTF_ARG_LENGTH_TYPE_HIGHL:
{ {
JERRY_UNREACHABLE(); LIBC_UNREACHABLE();
} }
} }
@ -283,7 +285,7 @@ libc_printf_write_d_i (_FILE *stream, /**< stream pointer */
if (!sign if (!sign
|| (flags & LIBC_PRINTF_ARG_FLAG_PRINT_SIGN)) || (flags & LIBC_PRINTF_ARG_FLAG_PRINT_SIGN))
{ {
JERRY_ASSERT (string_p > str_buffer); LIBC_ASSERT (string_p > str_buffer);
*--string_p = (sign ? '+' : '-'); *--string_p = (sign ? '+' : '-');
} }
else if (flags & LIBC_PRINTF_ARG_FLAG_SPACE) else if (flags & LIBC_PRINTF_ARG_FLAG_SPACE)
@ -310,7 +312,7 @@ libc_printf_write_d_i (_FILE *stream, /**< stream pointer */
* @return updated va_list * @return updated va_list
*/ */
static void static void
libc_printf_write_u_o_x_X(_FILE *stream, /**< stream pointer */ libc_printf_write_u_o_x_X(FILE *stream, /**< stream pointer */
char specifier, /**< specifier (u, o, x, X) */ char specifier, /**< specifier (u, o, x, X) */
va_list* args_list_p, /**< args' list */ va_list* args_list_p, /**< args' list */
libc_printf_arg_flags_mask_t flags, /**< field's flags */ libc_printf_arg_flags_mask_t flags, /**< field's flags */
@ -371,7 +373,7 @@ libc_printf_write_u_o_x_X(_FILE *stream, /**< stream pointer */
case LIBC_PRINTF_ARG_LENGTH_TYPE_HIGHL: case LIBC_PRINTF_ARG_LENGTH_TYPE_HIGHL:
{ {
JERRY_UNREACHABLE(); LIBC_UNREACHABLE();
} }
} }
@ -391,7 +393,7 @@ libc_printf_write_u_o_x_X(_FILE *stream, /**< stream pointer */
} }
else else
{ {
JERRY_ASSERT(specifier == 'o'); LIBC_ASSERT(specifier == 'o');
} }
} }
} }
@ -431,7 +433,7 @@ libc_printf_write_u_o_x_X(_FILE *stream, /**< stream pointer */
default: default:
{ {
JERRY_UNREACHABLE(); LIBC_UNREACHABLE();
} }
} }
@ -475,8 +477,8 @@ libc_printf_write_u_o_x_X(_FILE *stream, /**< stream pointer */
* *
* @return number of characters printed * @return number of characters printed
*/ */
static int int
vfprintf (_FILE *stream, /**< stream pointer */ vfprintf (FILE *stream, /**< stream pointer */
const char *format, /**< format string */ const char *format, /**< format string */
va_list args) /**< arguments */ va_list args) /**< arguments */
{ {
@ -531,7 +533,7 @@ vfprintf (_FILE *stream, /**< stream pointer */
if (*format_iter_p == '*') if (*format_iter_p == '*')
{ {
/* Not supported */ /* Not supported */
JERRY_UNREACHABLE (); LIBC_UNREACHABLE ();
} }
// If there is a number, recognize it as field width // If there is a number, recognize it as field width
@ -545,7 +547,7 @@ vfprintf (_FILE *stream, /**< stream pointer */
if (*format_iter_p == '.') if (*format_iter_p == '.')
{ {
/* Not supported */ /* Not supported */
JERRY_UNREACHABLE (); LIBC_UNREACHABLE ();
} }
switch (*format_iter_p) switch (*format_iter_p)
@ -639,7 +641,7 @@ vfprintf (_FILE *stream, /**< stream pointer */
case 'A': case 'A':
{ {
/* Not supported */ /* Not supported */
JERRY_UNREACHABLE (); LIBC_UNREACHABLE ();
break; break;
} }
@ -648,7 +650,7 @@ vfprintf (_FILE *stream, /**< stream pointer */
if (length & LIBC_PRINTF_ARG_LENGTH_TYPE_L) if (length & LIBC_PRINTF_ARG_LENGTH_TYPE_L)
{ {
/* Not supported */ /* Not supported */
JERRY_UNREACHABLE (); LIBC_UNREACHABLE ();
} }
else else
{ {
@ -672,7 +674,7 @@ vfprintf (_FILE *stream, /**< stream pointer */
if (length & LIBC_PRINTF_ARG_LENGTH_TYPE_L) if (length & LIBC_PRINTF_ARG_LENGTH_TYPE_L)
{ {
/* Not supported */ /* Not supported */
JERRY_UNREACHABLE (); LIBC_UNREACHABLE ();
} }
else else
{ {
@ -713,7 +715,7 @@ vfprintf (_FILE *stream, /**< stream pointer */
case 'n': case 'n':
{ {
/* Not supported */ /* Not supported */
JERRY_UNREACHABLE (); LIBC_UNREACHABLE ();
break; break;
} }
} }
@ -733,7 +735,7 @@ vfprintf (_FILE *stream, /**< stream pointer */
* @return number of characters printed * @return number of characters printed
*/ */
int int
fprintf (_FILE *stream, /**< stream pointer */ fprintf (FILE *stream, /**< stream pointer */
const char *format, /**< format string */ const char *format, /**< format string */
...) /**< parameters' values */ ...) /**< parameters' values */
{ {
@ -761,7 +763,7 @@ printf (const char *format, /**< format string */
va_start (args, format); va_start (args, format);
int ret = vfprintf (LIBC_STDOUT, format, args); int ret = vfprintf (stdout, format, args);
va_end (args); va_end (args);

View File

@ -17,23 +17,21 @@
* Jerry libc's common functions implementation * Jerry libc's common functions implementation
*/ */
#include "jerry-libc.h" #include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "jerry-libc-defs.h"
/** /**
* Unreachable stubs for routines that are never called, * Standard file descriptors
* but referenced from third-party libraries.
*/ */
#define JRT_UNREACHABLE_STUB_FOR(...) \ FILE *stdin = (FILE*) 0;
extern "C" __VA_ARGS__; \ FILE *stdout = (FILE*) 1;
__used __VA_ARGS__ \ FILE *stderr = (FILE*) 2;
{ \
JERRY_UNREACHABLE (); \
}
JRT_UNREACHABLE_STUB_FOR(void abort (void)) LIBC_UNREACHABLE_STUB_FOR(void abort (void))
JRT_UNREACHABLE_STUB_FOR(int raise (int sig_no __unused))
#undef JRT_UNREACHABLE_STUB_FOR
#ifdef __GNUC__ #ifdef __GNUC__
/* /*
@ -42,6 +40,8 @@ JRT_UNREACHABLE_STUB_FOR(int raise (int sig_no __unused))
* - memset -> call to memset; * - memset -> call to memset;
* - memmove -> call to memmove. * - memmove -> call to memmove.
*/ */
#define CALL_PRAGMA(x) _Pragma (#x)
CALL_PRAGMA(GCC diagnostic push) CALL_PRAGMA(GCC diagnostic push)
CALL_PRAGMA(GCC diagnostic ignored "-Wpragmas") CALL_PRAGMA(GCC diagnostic ignored "-Wpragmas")
CALL_PRAGMA(GCC push_options) CALL_PRAGMA(GCC push_options)
@ -53,7 +53,7 @@ CALL_PRAGMA(GCC optimize ("-fno-tree-loop-distribute-patterns"))
* *
* @return @s * @return @s
*/ */
void* void* __attr_used___ // FIXME
memset (void *s, /**< area to set values in */ memset (void *s, /**< area to set values in */
int c, /**< value to set */ int c, /**< value to set */
size_t n) /**< area size */ size_t n) /**< area size */
@ -119,7 +119,7 @@ memcpy (void *s1, /**< destination */
* *
* @return the dest pointer's value * @return the dest pointer's value
*/ */
void * void * __attr_used___ // FIXME
memmove (void *s1, /**< destination */ memmove (void *s1, /**< destination */
const void *s2, /**< source */ const void *s2, /**< source */
size_t n) /**< bytes number */ size_t n) /**< bytes number */
@ -233,7 +233,7 @@ strncmp (const char *s1, const char *s2, size_t n)
/** Copy a string. At most n bytes of src are copied. Warning: If there is no /** Copy a string. At most n bytes of src are copied. Warning: If there is no
null byte among the first n bytes of src, the string placed in dest will not be null-terminated. null byte among the first n bytes of src, the string placed in dest will not be null-terminated.
@return a pointer to the destination string dest. */ @return a pointer to the destination string dest. */
char * char * __attr_used___ // FIXME
strncpy (char *dest, const char *src, size_t n) strncpy (char *dest, const char *src, size_t n)
{ {
size_t i; size_t i;

View File

@ -1,86 +0,0 @@
/* Copyright 2014-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.
*/
/**
* Jerry libc declarations
*/
#ifndef JERRY_LIBC_H
#define JERRY_LIBC_H
#include "jrt.h"
typedef void _FILE;
/**
* stdin file descriptor
*/
#define LIBC_STDIN (_FILE*)0
/**
* stdout file descriptor
*/
#define LIBC_STDOUT (_FILE*)1
/**
* stderr file descriptor
*/
#define LIBC_STDERR (_FILE*)2
extern void* memset (void *s, int c, size_t n);
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* memmove (void *dest, const void *src, size_t n);
extern int printf (const char *format, ...);
extern int putchar (int);
extern "C" void __noreturn exit (int);
extern int strcmp (const char *, const char *);
extern int strncmp (const char *, const char *, size_t);
extern char* strncpy (char *, const char *, size_t);
extern float __strtof (const char *, char **);
extern size_t strlen (const char *);
extern int isspace (int);
extern int isupper (int);
extern int islower (int);
extern int isalpha (int);
extern int isdigit (int);
extern int isxdigit (int);
/**
* 'whence' argument of fseek that identifies position
* the 'offset' argument is added to.
*/
typedef enum
{
__SEEK_SET, /**< relative to begin of file */
__SEEK_CUR, /**< relative to current position */
__SEEK_END /**< relative to end of file */
} _whence_t;
extern _FILE* fopen (const char *, const char *);
extern int fclose (_FILE *);
extern int fseek (_FILE *, long offset, _whence_t);
extern long ftell (_FILE *);
extern void rewind (_FILE *);
extern size_t fread (void *, size_t, size_t, _FILE *);
extern size_t fwrite (const void *, size_t, size_t, _FILE *);
extern int fprintf (_FILE *, const char *, ...);
extern void jrt_set_mem_limits (size_t data_size, size_t stack_size);
#define HUGE_VAL (1e37f)
#endif /* JERRY_LIBC_H */

View File

@ -17,12 +17,17 @@
* Jerry libc platform-specific functions linux implementation * Jerry libc platform-specific functions linux implementation
*/ */
#include "jrt.h" #include <ctype.h>
#include "jerry-libc.h" #include <fcntl.h>
#include <signal.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syscall.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef __TARGET_HOST_x64 #ifdef __TARGET_HOST_x64
# include "asm_x64.h" # include "asm_x64.h"
@ -33,46 +38,33 @@
#else /* !__TARGET_HOST_x64 && !__TARGET_HOST_x86 && !__TARGET_HOST_ARMv7 */ #else /* !__TARGET_HOST_x64 && !__TARGET_HOST_x86 && !__TARGET_HOST_ARMv7 */
# error "!__TARGET_HOST_x64 && !__TARGET_HOST_x86 && !__TARGET_HOST_ARMv7 " # error "!__TARGET_HOST_x64 && !__TARGET_HOST_x86 && !__TARGET_HOST_ARMv7 "
#endif /* !__TARGET_HOST_x64 && !__TARGET_HOST_x86 && !__TARGET_HOST_ARMv7 */ #endif /* !__TARGET_HOST_x64 && !__TARGET_HOST_x86 && !__TARGET_HOST_ARMv7 */
#include "jerry-libc-defs.h"
FIXME(Rename __unused) LIBC_UNREACHABLE_STUB_FOR(int raise (int sig_no __attr_unused___))
#undef __unused
#include <syscall.h>
#include <sys/stat.h>
#include <fcntl.h>
FIXME (/* Include linux/fs.h */)
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
/** /**
* Exit program with ERR_SYSCALL if syscall_ret_val is negative * Exit program with ERR_SYSCALL if syscall_ret_val is negative
*/ */
#define LIBC_EXIT_ON_ERROR(syscall_ret_val) \ #define LIBC_EXIT_ON_ERROR(syscall_ret_val) \
if (unlikely ((syscall_ret_val) < 0)) \ if ((syscall_ret_val) < 0) \
{ \ { \
jerry_fatal (ERR_SYSCALL); \ libc_fatal ("Syscall successful", __FILE__, __FUNCTION__, __LINE__); \
} }
static long int syscall_1 (long int syscall_no, long int arg1); static long int syscall_1 (long int syscall_no, long int arg1);
static long int syscall_2 (long int syscall_no, long int arg1, long int arg2); static long int syscall_2 (long int syscall_no, long int arg1, long int arg2);
static long int syscall_3 (long int syscall_no, long int arg1, long int arg2, long int arg3); static long int syscall_3 (long int syscall_no, long int arg1, long int arg2, long int arg3);
extern "C" extern long int syscall_1_asm (long int syscall_no, long int arg1);
{ extern long int syscall_2_asm (long int syscall_no, long int arg1, long int arg2);
extern long int syscall_1_asm (long int syscall_no, long int arg1); extern long int syscall_3_asm (long int syscall_no, long int arg1, long int arg2, long int arg3);
extern long int syscall_2_asm (long int syscall_no, long int arg1, long int arg2);
extern long int syscall_3_asm (long int syscall_no, long int arg1, long int arg2, long int arg3);
}
/** /**
* System call with one argument. * System call with one argument.
* *
* @return syscall's return value * @return syscall's return value
*/ */
static __noinline long int static __attr_noinline___ long int
syscall_1 (long int syscall_no, /**< syscall number */ syscall_1 (long int syscall_no, /**< syscall number */
long int arg1) /**< argument */ long int arg1) /**< argument */
{ {
@ -88,7 +80,7 @@ syscall_1 (long int syscall_no, /**< syscall number */
* *
* @return syscall's return value * @return syscall's return value
*/ */
static __noinline long int static __attr_noinline___ long int
syscall_2 (long int syscall_no, /**< syscall number */ syscall_2 (long int syscall_no, /**< syscall number */
long int arg1, /**< first argument */ long int arg1, /**< first argument */
long int arg2) /**< second argument */ long int arg2) /**< second argument */
@ -105,7 +97,7 @@ syscall_2 (long int syscall_no, /**< syscall number */
* *
* @return syscall's return value * @return syscall's return value
*/ */
static __noinline long int static __attr_noinline___ long int
syscall_3 (long int syscall_no, /**< syscall number */ syscall_3 (long int syscall_no, /**< syscall number */
long int arg1, /**< first argument */ long int arg1, /**< first argument */
long int arg2, /**< second argument */ long int arg2, /**< second argument */
@ -122,20 +114,36 @@ syscall_3 (long int syscall_no, /**< syscall number */
int int
putchar (int c) putchar (int c)
{ {
fwrite (&c, 1, sizeof (char), LIBC_STDOUT); fwrite (&c, 1, sizeof (char), stdout);
return c; return c;
} /* putchar */ } /* putchar */
/**
* Output specified string
*/
int
puts(const char *s) /**< string to print */
{
while (*s)
{
putchar (*s);
s++;
}
return 0;
} /* puts */
/** /**
* Exit - cause normal process termination with specified status code * Exit - cause normal process termination with specified status code
*/ */
void __noreturn __used void __attr_noreturn___ __attr_used___
exit (int status) /**< status code */ exit (int status) /**< status code */
{ {
syscall_1 (__NR_close, (long int)LIBC_STDIN); syscall_1 (__NR_close, (long int)stdin);
syscall_1 (__NR_close, (long int)LIBC_STDOUT); syscall_1 (__NR_close, (long int)stdout);
syscall_1 (__NR_close, (long int)LIBC_STDERR); syscall_1 (__NR_close, (long int)stderr);
syscall_1 (__NR_exit_group, status); syscall_1 (__NR_exit_group, status);
@ -148,10 +156,10 @@ exit (int status) /**< status code */
/** /**
* fopen * fopen
* *
* @return _FILE pointer - upon successful completion, * @return FILE pointer - upon successful completion,
* NULL - otherwise * NULL - otherwise
*/ */
_FILE* FILE*
fopen (const char *path, /**< file path */ fopen (const char *path, /**< file path */
const char *mode) /**< file open mode */ const char *mode) /**< file open mode */
{ {
@ -161,8 +169,8 @@ fopen (const char *path, /**< file path */
bool create_if_not_exist = false; bool create_if_not_exist = false;
bool position_at_end = false; bool position_at_end = false;
JERRY_ASSERT(path != NULL && mode != NULL); LIBC_ASSERT(path != NULL && mode != NULL);
JERRY_ASSERT(mode[1] == '+' || mode[1] == '\0'); LIBC_ASSERT(mode[1] == '+' || mode[1] == '\0');
switch (mode[0]) switch (mode[0])
{ {
@ -188,13 +196,13 @@ fopen (const char *path, /**< file path */
if (mode[1] == '+') if (mode[1] == '+')
{ {
/* Not supported */ /* Not supported */
JERRY_UNREACHABLE(); LIBC_UNREACHABLE();
} }
break; break;
} }
default: default:
{ {
JERRY_UNREACHABLE(); LIBC_UNREACHABLE();
} }
} }
@ -210,7 +218,7 @@ fopen (const char *path, /**< file path */
} }
else else
{ {
JERRY_ASSERT(may_read && may_write); LIBC_ASSERT(may_read && may_write);
flags = O_RDWR; flags = O_RDWR;
} }
@ -240,7 +248,7 @@ fopen (const char *path, /**< file path */
* for the stream pointed to by STREAM to the beginning of the file. * for the stream pointed to by STREAM to the beginning of the file.
*/ */
void void
rewind (_FILE *stream) /**< stream pointer */ rewind (FILE *stream) /**< stream pointer */
{ {
syscall_3 (__NR_lseek, (long int) stream, 0, SEEK_SET); syscall_3 (__NR_lseek, (long int) stream, 0, SEEK_SET);
} /* rewind */ } /* rewind */
@ -252,7 +260,7 @@ rewind (_FILE *stream) /**< stream pointer */
* non-zero value - otherwise. * non-zero value - otherwise.
*/ */
int int
fclose (_FILE *fp) /**< stream pointer */ fclose (FILE *fp) /**< stream pointer */
{ {
syscall_2 (__NR_close, (long int)fp, 0); syscall_2 (__NR_close, (long int)fp, 0);
@ -263,32 +271,12 @@ fclose (_FILE *fp) /**< stream pointer */
* fseek * fseek
*/ */
int int
fseek (_FILE * fp, /**< stream pointer */ fseek (FILE * fp, /**< stream pointer */
long offset, /**< offset */ long offset, /**< offset */
_whence_t whence) /**< specifies position type int whence) /**< specifies position type
to add offset to */ * to add offset to */
{ {
int whence_real = SEEK_CUR; syscall_3 (__NR_lseek, (long int)fp, offset, whence);
switch (whence)
{
case __SEEK_SET:
{
whence_real = SEEK_SET;
break;
}
case __SEEK_CUR:
{
whence_real = SEEK_CUR;
break;
}
case __SEEK_END:
{
whence_real = SEEK_END;
break;
}
}
syscall_3 (__NR_lseek, (long int)fp, offset, whence_real);
return 0; return 0;
} /* fseek */ } /* fseek */
@ -297,7 +285,7 @@ fseek (_FILE * fp, /**< stream pointer */
* ftell * ftell
*/ */
long long
ftell (_FILE * fp) /**< stream pointer */ ftell (FILE * fp) /**< stream pointer */
{ {
long int ret = syscall_3 (__NR_lseek, (long int)fp, 0, SEEK_CUR); long int ret = syscall_3 (__NR_lseek, (long int)fp, 0, SEEK_CUR);
@ -313,7 +301,7 @@ size_t
fread (void *ptr, /**< address of buffer to read to */ fread (void *ptr, /**< address of buffer to read to */
size_t size, /**< size of elements to read */ size_t size, /**< size of elements to read */
size_t nmemb, /**< number of elements to read */ size_t nmemb, /**< number of elements to read */
_FILE *stream) /**< stream pointer */ FILE *stream) /**< stream pointer */
{ {
long int ret; long int ret;
size_t bytes_read = 0; size_t bytes_read = 0;
@ -341,7 +329,7 @@ size_t
fwrite (const void *ptr, /**< data to write */ fwrite (const void *ptr, /**< data to write */
size_t size, /**< size of elements to write */ size_t size, /**< size of elements to write */
size_t nmemb, /**< number of elements */ size_t nmemb, /**< number of elements */
_FILE *stream) /**< stream pointer */ FILE *stream) /**< stream pointer */
{ {
size_t bytes_written = 0; size_t bytes_written = 0;
@ -359,6 +347,8 @@ fwrite (const void *ptr, /**< data to write */
return bytes_written; return bytes_written;
} /* fwrite */ } /* fwrite */
// FIXME
#if 0
/** /**
* Setup new memory limits * Setup new memory limits
*/ */
@ -382,19 +372,20 @@ jrt_set_mem_limits (size_t data_size, /**< limit for data + bss + brk heap */
#ifdef __TARGET_HOST_x64 #ifdef __TARGET_HOST_x64
ret = syscall_2 (__NR_setrlimit, RLIMIT_DATA, (intptr_t) &data_limit); ret = syscall_2 (__NR_setrlimit, RLIMIT_DATA, (intptr_t) &data_limit);
JERRY_ASSERT (ret == 0); LIBC_ASSERT (ret == 0);
ret = syscall_2 (__NR_setrlimit, RLIMIT_STACK, (intptr_t) &stack_limit); ret = syscall_2 (__NR_setrlimit, RLIMIT_STACK, (intptr_t) &stack_limit);
JERRY_ASSERT (ret == 0); LIBC_ASSERT (ret == 0);
#elif defined (__TARGET_HOST_ARMv7) #elif defined (__TARGET_HOST_ARMv7)
ret = syscall_3 (__NR_prlimit64, 0, RLIMIT_DATA, (intptr_t) &data_limit); ret = syscall_3 (__NR_prlimit64, 0, RLIMIT_DATA, (intptr_t) &data_limit);
JERRY_ASSERT (ret == 0); LIBC_ASSERT (ret == 0);
ret = syscall_3 (__NR_prlimit64, 0, RLIMIT_STACK, (intptr_t) &stack_limit); ret = syscall_3 (__NR_prlimit64, 0, RLIMIT_STACK, (intptr_t) &stack_limit);
JERRY_ASSERT (ret == 0); LIBC_ASSERT (ret == 0);
#elif defined (__TARGET_HOST_x86) #elif defined (__TARGET_HOST_x86)
# error "__TARGET_HOST_x86 case is not implemented" # error "__TARGET_HOST_x86 case is not implemented"
#else /* !__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86 */ #else /* !__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86 */
# error "!__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86" # error "!__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86"
#endif /* !__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86 */ #endif /* !__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86 */
} /* jrt_set_mem_limits */ } /* jrt_set_mem_limits */
#endif // FIXME

View File

@ -1,4 +1,4 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd. /* Copyright 2015 Samsung Electronics Co., Ltd.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,27 +17,22 @@
* Jerry libc platform-specific functions stm32f4 implementation * Jerry libc platform-specific functions stm32f4 implementation
*/ */
#include "jerry-libc.h" #include <stdio.h>
#include <stdlib.h>
#include <stdarg.h> #include "jerry-libc-defs.h"
extern void __noreturn exit (int status);
/** Output of character. Writes the character c, cast to an unsigned char, to stdout. */ /** Output of character. Writes the character c, cast to an unsigned char, to stdout. */
int int
putchar (int c) putchar (int c __attr_unused___)
{ {
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS("putchar is not implemented for STM32F3.", c); return 1;
} /* putchar */ } /* putchar */
/** exit - cause normal process termination */ /** exit - cause normal process termination */
void __noreturn __used void __attr_noreturn___ __attr_used___
exit (int status __unused) exit (int status __attr_unused___)
{ {
/**
* TODO: Blink LEDs? status -> binary -> LEDs?
*/
while (true) while (true)
{ {
} }
@ -49,11 +44,11 @@ exit (int status __unused)
* @return number of bytes written * @return number of bytes written
*/ */
size_t size_t
fwrite (const void *ptr, /**< data to write */ fwrite (const void *ptr __attr_unused___, /**< data to write */
size_t size, /**< size of elements to write */ size_t size, /**< size of elements to write */
size_t nmemb, /**< number of elements */ size_t nmemb, /**< number of elements */
_FILE *stream) /**< stream pointer */ FILE *stream __attr_unused___) /**< stream pointer */
{ {
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS("fwrite is not implemented for STM32F3.", ptr, size, nmemb, stream); return size * nmemb;
} /* fwrite */ } /* fwrite */

View File

@ -1,59 +0,0 @@
/* Copyright 2014-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.
*/
/**
* Jerry libc platform-specific functions stm32f4 implementation
*/
#include "jerry-libc.h"
#include <stdarg.h>
extern void __noreturn exit (int status);
/** Output of character. Writes the character c, cast to an unsigned char, to stdout. */
int
putchar (int c)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS("putchar is not implemented for STM32F4.", c);
} /* putchar */
/** exit - cause normal process termination */
void __noreturn __used
exit (int status __unused)
{
/**
* TODO: Blink LEDs? status -> binary -> LEDs?
*/
while (true)
{
}
} /* exit */
/**
* fwrite
*
* @return number of bytes written
*/
size_t
fwrite (const void *ptr, /**< data to write */
size_t size, /**< size of elements to write */
size_t nmemb, /**< number of elements */
_FILE *stream) /**< stream pointer */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS("fwrite is not implemented for STM32F4.", ptr, size, nmemb, stream);
} /* fwrite */

112
plugins/CMakeLists.txt Normal file
View File

@ -0,0 +1,112 @@
# 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.
cmake_minimum_required (VERSION 2.8.12)
project (Jerry_Plugins CXX ASM)
# Compiler / linker flags
set(COMPILE_FLAGS_PLUGINS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY}")
# Definitions
# Debug
set(DEFINES_PLUGINS_DEBUG )
# Release
set(DEFINES_PLUGINS_RELEASE JERRY_NDEBUG)
# Platform-specific
# Linux
set(DEFINES_PLUGINS_LINUX __TARGET_HOST)
# MCU
# stm32f3
set(DEFINES_PLUGINS_MCU_STM32F3 __TARGET_MCU __TARGET_MCU_STM32F3)
# stm32f4
set(DEFINES_PLUGINS_MCU_STM32F4 __TARGET_MCU __TARGET_MCU_STM32F4)
# Include directories
set(INCLUDE_PLUGINS
${CMAKE_SOURCE_DIR}/src
lib-device-stm)
# Third-party
# Platform-specific
# Linux
set(INCLUDE_THIRD_PARTY_LINUX )
# MCU
# STM32F3
set(INCLUDE_THIRD_PARTY_MCU_STM32F3
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Include
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/inc
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Include
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0)
# STM32F4
set(INCLUDE_THIRD_PARTY_MCU_STM32F4
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Include
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/inc
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/Include
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0)
# Sources
file(GLOB SOURCE_PLUGINS lib-device-stm/*.cpp)
# Third-party
# Platform-specific
# MCU
# stm32f3
set(SOURCE_THIRD_PARTY_MCU_STM32F3
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/system_stm32f30x.c
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_tim.c
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_gpio.c
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_rcc.c)
# stm32f4
set(SOURCE_THIRD_PARTY_MCU_STM32F4
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c)
# Platform-specific configuration
set(DEFINES_PLUGINS ${DEFINES_PLUGINS_${PLATFORM_EXT}})
set(INCLUDE_PLUGINS ${INCLUDE_PLUGINS} ${INCLUDE_THIRD_PARTY_${PLATFORM_EXT}})
# Targets declaration
string(TOLOWER ${PLATFORM_EXT} PLATFORM_L)
set(TARGET_NAME plugins.${PLATFORM_L})
function(declare_targets_for_build_mode BUILD_MODE)
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.${TARGET_NAME})
set(DEFINES_PLUGINS ${DEFINES_PLUGINS} ${DEFINES_PLUGINS_${BUILD_MODE}})
# Jerry
add_library(${TARGET_NAME}.lib STATIC ${SOURCE_PLUGINS})
set_property(TARGET ${TARGET_NAME}.lib
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_PLUGINS} ${FLAGS_COMMON_${BUILD_MODE}}")
target_compile_definitions(${TARGET_NAME}.lib PRIVATE ${DEFINES_PLUGINS})
target_include_directories(${TARGET_NAME}.lib PRIVATE ${INCLUDE_PLUGINS})
# Third-party MCU library
if(DEFINED SOURCE_THIRD_PARTY_${PLATFORM_EXT})
add_library(${TARGET_NAME}.third_party.lib STATIC ${SOURCE_THIRD_PARTY_${PLATFORM_EXT}})
set_property(TARGET ${TARGET_NAME}.third_party.lib
PROPERTY COMPILE_FLAGS "${FLAGS_COMMON_${BUILD_MODE}}")
target_include_directories(${TARGET_NAME}.third_party.lib PRIVATE ${INCLUDE_PLUGINS})
target_link_libraries(${TARGET_NAME}.lib ${TARGET_NAME}.third_party.lib)
endif()
endfunction()
foreach(BUILD_MODE ${BUILD_MODES})
declare_targets_for_build_mode(${BUILD_MODE})
endforeach()

View File

@ -15,9 +15,10 @@
#pragma GCC optimize "O0" #pragma GCC optimize "O0"
#include <stdio.h>
#include "actuators.h" #include "actuators.h"
#include "common-io.h" #include "common-io.h"
#include "jerry-libc.h"
#ifdef __TARGET_HOST #ifdef __TARGET_HOST
/** /**

View File

@ -16,7 +16,7 @@
#ifndef ACTUATORS_H #ifndef ACTUATORS_H
#define ACTUATORS_H #define ACTUATORS_H
#include "jrt.h" #include <stdint.h>
void led_toggle (uint32_t); void led_toggle (uint32_t);
void led_on (uint32_t); void led_on (uint32_t);

View File

@ -15,34 +15,43 @@
#pragma GCC optimize "O0" #pragma GCC optimize "O0"
#include <stdio.h>
#include "actuators.h" #include "actuators.h"
#include "common-io.h" #include "common-io.h"
#include "jerry-libc.h"
#include "mcu-headers.h" #include "mcu-headers.h"
int int
digital_read (uint32_t arg1 __unused, uint32_t arg2 __unused) digital_read (uint32_t arg1, uint32_t arg2)
{ {
JERRY_UNIMPLEMENTED ("Digital read operation is not implemented."); (void) arg1;
(void) arg2;
return 0;
} }
void void
digital_write (uint32_t arg1 __unused, uint32_t arg2 __unused) digital_write (uint32_t arg1, uint32_t arg2)
{ {
JERRY_UNIMPLEMENTED ("Digital write operation is not implemented."); (void) arg1;
(void) arg2;
} }
int int
analog_read (uint32_t arg1 __unused, uint32_t arg2 __unused) analog_read (uint32_t arg1, uint32_t arg2)
{ {
JERRY_UNIMPLEMENTED ("Analog read operation is not implemented."); (void) arg1;
(void) arg2;
return 0;
} }
void void
analog_write (uint32_t arg1 __unused, uint32_t arg2 __unused) analog_write (uint32_t arg1, uint32_t arg2)
{ {
JERRY_UNIMPLEMENTED ("Analog write operation is not implemented."); (void) arg1;
(void) arg2;
} }
#ifdef __TARGET_HOST #ifdef __TARGET_HOST

View File

@ -16,7 +16,7 @@
#ifndef COMMON_IO_H #ifndef COMMON_IO_H
#define COMMON_IO_H #define COMMON_IO_H
#include "jrt.h" #include <stdint.h>
int digital_read (uint32_t, uint32_t); int digital_read (uint32_t, uint32_t);
void digital_write (uint32_t, uint32_t); void digital_write (uint32_t, uint32_t);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd. /* Copyright 2015 Samsung Electronics Co., Ltd.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -13,6 +13,16 @@
* limitations under the License. * limitations under the License.
*/ */
#pragma GCC optimize "O0" #include "actuators.h"
#include "common-io.h"
#include "init.h"
#include "sensors.h" void
plugin_device_stm_init (void)
{
#if defined (__TARGET_MCU_STM32F3) || defined (__TARGET_MCU_STM32F4)
initialize_sys_tick ();
initialize_leds ();
initialize_timer ();
#endif /* __TARGET_MCU_STM32F3 || __TARGET_MCU_STM32F4 */
} /* plugin_device_stm_init */

View File

@ -1,4 +1,4 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd. /* Copyright 2015 Samsung Electronics Co., Ltd.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -13,9 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef SENSORS_H #ifndef INIT_H
#define SENSORS_H #define INIT_H
#include "jrt.h" extern void plugin_device_stm_init (void);
#endif /* SENSORS_H */ #endif /* INIT_H */

146
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,146 @@
# 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.
cmake_minimum_required (VERSION 2.8.12)
project (JerryCore CXX C ASM)
# Definitions
# Get version information from git
execute_process(COMMAND git symbolic-ref -q HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE JERRY_GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE JERRY_GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Get build date
execute_process(COMMAND date +%d/%m/%Y
OUTPUT_VARIABLE JERRY_BUILD_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(DEFINES_JERRY
JERRY_BUILD_DATE="${JERRY_BUILD_DATE}"
JERRY_COMMIT_HASH="${JERRY_GIT_COMMIT}"
JERRY_BRANCH_NAME="${JERRY_GIT_BRANCH}")
# Build modes
# Debug
set(DEFINES_JERRY_DEBUG JERRY_ENABLE_PRETTY_PRINTER)
# Release
set(DEFINES_JERRY_RELEASE JERRY_NDEBUG)
# Modifiers
# Full profile
set(DEFINES_FULL_PROFILE CONFIG_ECMA_NUMBER_TYPE=CONFIG_ECMA_NUMBER_FLOAT64)
# Compact profile
set(DEFINES_COMPACT_PROFILE
CONFIG_ECMA_COMPACT_PROFILE)
# Minimal compact profile
set(DEFINES_COMPACT_PROFILE_MINIMAL
CONFIG_ECMA_COMPACT_PROFILE
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_STRING_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_MATH_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_JSON_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN)
# Memory statistics
set(DEFINES_JERRY_MEMORY_STATISTICS MEM_STATS)
# Valgrind
set(DEFINES_JERRY_VALGRIND JERRY_VALGRIND)
# Platform-specific
# Linux
# MCU
math(EXPR MEM_HEAP_AREA_SIZE_16K "16 * 1024")
set(DEFINES_JERRY_MCU CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE_16K})
# Include directories
set(INCLUDE_CORE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/mem
${CMAKE_SOURCE_DIR}/src/vm
${CMAKE_SOURCE_DIR}/src/ecma/builtin-objects
${CMAKE_SOURCE_DIR}/src/ecma/base
${CMAKE_SOURCE_DIR}/src/ecma/operations
${CMAKE_SOURCE_DIR}/src/parser/collections
${CMAKE_SOURCE_DIR}/src/parser/js
${CMAKE_SOURCE_DIR}/src/jrt)
# Third-party
# Valgrind
set(INCLUDE_THIRD_PARTY_VALGRIND ${CMAKE_SOURCE_DIR}/third-party/valgrind)
# Sources
# Jerry core
file(GLOB SOURCE_CORE_MEM mem/*.cpp)
file(GLOB SOURCE_CORE_VM vm/*.cpp)
file(GLOB SOURCE_CORE_ECMA_BUILTINS ecma/builtin-objects/*.cpp)
file(GLOB SOURCE_CORE_ECMA_BASE ecma/base/*.cpp)
file(GLOB SOURCE_CORE_ECMA_OPERATIONS ecma/operations/*.cpp)
file(GLOB SOURCE_CORE_PARSER_COLLECTIONS parser/collections/*.cpp)
file(GLOB SOURCE_CORE_PARSER_JS parser/js/*.cpp)
file(GLOB SOURCE_CORE_JRT jrt/*.cpp)
set(SOURCE_CORE
jerry.cpp
${SOURCE_CORE_MEM}
${SOURCE_CORE_VM}
${SOURCE_CORE_ECMA_BUILTINS}
${SOURCE_CORE_ECMA_BASE}
${SOURCE_CORE_ECMA_OPERATIONS}
${SOURCE_CORE_PARSER_COLLECTIONS}
${SOURCE_CORE_PARSER_JS}
${SOURCE_CORE_JRT})
# Platform-specific configuration
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_${PLATFORM}})
# Targets declaration
function(declare_targets_for_build_mode BUILD_MODE)
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}})
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_${BUILD_MODE}})
function(declare_target_with_modifiers ) # modifiers are passed in ARGN implicit argument
foreach(MODIFIER ${ARGN})
set(TARGET_NAME ${TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}})
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_${MODIFIER}})
endforeach()
add_library(${TARGET_NAME}.jerry-core STATIC ${SOURCE_CORE})
set_property(TARGET ${TARGET_NAME}.jerry-core
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}}")
target_compile_definitions(${TARGET_NAME}.jerry-core PRIVATE ${DEFINES_JERRY})
target_include_directories(${TARGET_NAME}.jerry-core PRIVATE ${INCLUDE_CORE})
endfunction()
foreach(MODIFIERS_LIST ${MODIFIERS_LISTS})
separate_arguments(MODIFIERS_LIST)
declare_target_with_modifiers(${MODIFIERS_LIST})
endforeach()
endfunction()
foreach(BUILD_MODE ${BUILD_MODES})
declare_targets_for_build_mode(${BUILD_MODE})
endforeach()

View File

@ -31,7 +31,7 @@
#include "ecma-lcache.h" #include "ecma-lcache.h"
#include "ecma-stack.h" #include "ecma-stack.h"
#include "jrt.h" #include "jrt.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "jrt-bit-fields.h" #include "jrt-bit-fields.h"
/** /**

View File

@ -284,7 +284,7 @@ typedef struct ecma_property_t
union union
{ {
/** Description of named data property */ /** Description of named data property */
struct __packed ecma_named_data_property_t struct __attr_packed___ ecma_named_data_property_t
{ {
/** Compressed pointer to property's name (pointer to String) */ /** Compressed pointer to property's name (pointer to String) */
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH; unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
@ -306,7 +306,7 @@ typedef struct ecma_property_t
} named_data_property; } named_data_property;
/** Description of named accessor property */ /** Description of named accessor property */
struct __packed ecma_named_accessor_property_t struct __attr_packed___ ecma_named_accessor_property_t
{ {
/** Compressed pointer to property's name (pointer to String) */ /** Compressed pointer to property's name (pointer to String) */
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH; unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
@ -328,7 +328,7 @@ typedef struct ecma_property_t
} named_accessor_property; } named_accessor_property;
/** Description of internal property */ /** Description of internal property */
struct __packed ecma_internal_property_t struct __attr_packed___ ecma_internal_property_t
{ {
/** Internal property's type */ /** Internal property's type */
unsigned int type : ECMA_PROPERTY_INTERNAL_PROPERTY_TYPE_WIDTH; unsigned int type : ECMA_PROPERTY_INTERNAL_PROPERTY_TYPE_WIDTH;

View File

@ -22,7 +22,7 @@
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
/* /*
* \addtogroup ecmahelpersbigintegers Helpers for operations intermediate 128-bit integers * \addtogroup ecmahelpersbigintegers Helpers for operations intermediate 128-bit integers

View File

@ -27,7 +27,7 @@
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-lcache.h" #include "ecma-lcache.h"
#include "jrt.h" #include "jrt.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "vm.h" #include "vm.h"
/** /**
@ -987,7 +987,7 @@ ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string d
* @return true - if strings are equal; * @return true - if strings are equal;
* false - otherwise. * false - otherwise.
*/ */
static bool __noinline static bool __attr_noinline___
ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-string */ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-string */
const ecma_string_t *string2_p) /* ecma-string */ const ecma_string_t *string2_p) /* ecma-string */
{ {

View File

@ -34,7 +34,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_value_t) * JERRY_BITSINBYTE == ECMA_VALUE_SIZE
* *
* @return type field * @return type field
*/ */
static ecma_type_t __attribute_pure__ static ecma_type_t __attr_pure___
ecma_get_value_type_field (const ecma_value_t& value) /**< ecma-value */ ecma_get_value_type_field (const ecma_value_t& value) /**< ecma-value */
{ {
return (ecma_type_t) jrt_extract_bit_field (value, return (ecma_type_t) jrt_extract_bit_field (value,
@ -47,7 +47,7 @@ ecma_get_value_type_field (const ecma_value_t& value) /**< ecma-value */
* *
* @return value field * @return value field
*/ */
static uintptr_t __attribute_pure__ static uintptr_t __attr_pure___
ecma_get_value_value_field (const ecma_value_t& value) /**< ecma-value */ ecma_get_value_value_field (const ecma_value_t& value) /**< ecma-value */
{ {
return (uintptr_t) jrt_extract_bit_field (value, return (uintptr_t) jrt_extract_bit_field (value,
@ -60,7 +60,7 @@ ecma_get_value_value_field (const ecma_value_t& value) /**< ecma-value */
* *
* @return ecma-value with updated field * @return ecma-value with updated field
*/ */
static ecma_value_t __attribute_pure__ static ecma_value_t __attr_pure___
ecma_set_value_type_field (const ecma_value_t& value, /**< ecma-value to set field in */ ecma_set_value_type_field (const ecma_value_t& value, /**< ecma-value to set field in */
ecma_type_t type_field) /**< new field value */ ecma_type_t type_field) /**< new field value */
{ {
@ -75,7 +75,7 @@ ecma_set_value_type_field (const ecma_value_t& value, /**< ecma-value to set fie
* *
* @return ecma-value with updated field * @return ecma-value with updated field
*/ */
static ecma_value_t __attribute_pure__ static ecma_value_t __attr_pure___
ecma_set_value_value_field (const ecma_value_t& value, /**< ecma-value to set field in */ ecma_set_value_value_field (const ecma_value_t& value, /**< ecma-value to set field in */
uintptr_t value_field) /**< new field value */ uintptr_t value_field) /**< new field value */
{ {
@ -91,7 +91,7 @@ ecma_set_value_value_field (const ecma_value_t& value, /**< ecma-value to set fi
* @return true - if the value contains implementation-defined empty simple value, * @return true - if the value contains implementation-defined empty simple value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_pure__ __attribute_always_inline__ bool __attr_pure___ __attr_always_inline___
ecma_is_value_empty (const ecma_value_t& value) /**< ecma-value */ ecma_is_value_empty (const ecma_value_t& value) /**< ecma-value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE
@ -104,7 +104,7 @@ ecma_is_value_empty (const ecma_value_t& value) /**< ecma-value */
* @return true - if the value contains ecma-undefined simple value, * @return true - if the value contains ecma-undefined simple value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_pure__ __attribute_always_inline__ bool __attr_pure___ __attr_always_inline___
ecma_is_value_undefined (const ecma_value_t& value) /**< ecma-value */ ecma_is_value_undefined (const ecma_value_t& value) /**< ecma-value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE
@ -117,7 +117,7 @@ ecma_is_value_undefined (const ecma_value_t& value) /**< ecma-value */
* @return true - if the value contains ecma-null simple value, * @return true - if the value contains ecma-null simple value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_pure__ __attribute_always_inline__ bool __attr_pure___ __attr_always_inline___
ecma_is_value_null (const ecma_value_t& value) /**< ecma-value */ ecma_is_value_null (const ecma_value_t& value) /**< ecma-value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE
@ -130,7 +130,7 @@ ecma_is_value_null (const ecma_value_t& value) /**< ecma-value */
* @return true - if the value contains ecma-true or ecma-false simple values, * @return true - if the value contains ecma-true or ecma-false simple values,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_pure__ __attribute_always_inline__ bool __attr_pure___ __attr_always_inline___
ecma_is_value_boolean (const ecma_value_t& value) /**< ecma-value */ ecma_is_value_boolean (const ecma_value_t& value) /**< ecma-value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE
@ -147,7 +147,7 @@ ecma_is_value_boolean (const ecma_value_t& value) /**< ecma-value */
* @return true - if the value contains ecma-true simple value, * @return true - if the value contains ecma-true simple value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_pure__ __attribute_always_inline__ bool __attr_pure___ __attr_always_inline___
ecma_is_value_true (const ecma_value_t& value) /**< ecma-value */ ecma_is_value_true (const ecma_value_t& value) /**< ecma-value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE
@ -160,7 +160,7 @@ ecma_is_value_true (const ecma_value_t& value) /**< ecma-value */
* @return true - if the value contains ecma-number value, * @return true - if the value contains ecma-number value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_pure__ __attribute_always_inline__ bool __attr_pure___ __attr_always_inline___
ecma_is_value_number (const ecma_value_t& value) /**< ecma-value */ ecma_is_value_number (const ecma_value_t& value) /**< ecma-value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_NUMBER); return (ecma_get_value_type_field (value) == ECMA_TYPE_NUMBER);
@ -172,7 +172,7 @@ ecma_is_value_number (const ecma_value_t& value) /**< ecma-value */
* @return true - if the value contains ecma-string value, * @return true - if the value contains ecma-string value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_pure__ __attribute_always_inline__ bool __attr_pure___ __attr_always_inline___
ecma_is_value_string (const ecma_value_t& value) /**< ecma-value */ ecma_is_value_string (const ecma_value_t& value) /**< ecma-value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_STRING); return (ecma_get_value_type_field (value) == ECMA_TYPE_STRING);
@ -184,7 +184,7 @@ ecma_is_value_string (const ecma_value_t& value) /**< ecma-value */
* @return true - if the value contains object value, * @return true - if the value contains object value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_pure__ __attribute_always_inline__ bool __attr_pure___ __attr_always_inline___
ecma_is_value_object (const ecma_value_t& value) /**< ecma-value */ ecma_is_value_object (const ecma_value_t& value) /**< ecma-value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT); return (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT);
@ -208,7 +208,7 @@ ecma_check_value_type_is_spec_defined (const ecma_value_t& value) /**< ecma-valu
/** /**
* Simple value constructor * Simple value constructor
*/ */
ecma_value_t __attribute_const__ __attribute_always_inline__ ecma_value_t __attr_const___ __attr_always_inline___
ecma_make_simple_value (ecma_simple_value_t value) /**< simple value */ ecma_make_simple_value (ecma_simple_value_t value) /**< simple value */
{ {
ecma_value_t ret_value = 0; ecma_value_t ret_value = 0;
@ -222,7 +222,7 @@ ecma_make_simple_value (ecma_simple_value_t value) /**< simple value */
/** /**
* Number value constructor * Number value constructor
*/ */
ecma_value_t __attribute_const__ ecma_value_t __attr_const___
ecma_make_number_value (ecma_number_t* num_p) /**< number to reference in value */ ecma_make_number_value (ecma_number_t* num_p) /**< number to reference in value */
{ {
JERRY_ASSERT(num_p != NULL); JERRY_ASSERT(num_p != NULL);
@ -241,7 +241,7 @@ ecma_make_number_value (ecma_number_t* num_p) /**< number to reference in value
/** /**
* String value constructor * String value constructor
*/ */
ecma_value_t __attribute_const__ ecma_value_t __attr_const___
ecma_make_string_value (ecma_string_t* ecma_string_p) /**< string to reference in value */ ecma_make_string_value (ecma_string_t* ecma_string_p) /**< string to reference in value */
{ {
JERRY_ASSERT(ecma_string_p != NULL); JERRY_ASSERT(ecma_string_p != NULL);
@ -260,7 +260,7 @@ ecma_make_string_value (ecma_string_t* ecma_string_p) /**< string to reference i
/** /**
* object value constructor * object value constructor
*/ */
ecma_value_t __attribute_const__ ecma_value_t __attr_const___
ecma_make_object_value (ecma_object_t* object_p) /**< object to reference in value */ ecma_make_object_value (ecma_object_t* object_p) /**< object to reference in value */
{ {
JERRY_ASSERT(object_p != NULL); JERRY_ASSERT(object_p != NULL);
@ -281,7 +281,7 @@ ecma_make_object_value (ecma_object_t* object_p) /**< object to reference in val
* *
* @return the pointer * @return the pointer
*/ */
ecma_number_t* __attribute_pure__ ecma_number_t* __attr_pure___
ecma_get_number_from_value (const ecma_value_t& value) /**< ecma-value */ ecma_get_number_from_value (const ecma_value_t& value) /**< ecma-value */
{ {
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_NUMBER); JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_NUMBER);
@ -295,7 +295,7 @@ ecma_get_number_from_value (const ecma_value_t& value) /**< ecma-value */
* *
* @return the pointer * @return the pointer
*/ */
ecma_string_t* __attribute_pure__ ecma_string_t* __attr_pure___
ecma_get_string_from_value (const ecma_value_t& value) /**< ecma-value */ ecma_get_string_from_value (const ecma_value_t& value) /**< ecma-value */
{ {
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_STRING); JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_STRING);
@ -309,7 +309,7 @@ ecma_get_string_from_value (const ecma_value_t& value) /**< ecma-value */
* *
* @return the pointer * @return the pointer
*/ */
ecma_object_t* __attribute_pure__ ecma_object_t* __attr_pure___
ecma_get_object_from_value (const ecma_value_t& value) /**< ecma-value */ ecma_get_object_from_value (const ecma_value_t& value) /**< ecma-value */
{ {
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT); JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT);
@ -439,7 +439,7 @@ ecma_free_value (ecma_value_t& value, /**< value description */
* *
* @return type field * @return type field
*/ */
static ecma_completion_type_t __attribute_const__ static ecma_completion_type_t __attr_const___
ecma_get_completion_value_type_field (ecma_completion_value_t completion_value) /**< completion value */ ecma_get_completion_value_type_field (ecma_completion_value_t completion_value) /**< completion value */
{ {
return (ecma_completion_type_t) jrt_extract_bit_field (completion_value, return (ecma_completion_type_t) jrt_extract_bit_field (completion_value,
@ -452,7 +452,7 @@ ecma_get_completion_value_type_field (ecma_completion_value_t completion_value)
* *
* @return value field * @return value field
*/ */
static ecma_value_t __attribute_const__ static ecma_value_t __attr_const___
ecma_get_completion_value_value_field (ecma_completion_value_t completion_value) /**< completion value */ ecma_get_completion_value_value_field (ecma_completion_value_t completion_value) /**< completion value */
{ {
return (ecma_value_t) jrt_extract_bit_field (completion_value, return (ecma_value_t) jrt_extract_bit_field (completion_value,
@ -465,7 +465,7 @@ ecma_get_completion_value_value_field (ecma_completion_value_t completion_value)
* *
* @return pointer to label descriptor * @return pointer to label descriptor
*/ */
static ecma_label_descriptor_t* __attribute_const__ static ecma_label_descriptor_t* __attr_const___
ecma_get_completion_value_label_descriptor (ecma_completion_value_t completion_value) /**< completion value */ ecma_get_completion_value_label_descriptor (ecma_completion_value_t completion_value) /**< completion value */
{ {
return ECMA_GET_NON_NULL_POINTER (ecma_label_descriptor_t, return ECMA_GET_NON_NULL_POINTER (ecma_label_descriptor_t,
@ -479,7 +479,7 @@ ecma_get_completion_value_label_descriptor (ecma_completion_value_t completion_v
* *
* @return completion value with updated field * @return completion value with updated field
*/ */
static ecma_completion_value_t __attribute_const__ static ecma_completion_value_t __attr_const___
ecma_set_completion_value_type_field (ecma_completion_value_t completion_value, /**< completion value ecma_set_completion_value_type_field (ecma_completion_value_t completion_value, /**< completion value
* to set field in */ * to set field in */
ecma_completion_type_t type_field) /**< new field value */ ecma_completion_type_t type_field) /**< new field value */
@ -495,7 +495,7 @@ ecma_set_completion_value_type_field (ecma_completion_value_t completion_value,
* *
* @return completion value with updated field * @return completion value with updated field
*/ */
static ecma_completion_value_t __attribute_pure__ static ecma_completion_value_t __attr_pure___
ecma_set_completion_value_value_field (ecma_completion_value_t completion_value, /**< completion value ecma_set_completion_value_value_field (ecma_completion_value_t completion_value, /**< completion value
* to set field in */ * to set field in */
const ecma_value_t& value_field) /**< new field value */ const ecma_value_t& value_field) /**< new field value */
@ -511,7 +511,7 @@ ecma_set_completion_value_value_field (ecma_completion_value_t completion_value,
* *
* @return completion value with updated field * @return completion value with updated field
*/ */
static ecma_completion_value_t __attribute_const__ static ecma_completion_value_t __attr_const___
ecma_set_completion_value_label_descriptor (ecma_completion_value_t completion_value, /**< completion value ecma_set_completion_value_label_descriptor (ecma_completion_value_t completion_value, /**< completion value
* to set field in */ * to set field in */
ecma_label_descriptor_t* label_desc_p) /**< pointer to the ecma_label_descriptor_t* label_desc_p) /**< pointer to the
@ -531,7 +531,7 @@ ecma_set_completion_value_label_descriptor (ecma_completion_value_t completion_v
* *
* @return completion value * @return completion value
*/ */
ecma_completion_value_t __attribute_pure__ __attribute_always_inline__ ecma_completion_value_t __attr_pure___ __attr_always_inline___
ecma_make_completion_value (ecma_completion_type_t type, /**< type */ ecma_make_completion_value (ecma_completion_type_t type, /**< type */
const ecma_value_t& value) /**< value */ const ecma_value_t& value) /**< value */
{ {
@ -559,7 +559,7 @@ ecma_make_completion_value (ecma_completion_type_t type, /**< type */
* *
* @return completion value * @return completion value
*/ */
ecma_completion_value_t __attribute_const__ ecma_completion_value_t __attr_const___
ecma_make_label_completion_value (ecma_completion_type_t type, /**< type */ ecma_make_label_completion_value (ecma_completion_type_t type, /**< type */
uint8_t depth_level, /**< depth level (in try constructions, uint8_t depth_level, /**< depth level (in try constructions,
with blocks, etc.) */ with blocks, etc.) */
@ -587,7 +587,7 @@ ecma_make_label_completion_value (ecma_completion_type_t type, /**< type */
* *
* @return completion value * @return completion value
*/ */
ecma_completion_value_t __attribute_const__ __attribute_always_inline__ ecma_completion_value_t __attr_const___ __attr_always_inline___
ecma_make_simple_completion_value (ecma_simple_value_t simple_value) /**< simple ecma-value */ ecma_make_simple_completion_value (ecma_simple_value_t simple_value) /**< simple ecma-value */
{ {
JERRY_ASSERT(simple_value == ECMA_SIMPLE_VALUE_UNDEFINED JERRY_ASSERT(simple_value == ECMA_SIMPLE_VALUE_UNDEFINED
@ -604,7 +604,7 @@ ecma_make_simple_completion_value (ecma_simple_value_t simple_value) /**< simple
* *
* @return completion value * @return completion value
*/ */
ecma_completion_value_t __attribute_pure__ __attribute_always_inline__ ecma_completion_value_t __attr_pure___ __attr_always_inline___
ecma_make_normal_completion_value (const ecma_value_t& value) /**< value */ ecma_make_normal_completion_value (const ecma_value_t& value) /**< value */
{ {
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, value); return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, value);
@ -615,7 +615,7 @@ ecma_make_normal_completion_value (const ecma_value_t& value) /**< value */
* *
* @return completion value * @return completion value
*/ */
ecma_completion_value_t __attribute_pure__ __attribute_always_inline__ ecma_completion_value_t __attr_pure___ __attr_always_inline___
ecma_make_throw_completion_value (const ecma_value_t& value) /**< value */ ecma_make_throw_completion_value (const ecma_value_t& value) /**< value */
{ {
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_THROW, value); return ecma_make_completion_value (ECMA_COMPLETION_TYPE_THROW, value);
@ -626,7 +626,7 @@ ecma_make_throw_completion_value (const ecma_value_t& value) /**< value */
* *
* @return 'throw' completion value * @return 'throw' completion value
*/ */
ecma_completion_value_t __attribute_const__ ecma_completion_value_t __attr_const___
ecma_make_throw_obj_completion_value (ecma_object_t *exception_p) /**< an object */ ecma_make_throw_obj_completion_value (ecma_object_t *exception_p) /**< an object */
{ {
JERRY_ASSERT(exception_p != NULL JERRY_ASSERT(exception_p != NULL
@ -642,7 +642,7 @@ ecma_make_throw_obj_completion_value (ecma_object_t *exception_p) /**< an object
* *
* @return (normal, empty, reserved) completion value. * @return (normal, empty, reserved) completion value.
*/ */
ecma_completion_value_t __attribute_const__ __attribute_always_inline__ ecma_completion_value_t __attr_const___ __attr_always_inline___
ecma_make_empty_completion_value (void) ecma_make_empty_completion_value (void)
{ {
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
@ -654,7 +654,7 @@ ecma_make_empty_completion_value (void)
* *
* @return completion value * @return completion value
*/ */
ecma_completion_value_t __attribute_pure__ __attribute_always_inline__ ecma_completion_value_t __attr_pure___ __attr_always_inline___
ecma_make_return_completion_value (const ecma_value_t& value) /**< value */ ecma_make_return_completion_value (const ecma_value_t& value) /**< value */
{ {
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_RETURN, value); return ecma_make_completion_value (ECMA_COMPLETION_TYPE_RETURN, value);
@ -665,7 +665,7 @@ ecma_make_return_completion_value (const ecma_value_t& value) /**< value */
* *
* @return completion value * @return completion value
*/ */
ecma_completion_value_t __attribute_const__ __attribute_always_inline__ ecma_completion_value_t __attr_const___ __attr_always_inline___
ecma_make_exit_completion_value (bool is_successful) /**< does completion value indicate ecma_make_exit_completion_value (bool is_successful) /**< does completion value indicate
successfulness completion successfulness completion
of script execution (true) or not (false) */ of script execution (true) or not (false) */
@ -680,7 +680,7 @@ ecma_make_exit_completion_value (bool is_successful) /**< does completion value
* *
* @return completion value * @return completion value
*/ */
ecma_completion_value_t __attribute_const__ __attribute_always_inline__ ecma_completion_value_t __attr_const___ __attr_always_inline___
ecma_make_meta_completion_value (void) ecma_make_meta_completion_value (void)
{ {
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_META, return ecma_make_completion_value (ECMA_COMPLETION_TYPE_META,
@ -692,7 +692,7 @@ ecma_make_meta_completion_value (void)
* *
* @return ecma-value * @return ecma-value
*/ */
ecma_value_t __attribute_const__ __attribute_always_inline__ ecma_value_t __attr_const___ __attr_always_inline___
ecma_get_completion_value_value (ecma_completion_value_t completion_value) /**< completion value */ ecma_get_completion_value_value (ecma_completion_value_t completion_value) /**< completion value */
{ {
const ecma_completion_type_t type = ecma_get_completion_value_type_field (completion_value); const ecma_completion_type_t type = ecma_get_completion_value_type_field (completion_value);
@ -712,7 +712,7 @@ ecma_get_completion_value_value (ecma_completion_value_t completion_value) /**<
* *
* @return pointer * @return pointer
*/ */
ecma_number_t* __attribute_const__ ecma_number_t* __attr_const___
ecma_get_number_from_completion_value (ecma_completion_value_t completion_value) /**< completion value */ ecma_get_number_from_completion_value (ecma_completion_value_t completion_value) /**< completion value */
{ {
return ecma_get_number_from_value (ecma_get_completion_value_value (completion_value)); return ecma_get_number_from_value (ecma_get_completion_value_value (completion_value));
@ -723,7 +723,7 @@ ecma_get_number_from_completion_value (ecma_completion_value_t completion_value)
* *
* @return pointer * @return pointer
*/ */
ecma_string_t* __attribute_const__ ecma_string_t* __attr_const___
ecma_get_string_from_completion_value (ecma_completion_value_t completion_value) /**< completion value */ ecma_get_string_from_completion_value (ecma_completion_value_t completion_value) /**< completion value */
{ {
return ecma_get_string_from_value (ecma_get_completion_value_value (completion_value)); return ecma_get_string_from_value (ecma_get_completion_value_value (completion_value));
@ -734,7 +734,7 @@ ecma_get_string_from_completion_value (ecma_completion_value_t completion_value)
* *
* @return pointer * @return pointer
*/ */
ecma_object_t* __attribute_const__ ecma_object_t* __attr_const___
ecma_get_object_from_completion_value (ecma_completion_value_t completion_value) /**< completion value */ ecma_get_object_from_completion_value (ecma_completion_value_t completion_value) /**< completion value */
{ {
return ecma_get_object_from_value (ecma_get_completion_value_value (completion_value)); return ecma_get_object_from_value (ecma_get_completion_value_value (completion_value));
@ -802,7 +802,7 @@ ecma_free_completion_value (ecma_completion_value_t completion_value) /**< compl
* @return true - if the completion type is normal, * @return true - if the completion type is normal,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_normal (ecma_completion_value_t value) /**< completion value */ ecma_is_completion_value_normal (ecma_completion_value_t value) /**< completion value */
{ {
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_NORMAL); return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_NORMAL);
@ -814,7 +814,7 @@ ecma_is_completion_value_normal (ecma_completion_value_t value) /**< completion
* @return true - if the completion type is throw, * @return true - if the completion type is throw,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_throw (ecma_completion_value_t value) /**< completion value */ ecma_is_completion_value_throw (ecma_completion_value_t value) /**< completion value */
{ {
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_THROW); return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_THROW);
@ -826,7 +826,7 @@ ecma_is_completion_value_throw (ecma_completion_value_t value) /**< completion v
* @return true - if the completion type is return, * @return true - if the completion type is return,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_return (ecma_completion_value_t value) /**< completion value */ ecma_is_completion_value_return (ecma_completion_value_t value) /**< completion value */
{ {
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_RETURN); return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_RETURN);
@ -838,7 +838,7 @@ ecma_is_completion_value_return (ecma_completion_value_t value) /**< completion
* @return true - if the completion type is exit, * @return true - if the completion type is exit,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_exit (ecma_completion_value_t value) /**< completion value */ ecma_is_completion_value_exit (ecma_completion_value_t value) /**< completion value */
{ {
if (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_EXIT) if (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_EXIT)
@ -859,7 +859,7 @@ ecma_is_completion_value_exit (ecma_completion_value_t value) /**< completion va
* @return true - if the completion type is meta, * @return true - if the completion type is meta,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_meta (ecma_completion_value_t value) /**< completion value */ ecma_is_completion_value_meta (ecma_completion_value_t value) /**< completion value */
{ {
if (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_META) if (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_META)
@ -880,7 +880,7 @@ ecma_is_completion_value_meta (ecma_completion_value_t value) /**< completion va
* @return true - if the completion type is break, * @return true - if the completion type is break,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_break (ecma_completion_value_t value) /**< completion value */ ecma_is_completion_value_break (ecma_completion_value_t value) /**< completion value */
{ {
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_BREAK); return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_BREAK);
@ -892,7 +892,7 @@ ecma_is_completion_value_break (ecma_completion_value_t value) /**< completion v
* @return true - if the completion type is continue, * @return true - if the completion type is continue,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_continue (ecma_completion_value_t value) /**< completion value */ ecma_is_completion_value_continue (ecma_completion_value_t value) /**< completion value */
{ {
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_CONTINUE); return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_CONTINUE);
@ -905,7 +905,7 @@ ecma_is_completion_value_continue (ecma_completion_value_t value) /**< completio
* value contains specified simple ecma-value, * value contains specified simple ecma-value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value, /**< completion value */ ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value, /**< completion value */
ecma_simple_value_t simple_value) /**< simple value to check ecma_simple_value_t simple_value) /**< simple value to check
for equality with */ for equality with */
@ -920,7 +920,7 @@ ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value, /**
* value contains ecma-true simple value, * value contains ecma-true simple value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_normal_true (ecma_completion_value_t value) /**< completion value */ ecma_is_completion_value_normal_true (ecma_completion_value_t value) /**< completion value */
{ {
return ecma_is_completion_value_normal_simple_value (value, ECMA_SIMPLE_VALUE_TRUE); return ecma_is_completion_value_normal_simple_value (value, ECMA_SIMPLE_VALUE_TRUE);
@ -933,7 +933,7 @@ ecma_is_completion_value_normal_true (ecma_completion_value_t value) /**< comple
* value contains ecma-false simple value, * value contains ecma-false simple value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_normal_false (ecma_completion_value_t value) /**< completion value */ ecma_is_completion_value_normal_false (ecma_completion_value_t value) /**< completion value */
{ {
return ecma_is_completion_value_normal_simple_value (value, ECMA_SIMPLE_VALUE_FALSE); return ecma_is_completion_value_normal_simple_value (value, ECMA_SIMPLE_VALUE_FALSE);
@ -946,7 +946,7 @@ ecma_is_completion_value_normal_false (ecma_completion_value_t value) /**< compl
* value contains empty simple value, * value contains empty simple value,
* false - otherwise. * false - otherwise.
*/ */
bool __attribute_const__ __attribute_always_inline__ bool __attr_const___ __attr_always_inline___
ecma_is_completion_value_empty (ecma_completion_value_t value) /**< completion value */ ecma_is_completion_value_empty (ecma_completion_value_t value) /**< completion value */
{ {
return (ecma_is_completion_value_normal (value) return (ecma_is_completion_value_normal (value)

View File

@ -186,7 +186,7 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
/** /**
* Check if the object is lexical environment. * Check if the object is lexical environment.
*/ */
bool __attribute_pure__ bool __attr_pure___
ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexical environment */ ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@ -199,7 +199,7 @@ ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexic
/** /**
* Get value of [[Extensible]] object's internal property. * Get value of [[Extensible]] object's internal property.
*/ */
bool __attribute_pure__ bool __attr_pure___
ecma_get_object_extensible (const ecma_object_t *object_p) /**< object */ ecma_get_object_extensible (const ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@ -229,7 +229,7 @@ ecma_set_object_extensible (ecma_object_t *object_p, /**< object */
/** /**
* Get object's internal implementation-defined type. * Get object's internal implementation-defined type.
*/ */
ecma_object_type_t __attribute_pure__ ecma_object_type_t __attr_pure___
ecma_get_object_type (const ecma_object_t *object_p) /**< object */ ecma_get_object_type (const ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@ -259,7 +259,7 @@ ecma_set_object_type (ecma_object_t *object_p, /**< object */
/** /**
* Get object's prototype. * Get object's prototype.
*/ */
ecma_object_t* __attribute_pure__ ecma_object_t* __attr_pure___
ecma_get_object_prototype (const ecma_object_t *object_p) /**< object */ ecma_get_object_prototype (const ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@ -278,7 +278,7 @@ ecma_get_object_prototype (const ecma_object_t *object_p) /**< object */
* *
* @return true / false * @return true / false
*/ */
bool __attribute_pure__ bool __attr_pure___
ecma_get_object_is_builtin (const ecma_object_t *object_p) /**< object */ ecma_get_object_is_builtin (const ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@ -318,7 +318,7 @@ ecma_set_object_is_builtin (ecma_object_t *object_p, /**< object */
/** /**
* Get type of lexical environment. * Get type of lexical environment.
*/ */
ecma_lexical_environment_type_t __attribute_pure__ ecma_lexical_environment_type_t __attr_pure___
ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment */ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@ -332,7 +332,7 @@ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment *
/** /**
* Get outer reference of lexical environment. * Get outer reference of lexical environment.
*/ */
ecma_object_t* __attribute_pure__ ecma_object_t* __attr_pure___
ecma_get_lex_env_outer_reference (const ecma_object_t *object_p) /**< lexical environment */ ecma_get_lex_env_outer_reference (const ecma_object_t *object_p) /**< lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@ -349,7 +349,7 @@ ecma_get_lex_env_outer_reference (const ecma_object_t *object_p) /**< lexical en
/** /**
* Get object's/lexical environment's property list. * Get object's/lexical environment's property list.
*/ */
ecma_property_t* __attribute_pure__ ecma_property_t* __attr_pure___
ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical environment */ ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@ -387,7 +387,7 @@ ecma_set_property_list (ecma_object_t *object_p, /**< object or lexical environm
/** /**
* Get lexical environment's 'provideThis' property * Get lexical environment's 'provideThis' property
*/ */
bool __attribute_pure__ bool __attr_pure___
ecma_get_lex_env_provide_this (const ecma_object_t *object_p) /**< object-bound lexical environment */ ecma_get_lex_env_provide_this (const ecma_object_t *object_p) /**< object-bound lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@ -405,7 +405,7 @@ ecma_get_lex_env_provide_this (const ecma_object_t *object_p) /**< object-bound
/** /**
* Get lexical environment's bound object. * Get lexical environment's bound object.
*/ */
ecma_object_t* __attribute_pure__ ecma_object_t* __attr_pure___
ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */ ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);

View File

@ -77,9 +77,9 @@ extern ecma_value_t ecma_make_simple_value (ecma_simple_value_t value);
extern ecma_value_t ecma_make_number_value (ecma_number_t* num_p); extern ecma_value_t ecma_make_number_value (ecma_number_t* num_p);
extern ecma_value_t ecma_make_string_value (ecma_string_t* ecma_string_p); extern ecma_value_t ecma_make_string_value (ecma_string_t* ecma_string_p);
extern ecma_value_t ecma_make_object_value (ecma_object_t* object_p); extern ecma_value_t ecma_make_object_value (ecma_object_t* object_p);
extern ecma_number_t* __attribute_pure__ ecma_get_number_from_value (const ecma_value_t& value); extern ecma_number_t* __attr_pure___ ecma_get_number_from_value (const ecma_value_t& value);
extern ecma_string_t* __attribute_pure__ ecma_get_string_from_value (const ecma_value_t& value); extern ecma_string_t* __attr_pure___ ecma_get_string_from_value (const ecma_value_t& value);
extern ecma_object_t* __attribute_pure__ ecma_get_object_from_value (const ecma_value_t& value); extern ecma_object_t* __attr_pure___ ecma_get_object_from_value (const ecma_value_t& value);
extern ecma_value_t ecma_copy_value (const ecma_value_t& value, bool do_ref_if_object); extern ecma_value_t ecma_copy_value (const ecma_value_t& value, bool do_ref_if_object);
extern void ecma_free_value (ecma_value_t& value, bool do_deref_if_object); extern void ecma_free_value (ecma_value_t& value, bool do_deref_if_object);
@ -97,11 +97,11 @@ extern ecma_completion_value_t ecma_make_return_completion_value (const ecma_val
extern ecma_completion_value_t ecma_make_exit_completion_value (bool is_successful); extern ecma_completion_value_t ecma_make_exit_completion_value (bool is_successful);
extern ecma_completion_value_t ecma_make_meta_completion_value (void); extern ecma_completion_value_t ecma_make_meta_completion_value (void);
extern ecma_value_t ecma_get_completion_value_value (ecma_completion_value_t completion_value); extern ecma_value_t ecma_get_completion_value_value (ecma_completion_value_t completion_value);
extern ecma_number_t* __attribute_const__ extern ecma_number_t* __attr_const___
ecma_get_number_from_completion_value (ecma_completion_value_t completion_value); ecma_get_number_from_completion_value (ecma_completion_value_t completion_value);
extern ecma_string_t* __attribute_const__ extern ecma_string_t* __attr_const___
ecma_get_string_from_completion_value (ecma_completion_value_t completion_value); ecma_get_string_from_completion_value (ecma_completion_value_t completion_value);
extern ecma_object_t* __attribute_const__ extern ecma_object_t* __attr_const___
ecma_get_object_from_completion_value (ecma_completion_value_t completion_value); ecma_get_object_from_completion_value (ecma_completion_value_t completion_value);
extern ecma_completion_value_t ecma_copy_completion_value (ecma_completion_value_t value); extern ecma_completion_value_t ecma_copy_completion_value (ecma_completion_value_t value);
extern void ecma_free_completion_value (ecma_completion_value_t completion_value); extern void ecma_free_completion_value (ecma_completion_value_t completion_value);
@ -230,20 +230,20 @@ extern ecma_object_t* ecma_create_decl_lex_env (ecma_object_t *outer_lexical_env
extern ecma_object_t* ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, extern ecma_object_t* ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p,
ecma_object_t *binding_obj_p, ecma_object_t *binding_obj_p,
bool provide_this); bool provide_this);
extern bool __attribute_pure__ ecma_is_lexical_environment (const ecma_object_t *object_p); extern bool __attr_pure___ ecma_is_lexical_environment (const ecma_object_t *object_p);
extern bool __attribute_pure__ ecma_get_object_extensible (const ecma_object_t *object_p); extern bool __attr_pure___ ecma_get_object_extensible (const ecma_object_t *object_p);
extern void ecma_set_object_extensible (ecma_object_t *object_p, bool is_extensible); extern void ecma_set_object_extensible (ecma_object_t *object_p, bool is_extensible);
extern ecma_object_type_t __attribute_pure__ ecma_get_object_type (const ecma_object_t *object_p); extern ecma_object_type_t __attr_pure___ ecma_get_object_type (const ecma_object_t *object_p);
extern void ecma_set_object_type (ecma_object_t *object_p, ecma_object_type_t type); extern void ecma_set_object_type (ecma_object_t *object_p, ecma_object_type_t type);
extern ecma_object_t* __attribute_pure__ ecma_get_object_prototype (const ecma_object_t *object_p); extern ecma_object_t* __attr_pure___ ecma_get_object_prototype (const ecma_object_t *object_p);
extern bool __attribute_pure__ ecma_get_object_is_builtin (const ecma_object_t *object_p); extern bool __attr_pure___ ecma_get_object_is_builtin (const ecma_object_t *object_p);
extern void ecma_set_object_is_builtin (ecma_object_t *object_p, extern void ecma_set_object_is_builtin (ecma_object_t *object_p,
bool is_builtin); bool is_builtin);
extern ecma_lexical_environment_type_t __attribute_pure__ ecma_get_lex_env_type (const ecma_object_t *object_p); extern ecma_lexical_environment_type_t __attr_pure___ ecma_get_lex_env_type (const ecma_object_t *object_p);
extern ecma_object_t* __attribute_pure__ ecma_get_lex_env_outer_reference (const ecma_object_t *object_p); extern ecma_object_t* __attr_pure___ ecma_get_lex_env_outer_reference (const ecma_object_t *object_p);
extern ecma_property_t* __attribute_pure__ ecma_get_property_list (const ecma_object_t *object_p); extern ecma_property_t* __attr_pure___ ecma_get_property_list (const ecma_object_t *object_p);
extern ecma_object_t* __attribute_pure__ ecma_get_lex_env_binding_object (const ecma_object_t *object_p); extern ecma_object_t* __attr_pure___ ecma_get_lex_env_binding_object (const ecma_object_t *object_p);
extern bool __attribute_pure__ ecma_get_lex_env_provide_this (const ecma_object_t *object_p); extern bool __attr_pure___ ecma_get_lex_env_provide_this (const ecma_object_t *object_p);
extern ecma_property_t* ecma_create_internal_property (ecma_object_t *object_p, extern ecma_property_t* ecma_create_internal_property (ecma_object_t *object_p,
ecma_internal_property_id_t property_id); ecma_internal_property_id_t property_id);

View File

@ -17,7 +17,7 @@
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-lcache.h" #include "ecma-lcache.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
@ -218,7 +218,7 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
* @return true - if (object, property name) pair is registered in LCache, * @return true - if (object, property name) pair is registered in LCache,
* false - probably, not registered. * false - probably, not registered.
*/ */
bool __attribute_always_inline__ bool __attr_always_inline___
ecma_lcache_lookup (ecma_object_t *object_p, /**< object */ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
const ecma_string_t *prop_name_p, /**< property's name */ const ecma_string_t *prop_name_p, /**< property's name */
ecma_property_t **prop_p_p) /**< out: if return value is true, ecma_property_t **prop_p_p) /**< out: if return value is true,

View File

@ -160,7 +160,7 @@ ecma_stack_slots_in_top_chunk (ecma_stack_frame_t *frame_p) /**< ecma-stack fram
/** /**
* Longpath for ecma_stack_push_value (for case current chunk may be doesn't have free slots) * Longpath for ecma_stack_push_value (for case current chunk may be doesn't have free slots)
*/ */
static void __noinline static void __attr_noinline___
ecma_stack_push_value_longpath (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */ ecma_stack_push_value_longpath (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */
{ {
JERRY_ASSERT (frame_p->current_slot_index >= JERRY_MIN (ECMA_STACK_FRAME_INLINED_VALUES_NUMBER, JERRY_ASSERT (frame_p->current_slot_index >= JERRY_MIN (ECMA_STACK_FRAME_INLINED_VALUES_NUMBER,
@ -205,7 +205,7 @@ ecma_stack_push_value (ecma_stack_frame_t *frame_p, /**< ecma-stack frame */
/** /**
* Get top value from ecma-stack * Get top value from ecma-stack
*/ */
ecma_value_t __attribute_always_inline__ ecma_value_t __attr_always_inline___
ecma_stack_top_value (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */ ecma_stack_top_value (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */
{ {
const size_t slots_in_top_chunk = ecma_stack_slots_in_top_chunk (frame_p); const size_t slots_in_top_chunk = ecma_stack_slots_in_top_chunk (frame_p);
@ -218,7 +218,7 @@ ecma_stack_top_value (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */
/** /**
* Longpath for ecma_stack_pop (for case a dynamically allocated chunk needs to be deallocated) * Longpath for ecma_stack_pop (for case a dynamically allocated chunk needs to be deallocated)
*/ */
static void __noinline static void __attr_noinline___
ecma_stack_pop_longpath (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */ ecma_stack_pop_longpath (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */
{ {
JERRY_ASSERT (frame_p->current_slot_index == 0 && frame_p->top_chunk_p != NULL); JERRY_ASSERT (frame_p->current_slot_index == 0 && frame_p->top_chunk_p != NULL);

View File

@ -54,7 +54,7 @@
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_array_object_is_array (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_array_object_is_array (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t& arg) /**< first argument */ const ecma_value_t& arg) /**< first argument */
{ {
ecma_simple_value_t is_array = ECMA_SIMPLE_VALUE_FALSE; ecma_simple_value_t is_array = ECMA_SIMPLE_VALUE_FALSE;

View File

@ -98,7 +98,7 @@ ecma_builtin_global_object_parse_float (const ecma_value_t& this_arg, /**< this
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_global_object_is_nan (const ecma_value_t& this_arg __unused, /**< this argument */ ecma_builtin_global_object_is_nan (const ecma_value_t& this_arg __attr_unused___, /**< this argument */
const ecma_value_t& arg) /**< routine's first argument */ const ecma_value_t& arg) /**< routine's first argument */
{ {
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@ -125,7 +125,7 @@ ecma_builtin_global_object_is_nan (const ecma_value_t& this_arg __unused, /**< t
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_global_object_is_finite (const ecma_value_t& this_arg __unused, /**< this argument */ ecma_builtin_global_object_is_finite (const ecma_value_t& this_arg __attr_unused___, /**< this argument */
const ecma_value_t& arg) /**< routine's first argument */ const ecma_value_t& arg) /**< routine's first argument */
{ {
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();

View File

@ -55,7 +55,7 @@
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_abs (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_math_object_abs (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t& arg) /**< routine's argument */ const ecma_value_t& arg) /**< routine's argument */
{ {
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@ -171,7 +171,7 @@ ecma_builtin_math_object_ceil (const ecma_value_t& this_arg, /**< 'this' argumen
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_cos (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_math_object_cos (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t& arg) /**< routine's argument */ const ecma_value_t& arg) /**< routine's argument */
{ {
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@ -239,7 +239,7 @@ ecma_builtin_math_object_cos (const ecma_value_t& this_arg __unused, /**< 'this'
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_exp (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_math_object_exp (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t& arg) /**< routine's argument */ const ecma_value_t& arg) /**< routine's argument */
{ {
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@ -305,7 +305,7 @@ ecma_builtin_math_object_floor (const ecma_value_t& this_arg, /**< 'this' argume
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_log (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_math_object_log (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t& arg) /**< routine's argument */ const ecma_value_t& arg) /**< routine's argument */
{ {
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@ -352,7 +352,7 @@ ecma_builtin_math_object_log (const ecma_value_t& this_arg __unused, /**< 'this'
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_max (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_math_object_max (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t args[], /**< arguments list */ const ecma_value_t args[], /**< arguments list */
ecma_length_t args_number) /**< number of arguments */ ecma_length_t args_number) /**< number of arguments */
{ {
@ -439,7 +439,7 @@ ecma_builtin_math_object_max (const ecma_value_t& this_arg __unused, /**< 'this'
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_min (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_math_object_min (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t args[], /**< arguments list */ const ecma_value_t args[], /**< arguments list */
ecma_length_t args_number) /**< number of arguments */ ecma_length_t args_number) /**< number of arguments */
{ {
@ -526,7 +526,7 @@ ecma_builtin_math_object_min (const ecma_value_t& this_arg __unused, /**< 'this'
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_pow (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_math_object_pow (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t& arg1, /**< first routine's argument */ const ecma_value_t& arg1, /**< first routine's argument */
const ecma_value_t& arg2) /**< second routine's argument */ const ecma_value_t& arg2) /**< second routine's argument */
{ {
@ -760,7 +760,7 @@ ecma_builtin_math_object_pow (const ecma_value_t& this_arg __unused, /**< 'this'
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_random (const ecma_value_t& this_arg __unused) /**< 'this' argument */ ecma_builtin_math_object_random (const ecma_value_t& this_arg __attr_unused___) /**< 'this' argument */
{ {
/* Implementation of George Marsaglia's XorShift random number generator */ /* Implementation of George Marsaglia's XorShift random number generator */
TODO (/* Check for license issues */); TODO (/* Check for license issues */);
@ -801,7 +801,7 @@ ecma_builtin_math_object_random (const ecma_value_t& this_arg __unused) /**< 'th
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_round (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_math_object_round (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t& arg) /**< routine's argument */ const ecma_value_t& arg) /**< routine's argument */
{ {
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@ -855,7 +855,7 @@ ecma_builtin_math_object_round (const ecma_value_t& this_arg __unused, /**< 'thi
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_sin (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_math_object_sin (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t& arg) /**< routine's argument */ const ecma_value_t& arg) /**< routine's argument */
{ {
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@ -923,7 +923,7 @@ ecma_builtin_math_object_sin (const ecma_value_t& this_arg __unused, /**< 'this'
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_math_object_sqrt (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_math_object_sqrt (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t& arg) /**< routine's argument */ const ecma_value_t& arg) /**< routine's argument */
{ {
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();

View File

@ -306,7 +306,7 @@ ecma_builtin_object_object_define_properties (const ecma_value_t& this_arg, /**<
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_object_object_define_property (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_object_object_define_property (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t& arg1, /**< routine's first argument */ const ecma_value_t& arg1, /**< routine's first argument */
const ecma_value_t& arg2, /**< routine's second argument */ const ecma_value_t& arg2, /**< routine's second argument */
const ecma_value_t& arg3) /**< routine's third argument */ const ecma_value_t& arg3) /**< routine's third argument */

View File

@ -54,7 +54,7 @@
* Returned value must be freed with ecma_free_completion_value. * Returned value must be freed with ecma_free_completion_value.
*/ */
static ecma_completion_value_t static ecma_completion_value_t
ecma_builtin_string_object_from_char_code (const ecma_value_t& this_arg __unused, /**< 'this' argument */ ecma_builtin_string_object_from_char_code (const ecma_value_t& this_arg __attr_unused___, /**< 'this' argument */
const ecma_value_t args[], /**< arguments list */ const ecma_value_t args[], /**< arguments list */
ecma_length_t args_number) /**< number of arguments */ ecma_length_t args_number) /**< number of arguments */
{ {

View File

@ -30,7 +30,7 @@
#include "ecma-objects-general.h" #include "ecma-objects-general.h"
#include "ecma-string-object.h" #include "ecma-string-object.h"
#include "ecma-try-catch-macro.h" #include "ecma-try-catch-macro.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{

View File

@ -44,7 +44,7 @@ ecma_pack_code_internal_property_value (bool is_strict, /**< is code strict? */
opcode_counter_t opcode_idx) /**< index of first opcode */ opcode_counter_t opcode_idx) /**< index of first opcode */
{ {
uint32_t value = opcode_idx; uint32_t value = opcode_idx;
const uint32_t is_strict_bit_offset = sizeof (value) * JERRY_BITSINBYTE - 1; const uint32_t is_strict_bit_offset = (uint32_t) (sizeof (value) * JERRY_BITSINBYTE - 1);
JERRY_ASSERT(((value) & (1u << is_strict_bit_offset)) == 0); JERRY_ASSERT(((value) & (1u << is_strict_bit_offset)) == 0);
@ -68,7 +68,7 @@ ecma_unpack_code_internal_property_value (uint32_t value, /**< packed value */
{ {
JERRY_ASSERT(out_is_strict_p != NULL); JERRY_ASSERT(out_is_strict_p != NULL);
const uint32_t is_strict_bit_offset = sizeof (value) * JERRY_BITSINBYTE - 1; const uint32_t is_strict_bit_offset = (uint32_t) (sizeof (value) * JERRY_BITSINBYTE - 1);
bool is_strict = ((value & (1u << is_strict_bit_offset)) != 0); bool is_strict = ((value & (1u << is_strict_bit_offset)) != 0);
*out_is_strict_p = is_strict; *out_is_strict_p = is_strict;

View File

@ -83,7 +83,7 @@ ecma_op_object_get (ecma_object_t *obj_p, /**< the object */
* @return pointer to a property - if it exists, * @return pointer to a property - if it exists,
* NULL (i.e. ecma-undefined) - otherwise. * NULL (i.e. ecma-undefined) - otherwise.
*/ */
static __noinline ecma_property_t* static __attr_noinline___ ecma_property_t*
ecma_op_object_get_own_property_longpath (ecma_object_t *obj_p, /**< the object */ ecma_op_object_get_own_property_longpath (ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */ ecma_string_t *property_name_p) /**< property name */
{ {

View File

@ -39,7 +39,7 @@
{ \ { \
JERRY_ASSERT(ecma_is_completion_value_normal (var ## _completion)); \ JERRY_ASSERT(ecma_is_completion_value_normal (var ## _completion)); \
\ \
ecma_value_t var __unused = ecma_get_completion_value_value (var ## _completion) ecma_value_t var __attr_unused___ = ecma_get_completion_value_value (var ## _completion)
/** /**
* The macro marks end of code block that is defined by corresponding * The macro marks end of code block that is defined by corresponding

View File

@ -16,7 +16,8 @@
#ifndef JERRY_H #ifndef JERRY_H
#define JERRY_H #define JERRY_H
#include "jrt_types.h" #include <stddef.h>
#include <stdint.h>
/** \addtogroup jerry Jerry engine interface /** \addtogroup jerry Jerry engine interface
* @{ * @{

View File

@ -21,7 +21,7 @@
* *
* @return bit-field's value * @return bit-field's value
*/ */
uint64_t __attribute_const__ uint64_t __attr_const___
jrt_extract_bit_field (uint64_t container, /**< container to extract bit-field from */ jrt_extract_bit_field (uint64_t container, /**< container to extract bit-field from */
uint32_t lsb, /**< least significant bit of the value uint32_t lsb, /**< least significant bit of the value
* to be extracted */ * to be extracted */
@ -42,7 +42,7 @@ jrt_extract_bit_field (uint64_t container, /**< container to extract bit-field f
* *
* @return bit-field's value * @return bit-field's value
*/ */
uint64_t __attribute_const__ uint64_t __attr_const___
jrt_set_bit_field_value (uint64_t container, /**< container to insert bit-field to */ jrt_set_bit_field_value (uint64_t container, /**< container to insert bit-field to */
uint64_t new_bit_field_value, /**< value of bit-field to insert */ uint64_t new_bit_field_value, /**< value of bit-field to insert */
uint32_t lsb, /**< least significant bit of the value uint32_t lsb, /**< least significant bit of the value

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd. /* Copyright 2014-2015 Samsung Electronics Co., Ltd.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,9 @@
#ifndef JERRY_BIT_FIELDS_H #ifndef JERRY_BIT_FIELDS_H
#define JERRY_BIT_FIELDS_H #define JERRY_BIT_FIELDS_H
extern uint64_t __attribute_const__ jrt_extract_bit_field (uint64_t value, uint32_t lsb, extern uint64_t __attr_const___ jrt_extract_bit_field (uint64_t value, uint32_t lsb,
uint32_t width); uint32_t width);
extern uint64_t __attribute_const__ jrt_set_bit_field_value (uint64_t value, uint64_t bit_field_value, extern uint64_t __attr_const___ jrt_set_bit_field_value (uint64_t value, uint64_t bit_field_value,
uint32_t lsb, uint32_t width); uint32_t lsb, uint32_t width);
#endif /* !JERRY_BIT_FIELDS_H */ #endif /* !JERRY_BIT_FIELDS_H */

View File

@ -18,7 +18,7 @@
*/ */
#include "jrt.h" #include "jrt.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
/* /*
* Exit with specified status code. * Exit with specified status code.
@ -75,8 +75,8 @@ jerry_assert_fail (const char *assertion, /**< assertion condition string */
const uint32_t line) /** line */ const uint32_t line) /** line */
{ {
#ifndef JERRY_NDEBUG #ifndef JERRY_NDEBUG
printf ("ICE: Assertion '%s' failed at %s(%s):%u.\n", printf ("ICE: Assertion '%s' failed at %s(%s):%lu.\n",
assertion, file, function, line); assertion, file, function, (unsigned long) line);
#else /* !JERRY_NDEBUG */ #else /* !JERRY_NDEBUG */
(void) assertion; (void) assertion;
(void) file; (void) file;
@ -98,7 +98,7 @@ jerry_unreachable (const char *comment, /**< comment to unreachable mark if exis
const uint32_t line) /**< line */ const uint32_t line) /**< line */
{ {
#ifndef JERRY_NDEBUG #ifndef JERRY_NDEBUG
printf ("ICE: Unreachable control path at %s(%s):%u was executed", file, function, line); printf ("ICE: Unreachable control path at %s(%s):%lu was executed", file, function, (unsigned long) line);
#else /* !JERRY_NDEBUG */ #else /* !JERRY_NDEBUG */
(void) file; (void) file;
(void) function; (void) function;
@ -125,7 +125,7 @@ jerry_unimplemented (const char *comment, /**< comment to unimplemented mark if
const uint32_t line) /**< line */ const uint32_t line) /**< line */
{ {
#ifndef JERRY_NDEBUG #ifndef JERRY_NDEBUG
printf ("SORRY: Unimplemented case at %s(%s):%u was executed", file, function, line); printf ("SORRY: Unimplemented case at %s(%s):%lu was executed", file, function, (unsigned long) line);
#else /* !JERRY_NDEBUG */ #else /* !JERRY_NDEBUG */
(void) file; (void) file;
(void) function; (void) function;

View File

@ -0,0 +1,53 @@
/* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Ensuring no macro implementation of functions declared in the headers are used */
#undef isspace
#undef isalpha
#undef islower
#undef isupper
#undef isdigit
#undef isxdigit
#undef memset
#undef memcmp
#undef memcpy
#undef memmove
#undef strcmp
#undef strncmp
#undef strncpy
#undef strlen
#undef putchar
#undef puts
#undef exit
#undef fopen
#undef rewind
#undef fclose
#undef fseek
#undef ftell
#undef fread
#undef fwrite
#undef vfprintf
#undef fprintf
#undef printf
#endif /* !JRT_LIBC_INCLUDES_H */

View File

@ -22,33 +22,27 @@
/** /**
* Attributes * Attributes
*/ */
#define __unused __attribute__((unused)) #define __attr_unused___ __attribute__((unused))
#define __used __attribute__((used)) #define __attr_used___ __attribute__((used))
#define __packed __attribute__((packed)) #define __attr_packed___ __attribute__((packed))
#define __noreturn __attribute__((noreturn)) #define __noreturn __attribute__((noreturn))
#define __noinline __attribute__((noinline)) #define __attr_noinline___ __attribute__((noinline))
#define __used __attribute__((used)) #define __attr_used___ __attribute__((used))
#ifndef __attribute_always_inline__ #ifndef __attr_always_inline___
# define __attribute_always_inline__ __attribute__((always_inline)) # define __attr_always_inline___ __attribute__((always_inline))
#endif /* !__attribute_always_inline__ */ #endif /* !__attr_always_inline___ */
#ifndef __attribute_const__ #ifndef __attr_const___
# define __attribute_const__ __attribute__((const)) # define __attr_const___ __attribute__((const))
#endif /* !__attribute_const__ */ #endif /* !__attr_const___ */
#ifndef __attribute_pure__ #ifndef __attr_pure___
# define __attribute_pure__ __attribute__((pure)) # define __attr_pure___ __attribute__((pure))
#endif /* !__attribute_pure__ */ #endif /* !__attr_pure___ */
/** /**
* Constants * Constants
*/ */
#define JERRY_BITSINBYTE 8 #define JERRY_BITSINBYTE 8
/**
* Standalone Jerry exit codes
*/
#define JERRY_STANDALONE_EXIT_CODE_OK (0)
#define JERRY_STANDALONE_EXIT_CODE_FAIL (1)
/** /**
* Asserts * Asserts
* *
@ -61,7 +55,7 @@
#define JERRY_STATIC_ASSERT_GLUE(a, b) JERRY_STATIC_ASSERT_GLUE_ (a, b) #define JERRY_STATIC_ASSERT_GLUE(a, b) JERRY_STATIC_ASSERT_GLUE_ (a, b)
#define JERRY_STATIC_ASSERT(x) \ #define JERRY_STATIC_ASSERT(x) \
typedef char JERRY_STATIC_ASSERT_GLUE (static_assertion_failed_, __LINE__) \ typedef char JERRY_STATIC_ASSERT_GLUE (static_assertion_failed_, __LINE__) \
[ (x) ? 1 : -1 ] __unused [ (x) ? 1 : -1 ] __attr_unused___
#define CALL_PRAGMA(x) _Pragma (#x) #define CALL_PRAGMA(x) _Pragma (#x)

View File

@ -17,9 +17,9 @@
#define JRT_TYPES_H #define JRT_TYPES_H
#include <float.h> #include <float.h>
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#endif /* !JRT_TYPES_H */ #endif /* !JRT_TYPES_H */

View File

@ -13,38 +13,49 @@
* limitations under the License. * limitations under the License.
*/ */
#include <stdio.h>
#include <string.h>
#include "jerry.h" #include "jerry.h"
#include "jerry-libc.h"
/** /**
* Maximum command line arguments number * Maximum command line arguments number
*/ */
#define JERRY_MAX_COMMAND_LINE_ARGS (64) #define JERRY_MAX_COMMAND_LINE_ARGS (64)
/**
* Maximum size of source code buffer
*/
#define JERRY_SOURCE_BUFFER_SIZE (1048576)
/**
* Standalone Jerry exit codes
*/
#define JERRY_STANDALONE_EXIT_CODE_OK (0)
#define JERRY_STANDALONE_EXIT_CODE_FAIL (1)
static uint8_t source_buffer[ JERRY_SOURCE_BUFFER_SIZE ]; static uint8_t source_buffer[ JERRY_SOURCE_BUFFER_SIZE ];
static const char* static const char*
read_sources (const char *script_file_names[], read_sources (const char *script_file_names[],
size_t files_count, int files_count,
size_t *out_source_size_p) size_t *out_source_size_p)
{ {
JERRY_ASSERT (files_count > 0); int i;
size_t i;
uint8_t *source_buffer_tail = source_buffer; uint8_t *source_buffer_tail = source_buffer;
for (i = 0; i < files_count; i++) for (i = 0; i < files_count; i++)
{ {
const char *script_file_name = script_file_names[i]; const char *script_file_name = script_file_names[i];
_FILE *file = fopen (script_file_name, "r"); FILE *file = fopen (script_file_name, "r");
if (file == NULL) if (file == NULL)
{ {
break; break;
} }
int fseek_status = fseek (file, 0, __SEEK_END); int fseek_status = fseek (file, 0, SEEK_END);
if (fseek_status != 0) if (fseek_status != 0)
{ {
@ -87,7 +98,6 @@ read_sources (const char *script_file_names[],
else else
{ {
const size_t source_size = (size_t) (source_buffer_tail - source_buffer); const size_t source_size = (size_t) (source_buffer_tail - source_buffer);
JERRY_ASSERT(source_size < sizeof (source_buffer));
*out_source_size_p = source_size; *out_source_size_p = source_size;
@ -96,8 +106,8 @@ read_sources (const char *script_file_names[],
} }
int int
main (int argc __unused, main (int argc,
char **argv __unused) char **argv)
{ {
if (argc >= JERRY_MAX_COMMAND_LINE_ARGS) if (argc >= JERRY_MAX_COMMAND_LINE_ARGS)
{ {
@ -108,12 +118,13 @@ main (int argc __unused,
const char *file_names[JERRY_MAX_COMMAND_LINE_ARGS]; const char *file_names[JERRY_MAX_COMMAND_LINE_ARGS];
int i; int i;
size_t files_counter = 0; int files_counter = 0;
size_t max_data_bss_size, max_stack_size; size_t max_data_bss_size, max_stack_size;
jerry_get_memory_limits (&max_data_bss_size, &max_stack_size); jerry_get_memory_limits (&max_data_bss_size, &max_stack_size);
jrt_set_mem_limits (max_data_bss_size, max_stack_size); // FIXME:
// jrt_set_mem_limits (max_data_bss_size, max_stack_size);
jerry_flag_t flags = JERRY_FLAG_EMPTY; jerry_flag_t flags = JERRY_FLAG_EMPTY;

View File

@ -15,35 +15,23 @@
#include "jerry.h" #include "jerry.h"
#include "common-io.h" /**
#include "actuators.h" * Standalone Jerry exit codes
#include "sensors.h" */
#define JERRY_STANDALONE_EXIT_CODE_OK (0)
#define JERRY_STANDALONE_EXIT_CODE_FAIL (1)
#include JERRY_MCU_SCRIPT_HEADER #include JERRY_MCU_SCRIPT_HEADER
static const char generated_source [] = JERRY_MCU_SCRIPT; static const char generated_source [] = JERRY_MCU_SCRIPT;
static uint32_t start __unused;
static uint32_t finish_native_ms __unused;
static uint32_t finish_parse_ms __unused;
static uint32_t finish_int_ms __unused;
int int
main (void) main (void)
{ {
initialize_sys_tick ();
initialize_leds ();
initialize_timer ();
const char *source_p = generated_source; const char *source_p = generated_source;
const size_t source_size = sizeof (generated_source); const size_t source_size = sizeof (generated_source);
set_sys_tick_counter ((uint32_t) - 1);
start = get_sys_tick_counter ();
jerry_completion_code_t ret_code = jerry_run_simple (source_p, source_size, JERRY_FLAG_EMPTY); jerry_completion_code_t ret_code = jerry_run_simple (source_p, source_size, JERRY_FLAG_EMPTY);
finish_parse_ms = (start - get_sys_tick_counter ()) / 1000;
if (ret_code == JERRY_COMPLETION_CODE_OK) if (ret_code == JERRY_COMPLETION_CODE_OK)
{ {
return JERRY_STANDALONE_EXIT_CODE_OK; return JERRY_STANDALONE_EXIT_CODE_OK;

View File

@ -18,7 +18,7 @@
*/ */
#include "jrt.h" #include "jrt.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "mem-allocator.h" #include "mem-allocator.h"
#include "mem-heap.h" #include "mem-heap.h"
#include "mem-poolman.h" #include "mem-poolman.h"

View File

@ -25,7 +25,7 @@
*/ */
#include "jrt.h" #include "jrt.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "mem-allocator.h" #include "mem-allocator.h"
#include "mem-config.h" #include "mem-config.h"
#include "mem-heap.h" #include "mem-heap.h"
@ -858,7 +858,7 @@ mem_heap_free_block (void *ptr) /**< pointer to beginning of data space of the b
* *
* @return recommended allocation size * @return recommended allocation size
*/ */
size_t __attribute_pure__ size_t __attr_pure___
mem_heap_recommend_allocation_size (size_t minimum_allocation_size) /**< minimum allocation size */ mem_heap_recommend_allocation_size (size_t minimum_allocation_size) /**< minimum allocation size */
{ {
size_t minimum_allocation_size_with_block_header = minimum_allocation_size + sizeof (mem_block_header_t); size_t minimum_allocation_size_with_block_header = minimum_allocation_size + sizeof (mem_block_header_t);
@ -885,7 +885,7 @@ mem_heap_print (bool dump_block_headers, /**< print block headers */
{ {
printf ("Heap: start=%p size=%lu, first block->%p, last block->%p\n", printf ("Heap: start=%p size=%lu, first block->%p, last block->%p\n",
mem_heap.heap_start, mem_heap.heap_start,
mem_heap.heap_size, (unsigned long) mem_heap.heap_size,
(void*) mem_heap.first_block_p, (void*) mem_heap.first_block_p,
(void*) mem_heap.last_block_p); (void*) mem_heap.last_block_p);
@ -898,7 +898,7 @@ mem_heap_print (bool dump_block_headers, /**< print block headers */
printf ("Block (%p): magic num=0x%08x, size in chunks=%lu, previous block->%p next block->%p\n", printf ("Block (%p): magic num=0x%08x, size in chunks=%lu, previous block->%p next block->%p\n",
(void*) block_p, (void*) block_p,
block_p->magic_num, block_p->magic_num,
mem_get_block_chunks_count (block_p), (unsigned long) mem_get_block_chunks_count (block_p),
(void*) mem_get_next_block_by_direction (block_p, MEM_DIRECTION_PREV), (void*) mem_get_next_block_by_direction (block_p, MEM_DIRECTION_PREV),
(void*) mem_get_next_block_by_direction (block_p, MEM_DIRECTION_NEXT)); (void*) mem_get_next_block_by_direction (block_p, MEM_DIRECTION_NEXT));
@ -936,7 +936,7 @@ mem_heap_print (bool dump_block_headers, /**< print block headers */
" Peak allocated= %lu bytes\n" " Peak allocated= %lu bytes\n"
" Peak waste = %lu bytes\n", " Peak waste = %lu bytes\n",
mem_heap_stats.size, mem_heap_stats.size,
MEM_HEAP_CHUNK_SIZE, (uint64_t) MEM_HEAP_CHUNK_SIZE,
mem_heap_stats.blocks, mem_heap_stats.blocks,
mem_heap_stats.allocated_blocks, mem_heap_stats.allocated_blocks,
mem_heap_stats.allocated_chunks, mem_heap_stats.allocated_chunks,

View File

@ -44,7 +44,7 @@ extern void mem_heap_finalize (void);
extern void* mem_heap_alloc_block (size_t size_in_bytes, mem_heap_alloc_term_t alloc_term); extern void* mem_heap_alloc_block (size_t size_in_bytes, mem_heap_alloc_term_t alloc_term);
extern bool mem_heap_try_resize_block (void *ptr, size_t size_in_bytes); extern bool mem_heap_try_resize_block (void *ptr, size_t size_in_bytes);
extern void mem_heap_free_block (void *ptr); extern void mem_heap_free_block (void *ptr);
extern size_t __attribute_pure__ mem_heap_recommend_allocation_size (size_t minimum_allocation_size); extern size_t __attr_pure___ mem_heap_recommend_allocation_size (size_t minimum_allocation_size);
extern void mem_heap_print (bool dump_block_headers, bool dump_block_data, bool dump_stats); extern void mem_heap_print (bool dump_block_headers, bool dump_block_data, bool dump_stats);
#ifdef MEM_STATS #ifdef MEM_STATS

View File

@ -27,7 +27,7 @@
#define JERRY_MEM_POOL_INTERNAL #define JERRY_MEM_POOL_INTERNAL
#include "jrt.h" #include "jrt.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "mem-allocator.h" #include "mem-allocator.h"
#include "mem-pool.h" #include "mem-pool.h"
@ -59,7 +59,7 @@ static void mem_check_pool (mem_pool_state_t *pool_p);
* *
* @return true / false * @return true / false
*/ */
bool __attribute_const__ bool __attr_const___
mem_pool_is_chunk_inside (mem_pool_state_t *pool_p, /**< pool */ mem_pool_is_chunk_inside (mem_pool_state_t *pool_p, /**< pool */
uint8_t *chunk_p) /**< chunk */ uint8_t *chunk_p) /**< chunk */
{ {
@ -181,7 +181,7 @@ mem_pool_free_chunk (mem_pool_state_t *pool_p, /**< pool */
* Check pool state consistency * Check pool state consistency
*/ */
static void static void
mem_check_pool (mem_pool_state_t __unused *pool_p) /**< pool (unused #ifdef JERRY_NDEBUG) */ mem_check_pool (mem_pool_state_t __attr_unused___ *pool_p) /**< pool (unused #ifdef JERRY_NDEBUG) */
{ {
#ifndef JERRY_NDEBUG #ifndef JERRY_NDEBUG
JERRY_ASSERT(pool_p->free_chunks_number <= MEM_POOL_CHUNKS_NUMBER); JERRY_ASSERT(pool_p->free_chunks_number <= MEM_POOL_CHUNKS_NUMBER);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd. /* Copyright 2014-2015 Samsung Electronics Co., Ltd.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -71,7 +71,7 @@ typedef struct __attribute__ ((aligned (MEM_ALIGNMENT))) mem_pool_state_t
extern void mem_pool_init (mem_pool_state_t *pool_p, size_t pool_size); extern void mem_pool_init (mem_pool_state_t *pool_p, size_t pool_size);
extern uint8_t* mem_pool_alloc_chunk (mem_pool_state_t *pool_p); extern uint8_t* mem_pool_alloc_chunk (mem_pool_state_t *pool_p);
extern void mem_pool_free_chunk (mem_pool_state_t *pool_p, uint8_t *chunk_p); extern void mem_pool_free_chunk (mem_pool_state_t *pool_p, uint8_t *chunk_p);
extern bool __attribute_const__ mem_pool_is_chunk_inside (mem_pool_state_t *pool_p, uint8_t *chunk_p); extern bool __attr_const___ mem_pool_is_chunk_inside (mem_pool_state_t *pool_p, uint8_t *chunk_p);
/** /**
* @} * @}

View File

@ -27,7 +27,7 @@
#define JERRY_MEM_POOL_INTERNAL #define JERRY_MEM_POOL_INTERNAL
#include "jrt.h" #include "jrt.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "mem-allocator.h" #include "mem-allocator.h"
#include "mem-heap.h" #include "mem-heap.h"
#include "mem-pool.h" #include "mem-pool.h"
@ -96,7 +96,7 @@ mem_pools_finalize (void)
* @return true - if there is a free chunk in mem_pools, * @return true - if there is a free chunk in mem_pools,
* false - otherwise (not enough memory). * false - otherwise (not enough memory).
*/ */
static bool __noinline static bool __attr_noinline___
mem_pools_alloc_longpath (void) mem_pools_alloc_longpath (void)
{ {
/** /**

View File

@ -15,7 +15,7 @@
#include "array-list.h" #include "array-list.h"
#include "mem-heap.h" #include "mem-heap.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#define ARRAY_LIST_MAGIC 0x39 #define ARRAY_LIST_MAGIC 0x39

View File

@ -16,7 +16,7 @@
#include "hash-table.h" #include "hash-table.h"
#include "array-list.h" #include "array-list.h"
#include "mem-heap.h" #include "mem-heap.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#define HASH_MAP_MAGIC 0x67 #define HASH_MAP_MAGIC 0x67

View File

@ -14,7 +14,7 @@
*/ */
#include "linked-list.h" #include "linked-list.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "jrt.h" #include "jrt.h"
#include "mem-heap.h" #include "mem-heap.h"
#include "lp-string.h" #include "lp-string.h"

View File

@ -15,7 +15,7 @@
#include "lit-id-hash-table.h" #include "lit-id-hash-table.h"
#include "mem-heap.h" #include "mem-heap.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "bytecode-data.h" #include "bytecode-data.h"
lit_id_hash_table * lit_id_hash_table *

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd. /* Copyright 2014-2015 Samsung Electronics Co., Ltd.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
*/ */
#include "lp-string.h" #include "lp-string.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
bool bool
lp_string_equal (lp_string s1, lp_string s2) lp_string_equal (lp_string s1, lp_string s2)

View File

@ -88,37 +88,37 @@ do { \
} while (0) } while (0)
#define DEFINE_STACK_ELEMENT(NAME, TYPE) \ #define DEFINE_STACK_ELEMENT(NAME, TYPE) \
static TYPE NAME##_stack_element (size_t) __unused; \ static TYPE NAME##_stack_element (size_t) __attr_unused___; \
static TYPE NAME##_stack_element (size_t elem) { \ static TYPE NAME##_stack_element (size_t elem) { \
return *((TYPE *) array_list_element (NAME.data, elem)); \ return *((TYPE *) array_list_element (NAME.data, elem)); \
} }
#define DEFINE_SET_STACK_ELEMENT(NAME, TYPE) \ #define DEFINE_SET_STACK_ELEMENT(NAME, TYPE) \
static void set_##NAME##_stack_element (size_t, TYPE) __unused; \ static void set_##NAME##_stack_element (size_t, TYPE) __attr_unused___; \
static void set_##NAME##_stack_element (size_t elem, TYPE value) { \ static void set_##NAME##_stack_element (size_t elem, TYPE value) { \
array_list_set_element (NAME.data, elem, &value); \ array_list_set_element (NAME.data, elem, &value); \
} }
#define DEFINE_STACK_HEAD(NAME, TYPE) \ #define DEFINE_STACK_HEAD(NAME, TYPE) \
static TYPE NAME##_stack_head (size_t) __unused; \ static TYPE NAME##_stack_head (size_t) __attr_unused___; \
static TYPE NAME##_stack_head (size_t elem) { \ static TYPE NAME##_stack_head (size_t elem) { \
return *((TYPE *) array_list_last_element (NAME.data, elem)); \ return *((TYPE *) array_list_last_element (NAME.data, elem)); \
} }
#define DEFINE_SET_STACK_HEAD(NAME, TYPE) \ #define DEFINE_SET_STACK_HEAD(NAME, TYPE) \
static void set_##NAME##_stack_head (size_t, TYPE) __unused; \ static void set_##NAME##_stack_head (size_t, TYPE) __attr_unused___; \
static void set_##NAME##_stack_head (size_t elem, TYPE value) { \ static void set_##NAME##_stack_head (size_t elem, TYPE value) { \
array_list_set_last_element (NAME.data, elem, &value); \ array_list_set_last_element (NAME.data, elem, &value); \
} }
#define DEFINE_STACK_PUSH(NAME, TYPE) \ #define DEFINE_STACK_PUSH(NAME, TYPE) \
static void NAME##_stack_push (TYPE) __unused; \ static void NAME##_stack_push (TYPE) __attr_unused___; \
static void NAME##_stack_push (TYPE value) { \ static void NAME##_stack_push (TYPE value) { \
NAME.data = array_list_append (NAME.data, &value); \ NAME.data = array_list_append (NAME.data, &value); \
} }
#define DEFINE_CONVERT_TO_RAW_DATA(NAME, TYPE) \ #define DEFINE_CONVERT_TO_RAW_DATA(NAME, TYPE) \
static TYPE *convert_##NAME##_to_raw_data (void) __unused; \ static TYPE *convert_##NAME##_to_raw_data (void) __attr_unused___; \
static TYPE *convert_##NAME##_to_raw_data (void) { \ static TYPE *convert_##NAME##_to_raw_data (void) { \
if (array_list_len (NAME.data) == 0) \ if (array_list_len (NAME.data) == 0) \
{ \ { \

View File

@ -18,7 +18,7 @@
#include "opcodes.h" #include "opcodes.h"
#include "stack.h" #include "stack.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "literal.h" #include "literal.h"
#include "scopes-tree.h" #include "scopes-tree.h"
#include "lit-id-hash-table.h" #include "lit-id-hash-table.h"

View File

@ -14,7 +14,7 @@
*/ */
#include "mem-allocator.h" #include "mem-allocator.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "lexer.h" #include "lexer.h"
#include "parser.h" #include "parser.h"
#include "stack.h" #include "stack.h"

View File

@ -15,7 +15,7 @@
#include "literal.h" #include "literal.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
literal literal
create_empty_literal (void) create_empty_literal (void)

View File

@ -20,7 +20,7 @@
#include "lexer.h" #include "lexer.h"
#include "stack.h" #include "stack.h"
#include "syntax-errors.h" #include "syntax-errors.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "opcodes-native-call.h" #include "opcodes-native-call.h"
#define MIN_TEMP_NAME 128 #define MIN_TEMP_NAME 128

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "parser.h" #include "parser.h"
#include "opcodes.h" #include "opcodes.h"
#include "serializer.h" #include "serializer.h"

View File

@ -15,7 +15,7 @@
#include "scopes-tree.h" #include "scopes-tree.h"
#include "mem-heap.h" #include "mem-heap.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "lexer.h" #include "lexer.h"
#include "bytecode-data.h" #include "bytecode-data.h"

View File

@ -16,7 +16,7 @@
#include "jrt.h" #include "jrt.h"
#include "serializer.h" #include "serializer.h"
#include "parser.h" #include "parser.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "bytecode-data.h" #include "bytecode-data.h"
#include "deserializer.h" #include "deserializer.h"
#include "pretty-printer.h" #include "pretty-printer.h"

View File

@ -17,7 +17,7 @@
#include "stack.h" #include "stack.h"
#include "jrt.h" #include "jrt.h"
#include "parser.h" #include "parser.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
typedef struct typedef struct
@ -64,7 +64,7 @@ syntax_add_prop_name (operand op, prop_type pt)
} }
void void
syntax_check_for_duplication_of_prop_names (bool is_strict, locus loc __unused) syntax_check_for_duplication_of_prop_names (bool is_strict, locus loc __attr_unused___)
{ {
if (STACK_SIZE (props) - STACK_TOP (U8) < 2) if (STACK_SIZE (props) - STACK_TOP (U8) < 2)
{ {
@ -145,7 +145,7 @@ void syntax_add_varg (operand op)
} }
static void static void
emit_error_on_eval_and_arguments (operand op, locus loc __unused) emit_error_on_eval_and_arguments (operand op, locus loc __attr_unused___)
{ {
if (op.type == OPERAND_LITERAL) if (op.type == OPERAND_LITERAL)
{ {
@ -170,7 +170,7 @@ syntax_check_for_eval_and_arguments_in_strict_mode (operand op, bool is_strict,
/* 13.1, 15.3.2 */ /* 13.1, 15.3.2 */
void void
syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc __unused) syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc __attr_unused___)
{ {
if (STACK_SIZE (props) - STACK_TOP (U8) < 2 || !is_strict) if (STACK_SIZE (props) - STACK_TOP (U8) < 2 || !is_strict)
{ {
@ -200,7 +200,7 @@ syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc _
} }
void void
syntax_check_delete (bool is_strict, locus loc __unused) syntax_check_delete (bool is_strict, locus loc __attr_unused___)
{ {
if (is_strict) if (is_strict)
{ {

View File

@ -30,13 +30,13 @@
putchar (' '); \ putchar (' '); \
} \ } \
printf ("^\n"); \ printf ("^\n"); \
printf ("ERROR: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \ printf ("ERROR: Ln %lu, Col %lu: %s\n", (unsigned long) (line + 1), (unsigned long) (column + 1), MESSAGE); \
jerry_fatal (ERR_PARSER); \ jerry_fatal (ERR_PARSER); \
} while (0) } while (0)
#define PARSE_WARN(MESSAGE, LOCUS) do { \ #define PARSE_WARN(MESSAGE, LOCUS) do { \
size_t line, column; \ size_t line, column; \
lexer_locus_to_line_and_column ((locus) (LOCUS), &line, &column); \ lexer_locus_to_line_and_column ((locus) (LOCUS), &line, &column); \
printf ("WARNING: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \ printf ("WARNING: Ln %lu, Col %lu: %s\n", (unsigned long) (line + 1), (unsigned long) (column + 1), MESSAGE); \
} while (0) } while (0)
#define PARSE_ERROR_VARG(MESSAGE, LOCUS, ...) do { \ #define PARSE_ERROR_VARG(MESSAGE, LOCUS, ...) do { \
size_t line, column; \ size_t line, column; \
@ -47,7 +47,7 @@
putchar (' '); \ putchar (' '); \
} \ } \
printf ("^\n"); \ printf ("^\n"); \
printf ("ERROR: Ln %d, Col %d: ", line + 1, column + 1); \ printf ("ERROR: Ln %lu, Col %lu: ", (unsigned long) (line + 1), (unsigned long) (column + 1)); \
printf (MESSAGE, __VA_ARGS__); \ printf (MESSAGE, __VA_ARGS__); \
printf ("\n"); \ printf ("\n"); \
jerry_fatal (ERR_PARSER); \ jerry_fatal (ERR_PARSER); \
@ -61,7 +61,7 @@
putchar (' '); \ putchar (' '); \
} \ } \
printf ("^\n"); \ printf ("^\n"); \
printf ("SORRY, Unimplemented: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \ printf ("SORRY, Unimplemented: Ln %lu, Col %lu: %s\n", (unsigned long) (line + 1), (unsigned long) (column + 1), MESSAGE); \
JERRY_UNIMPLEMENTED ("Unimplemented parser feature."); \ JERRY_UNIMPLEMENTED ("Unimplemented parser feature."); \
} while (0) } while (0)
#else /* JERRY_NDEBUG */ #else /* JERRY_NDEBUG */

View File

@ -16,7 +16,7 @@
#include "opcodes.h" #include "opcodes.h"
#include "opcodes-ecma-support.h" #include "opcodes-ecma-support.h"
#include "ecma-number-arithmetic.h" #include "ecma-number-arithmetic.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
/** /**
* Number arithmetic operations. * Number arithmetic operations.

View File

@ -231,8 +231,8 @@ opfunc_greater_or_equal_than (opcode_t opdata, /**< operation data */
* returned value must be freed with ecma_free_completion_value. * returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t ecma_completion_value_t
opfunc_instanceof (opcode_t opdata __unused, /**< operation data */ opfunc_instanceof (opcode_t opdata __attr_unused___, /**< operation data */
int_data_t *int_data __unused) /**< interpreter context */ int_data_t *int_data __attr_unused___) /**< interpreter context */
{ {
const idx_t dst_idx = opdata.data.instanceof.dst; const idx_t dst_idx = opdata.data.instanceof.dst;
const idx_t left_var_idx = opdata.data.instanceof.var_left; const idx_t left_var_idx = opdata.data.instanceof.var_left;
@ -277,8 +277,8 @@ opfunc_instanceof (opcode_t opdata __unused, /**< operation data */
* returned value must be freed with ecma_free_completion_value. * returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t ecma_completion_value_t
opfunc_in (opcode_t opdata __unused, /**< operation data */ opfunc_in (opcode_t opdata __attr_unused___, /**< operation data */
int_data_t *int_data __unused) /**< interpreter context */ int_data_t *int_data __attr_unused___) /**< interpreter context */
{ {
const idx_t dst_idx = opdata.data.in.dst; const idx_t dst_idx = opdata.data.in.dst;
const idx_t left_var_idx = opdata.data.in.var_left; const idx_t left_var_idx = opdata.data.in.var_left;

View File

@ -21,10 +21,7 @@
#include "opcodes-native-call.h" #include "opcodes-native-call.h"
#include "actuators.h" #include "jrt-libc-includes.h"
#include "common-io.h"
#include "sensors.h"
#include "jerry-libc.h"
/** /**
* 'Native call' opcode handler. * 'Native call' opcode handler.
@ -60,54 +57,12 @@ opfunc_native_call (opcode_t opdata, /**< operation data */
switch ((opcode_native_call_t)native_call_id_idx) switch ((opcode_native_call_t)native_call_id_idx)
{ {
case OPCODE_NATIVE_CALL_LED_TOGGLE: case OPCODE_NATIVE_CALL_LED_TOGGLE:
{
JERRY_ASSERT (args_number == 1);
ecma_number_t* num_p = ecma_get_number_from_value (arg_values[0]);
uint32_t int_num = ecma_number_to_uint32 (*num_p);
led_toggle (int_num);
ret_value = ecma_make_empty_completion_value ();
break;
}
case OPCODE_NATIVE_CALL_LED_ON: case OPCODE_NATIVE_CALL_LED_ON:
{
JERRY_ASSERT (args_number == 1);
ecma_number_t* num_p = ecma_get_number_from_value (arg_values[0]);
uint32_t int_num = ecma_number_to_uint32 (*num_p);
led_on (int_num);
ret_value = ecma_make_empty_completion_value ();
break;
}
case OPCODE_NATIVE_CALL_LED_OFF: case OPCODE_NATIVE_CALL_LED_OFF:
{
JERRY_ASSERT (args_number == 1);
ecma_number_t* num_p = ecma_get_number_from_value (arg_values[0]);
uint32_t int_num = ecma_number_to_uint32 (*num_p);
led_off (int_num);
ret_value = ecma_make_empty_completion_value ();
break;
}
case OPCODE_NATIVE_CALL_LED_ONCE: case OPCODE_NATIVE_CALL_LED_ONCE:
{
JERRY_ASSERT (args_number == 1);
ecma_number_t* num_p = ecma_get_number_from_value (arg_values[0]);
uint32_t int_num = ecma_number_to_uint32 (*num_p);
led_blink_once (int_num);
ret_value = ecma_make_empty_completion_value ();
break;
}
case OPCODE_NATIVE_CALL_WAIT: case OPCODE_NATIVE_CALL_WAIT:
{ {
JERRY_ASSERT (args_number == 1); JERRY_UNIMPLEMENTED ("Device operations are not implemented.");
ecma_number_t* num_p = ecma_get_number_from_value (arg_values[0]);
uint32_t int_num = ecma_number_to_uint32 (*num_p);
wait_ms (int_num);
ret_value = ecma_make_empty_completion_value ();
break;
} }
case OPCODE_NATIVE_CALL_PRINT: case OPCODE_NATIVE_CALL_PRINT:

View File

@ -43,7 +43,7 @@
*/ */
#define OP_UNIMPLEMENTED_LIST(op) \ #define OP_UNIMPLEMENTED_LIST(op) \
static char __unused unimplemented_list_end static char __attr_unused___ unimplemented_list_end
#define DEFINE_UNIMPLEMENTED_OP(op) \ #define DEFINE_UNIMPLEMENTED_OP(op) \
ecma_completion_value_t opfunc_ ## op (opcode_t opdata, int_data_t *int_data) \ ecma_completion_value_t opfunc_ ## op (opcode_t opdata, int_data_t *int_data) \
@ -58,7 +58,7 @@ OP_UNIMPLEMENTED_LIST (DEFINE_UNIMPLEMENTED_OP);
* 'Nop' opcode handler. * 'Nop' opcode handler.
*/ */
ecma_completion_value_t ecma_completion_value_t
opfunc_nop (opcode_t opdata __unused, /**< operation data */ opfunc_nop (opcode_t opdata __attr_unused___, /**< operation data */
int_data_t *int_data) /**< interpreter context */ int_data_t *int_data) /**< interpreter context */
{ {
int_data->pos++; int_data->pos++;
@ -378,8 +378,8 @@ opfunc_post_decr (opcode_t opdata, /**< operation data */
* The opcode is meta-opcode that is not supposed to be executed. * The opcode is meta-opcode that is not supposed to be executed.
*/ */
ecma_completion_value_t ecma_completion_value_t
opfunc_reg_var_decl (opcode_t opdata __unused, /**< operation data */ opfunc_reg_var_decl (opcode_t opdata __attr_unused___, /**< operation data */
int_data_t *int_data __unused) /**< interpreter context */ int_data_t *int_data __attr_unused___) /**< interpreter context */
{ {
JERRY_UNREACHABLE (); JERRY_UNREACHABLE ();
} /* opfunc_reg_var_decl */ } /* opfunc_reg_var_decl */
@ -1047,8 +1047,8 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
* However, ecma_free_completion_value may be called for it, but it is a no-op. * However, ecma_free_completion_value may be called for it, but it is a no-op.
*/ */
ecma_completion_value_t ecma_completion_value_t
opfunc_ret (opcode_t opdata __unused, /**< operation data */ opfunc_ret (opcode_t opdata __attr_unused___, /**< operation data */
int_data_t *int_data __unused) /**< interpreter context */ int_data_t *int_data __attr_unused___) /**< interpreter context */
{ {
return ecma_make_return_completion_value (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED)); return ecma_make_return_completion_value (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED));
} /* opfunc_ret */ } /* opfunc_ret */
@ -1063,8 +1063,8 @@ opfunc_ret (opcode_t opdata __unused, /**< operation data */
* However, ecma_free_completion_value may be called for it, but it is a no-op. * However, ecma_free_completion_value may be called for it, but it is a no-op.
*/ */
ecma_completion_value_t ecma_completion_value_t
opfunc_retval (opcode_t opdata __unused, /**< operation data */ opfunc_retval (opcode_t opdata __attr_unused___, /**< operation data */
int_data_t *int_data __unused) /**< interpreter context */ int_data_t *int_data __attr_unused___) /**< interpreter context */
{ {
ecma_completion_value_t ret_value; ecma_completion_value_t ret_value;
@ -1087,8 +1087,8 @@ opfunc_retval (opcode_t opdata __unused, /**< operation data */
* returned value must be freed with ecma_free_completion_value. * returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t ecma_completion_value_t
opfunc_prop_getter (opcode_t opdata __unused, /**< operation data */ opfunc_prop_getter (opcode_t opdata __attr_unused___, /**< operation data */
int_data_t *int_data __unused) /**< interpreter context */ int_data_t *int_data __attr_unused___) /**< interpreter context */
{ {
const idx_t lhs_var_idx = opdata.data.prop_getter.lhs; const idx_t lhs_var_idx = opdata.data.prop_getter.lhs;
const idx_t base_var_idx = opdata.data.prop_getter.obj; const idx_t base_var_idx = opdata.data.prop_getter.obj;
@ -1140,8 +1140,8 @@ opfunc_prop_getter (opcode_t opdata __unused, /**< operation data */
* returned value must be freed with ecma_free_completion_value. * returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t ecma_completion_value_t
opfunc_prop_setter (opcode_t opdata __unused, /**< operation data */ opfunc_prop_setter (opcode_t opdata __attr_unused___, /**< operation data */
int_data_t *int_data __unused) /**< interpreter context */ int_data_t *int_data __attr_unused___) /**< interpreter context */
{ {
const idx_t base_var_idx = opdata.data.prop_setter.obj; const idx_t base_var_idx = opdata.data.prop_setter.obj;
const idx_t prop_name_var_idx = opdata.data.prop_setter.prop; const idx_t prop_name_var_idx = opdata.data.prop_setter.prop;
@ -1198,7 +1198,7 @@ opfunc_prop_setter (opcode_t opdata __unused, /**< operation data */
*/ */
ecma_completion_value_t ecma_completion_value_t
opfunc_exitval (opcode_t opdata, /**< operation data */ opfunc_exitval (opcode_t opdata, /**< operation data */
int_data_t *int_data __unused) /**< interpreter context */ int_data_t *int_data __attr_unused___) /**< interpreter context */
{ {
JERRY_ASSERT (opdata.data.exitval.status_code == 0 JERRY_ASSERT (opdata.data.exitval.status_code == 0
|| opdata.data.exitval.status_code == 1); || opdata.data.exitval.status_code == 1);
@ -1633,7 +1633,7 @@ opfunc_delete_prop (opcode_t opdata, /**< operation data */
*/ */
ecma_completion_value_t ecma_completion_value_t
opfunc_meta (opcode_t opdata, /**< operation data */ opfunc_meta (opcode_t opdata, /**< operation data */
int_data_t *int_data __unused) /**< interpreter context */ int_data_t *int_data __attr_unused___) /**< interpreter context */
{ {
const opcode_meta_type type = (opcode_meta_type) opdata.data.meta.type; const opcode_meta_type type = (opcode_meta_type) opdata.data.meta.type;

View File

@ -16,7 +16,7 @@
#include "jrt.h" #include "jrt.h"
#ifdef JERRY_ENABLE_PRETTY_PRINTER #ifdef JERRY_ENABLE_PRETTY_PRINTER
#include "pretty-printer.h" #include "pretty-printer.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "lexer.h" #include "lexer.h"
#include "deserializer.h" #include "deserializer.h"
#include "opcodes-native-call.h" #include "opcodes-native-call.h"
@ -30,7 +30,7 @@
#name, #name,
#define __OPCODE_SIZE(name, arg1, arg2, arg3) \ #define __OPCODE_SIZE(name, arg1, arg2, arg3) \
sizeof (__op_##name) + 1, (uint8_t) (sizeof (__op_##name) + 1),
static const char* opcode_names[] = static const char* opcode_names[] =
{ {
@ -57,7 +57,7 @@ dump_literal (literal lit)
} }
else else
{ {
printf ("%d : NUMBER", lit.data.num); printf ("%d : Truncated NUMBER", (int) lit.data.num);
} }
break; break;
} }
@ -81,10 +81,10 @@ dump_literal (literal lit)
void void
pp_literals (const literal lits[], literal_index_t size) pp_literals (const literal lits[], literal_index_t size)
{ {
printf ("LITERALS %d:\n", size); printf ("LITERALS %lu:\n", (unsigned long) size);
for (literal_index_t i = 0; i < size; i++) for (literal_index_t i = 0; i < size; i++)
{ {
printf ("%3d ", i); printf ("%3lu ", (unsigned long) i);
dump_literal (lits[i]); dump_literal (lits[i]);
putchar ('\n'); putchar ('\n');
} }

View File

@ -23,7 +23,7 @@
#include "ecma-stack.h" #include "ecma-stack.h"
#include "jrt.h" #include "jrt.h"
#include "vm.h" #include "vm.h"
#include "jerry-libc.h" #include "jrt-libc-includes.h"
#include "mem-allocator.h" #include "mem-allocator.h"
#define __INIT_OP_FUNC(name, arg1, arg2, arg3) [ __op__idx_##name ] = opfunc_##name, #define __INIT_OP_FUNC(name, arg1, arg2, arg3) [ __op__idx_##name ] = opfunc_##name,
@ -133,10 +133,10 @@ interp_mem_stats_context_enter (int_data_t *int_data_p,
"%s Pools: %5u\n" "%s Pools: %5u\n"
"%s Allocated pool chunks: %5u\n\n", "%s Allocated pool chunks: %5u\n\n",
indent_prefix, (uint32_t) block_position, indent_prefix, (uint32_t) block_position,
indent_prefix, int_data_p->heap_stats_context_enter.allocated_bytes, indent_prefix, (uint32_t) int_data_p->heap_stats_context_enter.allocated_bytes,
indent_prefix, int_data_p->heap_stats_context_enter.waste_bytes, indent_prefix, (uint32_t) int_data_p->heap_stats_context_enter.waste_bytes,
indent_prefix, int_data_p->pools_stats_context_enter.pools_count, indent_prefix, (uint32_t) int_data_p->pools_stats_context_enter.pools_count,
indent_prefix, int_data_p->pools_stats_context_enter.allocated_chunks); indent_prefix, (uint32_t) int_data_p->pools_stats_context_enter.allocated_chunks);
} }
static void static void
@ -174,35 +174,36 @@ interp_mem_stats_context_exit (int_data_t *int_data_p,
printf ("%sAllocated heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n", printf ("%sAllocated heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, indent_prefix,
int_data_p->heap_stats_context_enter.allocated_bytes, (uint32_t) int_data_p->heap_stats_context_enter.allocated_bytes,
heap_stats_context_exit.allocated_bytes, (uint32_t) heap_stats_context_exit.allocated_bytes,
heap_stats_context_exit.allocated_bytes - int_data_p->heap_stats_context_enter.allocated_bytes, (uint32_t) (heap_stats_context_exit.allocated_bytes - int_data_p->heap_stats_context_enter.allocated_bytes),
int_data_p->context_peak_allocated_heap_bytes, (uint32_t) int_data_p->context_peak_allocated_heap_bytes,
heap_stats_context_exit.global_peak_allocated_bytes); (uint32_t) heap_stats_context_exit.global_peak_allocated_bytes);
printf ("%sWaste heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n", printf ("%sWaste heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, indent_prefix,
int_data_p->heap_stats_context_enter.waste_bytes, (uint32_t) int_data_p->heap_stats_context_enter.waste_bytes,
heap_stats_context_exit.waste_bytes, (uint32_t) heap_stats_context_exit.waste_bytes,
heap_stats_context_exit.waste_bytes - int_data_p->heap_stats_context_enter.waste_bytes, (uint32_t) (heap_stats_context_exit.waste_bytes - int_data_p->heap_stats_context_enter.waste_bytes),
int_data_p->context_peak_waste_heap_bytes, (uint32_t) int_data_p->context_peak_waste_heap_bytes,
heap_stats_context_exit.global_peak_waste_bytes); (uint32_t) heap_stats_context_exit.global_peak_waste_bytes);
printf ("%sPools count in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n", printf ("%sPools count in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, indent_prefix,
int_data_p->pools_stats_context_enter.pools_count, (uint32_t) int_data_p->pools_stats_context_enter.pools_count,
pools_stats_context_exit.pools_count, (uint32_t) pools_stats_context_exit.pools_count,
pools_stats_context_exit.pools_count - int_data_p->pools_stats_context_enter.pools_count, (uint32_t) (pools_stats_context_exit.pools_count - int_data_p->pools_stats_context_enter.pools_count),
int_data_p->context_peak_pools_count, (uint32_t) int_data_p->context_peak_pools_count,
pools_stats_context_exit.global_peak_pools_count); (uint32_t) pools_stats_context_exit.global_peak_pools_count);
printf ("%sAllocated pool chunks in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n", printf ("%sAllocated pool chunks in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, indent_prefix,
int_data_p->pools_stats_context_enter.allocated_chunks, (uint32_t) int_data_p->pools_stats_context_enter.allocated_chunks,
pools_stats_context_exit.allocated_chunks, (uint32_t) pools_stats_context_exit.allocated_chunks,
pools_stats_context_exit.allocated_chunks - int_data_p->pools_stats_context_enter.allocated_chunks, (uint32_t) (pools_stats_context_exit.allocated_chunks -
int_data_p->context_peak_allocated_pool_chunks, int_data_p->pools_stats_context_enter.allocated_chunks),
pools_stats_context_exit.global_peak_allocated_chunks); (uint32_t) int_data_p->context_peak_allocated_pool_chunks,
(uint32_t) pools_stats_context_exit.global_peak_allocated_chunks);
printf ("\n%s--- End of interpretation of a block at position %u ---\n\n", printf ("\n%s--- End of interpretation of a block at position %u ---\n\n",
indent_prefix, (uint32_t) block_position); indent_prefix, (uint32_t) block_position);
@ -279,47 +280,47 @@ interp_mem_stats_opcode_exit (int_data_t *int_data_p,
printf ("%s Allocated heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n", printf ("%s Allocated heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, indent_prefix,
heap_stats_before_p->allocated_bytes, (uint32_t) heap_stats_before_p->allocated_bytes,
heap_stats_after.allocated_bytes, (uint32_t) heap_stats_after.allocated_bytes,
heap_stats_after.allocated_bytes - heap_stats_before_p->allocated_bytes, (uint32_t) (heap_stats_after.allocated_bytes - heap_stats_before_p->allocated_bytes),
heap_stats_after.peak_allocated_bytes - JERRY_MAX (heap_stats_before_p->allocated_bytes, (uint32_t) (heap_stats_after.peak_allocated_bytes - JERRY_MAX (heap_stats_before_p->allocated_bytes,
heap_stats_after.allocated_bytes), heap_stats_after.allocated_bytes)),
heap_stats_after.global_peak_allocated_bytes); (uint32_t) heap_stats_after.global_peak_allocated_bytes);
if (heap_stats_before_p->waste_bytes != heap_stats_after.waste_bytes) if (heap_stats_before_p->waste_bytes != heap_stats_after.waste_bytes)
{ {
printf ("%s Waste heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n", printf ("%s Waste heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, indent_prefix,
heap_stats_before_p->waste_bytes, (uint32_t) heap_stats_before_p->waste_bytes,
heap_stats_after.waste_bytes, (uint32_t) heap_stats_after.waste_bytes,
heap_stats_after.waste_bytes - heap_stats_before_p->waste_bytes, (uint32_t) (heap_stats_after.waste_bytes - heap_stats_before_p->waste_bytes),
heap_stats_after.peak_waste_bytes - JERRY_MAX (heap_stats_before_p->waste_bytes, (uint32_t) (heap_stats_after.peak_waste_bytes - JERRY_MAX (heap_stats_before_p->waste_bytes,
heap_stats_after.waste_bytes), heap_stats_after.waste_bytes)),
heap_stats_after.global_peak_waste_bytes); (uint32_t) heap_stats_after.global_peak_waste_bytes);
} }
if (pools_stats_before_p->pools_count != pools_stats_after.pools_count) if (pools_stats_before_p->pools_count != pools_stats_after.pools_count)
{ {
printf ("%s Pools: %5u -> %5u (%+5d, local %5u, peak %5u)\n", printf ("%s Pools: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, indent_prefix,
pools_stats_before_p->pools_count, (uint32_t) pools_stats_before_p->pools_count,
pools_stats_after.pools_count, (uint32_t) pools_stats_after.pools_count,
pools_stats_after.pools_count - pools_stats_before_p->pools_count, (uint32_t) (pools_stats_after.pools_count - pools_stats_before_p->pools_count),
pools_stats_after.peak_pools_count - JERRY_MAX (pools_stats_before_p->pools_count, (uint32_t) (pools_stats_after.peak_pools_count - JERRY_MAX (pools_stats_before_p->pools_count,
pools_stats_after.pools_count), pools_stats_after.pools_count)),
pools_stats_after.global_peak_pools_count); (uint32_t) pools_stats_after.global_peak_pools_count);
} }
if (pools_stats_before_p->allocated_chunks != pools_stats_after.allocated_chunks) if (pools_stats_before_p->allocated_chunks != pools_stats_after.allocated_chunks)
{ {
printf ("%s Allocated pool chunks: %5u -> %5u (%+5d, local %5u, peak %5u)\n", printf ("%s Allocated pool chunks: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, indent_prefix,
pools_stats_before_p->allocated_chunks, (uint32_t) pools_stats_before_p->allocated_chunks,
pools_stats_after.allocated_chunks, (uint32_t) pools_stats_after.allocated_chunks,
pools_stats_after.allocated_chunks - pools_stats_before_p->allocated_chunks, (uint32_t) (pools_stats_after.allocated_chunks - pools_stats_before_p->allocated_chunks),
pools_stats_after.peak_allocated_chunks - JERRY_MAX (pools_stats_before_p->allocated_chunks, (uint32_t) (pools_stats_after.peak_allocated_chunks - JERRY_MAX (pools_stats_before_p->allocated_chunks,
pools_stats_after.allocated_chunks), pools_stats_after.allocated_chunks)),
pools_stats_after.global_peak_allocated_chunks); (uint32_t) pools_stats_after.global_peak_allocated_chunks);
} }
printf ("%s-- End of execution of opcode %s (position %u) --\n\n", printf ("%s-- End of execution of opcode %s (position %u) --\n\n",

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd. /* Copyright 2014-2015 Samsung Electronics Co., Ltd.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,7 +32,7 @@ static uint8_t opcode_sizes[] = {
0 0
}; };
static bool opcodes_equal (const opcode_t *, opcode_t *, uint16_t) __unused; static bool opcodes_equal (const opcode_t *, opcode_t *, uint16_t) __attr_unused___;
static bool static bool
opcodes_equal (const opcode_t *opcodes1, opcode_t *opcodes2, uint16_t size) opcodes_equal (const opcode_t *opcodes1, opcode_t *opcodes2, uint16_t size)

View File

@ -83,8 +83,8 @@ test_heap_give_some_memory_back (mem_try_give_memory_back_severity_t severity)
} /* test_heap_give_some_memory_back */ } /* test_heap_give_some_memory_back */
int int
main( int __unused argc, main( int __attr_unused___ argc,
char __unused **argv) char __attr_unused___ **argv)
{ {
uint8_t test_native_heap[test_heap_size]; uint8_t test_native_heap[test_heap_size];

View File

@ -24,8 +24,8 @@
* Unit test's main function. * Unit test's main function.
*/ */
int int
main( int __unused argc, main( int __attr_unused___ argc,
char __unused **argv) char __attr_unused___ **argv)
{ {
const ecma_char_t* zt_strings[] = const ecma_char_t* zt_strings[] =
{ {

View File

@ -41,8 +41,8 @@ uint8_t test_pool [TEST_POOL_SPACE_SIZE] __attribute__((aligned(MEM_ALIGNMENT)))
uint8_t* ptrs[test_max_sub_iters]; uint8_t* ptrs[test_max_sub_iters];
int int
main( int __unused argc, main( int __attr_unused___ argc,
char __unused **argv) char __attr_unused___ **argv)
{ {
srand((unsigned int) time(NULL)); srand((unsigned int) time(NULL));
int k = rand(); int k = rand();

View File

@ -41,8 +41,8 @@ const uint32_t test_max_sub_iters = 32;
uint8_t *ptrs[test_max_sub_iters]; uint8_t *ptrs[test_max_sub_iters];
int int
main( int __unused argc, main( int __attr_unused___ argc,
char __unused **argv) char __attr_unused___ **argv)
{ {
mem_init(); mem_init();

View File

@ -25,8 +25,8 @@
* Unit test's main function. * Unit test's main function.
*/ */
int int
main( int __unused argc, main( int __attr_unused___ argc,
char __unused **argv) char __attr_unused___ **argv)
{ {
char program[] = "a=1;var a;"; char program[] = "a=1;var a;";
bool is_ok; bool is_ok;

View File

@ -24,8 +24,8 @@
* Unit test's main function. * Unit test's main function.
*/ */
int int
main( int __unused argc, main( int __attr_unused___ argc,
char __unused **argv) char __attr_unused___ **argv)
{ {
const ecma_char_t* zt_strings[] = const ecma_char_t* zt_strings[] =
{ {