Update libretro-common

This commit is contained in:
twinaphex 2018-10-01 15:50:41 +02:00
parent 3dcefa9316
commit 7a72619eff
3 changed files with 48 additions and 0 deletions

View File

@ -146,6 +146,15 @@ cothread_t co_create(unsigned int size, void (*entrypoint)(void))
size += 512; /* allocate additional space for storage */
size &= ~15; /* align stack to 16-byte boundary */
#ifdef __GENODE__
if((handle = (cothread_t)genode_alloc_secondary_stack(size)))
{
long long *p = (long long*)((char*)handle); /* OS returns top of stack */
*--p = (long long)crash; /* crash if entrypoint returns */
*--p = (long long)entrypoint; /* start of function */
*(long long*)handle = (long long)p; /* stack pointer */
}
#else
if((handle = (cothread_t)malloc(size)))
{
long long *p = (long long*)((char*)handle + size); /* seek to top of stack */
@ -153,13 +162,18 @@ cothread_t co_create(unsigned int size, void (*entrypoint)(void))
*--p = (long long)entrypoint; /* start of function */
*(long long*)handle = (long long)p; /* stack pointer */
}
#endif
return handle;
}
void co_delete(cothread_t handle)
{
#ifdef __GENODE__
genode_free_secondary_stack(handle);
#else
free(handle);
#endif
}
#ifndef CO_USE_INLINE_ASM

View File

@ -0,0 +1,29 @@
/*
libco.genode_secondary_stack (2018-09-15)
author: Emery Hemingway
license: public domain
*/
/* Genode include */
#include <base/thread.h>
/* Libco include */
#include <libco.h>
extern "C"
void *genode_alloc_secondary_stack(unsigned long stack_size)
{
try {
return Genode::Thread::myself()->alloc_secondary_stack("libco", stack_size); }
catch (...) {
Genode::error("libco: failed to allocate ", stack_size, " byte secondary stack");
return nullptr;
}
}
extern "C"
void genode_free_secondary_stack(void *stack)
{
Genode::Thread::myself()->free_secondary_stack(stack);
}

View File

@ -4,6 +4,11 @@
license: public domain
*/
#ifdef __GENODE__
void *genode_alloc_secondary_stack(unsigned long stack_size);
void genode_free_secondary_stack(void *stack);
#endif
#if defined _MSC_VER
#include <Windows.h>
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)