If the timeout to net::poll() is -1, poll() will block until a requested
event occurs. However, in the poll() function, the Duration timeout is
converted to milliseconds (Duration is in microseconds). The conversion
involves integer arithmetics which results in a zero timeout (= -1 /
1000), i.e. poll() will return immediately and the following accept will
fail.
To fix this, only convert to milliseconds if timeout paramter is
non-negative.
Example to reproduce the error:
```
module echo;
import std::io, std::net;
fn void main()
{
TcpServerSocket server = tcp::listen("localhost", 6969, 69, REUSEADDR)!!;
server.sock.set_non_blocking(true)!!;
Poll[*] polls = {{ .socket = server.sock, .events = net::SUBSCRIBE_READ }};
if (catch net::poll(polls[..], net::POLL_FOREVER)) io::printn("poll error");
TcpSocket client = tcp::accept(&server)!!;
io::printn("OK");
}
```
Poll() will return immediately and the following tcp::accept() will fail
with an "ACCEPT_FAILED" error.
Reported-by: Alexey Kutepov <reximkut@gmail.com>
* Fix UX of the `c3c project add-target` subcommand
- Fix segfault on `project.json` containing empty map `{}`
- Enable `add-target` to operate on non-existing project files
- Extend `add-target` syntax to accept source through CLI args
This enables the following workflow without friction and needless
crashes:
```console
$ cat > main.c3 <<END
import std::io;
fn void main() {
io::printfn("Hello, World");
}
END
$ c3c project add-target main executable main.c3
$ c3c run
```
* Fix read_project() call in fetch_project()
* Keep the style of curlies consistent
* Fix JSON formatting in parse command, strings now "JSON-legal"
* Clean up
* Implemented JSON for CONST_BYTES
* Handle empty byte string, slightly more concise
* of course msvc is the *only* compiler that complains about this
There are now nolibc definitions for the inverse cosine and inverse
sine.
More test points were added for acos, asin, and atan in the math_tests module.
This was done becuase the nolibc inverse trigonometric functions have
various branching conditions depending on the provided input value. Several
branches in these functions were neglected.