1
0
mirror of https://github.com/janet-lang/janet synced 2024-10-31 22:16:16 +00:00

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.
This commit is contained in:
Calvin Rose 2020-07-25 13:34:40 -05:00
parent d37eda4e9b
commit ba08e487cb
7 changed files with 10 additions and 7 deletions

View File

@ -63,7 +63,7 @@ conf.set('JANET_NO_NET', not get_option('net'))
conf.set('JANET_REDUCED_OS', get_option('reduced_os'))
conf.set('JANET_NO_TYPED_ARRAY', not get_option('typed_array'))
conf.set('JANET_NO_INT_TYPES', not get_option('int_types'))
conf.set('JANET_NO_PRF', not get_option('prf'))
conf.set('JANET_PRF', get_option('prf'))
conf.set('JANET_RECURSION_GUARD', get_option('recursion_guard'))
conf.set('JANET_MAX_PROTO_DEPTH', get_option('max_proto_depth'))
conf.set('JANET_MAX_MACRO_EXPAND', get_option('max_macro_expand'))

View File

@ -10,7 +10,7 @@ option('assembler', type : 'boolean', value : true)
option('peg', type : 'boolean', value : true)
option('typed_array', type : 'boolean', value : true)
option('int_types', type : 'boolean', value : true)
option('prf', type : 'boolean', value : true)
option('prf', type : 'boolean', value : false)
option('net', type : 'boolean', value : true)
option('processes', type : 'boolean', value : true)
option('umask', type : 'boolean', value : true)

View File

@ -57,7 +57,7 @@
/* #define JANET_NO_UMASK */
/* Other settings */
/* #define JANET_NO_PRF */
/* #define JANET_PRF */
/* #define JANET_NO_UTC_MKTIME */
/* #define JANET_OUT_OF_MEMORY do { printf("janet out of memory\n"); exit(1); } while (0) */
/* #define JANET_EXIT(msg) do { printf("C assert failed executing janet: %s\n", msg); exit(1); } while (0) */

View File

@ -566,7 +566,8 @@ static Janet cfun_net_server(int32_t argc, Janet *argv) {
}
/* Put sfd on our loop */
JanetLoopFD lfd = {0};
JanetLoopFD lfd;
memset(&lfd, 0, sizeof(lfd));
lfd.stream = make_stream(sfd, 0);
lfd.event_type = JLE_READ_ACCEPT;
lfd.data.read_accept.handler = fun;

View File

@ -97,7 +97,7 @@ const char *const janet_status_names[16] = {
"alive"
};
#ifdef JANET_NO_PRF
#ifndef JANET_PRF
int32_t janet_string_calchash(const uint8_t *str, int32_t len) {
const uint8_t *end = str + len;

View File

@ -1381,7 +1381,7 @@ JANET_API int janet_verify(JanetFuncDef *def);
JANET_API JanetBuffer *janet_pretty(JanetBuffer *buffer, int depth, int flags, Janet x);
/* Misc */
#ifndef JANET_NO_PRF
#ifdef JANET_PRF
#define JANET_HASH_KEY_SIZE 16
JANET_API void janet_init_hash_key(uint8_t key[JANET_HASH_KEY_SIZE]);
#endif

View File

@ -48,7 +48,9 @@
(defn check-image
"Run a marshaling test using the make-image and load-image functions."
[x msg]
(assert-no-error msg (load-image (make-image x))))
(def im (make-image x))
(printf "\nimage-hash: %d" (-> im string hash))
(assert-no-error msg (load-image im)))
(check-image (fn [] (fn [] 1)) "marshal nested functions")
(check-image (fiber/new (fn [] (fn [] 1))) "marshal nested functions in fiber")