Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package moarvm for openSUSE:Factory checked in at 2021-03-29 18:21:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/moarvm (Old) and /work/SRC/openSUSE:Factory/.moarvm.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "moarvm" Mon Mar 29 18:21:55 2021 rev:28 rq:881720 version:2021.03 Changes: -------- --- /work/SRC/openSUSE:Factory/moarvm/moarvm.changes 2021-02-22 14:40:58.712658789 +0100 +++ /work/SRC/openSUSE:Factory/.moarvm.new.2401/moarvm.changes 2021-03-29 18:21:58.786274662 +0200 @@ -1,0 +2,9 @@ +Sun Mar 21 21:43:23 CET 2021 - n...@detonation.org + +- update to version 2021.03 + ++ Improve serialization of C types ++ Introduce `platform/socket.h` ++ Fix confused profiler output in multi-threaded apps + +------------------------------------------------------------------- Old: ---- MoarVM-2021.02.tar.gz New: ---- MoarVM-2021.03.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ moarvm.spec ++++++ --- /var/tmp/diff_new_pack.ZHHeyy/_old 2021-03-29 18:21:59.342275232 +0200 +++ /var/tmp/diff_new_pack.ZHHeyy/_new 2021-03-29 18:21:59.346275236 +0200 @@ -16,7 +16,7 @@ # -%global mvrel 2021.02 +%global mvrel 2021.03 Name: moarvm Version: %mvrel Release: 2.1 ++++++ MoarVM-2021.02.tar.gz -> MoarVM-2021.03.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/MANIFEST new/MoarVM-2021.03/MANIFEST --- old/MoarVM-2021.02/MANIFEST 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/MANIFEST 2021-03-20 11:18:07.000000000 +0100 @@ -1771,6 +1771,7 @@ src/platform/random.c src/platform/random.h src/platform/setjmp.h +src/platform/socket.h src/platform/stdint.h src/platform/sys.c src/platform/sys.h diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/VERSION new/MoarVM-2021.03/VERSION --- old/MoarVM-2021.02/VERSION 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/VERSION 2021-03-20 11:18:07.000000000 +0100 @@ -1 +1 @@ -2021.02 +2021.03 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/azure-pipelines.yml new/MoarVM-2021.03/azure-pipelines.yml --- old/MoarVM-2021.02/azure-pipelines.yml 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/azure-pipelines.yml 2021-03-20 11:18:07.000000000 +0100 @@ -119,7 +119,7 @@ condition: eq( variables['Agent.OS'], 'Windows_NT' ) - script: sudo apt-get install libzstd-dev - condition: eq( variables['Agent.OS'], 'Linux' ) + condition: and(succeeded(), eq( variables['Agent.OS'], 'Linux' )) displayName: Install libzstd-dev - checkout: self @@ -135,7 +135,7 @@ perl Configure.pl --prefix=../install $(MOAR_OPTIONS) make install workingDirectory: '$(Pipeline.Workspace)/MoarVM' - condition: ne( variables['Agent.OS'], 'Windows_NT' ) + condition: and(succeeded(), ne( variables['Agent.OS'], 'Windows_NT' )) displayName: Build MoarVM - pwsh: | ${{ variables.PWSH_DEV }} @@ -143,7 +143,7 @@ nmake install failOnStderr: false workingDirectory: '$(Pipeline.Workspace)/MoarVM' - condition: eq( variables['Agent.OS'], 'Windows_NT' ) + condition: and(succeeded(), eq( variables['Agent.OS'], 'Windows_NT' )) displayName: Build MoarVM (Windows) # Build NQP @@ -151,7 +151,7 @@ perl Configure.pl --prefix=../install $(NQP_OPTIONS) make install workingDirectory: '$(Pipeline.Workspace)/nqp' - condition: ne( variables['Agent.OS'], 'Windows_NT' ) + condition: and(succeeded(), ne( variables['Agent.OS'], 'Windows_NT' )) displayName: Build NQP - pwsh: | ${{ variables.PWSH_DEV }} @@ -159,7 +159,7 @@ nmake install failOnStderr: false workingDirectory: '$(Pipeline.Workspace)/nqp' - condition: eq( variables['Agent.OS'], 'Windows_NT' ) + condition: and(succeeded(), eq( variables['Agent.OS'], 'Windows_NT' )) displayName: Build NQP (Windows) # Build Rakudo @@ -167,7 +167,7 @@ perl Configure.pl --prefix=../install $(RAKUDO_OPTIONS) make install workingDirectory: '$(Pipeline.Workspace)/rakudo' - condition: ne( variables['Agent.OS'], 'Windows_NT' ) + condition: and(succeeded(), ne( variables['Agent.OS'], 'Windows_NT' )) displayName: Build Rakudo - pwsh: | ${{ variables.PWSH_DEV }} @@ -175,65 +175,65 @@ nmake install failOnStderr: false workingDirectory: '$(Pipeline.Workspace)/rakudo' - condition: eq( variables['Agent.OS'], 'Windows_NT' ) + condition: and(succeeded(), eq( variables['Agent.OS'], 'Windows_NT' )) displayName: Build Rakudo (Windows) # TODO: Should use "install moved" instead of "install-moved". But `prove` currently fails with an executable path that contains a space. - script: mv install install-moved workingDirectory: $(Pipeline.Workspace) - condition: and( eq( variables['RELOCATABLE'], 'yes' ), ne( variables['Agent.OS'], 'Windows_NT' ) ) + condition: and(succeeded(), eq( variables['RELOCATABLE'], 'yes' ), ne( variables['Agent.OS'], 'Windows_NT' ) ) displayName: Move installation - pwsh: mv install install-moved workingDirectory: $(Pipeline.Workspace) - condition: and( eq( variables['RELOCATABLE'], 'yes' ), eq( variables['Agent.OS'], 'Windows_NT' ) ) + condition: and(succeeded(), eq( variables['RELOCATABLE'], 'yes' ), eq( variables['Agent.OS'], 'Windows_NT' ) ) displayName: Move installation (Windows) # Test NQP - script: prove -j0 -r -e ../install/bin/nqp t/nqp t/hll t/qregex t/p5regex t/qast t/moar t/serialization t/nativecall t/concurrency workingDirectory: '$(Pipeline.Workspace)/nqp' - condition: and( ne( variables['RELOCATABLE'], 'yes' ), ne( variables['Agent.OS'], 'Windows_NT' ) ) + condition: and(succeeded(), ne( variables['RELOCATABLE'], 'yes' ), ne( variables['Agent.OS'], 'Windows_NT' ) ) displayName: Test NQP - pwsh: | ${{ variables.PWSH_DEV }} prove -j0 -r -e ..\install\bin\nqp t\nqp t\hll t\qregex t\p5regex t\qast t\moar t\serialization t\nativecall t\concurrency workingDirectory: '$(Pipeline.Workspace)/nqp' - condition: and( ne( variables['RELOCATABLE'], 'yes' ), eq( variables['Agent.OS'], 'Windows_NT' ) ) + condition: and(succeeded(), ne( variables['RELOCATABLE'], 'yes' ), eq( variables['Agent.OS'], 'Windows_NT' ) ) displayName: Test NQP (Windows) - script: prove -j0 -r -e ../install-moved/bin/nqp t/nqp t/hll t/qregex t/p5regex t/qast t/moar t/serialization t/nativecall t/concurrency workingDirectory: '$(Pipeline.Workspace)/nqp' - condition: and( eq( variables['RELOCATABLE'], 'yes' ), ne( variables['Agent.OS'], 'Windows_NT' ) ) + condition: and(succeeded(), eq( variables['RELOCATABLE'], 'yes' ), ne( variables['Agent.OS'], 'Windows_NT' ) ) displayName: Test NQP (relocated) - pwsh: | ${{ variables.PWSH_DEV }} prove -j0 -r -e ..\install-moved\bin\nqp t\nqp t\hll t\qregex t\p5regex t\qast t\moar t\serialization t\nativecall t\concurrency workingDirectory: '$(Pipeline.Workspace)/nqp' - condition: and( eq( variables['RELOCATABLE'], 'yes' ), eq( variables['Agent.OS'], 'Windows_NT' ) ) + condition: and(succeeded(), eq( variables['RELOCATABLE'], 'yes' ), eq( variables['Agent.OS'], 'Windows_NT' ) ) displayName: Test NQP (relocated, Windows) # Test Rakudo - script: prove -e ../install/bin/perl6 -vlr t workingDirectory: '$(Pipeline.Workspace)/rakudo' - condition: and( ne( variables['RELOCATABLE'], 'yes' ), ne( variables['Agent.OS'], 'Windows_NT' ) ) + condition: and(succeeded(), ne( variables['RELOCATABLE'], 'yes' ), ne( variables['Agent.OS'], 'Windows_NT' ) ) displayName: Test Rakudo - pwsh: | ${{ variables.PWSH_DEV }} prove -e ..\install\bin\perl6 -vlr t workingDirectory: '$(Pipeline.Workspace)/rakudo' - condition: and( ne( variables['RELOCATABLE'], 'yes' ), eq( variables['Agent.OS'], 'Windows_NT' ) ) + condition: and(succeeded(), ne( variables['RELOCATABLE'], 'yes' ), eq( variables['Agent.OS'], 'Windows_NT' ) ) displayName: Test Rakudo (Windows) - script: prove -e ../install-moved/bin/perl6 -vlr t workingDirectory: '$(Pipeline.Workspace)/rakudo' - condition: and( eq( variables['RELOCATABLE'], 'yes' ), ne( variables['Agent.OS'], 'Windows_NT' ) ) + condition: and(succeeded(), eq( variables['RELOCATABLE'], 'yes' ), ne( variables['Agent.OS'], 'Windows_NT' ) ) displayName: Test Rakudo (relocated) - pwsh: | ${{ variables.PWSH_DEV }} prove -e ..\install-moved\bin\perl6 -vlr t workingDirectory: '$(Pipeline.Workspace)/rakudo' - condition: and( eq( variables['RELOCATABLE'], 'yes' ), eq( variables['Agent.OS'], 'Windows_NT' ) ) + condition: and(succeeded(), eq( variables['RELOCATABLE'], 'yes' ), eq( variables['Agent.OS'], 'Windows_NT' ) ) displayName: Test Rakudo (relocated, Windows) - publish: $(Pipeline.Workspace)/install-moved - condition: eq( variables['RELOCATABLE'], 'yes' ) + condition: and(succeeded(), eq( variables['RELOCATABLE'], 'yes' )) displayName: Publish build artifact - script: | @@ -242,4 +242,4 @@ cp -v MoarVM-cover/nqp-profile ../nqp/ && cp -v MoarVM-cover/merge-profraw.sh ../nqp/ && ./html-cover.sh 2 - condition: eq( variables['COVERAGE'], 'yes' ) + condition: and(succeeded(), eq( variables['COVERAGE'], 'yes' )) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/build/Makefile.in new/MoarVM-2021.03/build/Makefile.in --- old/MoarVM-2021.02/build/Makefile.in 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/build/Makefile.in 2021-03-20 11:18:07.000000000 +0100 @@ -433,6 +433,7 @@ src/platform/malloc_trim.h \ src/platform/random.h \ src/platform/fork.h \ + src/platform/socket.h \ src/jit/graph.h \ src/jit/label.h \ src/jit/expr.h \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/docs/ChangeLog new/MoarVM-2021.03/docs/ChangeLog --- old/MoarVM-2021.02/docs/ChangeLog 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/docs/ChangeLog 2021-03-20 11:18:07.000000000 +0100 @@ -1,4 +1,19 @@ -New in 2021.01 +New in 2021.03 + +6model: ++ [776d2ff2,f745dda5,1ae3d8e5,37e15bbf,d441bfdf,2cc6df5f,f24507d2] + Improve serialization of C types + +IO: ++ [cdbdec1a.0ff77ecd,63b213cb] Introduce `platform/socket.h` + +Tooling/Build: ++ [23a7fb96] Avoid Azure CI failures on re-builds + +Profiler: ++ [e316dc34] Fix confused profiler output in multi-threaded apps + +New in 2021.02 6model: + [c6d2d355] Convert MVMSpeshCandidate to a REPR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/src/6model/reprs/NativeCall.c new/MoarVM-2021.03/src/6model/reprs/NativeCall.c --- old/MoarVM-2021.02/src/6model/reprs/NativeCall.c 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/src/6model/reprs/NativeCall.c 2021-03-20 11:18:07.000000000 +0100 @@ -99,8 +99,8 @@ MVMNativeCallBody *body = (MVMNativeCallBody *)data; MVMint16 i = 0; if (reader->root.version >= 22) { - body->lib_name = MVM_serialization_read_cstr(tc, reader); - body->sym_name = MVM_serialization_read_cstr(tc, reader); + body->lib_name = MVM_serialization_read_cstr(tc, reader, NULL); + body->sym_name = MVM_serialization_read_cstr(tc, reader, NULL); body->convention = MVM_serialization_read_int(tc, reader); body->num_args = MVM_serialization_read_int(tc, reader); body->ret_type = MVM_serialization_read_int(tc, reader); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/src/6model/serialization.c new/MoarVM-2021.03/src/6model/serialization.c --- old/MoarVM-2021.02/src/6model/serialization.c 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/src/6model/serialization.c 2021-03-20 11:18:07.000000000 +0100 @@ -326,23 +326,21 @@ } } -/* Writing function for null-terminated char array strings */ -void MVM_serialization_write_cstr(MVMThreadContext *tc, MVMSerializationWriter *writer, char *string) { - size_t len; - if (string) - len = strlen(string); - else - len = 0; - if (len) { - MVM_serialization_write_int(tc, writer, len); - expand_storage_if_needed(tc, writer, len); - memcpy(*(writer->cur_write_buffer) + *(writer->cur_write_offset), string, len); - *(writer->cur_write_offset) += len; - } else { - MVM_serialization_write_int(tc, writer, 0); +/* Writing function for pointers. */ +void MVM_serialization_write_ptr(MVMThreadContext *tc, MVMSerializationWriter *writer, const void *ptr, size_t size) { + MVM_serialization_write_int(tc, writer, size); + if (size) { + expand_storage_if_needed(tc, writer, size); + memcpy(*(writer->cur_write_buffer) + *(writer->cur_write_offset), ptr, size); + *(writer->cur_write_offset) += size; } } +/* Writing function for null-terminated char array strings. */ +void MVM_serialization_write_cstr(MVMThreadContext *tc, MVMSerializationWriter *writer, const char *cstr) { + MVM_serialization_write_ptr(tc, writer, cstr, cstr ? strlen(cstr) : 0); +} + /* Writing function for variable sized integers. Writes out a 64 bit value using between 1 and 9 bytes. */ void MVM_serialization_write_int(MVMThreadContext *tc, MVMSerializationWriter *writer, MVMint64 value) { @@ -1738,23 +1736,53 @@ return read_string_from_heap(tc, reader, offset); } -/* Reading function for null-terminated char array strings */ -char *MVM_serialization_read_cstr(MVMThreadContext *tc, MVMSerializationReader *reader) { - MVMint64 len = MVM_serialization_read_int(tc, reader); - char *strbuf = 0; - if (len > 0) { - const MVMuint8 *read_at = (MVMuint8 *) *(reader->cur_read_buffer) + *(reader->cur_read_offset); - assert_can_read(tc, reader, len); - strbuf = MVM_malloc(len + 1); - if (strbuf == 0) - fail_deserialize(tc, NULL, reader, "Cannot read a c string: malloc failed."); - memcpy(strbuf, read_at, len); - strbuf[len] = 0; - *(reader->cur_read_offset) += len; - } else if (len < 0) { - fail_deserialize(tc, NULL, reader, "Cannot read a c string with negative length %"PRIi64".", len); +/* Reading function for pointers. */ +void * MVM_serialization_read_ptr(MVMThreadContext *tc, MVMSerializationReader *reader, size_t *size) { + MVMint64 ptr_size; + void *ptr; + + if (!(ptr_size = MVM_serialization_read_int(tc, reader))) + ptr = NULL; + else if (ptr_size < 0 || ptr_size > SIZE_MAX) + fail_deserialize(tc, NULL, reader, + "Deserialized pointer with out-of-range size (%"PRIi64")", + ptr_size); + else { + const MVMuint8 *read_at = (MVMuint8 *)*(reader->cur_read_buffer) + *(reader->cur_read_offset); + assert_can_read(tc, reader, ptr_size); + ptr = MVM_malloc(ptr_size); + memcpy(ptr, read_at, ptr_size); + *(reader->cur_read_offset) += ptr_size; + } + + if (size) + *size = ptr_size; + return ptr; +} + +/* Reading function for null-terminated char array strings. */ +char * MVM_serialization_read_cstr(MVMThreadContext *tc, MVMSerializationReader *reader, size_t *len) { + MVMint64 cstr_len; + char *cstr; + + if (!(cstr_len = MVM_serialization_read_int(tc, reader))) + cstr = NULL; + else if (cstr_len < 0 || cstr_len >= SIZE_MAX) + fail_deserialize(tc, NULL, reader, + "Deserialized C string with out-of-range length (%"PRIi64")", + cstr_len); + else { + const MVMuint8 *read_at = (MVMuint8 *)*(reader->cur_read_buffer) + *(reader->cur_read_offset); + assert_can_read(tc, reader, cstr_len); + cstr = MVM_malloc(cstr_len + 1); + memcpy(cstr, read_at, cstr_len); + cstr[cstr_len] = '\0'; + *(reader->cur_read_offset) += cstr_len; } - return strbuf; + + if (len) + *len = cstr_len; + return cstr; } /* The SC id,idx pair is used in various ways, but common to them all is to @@ -2814,7 +2842,7 @@ } if (reader->root.version >= 18) { - st->debug_name = MVM_serialization_read_cstr(tc, reader); + st->debug_name = MVM_serialization_read_cstr(tc, reader, NULL); } else { st->debug_name = NULL; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/src/6model/serialization.h new/MoarVM-2021.03/src/6model/serialization.h --- old/MoarVM-2021.02/src/6model/serialization.h 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/src/6model/serialization.h 2021-03-20 11:18:07.000000000 +0100 @@ -190,13 +190,15 @@ MVMint64 MVM_serialization_read_int(MVMThreadContext *tc, MVMSerializationReader *reader); MVMnum64 MVM_serialization_read_num(MVMThreadContext *tc, MVMSerializationReader *reader); MVMString * MVM_serialization_read_str(MVMThreadContext *tc, MVMSerializationReader *reader); -char *MVM_serialization_read_cstr(MVMThreadContext *tc, MVMSerializationReader *reader); +void * MVM_serialization_read_ptr(MVMThreadContext *tc, MVMSerializationReader *reader, size_t *size); +char * MVM_serialization_read_cstr(MVMThreadContext *tc, MVMSerializationReader *reader, size_t *len); MVM_PUBLIC MVMObject * MVM_serialization_read_ref(MVMThreadContext *tc, MVMSerializationReader *reader); MVMSTable * MVM_serialization_read_stable_ref(MVMThreadContext *tc, MVMSerializationReader *reader); void MVM_serialization_force_stable(MVMThreadContext *tc, MVMSerializationReader *reader, MVMSTable *st); void MVM_serialization_write_int(MVMThreadContext *tc, MVMSerializationWriter *writer, MVMint64 value); void MVM_serialization_write_num(MVMThreadContext *tc, MVMSerializationWriter *writer, MVMnum64 value); void MVM_serialization_write_str(MVMThreadContext *tc, MVMSerializationWriter *writer, MVMString *value); -void MVM_serialization_write_cstr(MVMThreadContext *tc, MVMSerializationWriter *writer, char *string); +void MVM_serialization_write_ptr(MVMThreadContext *tc, MVMSerializationWriter *writer, const void *ptr, size_t size); +void MVM_serialization_write_cstr(MVMThreadContext *tc, MVMSerializationWriter *writer, const char *cstr); MVM_PUBLIC void MVM_serialization_write_ref(MVMThreadContext *tc, MVMSerializationWriter *writer, MVMObject *ref); void MVM_serialization_write_stable_ref(MVMThreadContext *tc, MVMSerializationWriter *writer, MVMSTable *st); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/src/debug/debugserver.c new/MoarVM-2021.03/src/debug/debugserver.c --- old/MoarVM-2021.02/src/debug/debugserver.c 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/src/debug/debugserver.c 2021-03-20 11:18:07.000000000 +0100 @@ -8,20 +8,7 @@ #define false FALSE #include "cmp.h" - -#ifdef _WIN32 - #include <winsock2.h> - #include <ws2tcpip.h> - typedef SOCKET Socket; - #define sa_family_t unsigned int -#else - #include "unistd.h" - #include <sys/socket.h> - #include <sys/un.h> - - typedef int Socket; - #define closesocket close -#endif +#include "platform/socket.h" typedef enum { MT_MessageTypeNotUnderstood, @@ -471,7 +458,7 @@ #endif } -static void send_greeting(Socket *sock) { +static void send_greeting(MVMSocket *sock) { char buffer[24] = "MOARVM-REMOTE-DEBUG\0"; MVMuint16 version = big_endian_16(DEBUGSERVER_MAJOR_PROTOCOL_VERSION); MVMuint16 *verptr = (MVMuint16 *)(&buffer[strlen("MOARVM-REMOTE-DEBUG") + 1]); @@ -485,7 +472,7 @@ send(*sock, buffer, 24, 0); } -static int receive_greeting(Socket *sock) { +static int receive_greeting(MVMSocket *sock) { const char *expected = "MOARVM-REMOTE-CLIENT-OK"; char buffer[24]; int received = 0; @@ -2705,7 +2692,7 @@ if (debugspam_network) fprintf(stderr, "asked to read %zu bytes\n", limit); while (total_read < limit) { - if ((read = recv(*((Socket*)ctx->buf), data, limit, 0)) == -1) { + if ((read = recv(*((MVMSocket*)ctx->buf), data, limit, 0)) == -1) { if (debugspam_network) fprintf(stderr, "minus one\n"); return 0; @@ -2737,7 +2724,7 @@ if (debugspam_network) fprintf(stderr, "asked to send %3zu bytes: ", limit); while (total_sent < limit) { - if ((sent = send(*(Socket*)ctx->buf, data, limit, 0)) == -1) { + if ((sent = send(*(MVMSocket*)ctx->buf, data, limit, 0)) == -1) { if (debugspam_network) fprintf(stderr, "but couldn't (socket disconnected?)\n"); return 0; @@ -3203,7 +3190,7 @@ static void debugserver_worker(MVMThreadContext *tc, MVMCallsite *callsite, MVMRegister *args) { int continue_running = 1; - Socket listensocket; + MVMSocket listensocket; MVMInstance *vm = tc->instance; MVMuint64 port = vm->debugserver->port; @@ -3260,7 +3247,7 @@ } while(continue_running) { - Socket clientsocket; + MVMSocket clientsocket; cmp_ctx_t ctx; MVM_gc_mark_thread_blocked(tc); @@ -3272,7 +3259,7 @@ if (!receive_greeting(&clientsocket)) { if (tc->instance->debugserver->debugspam_protocol) fprintf(stderr, "Debugserver: did not receive greeting properly\n"); - close(clientsocket); + MVM_platform_close_socket(clientsocket); continue; } @@ -3302,7 +3289,7 @@ cmp_write_str(&ctx, "reason", 6); cmp_write_str(&ctx, argument.parse_fail_message, strlen(argument.parse_fail_message)); - close(clientsocket); + MVM_platform_close_socket(clientsocket); uv_mutex_unlock(&vm->debugserver->mutex_network_send); break; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/src/io/syncsocket.c new/MoarVM-2021.03/src/io/syncsocket.c --- old/MoarVM-2021.02/src/io/syncsocket.c 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/src/io/syncsocket.c 2021-03-20 11:18:07.000000000 +0100 @@ -1,21 +1,5 @@ #include "moar.h" - -#ifdef _WIN32 - #include <winsock2.h> - #include <ws2tcpip.h> - #include <io.h> - - typedef SOCKET Socket; - #define sa_family_t unsigned int - #define isatty _isatty -#else - #include "unistd.h" - #include <sys/socket.h> - #include <sys/un.h> - - typedef int Socket; - #define closesocket close -#endif +#include "platform/socket.h" #if defined(_MSC_VER) #define snprintf _snprintf @@ -50,7 +34,7 @@ /* Data that we keep for a socket-based handle. */ typedef struct { /* The socket handle (file descriptor on POSIX, SOCKET on Windows). */ - Socket handle; + MVMSocket handle; /* Buffer of the last received packet of data, and start/end pointers * into the data. */ @@ -225,7 +209,7 @@ static MVMint64 do_close(MVMThreadContext *tc, MVMIOSyncSocketData *data) { if (data->handle) { - closesocket(data->handle); + MVM_platform_close_socket(data->handle); data->handle = 0; } return 0; @@ -246,7 +230,7 @@ return sizeof(struct sockaddr_in6); case AF_INET: return sizeof(struct sockaddr_in); -#ifndef _WIN32 +#ifdef MVM_HAS_PF_UNIX case AF_UNIX: return sizeof(struct sockaddr_un); #endif @@ -311,20 +295,14 @@ hints.ai_family = AF_INET6; break; case MVM_SOCKET_FAMILY_UNIX: { -#if defined(_WIN32) || !defined(AF_UNIX) - /* TODO: UNIX socket support exists in newer versions of Windows. - * See if it's good enough for us to use. */ - MVM_free(host_cstr); - MVM_exception_throw_adhoc(tc, "UNIX sockets are not supported by MoarVM on this platform"); -#else - static const size_t MAX_SUN_LEN = sizeof(((struct sockaddr_un *)NULL)->sun_path); - size_t sun_len = strnlen(host_cstr, MAX_SUN_LEN); +#ifdef MVM_HAS_PF_UNIX + size_t sun_len = strnlen(host_cstr, MVM_SUN_PATH_SIZE); - if (sun_len >= MAX_SUN_LEN) { + if (sun_len >= MVM_SUN_PATH_SIZE) { char *waste[] = { host_cstr, NULL }; MVM_exception_throw_adhoc_free( tc, waste, "Socket path '%s' is too long (max length supported by this platform is %zu characters)", - host_cstr, MAX_SUN_LEN - 1 + host_cstr, MVM_SUN_PATH_SIZE - 1 ); } else { struct sockaddr_un *result_un = MVM_malloc(sizeof(struct sockaddr_un)); @@ -333,6 +311,9 @@ MVM_free(host_cstr); return (struct sockaddr *)result_un; } +#else + MVM_free(host_cstr); + MVM_exception_throw_adhoc(tc, "UNIX sockets are not supported by MoarVM on this platform"); #endif } default: @@ -413,7 +394,7 @@ struct sockaddr *dest = MVM_io_resolve_host_name(tc, host, port, family, MVM_SOCKET_TYPE_STREAM, MVM_SOCKET_PROTOCOL_ANY, 0); int r; - Socket s = socket(dest->sa_family , SOCK_STREAM , 0); + MVMSocket s = socket(dest->sa_family , SOCK_STREAM , 0); if (MVM_IS_SOCKET_ERROR(s)) { MVM_free(dest); MVM_telemetry_interval_stop(tc, interval_id, "syncsocket connect"); @@ -445,7 +426,7 @@ struct sockaddr *dest = MVM_io_resolve_host_name(tc, host, port, family, MVM_SOCKET_TYPE_STREAM, MVM_SOCKET_PROTOCOL_ANY, 1); int r; - Socket s = socket(dest->sa_family , SOCK_STREAM , 0); + MVMSocket s = socket(dest->sa_family , SOCK_STREAM , 0); if (MVM_IS_SOCKET_ERROR(s)) { MVM_free(dest); throw_error(tc, s, "create socket"); @@ -507,7 +488,7 @@ static MVMint64 socket_is_tty(MVMThreadContext *tc, MVMOSHandle *h) { MVMIOSyncSocketData *data = (MVMIOSyncSocketData *)h->body.data; - return (MVMint64)isatty(data->handle); + return (MVMint64)MVM_platform_isatty(data->handle); } static MVMint64 socket_handle(MVMThreadContext *tc, MVMOSHandle *h) { @@ -550,7 +531,7 @@ static MVMObject * socket_accept(MVMThreadContext *tc, MVMOSHandle *h) { MVMIOSyncSocketData *data = (MVMIOSyncSocketData *)h->body.data; - Socket s; + MVMSocket s; unsigned int interval_id = MVM_telemetry_interval_start(tc, "syncsocket accept"); do { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/src/platform/socket.h new/MoarVM-2021.03/src/platform/socket.h --- old/MoarVM-2021.02/src/platform/socket.h 1970-01-01 01:00:00.000000000 +0100 +++ new/MoarVM-2021.03/src/platform/socket.h 2021-03-20 11:18:07.000000000 +0100 @@ -0,0 +1,38 @@ +#ifdef _WIN32 +# include <winsock2.h> +# include <ws2tcpip.h> +# include <io.h> +#else +# include <sys/socket.h> +# include <netinet/in.h> +# include <unistd.h> +#endif + +#ifdef _WIN32 +# if 0 +/* TODO: Is Windows' UNIX socket support more complete nowadays...? SOCK_DGRAM + * support was missing at one point. */ +# include <afunix.h> +# endif +#else +# include <sys/un.h> +# define MVM_HAS_PF_UNIX +# define MVM_SUN_PATH_SIZE sizeof(((struct sockaddr_un *)NULL)->sun_path) +#endif + +#ifdef _WIN32 +typedef ULONG in_addr_t; +typedef USHORT in_port_t; +typedef USHORT sa_family_t; +typedef SOCKET MVMSocket; +#else +typedef int MVMSocket; +#endif + +#ifdef _WIN32 +# define MVM_platform_close_socket closesocket +# define MVM_platform_isatty _isatty +#else +# define MVM_platform_close_socket close +# define MVM_platform_isatty isatty +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MoarVM-2021.02/src/profiler/instrument.c new/MoarVM-2021.03/src/profiler/instrument.c --- old/MoarVM-2021.02/src/profiler/instrument.c 2021-02-20 22:47:18.000000000 +0100 +++ new/MoarVM-2021.03/src/profiler/instrument.c 2021-03-20 11:18:07.000000000 +0100 @@ -683,7 +683,7 @@ ProfTcPdsStruct tcpds; - tcpds.tc = tc; + tcpds.tc = othertc; tcpds.pds = pds; tcpds.types_array = types_data;