61 Commits

Author SHA1 Message Date
Tilmann Scheller
1e99be90c3 Remove redundant extern keywords from function declarations/definitions. (#1495)
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-16 10:18:37 +01:00
Tilmann Scheller
0511091e8a Streamline copyright notices across the codebase. (#1473)
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-12-08 06:39:11 +01:00
Robert Sipka
fb3e8cf8b8 Replace // double slash comments with /* */. (#1461)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-11-29 15:54:35 +01:00
László Langó
4a0f78bc4b Fix fopen call on non-existing files. (#1442)
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-11-21 11:28:07 +01:00
Akos Kiss
e16cc83ce7 Simplify the way libgcc is linked (#1380)
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-09-30 09:02:42 +02:00
Akos Kiss
509407bfd4 Update jerry-libc unreachable asserts (#1379)
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-29 16:17:46 +02:00
Akos Kiss
2e1c180658 Enable make install (#1335)
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-09 13:32:36 +02:00
Robert Sipka
caee6f738e Fix -Wsign-conversion Clang warning.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-09-06 15:56:41 +02:00
Akos Kiss
a6d2e792f8 Improve the build system
* 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-30 09:10:30 +02:00
Akos Kiss
b4ab97581b Cleanup jerry-libc CMakeLists
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-14 22:35:31 +02:00
Akos Kiss
d5eb2f0be1 Let the build script use a default for toolchain
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-08-08 13:42:59 +02:00
Robert Sipka
ddab1d8152 Re-thinking the build system to bring it more into line with the conventions.
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-07-28 12:29:55 +02:00
Zoltan Herczeg
0940be57f6 Fix memcpy return value.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-26 23:45:58 -07:00
Zoltan Herczeg
64f49385ae Four byte optimized memcpy.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-22 03:15:04 -07:00
Akos Kiss
c7d33e9887 Don't concatenate multiple JS scripts in jerry
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-19 12:07:54 +02:00
Robert Sipka
94161d350a Check the return value of the gettimeofday() in 'jerry_port_get_time_zone' and 'jerry_port_get_current_time' functions.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-05-06 10:50:39 +02:00
Akos Kiss
33a1203d6b Drop jerry_port_putchar
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-23 22:50:50 +02:00
Akos Kiss
3a8d3b3bcc Unifiy the comments of preprocessor conditionals
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-18 19:20:49 +02:00
Akos Kiss
df1e428c71 Update existing and add missing copyright & license notices
* 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-16 00:06:44 +02:00
Akos Kiss
4b0b8f3d4f Merge darwin and linux jerry-libc targets into a single posix target
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-15 10:20:27 +02:00
Akos Kiss
ff185dc57e Turn assert functionality standard-conforming in jerry-libc
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-14 11:22:53 +02:00
Akos Kiss
a7f015ef47 Implement raise () in libc
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-12 22:45:01 +02:00
Akos Kiss
9ab0998ae6 Remove syscall trampolines from jerry-libc
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-12 00:54:42 +02:00
Dániel Bátyai
764229b262 Fix syscall assertion when input file does not exist
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2016-04-11 14:34:08 +02:00
Akos Kiss
3e02e792b6 Fix .size longjmp in the linux port of jerry-libc
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-12 00:34:34 +01:00
László Langó
9bf1ecc677 Disable date object related system calls by default
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-03-08 12:13:55 +01:00
László Langó
76b37f34d0 Build fix
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-23 12:31:05 +01:00
László Langó
a0bedaa43d Remove EXTERN_C macros and use block based solution
Related issue: #900

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-02-19 15:45:14 +01:00
Akos Kiss
3608f8df86 Refactoring and fixing jerry-libc
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-18 15:40:56 +01:00
László Langó
684ed7268c Fix system call related date builtin functions
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-18 14:05:36 +00:00
László Langó
a7715a5d78 Fix style issues and improve vera++ rules.
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-02-18 13:27:54 +00:00
Akos Kiss
0d7ea70b41 Eliminating doxygen warnings by fixing the documentation
* 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-16 21:05:58 +01:00
Akos Kiss
f959ba95a4 Refactoring the build system
* 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-15 18:05:01 +01:00
László Langó
d038284bff Style fix: fix comments at the end of function definitions.
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-02-05 13:46:51 +01:00
László Langó
b1acf1a562 Style fix: align pointer dereference operator to right
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-02-05 13:06:34 +01:00
Xin Hu
ba95cb010a Update strcmp implementation, to improve performance
JerryScript-DCO-1.0-Signed-off-by: Xin Hu Xin.A.Hu@intel.com
2016-01-14 19:55:13 +03:00
SaeHie Park
d11a9e1c0d Change processor name from x86 to i686 for 32bit host
* to make it same as 'uname -p' result

JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
2015-11-24 18:48:23 +09:00
Sung-Jae Lee
01f66f7b04 Enable build on Mac OS X with clang
* 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-09-15 10:31:57 +09:00
Ruben Ayrapetyan
7b3042fdc9 Remove usage of isalpha, isdigit, isxdigit, isspace in the whole engine 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-20 15:47:19 +03:00
SaeHie Park
93e3cb13dd Fix jmp_buf size to fix assert in arm-linux
Related issue: #296

JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
2015-07-06 06:52:04 +09:00
Ruben Ayrapetyan
a4e54e736e Support syntax error feedback in parser.
Now, parser correctly finishes parse procedure if syntax of source code is incorrect (syntax correctness is indicated using return value):
 - parser-internal memory management is performed using jsp_mm_alloc / jsp_mm_free;
 - upon detection of incorrect syntax, all parser-allocated memory regions are deallocated using jsp_mm_free_all and parse finishes with corresponding return value.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
2015-06-19 17:05:15 +03:00
Ruben Ayrapetyan
de7b72d726 Add configuration for ARMv7 softfloat build; update setjmp / longjmp ARMv7 implementation to handle the softfloat-mode properly.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
2015-06-17 17:03:42 +03:00
Ruben Ayrapetyan
b008867d81 Implement setjmp / longjmp in jerry-libc.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
2015-06-17 17:03:42 +03:00
Ruben Ayrapetyan
f115f731c3 Switch unit tests to jerry-libc.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
2015-06-17 17:03:42 +03:00
Ruben Ayrapetyan
6d6c913bdc Move random number generator from Math.random to jerry-libc, replace the logic with call to rand in Math.random.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
2015-06-17 17:02:50 +03:00
Ruben Ayrapetyan
30277153b9 Fix strncmp, fread and fwrite in jerry-libc.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
2015-06-17 17:02:50 +03:00
Ruben Ayrapetyan
630a1e8eba Move architecture-depedendent libc internal headers to jerry-libc/arch folder.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
2015-06-17 17:02:49 +03:00
Andrey Shitov
53801e3b41 Replace array of literals with literal storage.
JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin e.gavrin@samsung.com
JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
2015-06-10 21:40:10 +03:00
Peter Gal
f6b875c36c Use __func__ instead of __FUNCTION__
The __FUNCTION__ is not part of the C99/C++11 standard.
So replace all occurrences with the standard __func__.

Side note: GCC 5.1 warns when using -Wpedantic -std=c99
and __FUNCTION__.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2015-06-09 18:03:42 +02:00
Akos Kiss
d6fb76416a Add abort () to jerry-libc
Added declaration and implementations of `void abort (void)` to
jerry-libc. As the linux implementation relies on the `getpid`
syscall - which has no arguments - `syscall_0` implementations
have been added as well.

`libc_fatal` has been adapted to use the new `abort` function
instead of `exit`. This also made the definition of
`LIBC_FATAL_ERROR_EXIT_CODE` unnecessary.

Finally, the syscall fatal error message was fixed.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2015-06-02 18:12:29 +02:00