mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-23 22:52:34 +01:00
byuu says: Changelog: - added 30 new PAL games to icarus (courtesy of Mikerochip) - new version of libco no longer requires mprotect nor W|X permissions - nall: default C compiler to -std=c11 instead of -std=c99 - nall: use `-fno-strict-aliasing` during compilation - updated nall/certificates (hopefully for the last time) - updated nall/http to newer coding conventions - nall: improve handling of range() function I didn't really work on higan at all, this is mostly just a release because lots of other things have changed. The most interesting is `-fno-strict-aliasing` ... basically, it joins `-fwrapv` as being "stop the GCC developers from doing *really* evil shit that could lead to security vulnerabilities or instabilities." For the most part, it's a ~2% speed penalty for higan. Except for the Sega Genesis, where it's a ~10% speedup. I have no idea how that's possible, but clearly something's going very wrong with strict aliasing on the Genesis core. So ... it is what it is. If you need the performance for the non-Genesis cores, you can turn it off in your builds. But I'm getting quite sick of C++'s "surprises" and clever compiler developers, so I'm keeping it on in all of my software going forward.
52 lines
913 B
C
52 lines
913 B
C
/*
|
|
libco.win (2008-01-28)
|
|
authors: Nach, byuu
|
|
license: public domain
|
|
*/
|
|
|
|
#define LIBCO_C
|
|
#include "libco.h"
|
|
|
|
#define WINVER 0x0400
|
|
#define _WIN32_WINNT 0x0400
|
|
#include <windows.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
static thread_local cothread_t co_active_ = 0;
|
|
|
|
static void __stdcall co_thunk(void* coentry) {
|
|
((void (*)(void))coentry)();
|
|
}
|
|
|
|
cothread_t co_active() {
|
|
if(!co_active_) {
|
|
ConvertThreadToFiber(0);
|
|
co_active_ = GetCurrentFiber();
|
|
}
|
|
return co_active_;
|
|
}
|
|
|
|
cothread_t co_create(unsigned int heapsize, void (*coentry)(void)) {
|
|
if(!co_active_) {
|
|
ConvertThreadToFiber(0);
|
|
co_active_ = GetCurrentFiber();
|
|
}
|
|
return (cothread_t)CreateFiber(heapsize, co_thunk, (void*)coentry);
|
|
}
|
|
|
|
void co_delete(cothread_t cothread) {
|
|
DeleteFiber(cothread);
|
|
}
|
|
|
|
void co_switch(cothread_t cothread) {
|
|
co_active_ = cothread;
|
|
SwitchToFiber(cothread);
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|