Calvin Rose
922a21d359
Run make format.
2020-09-05 21:26:21 -05:00
Calvin Rose
2f89bdc672
Conditional compilation on some c99 syntax in header.
...
If the header is in a C++11 compilation unit, use C++11
aggregate initialization syntax instead.
2020-09-05 09:45:34 -05:00
Calvin Rose
25156eb83e
For #469 - Add support for C++ and mixed C/C++
...
WIP and for native modules. Required a few changes to headers and
some changes to JPM.
2020-09-04 17:41:36 -05:00
Calvin Rose
0145b133a1
Add os/spawn instead of os/execute with :a
2020-09-04 08:09:05 -05:00
Calvin Rose
6273e56886
Add janet_getjfile to C API.
2020-08-29 17:36:14 -05:00
Calvin Rose
a31e079f93
Fix import macro to not coerce everything to string.
2020-08-27 08:19:41 -05:00
Calvin Rose
86e00e865e
Merge branch 'master' into ev
2020-08-23 11:25:04 -05:00
Calvin Rose
28439d822a
Add cancel function.
...
This should allow better stack unwinding on a fiber that
no longer needs to complete.
2020-08-22 15:35:37 -05:00
Calvin Rose
30522bbf7d
Merge branch 'master' into ev
2020-08-16 17:52:36 -05:00
Calvin Rose
06c268c274
Start working on throwing errors from async functions.
2020-08-11 08:33:24 -05:00
Calvin Rose
fb26c9b2c4
Add ev/select and ev/rselect initial implementation.
...
Getting closer to a CSP implmententation. Probably
useful to move scheduling fields outside of fibers
and into an external table.
2020-08-09 00:20:27 -05:00
Calvin Rose
78ffb63429
Disallow mutlitple state machines waiting for a single fiber.
...
A 'select' operator will be channel based, not state machine based.
2020-08-08 07:51:46 -05:00
Calvin Rose
1213990b7d
Merge branch 'master' into ev
2020-08-07 19:51:37 -05:00
Andrew Chambers
38dc844e85
Add missing JANET_API to janet_cryptorand.
2020-08-07 14:02:26 +12:00
Andrew Chambers
4d4ca7bb36
Initialize PRF with random data when it is enabled.
2020-08-04 12:13:36 +12:00
Calvin Rose
5899671d96
Merge branch 'master' into ev
2020-08-03 07:54:53 -05:00
Andre Alves Garzia
ba2beffcd8
Make sure JANET_NO_NANBOX is defined for ARM targets
2020-07-28 16:51:19 +01:00
Calvin Rose
d393fbf360
Merge branch 'master' into ev
2020-07-25 14:07:47 -05:00
Calvin Rose
ba08e487cb
Disable PRF by default.
...
Since it is not any better by default without initializing the key, we
disable it by default. It can be turned on with JANET_PRF in
janetconf.h.
2020-07-25 13:34:40 -05:00
Calvin Rose
553b4d9428
Add timeouts to net functions.
...
Further debugging of the general timeout system, as well
as having a single fiber wait on multiple state machines (select).
2020-07-19 19:41:12 -05:00
Calvin Rose
9ba94d2c6b
More work on timeouts and racing listeners.
...
When two listeners are racing to resume the same fiber, the
first should cancel out the other.
2020-07-05 17:26:17 -05:00
Calvin Rose
a4de83b3a3
Merge branch 'master' into ev
2020-07-05 10:11:23 -05:00
Calvin Rose
617ec7f565
Threading improvements.
...
- Add thread/exit to kill the current thread.
- Add global lock aroung custom getline and add atexit handler
- to prevent any possible issues when exiting program.
- Allow sending stderr, stdout, and stdin over thread.
2020-07-03 16:28:07 -05:00
Calvin Rose
7b31a87b3c
Update integer limits and printing.
2020-07-03 14:14:59 -05:00
Calvin Rose
37a430c97c
Move declarations around.
2020-07-03 13:47:48 -05:00
Calvin Rose
a0abf307b4
Merge branch 'master' into ev
2020-07-03 12:14:48 -05:00
Calvin Rose
aefde67aa2
And lots of optimization functionality.
2020-06-28 18:16:57 -05:00
Calvin Rose
9c5e97144d
More small changes to help with cross compilation
...
via makefile. Add option to turn off built in
getline via janetconf.
2020-06-27 12:39:16 -05:00
Calvin Rose
51ff43e2f2
Update range checks for 64 bit integers.
2020-06-27 11:23:47 -05:00
Calvin Rose
328ee94412
Merge branch 'master' into ev
2020-06-22 22:25:44 -05:00
Calvin Rose
b5e32a9ce5
Expose janet_table_clear.
2020-06-15 15:33:41 -05:00
Calvin Rose
ce2079104a
Merge branch 'master' into ev
2020-06-11 19:20:51 -05:00
Calvin Rose
6d096551f0
Add Peg combinators 'to' and 'thru'.
...
Inpsired by the REBOL operators of the same name, these
combinators match bytes up to or inculding a given pattern.
(to patt) is (almost) equalivalent to (any (if-not patt 1)), and
(thru patt) is equivalent to (* (to patt) patt). The one difference
is that if the end of the input is reached and patt is not
matched, the entire pattern does not match.
2020-06-10 21:18:50 -05:00
Calvin Rose
ec0d0ba368
Initial UDP implementation.
2020-06-02 19:47:50 -05:00
Leaf
bed02c2f95
Remove unused flags
2020-06-02 09:14:31 +00:00
Calvin Rose
a78af0a7fb
Do not explicitly free state machines, instead return a status.
...
This makes it harder to have some kind of use after free issue.
2020-05-30 11:31:05 -05:00
Calvin Rose
4c211c8dce
More updates to the ev library.
2020-05-28 16:51:11 -05:00
Calvin Rose
b68b0a256e
Start with ev module.
2020-05-28 10:39:40 -05:00
Calvin Rose
3100080a50
Add NO_UMASK and NO_REALPATH config options.
2020-05-10 23:07:54 -05:00
Calvin Rose
d05bb1c125
Fix nanboxing issue.
2020-05-10 20:14:47 -05:00
Calvin Rose
73dba691b1
Re-disable processes on emscripten build.
2020-05-09 12:04:47 -05:00
Calvin Rose
b1f76139a7
Add several configurable options - #379
2020-05-09 12:00:01 -05:00
Calvin Rose
8b5bcaee3c
Add lenprefix combinator to pegs.
...
This lets peg match n repeitions of a pattern, where
n is supplied from other parsed input and is not a constant.
2020-05-02 10:39:35 -05:00
Calvin Rose
f6bd41ada7
Add %M, %m, %N, and %n formatters.
...
These will not truncate long values.
2020-04-26 13:17:28 -05:00
Calvin Rose
7b5f40772f
Disable networking for emscripten build.
2020-04-26 12:37:27 -05:00
Calvin Rose
d2ebf4b52d
Merge branch 'net'
2020-04-26 12:27:37 -05:00
Calvin Rose
da4d8254fa
Silence warning in MSVC about VLAs.
...
When janet.h is included as a C++ header in
MSVC, shows warnings.
2020-04-25 17:13:25 -04:00
Calvin Rose
57332c5ccf
Change order of declarations for MSVC C++ support.
2020-04-25 15:42:44 -05:00
Calvin Rose
a87015598c
Make janet_equals and janet_compare non recursive
...
This makes these operatios use constant stack space rather
than linear stackspace given the size of the inputs. This is important
to prevent certain parser input from causing a stack overflow - in
general, we try to avoid unbounded recursion.
2020-04-24 16:18:31 -05:00
Calvin Rose
42c257d0fc
Merge branch 'master' into net
2020-04-19 13:38:51 -05:00
Calvin Rose
5054eb4276
Add JANET_MARSH_UNSAFE flag.
...
This allows unmarshal to optional marshal raw
pointers and cfunctions and send them across threads.
This flag is only exposed in the C API as it is very easy
to misuse and cause segfaults.
2020-04-19 10:56:39 -05:00
Calvin Rose
4ac382e553
Add alias JANET_SIGNAL_EVENT.
2020-04-17 16:27:02 -05:00
Calvin Rose
596111c988
Merge branch 'master' into net
2020-04-17 15:08:26 -05:00
Calvin Rose
71882475d6
janet_formatb -> janet_formatbv, new janet_formatb
...
The old function was not very useable. In the likely
case that there is no external code using this
(not well documented/janet_formatc is more convenient), we
can change this.
2020-04-14 07:38:41 -05:00
Calvin Rose
a09112404d
Add better error message on unexpected eos.
...
Show innermost open delimiter
2020-04-13 23:18:27 -05:00
Calvin Rose
b75a22b753
Make JANET_FRAME_SIZE consistent across architectures.
...
This means unmarshalling fibers should work across arches.
2020-04-06 12:41:56 -05:00
q66
5d840b944b
Fix wrong check on big endian systems
...
We can't randomly type pun random-sized types on big endian
systems.
2020-03-30 13:38:49 -05:00
q66
a40b2767c5
Fix endian check for little endian PowerPC and maybe others
...
This fixes various subtle breakage on ppc64le at very least.
2020-03-30 13:38:49 -05:00
Calvin Rose
b0d8369534
Increase reference accuracy of on-stack close envs.
...
Using a bitset to indicate which stack values are upvalues, we
can more accurately track when a reference to a stack value
persists after the stack frame exits.
2020-03-18 09:30:10 -05:00
Andrew Chambers
635ae3a523
Properly export u64_type
2020-03-17 11:02:57 +13:00
Calvin Rose
6a3a983f43
Expose abstract type definitions in janet.h
...
This makes certain operations easier, and allows
more access to built in APIs.
2020-03-14 10:12:47 -05:00
Calvin Rose
8f1527712e
Merge branch 'master' into net
2020-03-05 18:08:35 -06:00
Calvin Rose
10ec319c32
Add better debug info to amalgamated source.
2020-02-27 00:16:54 -06:00
Calvin Rose
f4d7fd97f6
Working TCP echo server and client.
...
Required a few changes to APIs, namely janet_root_fiber()
to get topmost fiber that is active in the current scheduler.
This is distinct from janet_current_fiber(), which gets the bottom
most fiber in the fiber stack - it might have a parent, and so cannot
be reliably resumed.
This is the kind of situation that makes symmetric coroutines more
attractive.
2020-02-09 20:00:50 -06:00
Calvin Rose
c0d2140d14
Begin net/ module in core.
...
Humble beginnings.
2020-02-01 20:39:54 -06:00
Calvin Rose
333ae7c4f8
Make amalgamtion the default when building.
...
This way we can support fewer build configurations. Also, remove
all undefined behavior due to use of memcpy with NULL pointers. GCC
was exploiting this to remove NULL checks in some builds.
2020-01-28 23:38:52 -06:00
Calvin Rose
28d41039b8
Add mod function to core.
...
The `mod` function is a pair function with `%`, or te remainder
function and is distinct from it. This is taken from common lisp.
2020-01-23 18:54:30 -06:00
Calvin Rose
4fad0714e7
Add janet_gcpressure. Address #269 .
2020-01-22 20:52:35 -06:00
Calvin Rose
e179f26d50
Add call function pointer to abstract types.
...
This will allow better JITs, FFIs, DSLs, etc.
2020-01-21 18:22:24 -06:00
Calvin Rose
2dd852da54
Use ATEND macros to add fields to abstract types.
...
This means we can add new properties to abstract types without
breaking old code. We can also make simple abstract types without
needing to add many NULL fields to the type.
2020-01-20 13:06:50 -06:00
Calvin Rose
f4077b678a
Allow calling next on abstracts.
...
This will allow the creation of infinte
streams, low cost generators, etc.
2020-01-18 18:09:20 -06:00
Calvin Rose
51678c1aba
Extend power of the each form
...
This changes the implementation of the `next` function which
is now used to implement each. This let's us iterate over
more types, not just tables and structs.
2020-01-18 17:55:07 -06:00
Andrew Chambers
344f0b743d
Make hash api more future proof.
2020-01-17 17:25:40 +13:00
Calvin Rose
23c7c3bf1c
Allow disabling keyed hash function (prf) in conf
...
In some cases, one might want to disable what is currently
SipHash for speed / better security mechansims. For example, using
red black trees for caches rather than hash tables.
2020-01-16 21:06:03 -06:00
Andrew Chambers
ea02b2fde9
Use siphash for string hashing.
...
The hash key still needs to randomly initialized
for the security advantage, but this patch is a
step closer to avoiding hash based DOS.
Further work may including exposing the raw hash
function for use by abstract types who also choose to
implement hash.
2020-01-17 12:06:55 +13:00
Calvin Rose
a68ee7aac6
Update Copyright 2020.
2020-01-12 10:50:37 -06:00
Calvin Rose
2f0570aad6
Address #249
...
If JANET_ENTRY_NAME is defined, we are compiling into a single binary.
In this case, we don't want to define the config symbol multiple times
with same name, as this causes the linker error.
2020-01-12 10:13:06 -06:00
Calvin Rose
3d40c95e80
Add ability to Janet signal from C functions.
...
While C functions are not re-entrant, signaling from a C function
can be used to implement async returns. When resuming a fiber that
signalled from within a C function, the fiber is started after the
instruction that emitted the signal. The resume argument is used
as the return result from the c function.
2020-01-10 20:44:16 -06:00
Andrew Chambers
acdbf8911c
Add scratch calloc.
2020-01-03 12:10:17 +13:00
Calvin Rose
2ba4337e6f
Remove all feature test macros from janet.h
...
This should help improve compatibility with other C code.
2019-12-30 15:12:17 -05:00
Calvin Rose
407d8af026
Address #233
...
Move _POSIX_C_SOURCE to internal header.
2019-12-30 12:31:26 -05:00
Calvin Rose
a964a95c1e
Fix warnings on BSDs.
2019-12-29 19:53:35 -05:00
Andrew Chambers
2bebace8eb
Extend file api to allow creating and checking.
2019-12-30 04:02:46 +13:00
Calvin Rose
022be217a2
Remove ==, not==, and order[<,<=,>,>=].
...
This unifies equality and comparison checking. Before, we had
separate functions and vm opcodes for comparing general values vs.
for comparing numbers, where the numberic functions were polymorphic and
had special cases for handling NaNs. By unfiying them, abstract types
can now better integrate with other number types and behave as keys.
For now, the old functions are aliased but will eventually be removed.
2019-12-28 16:04:15 -05:00
Calvin Rose
b8004555ea
Start cleaning up defines in janet.h
2019-12-15 15:41:58 -06:00
Calvin Rose
bc8ee207d5
Address #219 .
...
Adds several shorthands to the C API.
2019-12-14 11:31:46 -06:00
Calvin Rose
56784a34a1
Address #224 - Exposed file flags in janet.h
...
A caller can check if a file is closed with
if (flags & JANET_FILE_CLOSED) ...
2019-12-14 09:03:56 -06:00
Calvin Rose
aa7f3411f5
Use JANET_SINGLE_THREADED to disable threads.
2019-12-12 17:39:22 -06:00
Calvin Rose
36b2f27873
Merge branch 'master' into threads-3
2019-12-12 17:07:03 -06:00
Calvin Rose
2d5af32660
Refine typedefs.
2019-12-09 20:12:10 -06:00
Calvin Rose
e592b24333
Added some type aliases to janet.h
...
This should make it clearer if a pointer is really just a
plain pointer, or a pointer with a header.
2019-12-09 20:05:53 -06:00
Calvin Rose
8700a407ce
Update janet_getmethod to better match new get api.
2019-12-09 18:45:05 -06:00
Andrew Chambers
57ccfb692c
Abstract type getters can indicate key absence.
...
This change to the c api allows abstract types to indicate
to the runtime if a key was absent, or if it meant to return nil.
2019-12-09 16:50:33 +13:00
Calvin Rose
ee646dadf2
Merge branch 'master' into threads-3
2019-12-07 12:14:44 -06:00
Calvin Rose
73f5314141
Work on moving to mailbox abstraction.
...
Should be more efficient in the common case.
2019-12-07 12:14:16 -06:00
Calvin Rose
546669082f
New unmarshal proposal.
...
Gives more control over unmarshalling
abstract types. This should also
make it possible/easy to write abstract types that cannot
cause unmarshal to segfault.
2019-12-06 22:12:18 -06:00
Calvin Rose
c804ae9f7c
Update threads.c to avoid a deadlock.
2019-12-06 01:46:23 -06:00
Calvin Rose
1a4035b02c
Merge branch 'master' into threads-3
2019-12-04 22:39:30 -06:00
Calvin Rose
e908029392
Work on thread/receive doubling as select.
2019-12-04 22:31:01 -06:00
Calvin Rose
fd4220f254
Keep single global pthread_cond_t per thread.
...
This will allow thread/select to be implemented.
Also add thread/close and close method to threads.
2019-12-04 21:44:53 -06:00