9 Commits

Author SHA1 Message Date
Robert Fancsik
badfdf4dba
Replace vera++ with clang-format (#4518)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-11-05 14:15:47 +01:00
Péter Gál
0c61aee597
Improve the JSON C API (#3943)
* Added more details into documentation.
* Moved the C unit-test into its own file.
* Added extra test cases.
* Extended the API reference documentation with doctests.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-01 14:50:39 +02:00
Akos Kiss
f29e6f9020
Fix undefined overflow behavior when converting double to integer (#3629)
Overflows in conversions from floating-point to integer are
undefined behavior in the C99 standard. (Clause 6.3.1.4: "If the
value of the integral part cannot be represented by the integer
type, the behavior is undefined.")

When UBSAN is enabled, this gets reported at `srand()` calls. (The
random seed is usually initialized using the date port API, which
represents dates as `double`s. But `srand` takes an `unsigned int`.
A simple cast from `double` to `unsigned` becomes undefined
behavior if the value is too large. And "now" is too large
nowadays. So, effectively, all executions start with an undefined
behavior.)

This patch fixes this by casting the floating-point value of the
date to an integer through a union.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2020-03-27 11:03:28 +01:00
Csaba Osztrogonác
051febfed7 Fix unused parameter related build issues on Windows (#3003)
MSVC doen't support __attribute__((unused)),
we should use JERRY_UNUSED macro instead.

Additionally removed the internal jrt.h include from
tests/unit-core/test-common.h which was layering violation.
It made JERRY_ASSERT unavailable, we should use TEST_ASSERT.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-08-06 10:13:41 +02:00
Akos Kiss
3d3a8008a8 Don't use strlen for string literals (#2517)
Their length (size) is known at compile time. Therefore `sizeof`
is more efficient for them.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2018-09-17 10:07:24 +02:00
Akos Kiss
65ae949dc3 Add jerryscript-compiler.h public header to cover compiler incompatibilities (#2313)
In general, public headers should not have compiler-specific
constructs but both the core and the port headers have attributes,
which are non-standard. It's better to factor out such constructs
to a common place (a new header) and hide them behind macros, which
can then be defined on a per-compiler basis.

This patch moves the existing definitions of function attributes and
likely/unlikely builtins to the new header. At the same time, it
unifies the names of these attribute defines and where they are
used. Moreover, it touches on jerry-main and removes the uses of
`__attribute__((unused))` entirely and replaces them with the
elsewhere used `(void) ...` pattern.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2018-05-14 09:41:26 +09:00
Daniel Balla
4690d128b3 Add info to documentation about random numbers, initialize srand (#2056)
Issue #2053 has highlighted the fact that random numbers are always generated with the same seed.
An example of generating different random numbers, other than the original seed, has been added to the documentation.
Furthermore srand initialization has been added to jerry-main, and targets.
Update test-common.h with srand call.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2017-11-03 15:31:57 +01:00
Akos Kiss
742654a3f1 Fix #endif comment at end of header files (#2049)
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-10-21 14:47:37 +02:00
Akos Kiss
6ca8319aea Split unit tests into separate directories (#1761)
The unit tests should follow the component structure, so this patch
moves all `jerry-core` unit tests under `tests/unit-core` and the
`jerry-libm` unit tests under `tests/unit-libm`.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-04-22 10:57:45 +09:00