Age | Commit message (Collapse) | Author |
|
Move the invocation of the unhandled exception callback handler out of
`uc_vm_execute_chunk()` into both `uc_vm_execute()` and `uc_vm_invoke()`
in order to consistently report exceptions exactly once regardless of
whether a native or managed code function is executed as topmost VM
call.
This solves cases where the unhandled exception callback was either
called multiple times or never at all.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When invoking a native function as toplevel VM call which indirectly
triggers an unhandled exception in managed code, the callframes are
completely reset before the C function returns, leading to invalid
memory accesses when `uc_vm_call_native()` subsequently popped it's
own callframe again.
This issue did not surface by executing script code through the
interpreter since in this case the VM will always execute a managed
code as toplevel call, but it could be triggered by invoking a native
function triggering an exception through the C API using `uc_vm_call()`
on a fresh `uc_vm_t` context or by utilizing the CLI interpreters `-l`
flag to preload a native code library triggering an exception.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Do not continue loading other libraries or executing the main code if
loading one of the preload libraries fails.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fixes: dfaf05a ("ci: debian: automatically update changelog from Git tag")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
fs: fix off-by-one in fs.dirname() function
|
|
Debian package build
|
|
Make sure fs.dirname() doesn't truncate the last character of the
returned path. Previously ucv_string_new_length was called with a
length which no longer included the last character (which had just
been tested not to be a '/' or '.' and hence broke the loop at that
point).
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
[testcase added]
Signed-off-by: Paul Spooren <mail@aparcar.org>
[testcase folded into this commit and fixed]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The libjson-c versions commonly shipped by Debian and Ubuntu lack unsigned
64bit integer support and a number of extended API functions.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Paul Spooren <mail@aparcar.org>
|
|
This adds Debian packages for the ucode interpreter, the runtime library,
development headers and extension modules.
Fixes: #55
Signed-off-by: Paul Spooren <mail@aparcar.org>
[split into multiple packages, pass SOVERSION to the build]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Treat the char value as unsigned when testing its value to yield consistent
results on both platforms with signed chars and those with unsigned chars
by default (e.g. ARM ones). This also avoids encoding byte values > 127 as
\uXXXX escape sequences, potentially breaking the strng contents.
Fixes: #62
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
uloop: add support for tasks
|
|
lib: add date and time related functions
|
|
Add five new functions to deal with date calculation and timing:
- localtime(), gmtime() - return a broken down calendar date and time
specification from the given epoch (or now, if absent) in local and
UTC time respectively
- timelocal(), timegm() - the inverse operation for the former functions,
taking a date and time specification (interpreted as local or UTC time
respectively) and turning it into an epoch value
- clock() - return the second and nanosecond values of the system clock,
useful for time/performance measurements
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
lib: provide API function to obtain stdlib function implementations
|
|
Provide a new API function `uc_stdlib_function()` which allows to fetch
the C implementation of the given named standard library function.
This is useful for loadable modules or applications that embed ucode which
want to reuse core functions such as `sprintf()`.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
main: turn ucode into multicall executable
|
|
Turn the ucode executable into a multicall binary and select default flags
based on the name it was invoked with. Introduce two new symlinks "ucc" and
"utpl" which start ucode in compile and template mode respectively.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Tasks are similar to processes but instead of executing a new process, an
ucode function is invoked instead, running independently of the main
process.
Example usage:
uloop.init();
let t = uloop.task(
// program function
function(pipe) {
let input = pipe.receive();
pipe.send({ got_input: input });
return { result: true };
},
// parent recv function, invoked when task function calls pipe.send()
function(res) {
printf("Received output message: %.J\n", res);
},
// parent send function, invoked when task function calls pipe.receive()
function() {
let input = { test: "Example" };
printf("Sending input message: %.J\n", input);
return input;
}
);
uloop.run();
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Build minimal version to detect compile issues.
Signed-off-by: Paul Spooren <mail@aparcar.org>
|
|
lib: add argument position support (`%m$`) to `sprintf()` and `printf()`
|
|
Portability fixes for macOS
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
We now include `json-c/json-c.h` on all supported environments.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Different libc implementations produce different syntax error messages
on invalid regular expression patterns, so rework the test case to
produce stable output across all environments.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
A typo in the custom order function of the test case caused the test case
to yield differently sorted results on OS X, triggered by differences in
the libc's `qsort()` implementation.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Since OS X `getopt()` does not handle optional arguments, we need to
always pass a value to `-T`.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Filter the zero padding `0` flag for `%s` formats to achieve constisten
outputs on Linux and OS X systems.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
This ensures that GNU readlink is preferred over OS X own readlink when
executing test cases. This is required due to lacking `-f` flag support
on OS X.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
OS X `socket()` does not support the `SOCK_NONBLOCK` or `SOCK_CLOEXEC`
constants, so apply these flags using `fcntl()` after creating the socket.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
It should be enough to include `sys/types.h` to obtain `major()` and
`minor()` definitions on OS X, so avoid including the the Linux specific
`sys/sysmacros.h` header in this case.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Since `execvpe()` is a GNU extension, fall back to using `execve()` on OS X.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
OS X does not implement `sigtimedwait()` used by `uc_system()` - add a
simple implementation of it.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Add OS X specific linker flags
- Default disable Linux specific modules on OS X
- Simplify json-c discovery
- Fix uloop_timeout_remaining64() detection
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Identifiers starting with one or two underscores are reserved for system
headers and toolchain implementations and should not appear in user code.
Also on OS X, the ucode __TYPES_H_ guard clashes with the system types.h
header. Rename all ucode header guards to avoid such clashes.
Supersedes: #43
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
nl80211: add missing attributes and correct some attribute flags
|
|
main: rework CLI frontend
|
|
Suggested-by: John Crispin <john@phrozen.org>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Let `require()` always evaluate the executed code in raw mode
- Let `render()` always evaluate the executed code in template mode
- Let `include()` inherit the raw mode semantics of the calling scope
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Change command line flags to be align better with those of other
interpreters and with the gcc compiler, e.g. `-D` and `-U` to
define and undefine globals, `-e` to execute script expression etc.
- Pass only excess CLI arguments as `ARGV` to scripts, e.g.
`ucode -e 'print("Hello world")' -- -x -y` would pass only
`[ "-x", "-y" ]` as ARGV contents
- Default to raw mode and introduce flag to enable template mode
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
lib: fix potential integer underflow on empty render output
|