aboutsummaryrefslogtreecommitdiff
path: root/jerry-libc
AgeCommit message (Collapse)Author
2018-06-12Use binary mode when opening via fopen in the tools (#2371)Péter Gál
In the snapshot tool the files were opened in text mode. However the snapshot files are binary files thus it is advised to use the binary mode when opening the files. Specifying the binary mode is a must on Windows platform otherwise the read/write operations are inserting extra '\r' characters. To make the tools consitent across OSes all fopen are now opening files in binary mode. Also update jerry-libc to accept the 'b' modifier and add a test case where the JS file uses CR-LF line endings. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2018-06-05Buildable as shared libraries (#2351)willeio
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu JerryScript-DCO-1.0-Signed-off-by: wille-io mike@wille.io
2018-04-03Remove TARGET_HOST macros (#2264)Istvan Miklos
Remove TARGET_HOST defines from the jerry-libc module and replace with compiler provided macros. JerryScript-DCO-1.0-Signed-off-by: Istvan Miklos imiklos2@inf.u-szeged.hu
2017-11-16Ensure that the test version of the command line tool is stable for ↵Akos Kiss
benchmarking (#2076) Some benchmark suites contain test cases that have nonreproducible behaviour. This is mostly caused by relying on "now" when dealing with dates or timestamps, instead of using a fixed moment. (A notorious example is the crypto-aes.js test case of the sunspider bechmark suite, where the heap memory consumption can vary between 34K-41K heap because of using `(new Date()).getTime()`.) This commit renames the jerry-minimal command line tool to jerry-test (to better reflect its purpose) and adds extra code, which intercepts some calls to libc (`gettimeofday`, `rand`) and pins their results to some fixed values. This makes the tool useless in a general case but ensures stable results when benchmarking -- for which it is mostly used. As a side effect, the commit also changes jerry-libc by making all libc functions weak symbols to allow their override from application code. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-11-10Whitespace gardening in jerry-libc (#2082)Akos Kiss
Also includes the addition and styling of some doc comments (but those are whitespace too). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-11-06Fix jerry-libc's srand function (#2068)Daniel Balla
The previous implementation of srand was wrong in jerry-libc. It set all 4 values to the seed, not modifying anything in them, causing random values to be repeated pretty often. This approach fixes the mentioned issue. JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2017-09-22module: Re-implement using library constructors/destructors (#2018)Gabriel "_|Nix|_" Schulhof
By using constructors/destructors we unify the case of static linking with that of dynamic linking, and we reuse the build flag FEATURE_INIT_FINI. Using constructors/destructors also allows us to cover the case where library constructor/destructor functionality is unavailable, because we can expose the module registration/unregistration functions as global symbols, to be called explicitly from within the application. Fixes https://github.com/jerryscript-project/jerryscript/issues/1952 JerryScript-DCO-1.0-Signed-off-by: Gabriel Schulhof gabriel.schulhof@intel.com
2017-06-26Add strtol to jerry-libc and make use of it in jerry-main (#1891)Akos Kiss
As a side effect, refactor the variable types in `print_unhandled_exception` to reduce the overuse of sized integer types (generic `unsigned int` is better than `uint32_t` if there is no actual requirement on integer width). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-04-13Add support for init/fini arrays to libc (#1725)Akos Kiss
The arrays contain the addresses of functions annotated with constructor or destructor attributes. The support is optional, requires FEATURE_INIT_FINI cmake option to be set. As of now, the option is _not_ available in tools/build.py directly, only via `--cmake-param="-DFEATURE_INIT_FINI=ON"`. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-01-23Added #if control around GCC built-in functions so that the code can be (#1483)t-harvey
compiled using non-GCC compilers. This included adding an initialization to a variable that looks(!) like it can reach a use before being initialized (b/c we turned JERRY_UNREACHABLE into a nop) -- an example: int foo; switch (value_can_only_be_one_or_two) case 1: case 2: foo = 5; default: JERRY_UNREACHABLE(); x = foo +1; ...the compiler assumes that the path can go through the default case, which leaves the value of foo undefined. JerryScript-DCO-1.0-Signed-off-by: Timothy Harvey t-harvey@ti.com
2016-12-16Remove redundant extern keywords from function declarations/definitions. (#1495)Tilmann Scheller
Extern keywords on function declarations/definitions provide no additional value since function declarations/definitions default to external linkage in C99, e.g. removing them won't change the semantics of the program. The extern keywords were essentially a legacy from the early days of the project. This commit cleans this up across the whole codebase in one go to minimize history disruption. The bulk of the changes in this commit were produced by a custom clang-tidy checker. Note that variables declarations carrying the extern keyword are untouched by this commit since there the presence of the keyword actually has an impact on the semantics of the program. JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
2016-12-08Streamline copyright notices across the codebase. (#1473)Tilmann Scheller
Since the project is now hosted at the JS Foundation we can move to unified copyright notices for the project. Starting with this commit all future contributions to the project should only carry the following copyright notice (except for third-party code which requires copyright information to be preserved): "Copyright JS Foundation and other contributors, http://js.foundation" (without the quotes) This avoids cluttering the codebase with contributor-specific copyright notices which have a higher maintenance overhead and tend to get outdated quickly. Also dropping the year from the copyright notices helps to avoid yearly code changes just to update the copyright notices. Note that each contributor still retains full copyright ownership of his/her contributions and the respective authorship is tracked very accurately via Git. JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
2016-11-29Replace `//` double slash comments with `/* */`. (#1461)Robert Sipka
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-11-21Fix fopen call on non-existing files. (#1442)László Langó
The main implementation of unix platform hangs, if the engine was built with jerry-libc. Open system call returns with a negative error code if cannot open the file, but fopen must return NULL when error happens. Fixes #1437. JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-09-30Simplify the way libgcc is linked (#1380)Akos Kiss
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-09-29Update jerry-libc unreachable asserts (#1379)Akos Kiss
Newer compilers (especially clang) warn (and fail) on `assert (!"message");` constructs typically used to assert on unreachable code paths (multiple occurrences in jerry-libc). A more up-to-date approach is to use `assert (false && "message");`. This patch applies the pattern to all relevant asserts in jerry-libc. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-09-09Enable `make install` (#1335)Akos Kiss
With the new build system, the conventional `cmake && make` already works. However, the last step, i.e., `make install` was still missing (didn't work). This patch adds the `install()` commands to CMakeLists that are required to generate the `install` target in the Makefile. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-09-06Fix -Wsign-conversion Clang warning.Robert Sipka
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-08-30Improve the build systemAkos Kiss
* Remove JERRY_CORE CMake option: the building of the core JerryScript library should not be optional. * Fix wording of comments, status and error messages. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-14Cleanup jerry-libc CMakeListsAkos Kiss
Remove "-I/home/.../jerryscript/jerry-libc/__TARGET_HOST" and "-D__TARGET_HOST" from compiler command line, they don't add anything useful. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-08Let the build script use a default for toolchainAkos Kiss
The `cmake` directory already contains several toolchain files for various platforms (operating system + architecture). However, `tools/build.py` does not define a toolchain file for cmake unless explicitly specified. This patch changes the script to look into the `cmake` directory for a file named `toolchain_$(os)_$(arch).cmake` and, if found, pass that to cmake by default. OS and arch are determined by `os.uname()`. As Linux on Raspberry Pi identifies itself as "armv7l", the legacy "armv7l-hf" arch name is shortened to "armv7l". This way, building jerry on RPi (natively, not cross) becomes possible by simply running `tools/build.py` without any extra options. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-07-28Re-thinking the build system to bring it more into line with the conventions.Robert Sipka
We removed that implementation where the build directory isn't set up to build with exactly one configuration of the project but potentially several variants: the same build directory can/must be used for debug and release builds, for full or compact profile versions, etc. So we reworked the CMakeLists, and now one build dir deal with exactly one configuration of the project's libraries and tools. JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-06-26Fix memcpy return value.Zoltan Herczeg
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-22Four byte optimized memcpy.Zoltan Herczeg
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-05-19Don't concatenate multiple JS scripts in jerryAkos Kiss
Jerry (the command line tool) has been supporting the execution of multiple script files for long. However, until now, it simply concatenated all sources into a single source buffer and parsed/executed them as one unit. Other JS execution tools (e.g., jsc, v8) load and execute separate files as separate units -- but still in the same execution environment. The most significant effect of this approach is that the `"use strict;"` directive (or the absence of it) at the beginning of each JS script file takes effect as expected (i.e., as if the script was executed alone). Contrarily, the concatenation-based approach forces the strictness of the first script on all the rest (i.e., if the first script starts with `"use strict";` the rest is also executed in a strict environment even if they did not contain the directive, and vice versa). This patch makes the jerry command line tool to load/parse/run one unit at a time. Side effects: - As there is no need for separate file read routines that load one file (a snapshot) or concat multiple (JS sources) anymore, those routines got merged. - Both previous read routines used multiple stdio functions (`fseek`, `ftell`, and `rewind`). This has been simplified to rely on `fread` only to find out the length of the input. - This simplification made the above mentioned functions superfluous in jerry-libc. - As some error messages had to be touched in this patch, several more have been beautified to make them more consistent. - One small change was needed in `jerry_parse` in jerry-core to allow subsequent parsing of multiple sources (without that, an assertion was triggered). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-05-06Check the return value of the gettimeofday() in 'jerry_port_get_time_zone' ↵Robert Sipka
and 'jerry_port_get_current_time' functions. JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-04-23Drop jerry_port_putcharAkos Kiss
Recent changes eliminate the need for `jerry_port_putchar`. As port API discussions don't make it likely that it will ever be needed again, this patch removes its declaration from jerry-port.h and its implementations from the port(s). The related code in jerry-libc is not needed either: whatever `putc` (and `puts`) can do, `printf` can do as well. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-18Unifiy the comments of preprocessor conditionalsAkos Kiss
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-16Update existing and add missing copyright & license noticesAkos Kiss
* LICENSE needed year update. * The asm component of the posix target of jerry-libc had no copyright & license notice since it has been introduced in 2015. Traced back history and added missing header with correct years. * Three tests in jerry/fail/1 also missed header. Added. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-15Merge darwin and linux jerry-libc targets into a single posix targetAkos Kiss
The two target implementations are very close clones of each other. The only known differences are the following: * The asm component of the linux target has `.type` and `.size` declarations for the functions defined therein, while the darwin target doesn't support those. * Linux uses `__NR_xxx` mnemonics for syscall numbers, while darwin uses `SYS_xxx` format. * Darwin does not have `exit_group` syscall but `exit` only. * The linux target has a commented out `jrt_set_mem_limits` fuction declaration at the end of the C source. (Based on its name, this function does not really belong here.) Simple preprocessor macros can unify the first three differences. While for the sake of legacy, we can keep the fourth commented-out code in the code base; it might turn out to be useful elsewhere in the future. Since it remains commented out it wont cause any problems on any OSs. So, this patch gets rid of a lot of duplication. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-14Turn assert functionality standard-conforming in jerry-libcAkos Kiss
Introducing the `assert.h` public header with the `assert(x)` macro and already making use of it in jerry-libc sources. These newly introduced ISO C-conforming features replace the non-conforming `LIBC_ASSERT` and `LIBC_NDEBUG` at no cost, and they also have the benefit that we can expose `assert` in a public header and make it useful to jerry-libc users. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-12Implement `raise ()` in libcAkos Kiss
The core functionality (i.e., the equivalent of `kill (getpid (), sig);`) was already there in the implementation of `abort ()`. Now, it got factored out to `raise ()` so that others (most importantly, `__aeabi_ldiv0`) can call and link to it as well. Also, removed `LIBC_UNREACHABLE_STUB_FOR` macro, as it is not used anymore. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-12Remove syscall trampolines from jerry-libcAkos Kiss
After recent changes to jerry-libc, `syscall_N` C functions became pure trampolines to their appropriate `syscall_N_asm` counterparts written in assembly. Removing the C functions and renaming the assembly functions to take their place simplifies the code. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-11Fix syscall assertion when input file does not existDániel Bátyai
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2016-03-12Fix `.size longjmp` in the linux port of jerry-libcAkos Kiss
Fixing a typo, which resulted in an undefined (but harmless) symbol in jerry-asm. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-03-08Disable date object related system calls by defaultLászló Langó
Use DATE_SYS_CALLS=ON for make target to enable the date related system calls. Also fix some minor issues. Related issue: #923 JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-02-23Build fixLászló Langó
Fix build error on darwin and build with default libc. JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-02-19Remove EXTERN_C macros and use block based solutionLászló Langó
Related issue: #900 JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-02-18Refactoring and fixing jerry-libcAkos Kiss
Refactor memory and string handling routines * Potential code size improvements: * Most loops don't really need a new incrementing index variable running between 0..n-1 but can just loop `while (n--)`, and the bodies don't need array indexing but can just use the `*p++` idiom. * Compare routines are not required to return -1, 0, and +1, but any negative, zero, or positive result will do. * `strncmp` may follow the other routines and does not have to have defined behaviour if any of its args is NULL. * Fix: * `strncmp` did not work correctly if the strings were equal but `n` was greater than their length (did not stop at the terminating zero character). Refactor printf * Merging code duplications, removing dead initialization. Refactor rand and srand * Making sure that the type of the state variables is OK (`uint32_t` instead of `unsigned int`). * Getting type conversions OK. * Fixing `srand` to write all state variables and thus indeed generate the same random sequence. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-02-18Fix system call related date builtin functionsLászló Langó
Related issues: #213, #691 * Fixed 'ecma_date_local_tza' and 'ecma_date_daylight_saving_ta' date builtin helper functions * Added syscall of gettimeofday function to get the current system time and timezone. * Fixed related regression test files. JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-02-18Fix style issues and improve vera++ rules.László Langó
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-02-16Eliminating doxygen warnings by fixing the documentationAkos Kiss
* Fix "end of file while inside a group" doxygen warnings. * Fix "unknown command" doxygen warnings caused by incorrect argument references. Instead of `@foo`, `@a foo` is the proper format. * Fix "unknown command" doxygen warnings caused by incorrect parameter direction specifications. Instead of `@in`, `@out`, and `@in-out`, `[in]`, `[out]`, and `[in,out]` are the proper formats. * Wrapping special characters in quotes to avoid doxygen confusion. Raw pipe, semicolon, dot, backslash, etc. characters can drive doxygen into various misinterpretations and warnings. E.g.: ``` End of list marker found without any preceding list items Found unknown command ``` Putting quotes around such text snipets eliminates the errors. * Fix the documentation of `ecma_builtin_global_object_print`. Raw <> and \ sequences confused doxygen in various ways (it tried to interpret them as XML tags and doxygen commands). * Fix "ignoring title that does not match old title" doxygen warnings. At some places, the group titles were out of sync, at others, the group names were incorrect. * Fix "parameters are not documented" doxygen warnings. Fixing various typos in the inline parameter documentations (`/*`, `/**`, `/** <`, and `/**>` are all considered incorrect, the right format is `/**<`). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-02-15Refactoring the build systemAkos Kiss
* Removed unused or unnecessary parts from various make files * Eliminated lots of duplications from Makefile with the help of macros. * Split tools/precommit.sh to its independent components: * the part that checks the existence of the "signed off" text in commit messages (this on got factored out to tools/check-signed-off.sh), * the part that uses vera++ for style checking (this one got factored out to tools/check-vera.sh), * the part that invokes targets in the cmake-generated build directory, and * the part that performs various tests (these latter two got moved into the Makefile). * Moved the functionality of precommit-full-testing.sh into the Makefile, too. * Added ninja build system support (e.g., `make NINJA=1`). * Updated leading documentation comments (they were somewhat stale). * Tried to keep the target names exactly the same as they were -- almost succeeded... (some changes are intentional, and are subject to personal preferences). * Simplified console output of `make precommit` * Unified test runner scripts and their output format * Eliminated nothing-to-stdout everything-to-log-file policy: info is printed to stdout and it is the caller's responsibility to redirect it to a file if needed. * Also applied some renaming and coding style unification to the scripts. * Merged the functionality of tools/runners/run-test-suite-jerry*.sh into the Makefile * Merged everything related to a test suite execution in a single script. * The new script also allows to specify pass and xfail tests in a single list file, which was not possible hitherto. * Also, the paths of the test cases given in a file are interpreted relative to their container files. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-02-05Style fix: fix comments at the end of function definitions.László Langó
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-02-05Style fix: align pointer dereference operator to rightLászló Langó
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-01-14Update strcmp implementation, to improve performanceXin Hu
JerryScript-DCO-1.0-Signed-off-by: Xin Hu Xin.A.Hu@intel.com
2015-11-24Change processor name from x86 to i686 for 32bit hostSaeHie Park
* to make it same as 'uname -p' result JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
2015-09-15Enable build on Mac OS X with clangSung-Jae Lee
* Add build target 'darwin' * Modify compiler options to work with clang * Support 'jerry-libc' on Mac OS X For MPU target build, install `gcc-arm-none-eabi` tool chain using `Homebrew` as following. ```` brew tap PX4/homebrew-px4 brew update brew install gcc-arm-none-eabi ```` https://pixhawk.org/dev/toolchain_installation_mac JerryScript-DCO-1.0-Signed-off-by: Sung-Jae Lee sjlee@mail.com
2015-07-20Remove usage of isalpha, isdigit, isxdigit, isspace in the whole engine ↵Ruben Ayrapetyan
except implementation of JSON built-in, moving the functions to JSON built-in's module. JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
2015-07-06Fix jmp_buf size to fix assert in arm-linuxSaeHie Park
Related issue: #296 JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com