mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-07 06:30:35 +01:00
byuu says: Changelog: - added Cocoa target: higan can now be compiled for OS X Lion [Cydrak, byuu] - SNES/accuracy profile hires color blending improvements - fixes Marvelous text [AWJ] - fixed a slight bug in SNES/SA-1 VBR support caused by a typo - added support for multi-pass shaders that can load external textures (requires OpenGL 3.2+) - added game library path (used by ananke->Import Game) to Settings->Advanced - system profiles, shaders and cheats database can be stored in "all users" shared folders now (eg /usr/share on Linux) - all configuration files are in BML format now, instead of XML (much easier to read and edit this way) - main window supports drag-and-drop of game folders (but not game files / ZIP archives) - audio buffer clears when entering a modal loop on Windows (prevents audio repetition with DirectSound driver) - a substantial amount of code clean-up (probably the biggest refactoring to date) One highly desired target for this release was to default to the optimal drivers instead of the safest drivers, but because AMD drivers don't seem to like my OpenGL 3.2 driver, I've decided to postpone that. AMD has too big a market share. Hopefully with v093 officially released, we can get some public input on what AMD doesn't like.
103 lines
2.2 KiB
C
103 lines
2.2 KiB
C
/*
|
|
libco.sjlj (2008-01-28)
|
|
author: Nach
|
|
license: public domain
|
|
*/
|
|
|
|
/*
|
|
* Note this was designed for UNIX systems. Based on ideas expressed in a paper
|
|
* by Ralf Engelschall.
|
|
* For SJLJ on other systems, one would want to rewrite springboard() and
|
|
* co_create() and hack the jmb_buf stack pointer.
|
|
*/
|
|
|
|
#define LIBCO_C
|
|
#include "libco.h"
|
|
#include <stdlib.h>
|
|
#include <signal.h>
|
|
#include <setjmp.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct {
|
|
sigjmp_buf context;
|
|
void (*coentry)(void);
|
|
void *stack;
|
|
} cothread_struct;
|
|
|
|
static thread_local cothread_struct co_primary;
|
|
static thread_local cothread_struct *creating, *co_running = 0;
|
|
|
|
static void springboard(int ignored) {
|
|
if(sigsetjmp(creating->context, 0)) {
|
|
co_running->coentry();
|
|
}
|
|
}
|
|
|
|
cothread_t co_active() {
|
|
if(!co_running) co_running = &co_primary;
|
|
return (cothread_t)co_running;
|
|
}
|
|
|
|
cothread_t co_create(unsigned int size, void (*coentry)(void)) {
|
|
if(!co_running) co_running = &co_primary;
|
|
|
|
cothread_struct *thread = (cothread_struct*)malloc(sizeof(cothread_struct));
|
|
if(thread) {
|
|
struct sigaction handler;
|
|
struct sigaction old_handler;
|
|
|
|
stack_t stack;
|
|
stack_t old_stack;
|
|
|
|
thread->coentry = thread->stack = 0;
|
|
|
|
stack.ss_flags = 0;
|
|
stack.ss_size = size;
|
|
thread->stack = stack.ss_sp = malloc(size);
|
|
if(stack.ss_sp && !sigaltstack(&stack, &old_stack)) {
|
|
handler.sa_handler = springboard;
|
|
handler.sa_flags = SA_ONSTACK;
|
|
sigemptyset(&handler.sa_mask);
|
|
creating = thread;
|
|
|
|
if(!sigaction(SIGUSR1, &handler, &old_handler)) {
|
|
if(!raise(SIGUSR1)) {
|
|
thread->coentry = coentry;
|
|
}
|
|
sigaltstack(&old_stack, 0);
|
|
sigaction(SIGUSR1, &old_handler, 0);
|
|
}
|
|
}
|
|
|
|
if(thread->coentry != coentry) {
|
|
co_delete(thread);
|
|
thread = 0;
|
|
}
|
|
}
|
|
|
|
return (cothread_t)thread;
|
|
}
|
|
|
|
void co_delete(cothread_t cothread) {
|
|
if(cothread) {
|
|
if(((cothread_struct*)cothread)->stack) {
|
|
free(((cothread_struct*)cothread)->stack);
|
|
}
|
|
free(cothread);
|
|
}
|
|
}
|
|
|
|
void co_switch(cothread_t cothread) {
|
|
if(!sigsetjmp(co_running->context, 0)) {
|
|
co_running = (cothread_struct*)cothread;
|
|
siglongjmp(co_running->context, 1);
|
|
}
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|