On 03/26 09:28, Solene Rapenne wrote: > On Thu, Mar 26, 2020 at 08:06:12PM +0100, Solene Rapenne wrote: > > The following patch updates mednafen to last version, I tried a few > > platform successfully on adm64. > > > > I disabled snes module at compile time because it just doesn't work and > > crashes, instead of providing a README explaining how to modify > > medfnafen.cfg to disable snes to fallback to snes_faust module. > > > > > > Thanks to bentley@ I applied same patches on libco that are used in > emulators/hikan and snes modules works.
I briefly tested all emulation modes I could and everything seems to work. OK jeremy@ Thanks, Jeremy > > > Index: Makefile > =================================================================== > RCS file: /data/cvs/ports/emulators/mednafen/Makefile,v > retrieving revision 1.27 > diff -u -p -r1.27 Makefile > --- Makefile 19 Jun 2019 04:01:21 -0000 1.27 > +++ Makefile 26 Mar 2020 20:28:27 -0000 > @@ -3,7 +3,7 @@ > BROKEN-hppa = ../../include/mednafen/state.h:21:7: error: > 'exception_ptr' in namespace 'std' does not name a type > COMMENT = emulates numerous game consoles > > -DISTNAME = mednafen-1.22.2 > +DISTNAME = mednafen-1.24.1 > > CATEGORIES = emulators games > HOMEPAGE = https://mednafen.github.io > Index: distinfo > =================================================================== > RCS file: /data/cvs/ports/emulators/mednafen/distinfo,v > retrieving revision 1.12 > diff -u -p -r1.12 distinfo > --- distinfo 19 Jun 2019 04:01:21 -0000 1.12 > +++ distinfo 26 Mar 2020 18:05:53 -0000 > @@ -1,2 +1,2 @@ > -SHA256 (mednafen-1.22.2.tar.xz) = > +tQzrGlGltaeo49vS+HQpsGqNgnsf0bOdUEr4vLfL5U= > -SIZE (mednafen-1.22.2.tar.xz) = 3270004 > +SHA256 (mednafen-1.24.1.tar.xz) = > pHrfP69NpmkgvruUNuKMv4f/ZjJNC7OSAzy7R4tnX+c= > +SIZE (mednafen-1.24.1.tar.xz) = 3293992 > Index: patches/patch-src_sexyal_sexyal_cpp > =================================================================== > RCS file: > /data/cvs/ports/emulators/mednafen/patches/patch-src_sexyal_sexyal_cpp,v > retrieving revision 1.1 > diff -u -p -r1.1 patch-src_sexyal_sexyal_cpp > --- patches/patch-src_sexyal_sexyal_cpp 8 Sep 2018 23:08:39 -0000 > 1.1 > +++ patches/patch-src_sexyal_sexyal_cpp 26 Mar 2020 20:00:02 -0000 > @@ -8,7 +8,7 @@ audio device. You can still use the ope > Index: src/sexyal/sexyal.cpp > --- src/sexyal/sexyal.cpp.orig > +++ src/sexyal/sexyal.cpp > -@@ -150,6 +150,10 @@ static SexyAL_driver drivers[] = > +@@ -153,6 +153,10 @@ static SexyAL_driver drivers[] = > { SEXYAL_TYPE_ALSA, "ALSA", "alsa", SexyALI_ALSA_Open, > SexyALI_ALSA_EnumerateDevices }, > #endif > > @@ -19,7 +19,7 @@ Index: src/sexyal/sexyal.cpp > #if HAVE_OPENBSD_AUDIO > { SEXYAL_TYPE_OPENBSD, "OpenBSD(/dev/audio*)", "openbsd", > SexyALI_OpenBSD_Open, SexyALI_OpenBSD_EnumerateDevices }, > #endif > -@@ -182,13 +186,6 @@ static SexyAL_driver drivers[] = > +@@ -185,13 +189,6 @@ static SexyAL_driver drivers[] = > { SEXYAL_TYPE_DOS_ES1371, "Ensoniq ES1371", "es1371", > SexyALI_DOS_ES1371_Open, NULL, SexyALI_DOS_ES1371_Avail }, > { SEXYAL_TYPE_DOS_CMI8738, "CMI8738", "cmi8738", > SexyALI_DOS_CMI8738_Open, NULL, SexyALI_DOS_CMI8738_Avail }, > #endif > Index: patches/patch-src_snes_src_lib_libco_amd64_c > =================================================================== > RCS file: patches/patch-src_snes_src_lib_libco_amd64_c > diff -N patches/patch-src_snes_src_lib_libco_amd64_c > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ patches/patch-src_snes_src_lib_libco_amd64_c 26 Mar 2020 20:19:36 > -0000 > @@ -0,0 +1,47 @@ > +$OpenBSD$ > + > +This prevent the snes module to crash on load on amd64 > + > +Index: src/snes/src/lib/libco/amd64.c > +--- src/snes/src/lib/libco/amd64.c.orig > ++++ src/snes/src/lib/libco/amd64.c > +@@ -13,6 +13,10 @@ > + > + #include <assert.h> > + #include <stdlib.h> > ++#include <err.h> > ++#include <stdint.h> > ++#include <unistd.h> > ++#include <sys/mman.h> > + > + #ifdef __cplusplus > + extern "C" { > +@@ -21,6 +25,7 @@ extern "C" { > + static thread_local long long co_active_buffer[64]; > + static thread_local cothread_t co_active_handle = 0; > + static void (*co_swap)(cothread_t, cothread_t) = 0; > ++long pagesize, newsize; > + > + #ifdef _WIN32 > + /* ABI: Win64 */ > +@@ -119,7 +124,19 @@ cothread_t co_create(unsigned int size, void (*entrypo > + size += 512; /* allocate additional space for storage */ > + size &= ~15; /* align stack to 16-byte boundary */ > + > +- if(handle = (cothread_t)malloc(size)) { > ++ pagesize = sysconf(_SC_PAGESIZE); > ++ if(pagesize == -1) > ++ err(1, "sysconf failed"); > ++ newsize = size / pagesize * pagesize + !!(size % pagesize) * pagesize; > ++ handle = (cothread_t)malloc(newsize); > ++ if(handle == NULL) > ++ err(1, "malloc failed"); > ++ if((uintptr_t)handle % pagesize) > ++ err(1, "misaligned allocation"); > ++ handle = (cothread_t)mmap(handle, newsize, PROT_READ|PROT_WRITE, > MAP_FIXED|MAP_STACK|MAP_PRIVATE|MAP_ANON, -1, 0); > ++ if(handle == MAP_FAILED) > ++ err(1, "mmap failed"); > ++ else { > + long long *p = (long long*)((char*)handle + size); /* seek to top of > stack */ > + *--p = (long long)crash; /* crash if > entrypoint returns */ > + *--p = (long long)entrypoint; /* start of > function */ > Index: patches/patch-src_snes_src_lib_libco_x86_c > =================================================================== > RCS file: patches/patch-src_snes_src_lib_libco_x86_c > diff -N patches/patch-src_snes_src_lib_libco_x86_c > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ patches/patch-src_snes_src_lib_libco_x86_c 26 Mar 2020 20:16:29 > -0000 > @@ -0,0 +1,45 @@ > +$OpenBSD$ > + > +This prevent the snes module to crash on load on i386 > + > +Index: src/snes/src/lib/libco/x86.c > +--- src/snes/src/lib/libco/x86.c.orig > ++++ src/snes/src/lib/libco/x86.c > +@@ -9,6 +9,8 @@ > + > + #include <assert.h> > + #include <stdlib.h> > ++#include <err.h> > ++#include <stdint.h> > + > + #ifdef __cplusplus > + extern "C" { > +@@ -25,6 +27,7 @@ extern "C" { > + static thread_local long co_active_buffer[64]; > + static thread_local cothread_t co_active_handle = 0; > + static void (fastcall *co_swap)(cothread_t, cothread_t) = 0; > ++long pagesize, newsize; > + > + /* ABI: fastcall */ > + force_text_section static const unsigned char co_swap_function[] = { > +@@ -64,7 +67,19 @@ cothread_t co_create(unsigned int size, void (*entrypo > + size += 256; /* allocate additional space for storage */ > + size &= ~15; /* align stack to 16-byte boundary */ > + > +- if(handle = (cothread_t)malloc(size)) { > ++ pagesize = sysconf(_SC_PAGESIZE); > ++ if(pagesize == -1) > ++ err(1, "sysconf failed"); > ++ newsize = size / pagesize * pagesize + !!(size % pagesize) * pagesize; > ++ handle = (cothread_t)malloc(newsize); > ++ if(handle == NULL) > ++ err(1, "malloc failed"); > ++ if((uintptr_t)handle % pagesize) > ++ err(1, "misaligned allocation"); > ++ handle = (cothread_t)mmap(handle, newsize, PROT_READ|PROT_WRITE, > MAP_FIXED|MAP_STACK|MAP_PRIVATE|MAP_ANON, -1, 0); > ++ if(handle == MAP_FAILED) > ++ err(1, "mmap failed"); > ++ else { > + long *p = (long*)((char*)handle + size); /* seek to top of stack */ > + *--p = (long)crash; /* crash if entrypoint > returns */ > + *--p = (long)entrypoint; /* start of function */
