mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	Squashed commit of the following:
commitfbb0711ae1Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 12:07:55 2023 -0500 Distinguish between subprocess when testing. commit676b233566Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:59:17 2023 -0500 Hack for qemu based testing (also should work with valgrind) commitd7431c7cdbAuthor: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:54:04 2023 -0500 Revert "Test removing 32bit ptr marshalling." This reverts commit566b45ea44. commit566b45ea44Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:52:22 2023 -0500 Test removing 32bit ptr marshalling. commitff2f71d2bcAuthor: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:42:10 2023 -0500 Conditionally compile marshal_ptr code. commitbd420aeb0eAuthor: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:38:34 2023 -0500 Add range checking to bit-shift code to prevent undefined behavior. commitb738319f8dAuthor: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 11:17:30 2023 -0500 Remove range check on 32 bit arch since it will always pass. commit7248626235Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 10:56:45 2023 -0500 Quiet some build warnings. commit141c1de946Author: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 10:50:13 2023 -0500 Add marshal utilities for pointers. commitc2d77d6720Merge:677b8a6fff90b81eAuthor: Calvin Rose <calsrose@gmail.com> Date: Sat Jun 24 10:40:35 2023 -0500 Merge branch 'master' into armtest commit677b8a6f32Author: Ico Doornekamp <ico@zevv.nl> Date: Mon Jun 12 21:01:26 2023 +0200 Added ARM32 test
This commit is contained in:
		| @@ -401,7 +401,7 @@ static void janet_stream_marshal(void *p, JanetMarshalContext *ctx) { | ||||
|     } | ||||
|     janet_marshal_abstract(ctx, p); | ||||
|     janet_marshal_int(ctx, (int32_t) s->flags); | ||||
|     janet_marshal_int64(ctx, (intptr_t) s->methods); | ||||
|     janet_marshal_ptr(ctx, s->methods); | ||||
| #ifdef JANET_WINDOWS | ||||
|     /* TODO - ref counting to avoid situation where a handle is closed or GCed | ||||
|      * while in transit, and it's value gets reused. DuplicateHandle does not work | ||||
| @@ -438,7 +438,7 @@ static void *janet_stream_unmarshal(JanetMarshalContext *ctx) { | ||||
|     p->_mask = 0; | ||||
|     p->state = NULL; | ||||
|     p->flags = (uint32_t) janet_unmarshal_int(ctx); | ||||
|     p->methods = (void *) janet_unmarshal_int64(ctx); | ||||
|     p->methods =  janet_unmarshal_ptr(ctx); | ||||
| #ifdef JANET_WINDOWS | ||||
|     p->handle = (JanetHandle) janet_unmarshal_int64(ctx); | ||||
| #else | ||||
|   | ||||
| @@ -362,6 +362,15 @@ void janet_marshal_int(JanetMarshalContext *ctx, int32_t value) { | ||||
|     pushint(st, value); | ||||
| } | ||||
|  | ||||
| /* Only use in unsafe - don't marshal pointers otherwise */ | ||||
| void janet_marshal_ptr(JanetMarshalContext *ctx, const void *ptr) { | ||||
| #ifdef JANET_32 | ||||
|     janet_marshal_int(ctx, (intptr_t) ptr); | ||||
| #else | ||||
|     janet_marshal_int64(ctx, (intptr_t) ptr); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| void janet_marshal_byte(JanetMarshalContext *ctx, uint8_t value) { | ||||
|     MarshalState *st = (MarshalState *)(ctx->m_state); | ||||
|     pushbyte(st, value); | ||||
| @@ -1165,6 +1174,15 @@ int64_t janet_unmarshal_int64(JanetMarshalContext *ctx) { | ||||
|     return read64(st, &(ctx->data)); | ||||
| } | ||||
|  | ||||
| void *janet_unmarshal_ptr(JanetMarshalContext *ctx) { | ||||
|     UnmarshalState *st = (UnmarshalState *)(ctx->u_state); | ||||
| #ifdef JANET_32 | ||||
|     return (void *) ((intptr_t) readint(st, &(ctx->data))); | ||||
| #else | ||||
|     return (void *) ((intptr_t) read64(st, &(ctx->data))); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| uint8_t janet_unmarshal_byte(JanetMarshalContext *ctx) { | ||||
|     UnmarshalState *st = (UnmarshalState *)(ctx->u_state); | ||||
|     MARSH_EOS(st, ctx->data); | ||||
|   | ||||
| @@ -357,7 +357,8 @@ SlotHeadPair *dohead_destructure(JanetCompiler *c, SlotHeadPair *into, JanetFopt | ||||
|  | ||||
|     if (has_drop && can_destructure_lhs && rhs_is_indexed) { | ||||
|         /* Code is of the form (def [a b] [1 2]), avoid the allocation of two tuples */ | ||||
|         JanetView view_lhs, view_rhs; | ||||
|         JanetView view_lhs = {0}; | ||||
|         JanetView view_rhs = {0}; | ||||
|         janet_indexed_view(lhs, &view_lhs.items, &view_lhs.len); | ||||
|         janet_indexed_view(rhs, &view_rhs.items, &view_rhs.len); | ||||
|         int found_amp = 0; | ||||
|   | ||||
| @@ -698,11 +698,16 @@ Janet janet_lengthv(Janet x) { | ||||
|             const JanetAbstractType *type = janet_abstract_type(abst); | ||||
|             if (type->length != NULL) { | ||||
|                 size_t len = type->length(abst, janet_abstract_size(abst)); | ||||
|                 if ((uint64_t) len <= (uint64_t) JANET_INTMAX_INT64) { | ||||
|                     return janet_wrap_number((double) len); | ||||
|                 /* If len is always less then double, we can never overflow */ | ||||
| #ifdef JANET_32 | ||||
|                 return janet_wrap_number(len); | ||||
| #else | ||||
|                 if (len < (size_t) JANET_INTMAX_INT64) { | ||||
|                     return janet_wrap_number(len); | ||||
|                 } else { | ||||
|                     janet_panicf("integer length %u too large", len); | ||||
|                 } | ||||
| #endif | ||||
|             } | ||||
|             Janet argv[1] = { x }; | ||||
|             return janet_mcall("length", 1, argv); | ||||
|   | ||||
| @@ -138,7 +138,7 @@ | ||||
|             vm_pcnext();\ | ||||
|         }\ | ||||
|     } | ||||
| #define _vm_bitop_immediate(op, type1)\ | ||||
| #define _vm_bitop_immediate(op, type1, rangecheck, msg)\ | ||||
|     {\ | ||||
|         Janet op1 = stack[B];\ | ||||
|         if (!janet_checktype(op1, JANET_NUMBER)) {\ | ||||
| @@ -147,13 +147,15 @@ | ||||
|             stack[A] = janet_mcall(#op, 2, _argv);\ | ||||
|             vm_checkgc_pcnext();\ | ||||
|         } else {\ | ||||
|             type1 x1 = (type1) janet_unwrap_number(op1);\ | ||||
|             double y1 = janet_unwrap_number(op1);\ | ||||
|             if (!rangecheck(y1)) { vm_commit(); janet_panicf("value %v out of range for " msg, op1); }\ | ||||
|             type1 x1 = (type1) y1;\ | ||||
|             stack[A] = janet_wrap_number((type1) (x1 op CS));\ | ||||
|             vm_pcnext();\ | ||||
|         }\ | ||||
|     } | ||||
| #define vm_bitop_immediate(op) _vm_bitop_immediate(op, int32_t); | ||||
| #define vm_bitopu_immediate(op) _vm_bitop_immediate(op, uint32_t); | ||||
| #define vm_bitop_immediate(op) _vm_bitop_immediate(op, int32_t, janet_checkintrange, "32-bit signed integers"); | ||||
| #define vm_bitopu_immediate(op) _vm_bitop_immediate(op, uint32_t, janet_checkuintrange, "32-bit unsigned integers"); | ||||
| #define _vm_binop(op, wrap)\ | ||||
|     {\ | ||||
|         Janet op1 = stack[B];\ | ||||
| @@ -170,13 +172,17 @@ | ||||
|         }\ | ||||
|     } | ||||
| #define vm_binop(op) _vm_binop(op, janet_wrap_number) | ||||
| #define _vm_bitop(op, type1)\ | ||||
| #define _vm_bitop(op, type1, rangecheck, msg)\ | ||||
|     {\ | ||||
|         Janet op1 = stack[B];\ | ||||
|         Janet op2 = stack[C];\ | ||||
|         if (janet_checktype(op1, JANET_NUMBER) && janet_checktype(op2, JANET_NUMBER)) {\ | ||||
|             type1 x1 = (type1) janet_unwrap_number(op1);\ | ||||
|             int32_t x2 = janet_unwrap_integer(op2);\ | ||||
|             double y1 = janet_unwrap_number(op1);\ | ||||
|             double y2 = janet_unwrap_number(op2);\ | ||||
|             if (!rangecheck(y1)) { vm_commit(); janet_panicf("value %v out of range for " msg, op1); }\ | ||||
|             if (!janet_checkintrange(y2)) { vm_commit(); janet_panicf("rhs must be valid 32-bit signed integer, got %f", op2); }\ | ||||
|             type1 x1 = (type1) y1;\ | ||||
|             int32_t x2 = (int32_t) y2;\ | ||||
|             stack[A] = janet_wrap_number((type1) (x1 op x2));\ | ||||
|             vm_pcnext();\ | ||||
|         } else {\ | ||||
| @@ -185,8 +191,8 @@ | ||||
|             vm_checkgc_pcnext();\ | ||||
|         }\ | ||||
|     } | ||||
| #define vm_bitop(op) _vm_bitop(op, int32_t) | ||||
| #define vm_bitopu(op) _vm_bitop(op, uint32_t) | ||||
| #define vm_bitop(op) _vm_bitop(op, int32_t, janet_checkintrange, "32-bit signed integers") | ||||
| #define vm_bitopu(op) _vm_bitop(op, uint32_t, janet_checkuintrange, "32-bit unsigned integers") | ||||
| #define vm_compop(op) \ | ||||
|     {\ | ||||
|         Janet op1 = stack[B];\ | ||||
|   | ||||
| @@ -2053,6 +2053,7 @@ JANET_API int janet_cryptorand(uint8_t *out, size_t n); | ||||
| JANET_API void janet_marshal_size(JanetMarshalContext *ctx, size_t value); | ||||
| JANET_API void janet_marshal_int(JanetMarshalContext *ctx, int32_t value); | ||||
| JANET_API void janet_marshal_int64(JanetMarshalContext *ctx, int64_t value); | ||||
| JANET_API void janet_marshal_ptr(JanetMarshalContext *ctx, const void *value); | ||||
| JANET_API void janet_marshal_byte(JanetMarshalContext *ctx, uint8_t value); | ||||
| JANET_API void janet_marshal_bytes(JanetMarshalContext *ctx, const uint8_t *bytes, size_t len); | ||||
| JANET_API void janet_marshal_janet(JanetMarshalContext *ctx, Janet x); | ||||
| @@ -2062,6 +2063,7 @@ JANET_API void janet_unmarshal_ensure(JanetMarshalContext *ctx, size_t size); | ||||
| JANET_API size_t janet_unmarshal_size(JanetMarshalContext *ctx); | ||||
| JANET_API int32_t janet_unmarshal_int(JanetMarshalContext *ctx); | ||||
| JANET_API int64_t janet_unmarshal_int64(JanetMarshalContext *ctx); | ||||
| JANET_API void *janet_unmarshal_ptr(JanetMarshalContext *ctx); | ||||
| JANET_API uint8_t janet_unmarshal_byte(JanetMarshalContext *ctx); | ||||
| JANET_API void janet_unmarshal_bytes(JanetMarshalContext *ctx, uint8_t *dest, size_t len); | ||||
| JANET_API Janet janet_unmarshal_janet(JanetMarshalContext *ctx); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose