mirror of https://github.com/bsnes-emu/bsnes.git
Merge commit '5e109224fb3480d806e44d74587d052c7f88bf83' into master
This commit is contained in:
commit
0ab0ab6957
|
@ -25,7 +25,7 @@ cothread_t co_active() {
|
|||
}
|
||||
|
||||
cothread_t co_derive(void* memory, unsigned int heapsize, void (*coentry)(void)) {
|
||||
//Windows fibers do not allow users to supply their own memory
|
||||
/* Windows fibers do not allow users to supply their own memory */
|
||||
return (cothread_t)0;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,16 +11,16 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
struct ppc64_context {
|
||||
//GPRs
|
||||
/* GPRs */
|
||||
uint64_t gprs[32];
|
||||
uint64_t lr;
|
||||
uint64_t ccr;
|
||||
|
||||
//FPRs
|
||||
/* FPRs */
|
||||
uint64_t fprs[32];
|
||||
|
||||
#ifdef __ALTIVEC__
|
||||
//Altivec (VMX)
|
||||
/* Altivec (VMX) */
|
||||
uint64_t vmx[12 * 2];
|
||||
uint32_t vrsave;
|
||||
#endif
|
||||
|
@ -43,7 +43,7 @@ __asm__(
|
|||
"swap_context:\n"
|
||||
".cfi_startproc\n"
|
||||
|
||||
//save GPRs
|
||||
/* save GPRs */
|
||||
"std 1, 8(4)\n"
|
||||
"std 2, 16(4)\n"
|
||||
"std 12, 96(4)\n"
|
||||
|
@ -67,15 +67,15 @@ __asm__(
|
|||
"std 30, 240(4)\n"
|
||||
"std 31, 248(4)\n"
|
||||
|
||||
//save LR
|
||||
/* save LR */
|
||||
"mflr 5\n"
|
||||
"std 5, 256(4)\n"
|
||||
|
||||
//save CCR
|
||||
/* save CCR */
|
||||
"mfcr 5\n"
|
||||
"std 5, 264(4)\n"
|
||||
|
||||
//save FPRs
|
||||
/* save FPRs */
|
||||
"stfd 14, 384(4)\n"
|
||||
"stfd 15, 392(4)\n"
|
||||
"stfd 16, 400(4)\n"
|
||||
|
@ -96,7 +96,7 @@ __asm__(
|
|||
"stfd 31, 520(4)\n"
|
||||
|
||||
#ifdef __ALTIVEC__
|
||||
//save VMX
|
||||
/* save VMX */
|
||||
"li 5, 528\n"
|
||||
"stvxl 20, 4, 5\n"
|
||||
"addi 5, 5, 16\n"
|
||||
|
@ -123,12 +123,12 @@ __asm__(
|
|||
"stvxl 31, 4, 5\n"
|
||||
"addi 5, 5, 16\n"
|
||||
|
||||
//save VRSAVE
|
||||
/* save VRSAVE */
|
||||
"mfvrsave 5\n"
|
||||
"stw 5, 736(4)\n"
|
||||
#endif
|
||||
|
||||
//restore GPRs
|
||||
/* restore GPRs */
|
||||
"ld 1, 8(3)\n"
|
||||
"ld 2, 16(3)\n"
|
||||
"ld 12, 96(3)\n"
|
||||
|
@ -152,15 +152,15 @@ __asm__(
|
|||
"ld 30, 240(3)\n"
|
||||
"ld 31, 248(3)\n"
|
||||
|
||||
//restore LR
|
||||
/* restore LR */
|
||||
"ld 5, 256(3)\n"
|
||||
"mtlr 5\n"
|
||||
|
||||
//restore CCR
|
||||
/* restore CCR */
|
||||
"ld 5, 264(3)\n"
|
||||
"mtcr 5\n"
|
||||
|
||||
//restore FPRs
|
||||
/* restore FPRs */
|
||||
"lfd 14, 384(3)\n"
|
||||
"lfd 15, 392(3)\n"
|
||||
"lfd 16, 400(3)\n"
|
||||
|
@ -181,7 +181,7 @@ __asm__(
|
|||
"lfd 31, 520(3)\n"
|
||||
|
||||
#ifdef __ALTIVEC__
|
||||
//restore VMX
|
||||
/* restore VMX */
|
||||
"li 5, 528\n"
|
||||
"lvxl 20, 3, 5\n"
|
||||
"addi 5, 5, 16\n"
|
||||
|
@ -208,12 +208,12 @@ __asm__(
|
|||
"lvxl 31, 3, 5\n"
|
||||
"addi 5, 5, 16\n"
|
||||
|
||||
//restore VRSAVE
|
||||
/* restore VRSAVE */
|
||||
"lwz 5, 720(3)\n"
|
||||
"mtvrsave 5\n"
|
||||
#endif
|
||||
|
||||
//branch to LR
|
||||
/* branch to LR */
|
||||
"blr\n"
|
||||
|
||||
".cfi_endproc\n"
|
||||
|
@ -231,21 +231,21 @@ cothread_t co_derive(void* memory, unsigned int size, void (*coentry)(void)) {
|
|||
uint8_t* sp;
|
||||
struct ppc64_context* context = (struct ppc64_context*)memory;
|
||||
|
||||
//save current context into new context to initialize it
|
||||
/* save current context into new context to initialize it */
|
||||
swap_context(context, context);
|
||||
|
||||
//align stack
|
||||
/* align stack */
|
||||
sp = (uint8_t*)memory + size - STACK_ALIGN;
|
||||
sp = (uint8_t*)ALIGN(sp, STACK_ALIGN);
|
||||
|
||||
//write 0 for initial backchain
|
||||
/* write 0 for initial backchain */
|
||||
*(uint64_t*)sp = 0;
|
||||
|
||||
//create new frame with backchain
|
||||
/* create new frame with backchain */
|
||||
sp -= MIN_STACK_FRAME;
|
||||
*(uint64_t*)sp = (uint64_t)(sp + MIN_STACK_FRAME);
|
||||
|
||||
//update context with new stack (r1) and entrypoint (r12, lr)
|
||||
/* update context with new stack (r1) and entrypoint (r12, lr) */
|
||||
context->gprs[ 1] = (uint64_t)sp;
|
||||
context->gprs[12] = (uint64_t)coentry;
|
||||
context->lr = (uint64_t)coentry;
|
||||
|
|
|
@ -10,33 +10,33 @@
|
|||
do not use this unless you are certain your application won't use SSE */
|
||||
/* #define LIBCO_NO_SSE */
|
||||
|
||||
#if !defined(thread_local) // User can override thread_local for obscure compilers
|
||||
#if !defined(LIBCO_MP) // Running in single-threaded environment
|
||||
#if !defined(thread_local) /* User can override thread_local for obscure compilers */
|
||||
#if !defined(LIBCO_MP) /* Running in single-threaded environment */
|
||||
#define thread_local
|
||||
#else // Running in multi-threaded environment
|
||||
#if defined(__STDC_VERSION__) // Compiling as C Language
|
||||
#if defined(_MSC_VER) // Don't rely on MSVC's C11 support
|
||||
#else /* Running in multi-threaded environment */
|
||||
#if defined(__STDC_VERSION__) /* Compiling as C Language */
|
||||
#if defined(_MSC_VER) /* Don't rely on MSVC's C11 support */
|
||||
#define thread_local __declspec(thread)
|
||||
#elif __STDC_VERSION__ < 201112L // If we are on C90/99
|
||||
#if defined(__clang__) || defined(__GNUC__) // Clang and GCC
|
||||
#elif __STDC_VERSION__ < 201112L /* If we are on C90/99 */
|
||||
#if defined(__clang__) || defined(__GNUC__) /* Clang and GCC */
|
||||
#define thread_local __thread
|
||||
#else // Otherwise, we ignore the directive (unless user provides their own)
|
||||
#else /* Otherwise, we ignore the directive (unless user provides their own) */
|
||||
#define thread_local
|
||||
#endif
|
||||
#else // C11 and newer define thread_local in threads.h
|
||||
#else /* C11 and newer define thread_local in threads.h */
|
||||
#include <threads.h>
|
||||
#endif
|
||||
#elif defined(__cplusplus) // Compiling as C++ Language
|
||||
#if __cplusplus < 201103L // thread_local is a C++11 feature
|
||||
#elif defined(__cplusplus) /* Compiling as C++ Language */
|
||||
#if __cplusplus < 201103L /* thread_local is a C++11 feature */
|
||||
#if defined(_MSC_VER)
|
||||
#define thread_local __declspec(thread)
|
||||
#elif defined(__clang__) || defined(__GNUC__)
|
||||
#define thread_local __thread
|
||||
#else // Otherwise, we ignore the directive (unless user provides their own)
|
||||
#else /* Otherwise, we ignore the directive (unless user provides their own) */
|
||||
#define thread_local
|
||||
#endif
|
||||
#else // In C++ >= 11, thread_local in a builtin keyword
|
||||
// Don't do anything
|
||||
#else /* In C++ >= 11, thread_local in a builtin keyword */
|
||||
/* Don't do anything */
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
@ -55,29 +55,29 @@
|
|||
- alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
|
||||
*/
|
||||
#if !defined(alignas)
|
||||
#if defined(__STDC_VERSION__) // C Language
|
||||
#if defined(_MSC_VER) // Don't rely on MSVC's C11 support
|
||||
#if defined(__STDC_VERSION__) /* C Language */
|
||||
#if defined(_MSC_VER) /* Don't rely on MSVC's C11 support */
|
||||
#define alignas(bytes) __declspec(align(bytes))
|
||||
#elif __STDC_VERSION__ >= 201112L // C11 and above
|
||||
#elif __STDC_VERSION__ >= 201112L /* C11 and above */
|
||||
#include <stdalign.h>
|
||||
#elif defined(__clang__) || defined(__GNUC__) // C90/99 on Clang/GCC
|
||||
#elif defined(__clang__) || defined(__GNUC__) /* C90/99 on Clang/GCC */
|
||||
#define alignas(bytes) __attribute__ ((aligned (bytes)))
|
||||
#else // Otherwise, we ignore the directive (user should provide their own)
|
||||
#else /* Otherwise, we ignore the directive (user should provide their own) */
|
||||
#define alignas(bytes)
|
||||
#endif
|
||||
#elif defined(__cplusplus) // C++ Language
|
||||
#elif defined(__cplusplus) /* C++ Language */
|
||||
#if __cplusplus < 201103L
|
||||
#if defined(_MSC_VER)
|
||||
#define alignas(bytes) __declspec(align(bytes))
|
||||
#elif defined(__clang__) || defined(__GNUC__) // C++98/03 on Clang/GCC
|
||||
#elif defined(__clang__) || defined(__GNUC__) /* C++98/03 on Clang/GCC */
|
||||
#define alignas(bytes) __attribute__ ((aligned (bytes)))
|
||||
#else // Otherwise, we ignore the directive (unless user provides their own)
|
||||
#else /* Otherwise, we ignore the directive (unless user provides their own) */
|
||||
#define alignas(bytes)
|
||||
#endif
|
||||
#else // C++ >= 11 has alignas keyword
|
||||
// Do nothing
|
||||
#else /* C++ >= 11 has alignas keyword */
|
||||
/* Do nothing */
|
||||
#endif
|
||||
#endif // = !defined(__STDC_VERSION__) && !defined(__cplusplus)
|
||||
#endif /* = !defined(__STDC_VERSION__) && !defined(__cplusplus) */
|
||||
#endif
|
||||
|
||||
#if !defined(LIBCO_ASSERT)
|
||||
|
|
Loading…
Reference in New Issue