mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-27 13:47:42 +00:00 
			
		
		
		
	Compare commits
	
		
			16 Commits
		
	
	
		
			s390x-ci-f
			...
			installer-
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | bf6799bb67 | ||
|   | a4e7d2f142 | ||
|   | 85cb35e68f | ||
|   | 5b79b48ae0 | ||
|   | 7c44127bcb | ||
|   | 9338312103 | ||
|   | a0eeb630e7 | ||
|   | 6535d72bd4 | ||
|   | a7d424bc81 | ||
|   | 2bceba4a7a | ||
|   | e3159bb0f5 | ||
|   | 5d1bd8a932 | ||
|   | bafa6bfff0 | ||
|   | e2eb7ab4b2 | ||
|   | 9f4497a5ae | ||
|   | 70de8bf092 | 
							
								
								
									
										7
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							| @@ -38,6 +38,9 @@ jobs: | ||||
|       - name: Test the project | ||||
|         shell: cmd | ||||
|         run: build_win test | ||||
|       - name: Test installer build | ||||
|         shell: cmd | ||||
|         run: build_win dist | ||||
|  | ||||
|   test-windows-min: | ||||
|     name: Build and test on Windows Minimal build | ||||
| @@ -119,7 +122,7 @@ jobs: | ||||
|           sudo apt-get update | ||||
|           sudo apt-get install gcc-arm-linux-gnueabi qemu-user | ||||
|       - name: Compile the project | ||||
|         run: make RUN="qemu-arm -L /usr/arm-linux-gnueabi/" CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-gcc  | ||||
|         run: make RUN="qemu-arm -L /usr/arm-linux-gnueabi/" CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-gcc | ||||
|       - name: Test the project | ||||
|         run: make RUN="qemu-arm -L /usr/arm-linux-gnueabi/" SUBRUN="qemu-arm -L /usr/arm-linux-gnueabi/" test VERBOSE=1 | ||||
|  | ||||
| @@ -132,4 +135,4 @@ jobs: | ||||
|     - name: Do Qemu build and test | ||||
|       run: | | ||||
|         docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||||
|         docker run --rm -v .:/janet s390x/ubuntu bash -c "apt-get -y update && apt-get -y install git build-essential && cd /janet && make -j3 && make test" | ||||
|         docker run --rm -v .:/janet --platform linux/s390x ubuntu bash -c "apt-get -y update && apt-get -y install git build-essential && cd /janet && make -j3 && make test" | ||||
|   | ||||
| @@ -1,7 +1,13 @@ | ||||
| # Changelog | ||||
| All notable changes to this project will be documented in this file. | ||||
|  | ||||
| ## ??? - Unreleased | ||||
| ## 1.37.0 - 2024-12-05 | ||||
| - Fix meson cross compilation | ||||
| - Update timeout documentation for networking APIs: timeouts raise errors and do not return nil. | ||||
| - Add `janet_addtimeout_nil(double sec);` to the C API. | ||||
| - Change string hashing. | ||||
| - Fix string equality bug. | ||||
| - Add `assertf` | ||||
| - Change how JANET_PROFILE is loaded to allow more easily customizing the environment. | ||||
| - Add `*repl-prompt*` dynamic binding to allow customizing the built in repl. | ||||
| - Add multiple path support in the `JANET_PATH` environment variables. This lets | ||||
|   | ||||
| @@ -138,7 +138,8 @@ if defined APPVEYOR_REPO_TAG_NAME ( | ||||
|     set RELEASE_VERSION=%JANET_VERSION% | ||||
| ) | ||||
| if defined CI ( | ||||
|     set WIXBIN="c:\Program Files (x86)\WiX Toolset v3.11\bin\" | ||||
|     set WIXBIN="%WIX%bin\" | ||||
|     echo WIXBIN = %WIXBIN% | ||||
| ) else ( | ||||
|     set WIXBIN= | ||||
| ) | ||||
|   | ||||
							
								
								
									
										27
									
								
								meson.build
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								meson.build
									
									
									
									
									
								
							| @@ -26,8 +26,17 @@ project('janet', 'c', | ||||
| janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet') | ||||
| header_path = join_paths(get_option('prefix'), get_option('includedir'), 'janet') | ||||
|  | ||||
| # Link math library on all systems | ||||
| # Compilers | ||||
| cc = meson.get_compiler('c') | ||||
| native_cc = meson.get_compiler('c', native : true) | ||||
|  | ||||
| # Native deps | ||||
| native_m_dep = native_cc.find_library('m', required : false) | ||||
| native_dl_dep = native_cc.find_library('dl', required : false) | ||||
| native_android_spawn_dep = native_cc.find_library('android-spawn', required : false) | ||||
| native_thread_dep = dependency('threads', native : true) | ||||
|  | ||||
| # Deps | ||||
| m_dep = cc.find_library('m', required : false) | ||||
| dl_dep = cc.find_library('dl', required : false) | ||||
| android_spawn_dep = cc.find_library('android-spawn', required : false) | ||||
| @@ -164,11 +173,18 @@ mainclient_src = [ | ||||
|   'src/mainclient/shell.c' | ||||
| ] | ||||
|  | ||||
| janet_dependencies = [m_dep, dl_dep, android_spawn_dep] | ||||
| janet_native_dependencies = [native_m_dep, native_dl_dep, native_android_spawn_dep] | ||||
| if not get_option('single_threaded') | ||||
|   janet_dependencies += thread_dep | ||||
|   janet_native_dependencies += native_thread_dep | ||||
| endif | ||||
|  | ||||
| # Build boot binary | ||||
| janet_boot = executable('janet-boot', core_src, boot_src, | ||||
|   include_directories : incdir, | ||||
|   c_args : '-DJANET_BOOTSTRAP', | ||||
|   dependencies : [m_dep, dl_dep, thread_dep, android_spawn_dep], | ||||
|   dependencies : janet_native_dependencies, | ||||
|   native : true) | ||||
|  | ||||
| # Build janet.c | ||||
| @@ -181,11 +197,6 @@ janetc = custom_target('janetc', | ||||
|     'JANET_PATH', janet_path | ||||
|   ]) | ||||
|  | ||||
| janet_dependencies = [m_dep, dl_dep, android_spawn_dep] | ||||
| if not get_option('single_threaded') | ||||
|   janet_dependencies += thread_dep | ||||
| endif | ||||
|  | ||||
| # Allow building with no shared library | ||||
| if cc.has_argument('-fvisibility=hidden') | ||||
|   lib_cflags = ['-fvisibility=hidden'] | ||||
| @@ -231,7 +242,7 @@ if meson.is_cross_build() | ||||
|   endif | ||||
|   janet_nativeclient = executable('janet-native', janetc, mainclient_src, | ||||
|     include_directories : incdir, | ||||
|     dependencies : janet_dependencies, | ||||
|     dependencies : janet_native_dependencies, | ||||
|     c_args : extra_native_cflags, | ||||
|     native : true) | ||||
| else | ||||
|   | ||||
| @@ -154,11 +154,6 @@ | ||||
|        ,v | ||||
|        (,error ,(if err err (string/format "assert failure in %j" x)))))) | ||||
|  | ||||
| (defmacro assertf | ||||
|   "Convenience macro that combines `assert` and `string/format`." | ||||
|   [x & args] | ||||
|   ~(as-macro ,assert ,x (,string/format ,;args))) | ||||
|  | ||||
| (defmacro defdyn | ||||
|   ``Define an alias for a keyword that is used as a dynamic binding. The | ||||
|   alias is a normal, lexically scoped binding that can be used instead of | ||||
| @@ -209,6 +204,16 @@ | ||||
|   [fmt & args] | ||||
|   (error (string/format fmt ;args))) | ||||
|  | ||||
| (defmacro assertf | ||||
|   "Convenience macro that combines `assert` and `string/format`." | ||||
|   [x fmt & args] | ||||
|   (def v (gensym)) | ||||
|   ~(do | ||||
|      (def ,v ,x) | ||||
|      (if ,v | ||||
|        ,v | ||||
|        (,errorf ,fmt ,;args)))) | ||||
|  | ||||
| (defmacro default | ||||
|   ``Define a default value for an optional argument. | ||||
|   Expands to `(def sym (if (= nil sym) val sym))`.`` | ||||
| @@ -2660,7 +2665,6 @@ | ||||
|  | ||||
|       (do | ||||
|         (var pindex 0) | ||||
|         (var pstatus nil) | ||||
|         (def len (length buf)) | ||||
|         (when (= len 0) | ||||
|           (:eof p) | ||||
|   | ||||
| @@ -6,8 +6,8 @@ | ||||
| #define JANET_VERSION_MAJOR 1 | ||||
| #define JANET_VERSION_MINOR 37 | ||||
| #define JANET_VERSION_PATCH 0 | ||||
| #define JANET_VERSION_EXTRA "-dev" | ||||
| #define JANET_VERSION "1.37.0-dev" | ||||
| #define JANET_VERSION_EXTRA "" | ||||
| #define JANET_VERSION "1.37.0" | ||||
|  | ||||
| /* #define JANET_BUILD "local" */ | ||||
|  | ||||
|   | ||||
| @@ -625,6 +625,18 @@ void janet_addtimeout(double sec) { | ||||
|     add_timeout(to); | ||||
| } | ||||
|  | ||||
| /* Set timeout for the current root fiber but resume with nil instead of raising an error */ | ||||
| void janet_addtimeout_nil(double sec) { | ||||
|     JanetFiber *fiber = janet_vm.root_fiber; | ||||
|     JanetTimeout to; | ||||
|     to.when = ts_delta(ts_now(), sec); | ||||
|     to.fiber = fiber; | ||||
|     to.curr_fiber = NULL; | ||||
|     to.sched_id = fiber->sched_id; | ||||
|     to.is_error = 0; | ||||
|     add_timeout(to); | ||||
| } | ||||
|  | ||||
| void janet_ev_inc_refcount(void) { | ||||
|     janet_atomic_inc(&janet_vm.listener_count); | ||||
| } | ||||
|   | ||||
| @@ -829,7 +829,7 @@ JANET_CORE_FN(cfun_stream_accept_loop, | ||||
| JANET_CORE_FN(cfun_stream_accept, | ||||
|               "(net/accept stream &opt timeout)", | ||||
|               "Get the next connection on a server stream. This would usually be called in a loop in a dedicated fiber. " | ||||
|               "Takes an optional timeout in seconds, after which will return nil. " | ||||
|               "Takes an optional timeout in seconds, after which will raise an error. " | ||||
|               "Returns a new duplex stream which represents a connection to the client.") { | ||||
|     janet_arity(argc, 1, 2); | ||||
|     JanetStream *stream = janet_getabstract(argv, 0, &janet_stream_type); | ||||
| @@ -844,7 +844,7 @@ JANET_CORE_FN(cfun_stream_read, | ||||
|               "Read up to n bytes from a stream, suspending the current fiber until the bytes are available. " | ||||
|               "`n` can also be the keyword `:all` to read into the buffer until end of stream. " | ||||
|               "If less than n bytes are available (and more than 0), will push those bytes and return early. " | ||||
|               "Takes an optional timeout in seconds, after which will return nil. " | ||||
|               "Takes an optional timeout in seconds, after which will raise an error. " | ||||
|               "Returns a buffer with up to n more bytes in it, or raises an error if the read failed.") { | ||||
|     janet_arity(argc, 2, 4); | ||||
|     JanetStream *stream = janet_getabstract(argv, 0, &janet_stream_type); | ||||
| @@ -864,7 +864,7 @@ JANET_CORE_FN(cfun_stream_read, | ||||
| JANET_CORE_FN(cfun_stream_chunk, | ||||
|               "(net/chunk stream nbytes &opt buf timeout)", | ||||
|               "Same a net/read, but will wait for all n bytes to arrive rather than return early. " | ||||
|               "Takes an optional timeout in seconds, after which will return nil.") { | ||||
|               "Takes an optional timeout in seconds, after which will raise an error.") { | ||||
|     janet_arity(argc, 2, 4); | ||||
|     JanetStream *stream = janet_getabstract(argv, 0, &janet_stream_type); | ||||
|     janet_stream_flags(stream, JANET_STREAM_READABLE | JANET_STREAM_SOCKET); | ||||
| @@ -878,7 +878,7 @@ JANET_CORE_FN(cfun_stream_chunk, | ||||
| JANET_CORE_FN(cfun_stream_recv_from, | ||||
|               "(net/recv-from stream nbytes buf &opt timeout)", | ||||
|               "Receives data from a server stream and puts it into a buffer. Returns the socket-address the " | ||||
|               "packet came from. Takes an optional timeout in seconds, after which will return nil.") { | ||||
|               "packet came from. Takes an optional timeout in seconds, after which will raise an error.") { | ||||
|     janet_arity(argc, 3, 4); | ||||
|     JanetStream *stream = janet_getabstract(argv, 0, &janet_stream_type); | ||||
|     janet_stream_flags(stream, JANET_STREAM_UDPSERVER | JANET_STREAM_SOCKET); | ||||
| @@ -892,7 +892,7 @@ JANET_CORE_FN(cfun_stream_recv_from, | ||||
| JANET_CORE_FN(cfun_stream_write, | ||||
|               "(net/write stream data &opt timeout)", | ||||
|               "Write data to a stream, suspending the current fiber until the write " | ||||
|               "completes. Takes an optional timeout in seconds, after which will return nil. " | ||||
|               "completes. Takes an optional timeout in seconds, after which will raise an error. " | ||||
|               "Returns nil, or raises an error if the write failed.") { | ||||
|     janet_arity(argc, 2, 3); | ||||
|     JanetStream *stream = janet_getabstract(argv, 0, &janet_stream_type); | ||||
| @@ -911,7 +911,7 @@ JANET_CORE_FN(cfun_stream_write, | ||||
| JANET_CORE_FN(cfun_stream_send_to, | ||||
|               "(net/send-to stream dest data &opt timeout)", | ||||
|               "Writes a datagram to a server stream. dest is a the destination address of the packet. " | ||||
|               "Takes an optional timeout in seconds, after which will return nil. " | ||||
|               "Takes an optional timeout in seconds, after which will raise an error. " | ||||
|               "Returns stream.") { | ||||
|     janet_arity(argc, 3, 4); | ||||
|     JanetStream *stream = janet_getabstract(argv, 0, &janet_stream_type); | ||||
|   | ||||
| @@ -71,10 +71,10 @@ int janet_string_compare(const uint8_t *lhs, const uint8_t *rhs) { | ||||
| int janet_string_equalconst(const uint8_t *lhs, const uint8_t *rhs, int32_t rlen, int32_t rhash) { | ||||
|     int32_t lhash = janet_string_hash(lhs); | ||||
|     int32_t llen = janet_string_length(lhs); | ||||
|     if (lhs == rhs) | ||||
|         return 1; | ||||
|     if (lhash != rhash || llen != rlen) | ||||
|         return 0; | ||||
|     if (lhs == rhs) | ||||
|         return 1; | ||||
|     return !memcmp(lhs, rhs, rlen); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -117,14 +117,20 @@ const char *const janet_status_names[16] = { | ||||
|     "alive" | ||||
| }; | ||||
|  | ||||
| uint32_t janet_hash_mix(uint32_t input, uint32_t more) { | ||||
|     uint32_t mix1 = (more + 0x9e3779b9 + (input << 6) + (input >> 2)); | ||||
|     return input ^ (0x9e3779b9 + (mix1 << 6) + (mix1 >> 2)); | ||||
| } | ||||
|  | ||||
| #ifndef JANET_PRF | ||||
|  | ||||
| int32_t janet_string_calchash(const uint8_t *str, int32_t len) { | ||||
|     if (NULL == str) return 5381; | ||||
|     if (NULL == str || len == 0) return 5381; | ||||
|     const uint8_t *end = str + len; | ||||
|     uint32_t hash = 5381; | ||||
|     while (str < end) | ||||
|         hash = (hash << 5) + hash + *str++; | ||||
|     hash = janet_hash_mix(hash, (uint32_t) len); | ||||
|     return (int32_t) hash; | ||||
| } | ||||
|  | ||||
| @@ -240,11 +246,6 @@ int32_t janet_string_calchash(const uint8_t *str, int32_t len) { | ||||
|  | ||||
| #endif | ||||
|  | ||||
| uint32_t janet_hash_mix(uint32_t input, uint32_t more) { | ||||
|     uint32_t mix1 = (more + 0x9e3779b9 + (input << 6) + (input >> 2)); | ||||
|     return input ^ (0x9e3779b9 + (mix1 << 6) + (mix1 >> 2)); | ||||
| } | ||||
|  | ||||
| /* Computes hash of an array of values */ | ||||
| int32_t janet_array_calchash(const Janet *array, int32_t len) { | ||||
|     const Janet *end = array + len; | ||||
|   | ||||
| @@ -1442,6 +1442,7 @@ JANET_NO_RETURN JANET_API void janet_sleep_await(double sec); | ||||
| /* For use inside listeners - adds a timeout to the current fiber, such that | ||||
|  * it will be resumed after sec seconds if no other event schedules the current fiber. */ | ||||
| JANET_API void janet_addtimeout(double sec); | ||||
| JANET_API void janet_addtimeout_nil(double sec); | ||||
| JANET_API void janet_ev_inc_refcount(void); | ||||
| JANET_API void janet_ev_dec_refcount(void); | ||||
|  | ||||
|   | ||||
| @@ -987,11 +987,10 @@ | ||||
| (setdyn *debug* nil) | ||||
|  | ||||
| # issue #1516 | ||||
| (assert (assertf true) "assertf 1 argument") | ||||
| (assert-error "assertf 1 argument" (macex '(assertf true))) | ||||
| (assert (assertf true "fun message") "assertf 2 arguments") | ||||
| (assert (assertf true "%s message" "mystery") "assertf 3 arguments") | ||||
| (assert (assertf (not nil) "%s message" "ordinary") "assertf not nil") | ||||
| (assert-error "assertf error 1" (assertf false)) | ||||
| (assert-error "assertf error 2" (assertf false "fun message")) | ||||
| (assert-error "assertf error 3" (assertf false "%s message" "mystery")) | ||||
| (assert-error "assertf error 4" (assertf nil "%s %s" "alice" "bob")) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user