Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
flycast
Commits
1b683c7a
Commit
1b683c7a
authored
Apr 12, 2021
by
Libretro-Admin
Browse files
Revert "Split up context code into separate file context.cpp"
This reverts commit
3092c1b0
.
parent
5ac0d804
Pipeline
#19868
passed with stages
in 3 minutes and 8 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Makefile.common
View file @
1b683c7a
...
...
@@ -436,7 +436,6 @@ endif
SOURCES_CXX
+=
$(CORE_DIR)
/core/libretro/libretro.cpp
\
$(CORE_DIR)
/core/libretro/audiostream.cpp
\
$(CORE_DIR)
/core/libretro/common.cpp
\
$(CORE_DIR)
/core/libretro/context.cpp
\
$(CORE_DIR)
/core/libretro/vmem_utils.cpp
SOURCES_C
+=
$(LIBRETRO_COMM_DIR)
/memmap/memalign.c
\
...
...
core/libretro/common.cpp
View file @
1b683c7a
...
...
@@ -2,6 +2,23 @@
#include <errno.h>
#ifdef __MACH__
#define _XOPEN_SOURCE 1
#define __USE_GNU 1
#endif
#if !defined(TARGET_NO_EXCEPTIONS)
#ifndef _WIN32
#ifndef __HAIKU__
#include <ucontext.h>
#endif
#endif
#endif
#if defined(_ANDROID)
#include <asm/sigcontext.h>
#endif
#include <fcntl.h>
#include <semaphore.h>
#include <stdarg.h>
...
...
@@ -27,7 +44,6 @@ bool VramLockedWrite(u8* address);
bool
ngen_Rewrite
(
size_t
&
addr
,
size_t
retadr
,
size_t
acc
);
bool
BM_LockedWrite
(
u8
*
address
);
static
LONG
ExceptionHandler
(
EXCEPTION_POINTERS
*
ExceptionInfo
)
{
EXCEPTION_POINTERS
*
ep
=
ExceptionInfo
;
...
...
@@ -168,15 +184,80 @@ void setup_seh(void)
#endif
#endif
#define MCTX(p) (((ucontext_t *)(segfault_ctx))->uc_mcontext p)
template
<
typename
Ta
,
typename
Tb
>
static
void
bicopy
(
Ta
&
rei
,
Tb
&
seg
,
bool
to_segfault
)
{
if
(
to_segfault
)
seg
=
rei
;
else
rei
=
seg
;
}
static
void
context_segfault
(
host_context_t
*
reictx
,
void
*
segfault_ctx
,
bool
to_segfault
)
{
#if !defined(TARGET_NO_EXCEPTIONS)
#if HOST_CPU == CPU_ARM
#ifdef __linux__
bicopy
(
reictx
->
pc
,
MCTX
(.
arm_pc
),
to_segfault
);
u32
*
r
=
(
u32
*
)
&
MCTX
(.
arm_r0
);
for
(
int
i
=
0
;
i
<
15
;
i
++
)
bicopy
(
reictx
->
r
[
i
],
r
[
i
],
to_segfault
);
#elif defined(__MACH__)
bicopy
(
reictx
->
pc
,
MCTX
(
->
__ss
.
__pc
),
to_segfault
);
for
(
int
i
=
0
;
i
<
15
;
i
++
)
bicopy
(
reictx
->
r
[
i
],
MCTX
(
->
__ss
.
__r
[
i
]),
to_segfault
);
#endif
#elif HOST_CPU == CPU_ARM64
bicopy
(
reictx
->
pc
,
MCTX
(.
pc
),
to_segfault
);
bicopy
(
reictx
->
x2
,
MCTX
(.
regs
[
2
]),
to_segfault
);
#elif HOST_CPU == CPU_X86
#ifdef __linux__
bicopy
(
reictx
->
pc
,
MCTX
(.
gregs
[
REG_EIP
]),
to_segfault
);
bicopy
(
reictx
->
esp
,
MCTX
(.
gregs
[
REG_ESP
]),
to_segfault
);
bicopy
(
reictx
->
eax
,
MCTX
(.
gregs
[
REG_EAX
]),
to_segfault
);
bicopy
(
reictx
->
ecx
,
MCTX
(.
gregs
[
REG_ECX
]),
to_segfault
);
#elif defined(__MACH__)
bicopy
(
reictx
->
pc
,
MCTX
(
->
__ss
.
__eip
),
to_segfault
);
bicopy
(
reictx
->
esp
,
MCTX
(
->
__ss
.
__esp
),
to_segfault
);
bicopy
(
reictx
->
eax
,
MCTX
(
->
__ss
.
__eax
),
to_segfault
);
bicopy
(
reictx
->
ecx
,
MCTX
(
->
__ss
.
__ecx
),
to_segfault
);
#endif
#elif HOST_CPU == CPU_X64
#ifdef __linux__
bicopy
(
reictx
->
pc
,
MCTX
(.
gregs
[
REG_RIP
]),
to_segfault
);
#elif defined(__MACH__)
bicopy
(
reictx
->
pc
,
MCTX
(
->
__ss
.
__rip
),
to_segfault
);
#endif
#elif HOST_CPU == CPU_MIPS
bicopy
(
reictx
->
pc
,
MCTX
(.
pc
),
to_segfault
);
#elif HOST_CPU == CPU_GENERIC
//nothing!
#else
#error Unsupported HOST_CPU
#endif
#endif
}
static
void
context_from_segfault
(
host_context_t
*
reictx
,
void
*
segfault_ctx
)
{
context_segfault
(
reictx
,
segfault_ctx
,
false
);
}
static
void
context_to_segfault
(
host_context_t
*
reictx
,
void
*
segfault_ctx
)
{
context_segfault
(
reictx
,
segfault_ctx
,
true
);
}
#if !defined(TARGET_NO_EXCEPTIONS)
bool
ngen_Rewrite
(
size_t
&
addr
,
size_t
retadr
,
size_t
acc
);
u32
*
ngen_readm_fail_v2
(
u32
*
ptr
,
u32
*
regs
,
u32
saddr
);
bool
VramLockedWrite
(
u8
*
address
);
bool
BM_LockedWrite
(
u8
*
address
);
void
context_from_segfault
(
host_context_t
*
hctx
,
void
*
segfault_ctx
);
void
context_to_segfault
(
host_context_t
*
hctx
,
void
*
segfault_ctx
);
#ifdef __MACH__
static
void
sigill_handler
(
int
sn
,
siginfo_t
*
si
,
void
*
segfault_ctx
)
{
...
...
core/libretro/context.cpp
deleted
100755 → 0
View file @
5ac0d804
#include "oslib/host_context.h"
#if defined(_ANDROID)
#include <asm/sigcontext.h>
#else
#ifdef __MACH__
#define _XOPEN_SOURCE 1
#define __USE_GNU 1
#endif
#if !defined(TARGET_NO_EXCEPTIONS)
#ifndef _WIN32
#ifndef __HAIKU__
#include <ucontext.h>
#endif
#endif
#endif
#endif
#define MCTX(p) (((ucontext_t *)(segfault_ctx))->uc_mcontext p)
template
<
typename
Ta
,
typename
Tb
>
static
void
bicopy
(
Ta
&
rei
,
Tb
&
seg
,
bool
to_segfault
)
{
if
(
to_segfault
)
seg
=
rei
;
else
rei
=
seg
;
}
static
void
context_segfault
(
host_context_t
*
reictx
,
void
*
segfault_ctx
,
bool
to_segfault
)
{
#if !defined(TARGET_NO_EXCEPTIONS)
#if HOST_CPU == CPU_ARM
#ifdef __linux__
bicopy
(
reictx
->
pc
,
MCTX
(.
arm_pc
),
to_segfault
);
u32
*
r
=
(
u32
*
)
&
MCTX
(.
arm_r0
);
for
(
int
i
=
0
;
i
<
15
;
i
++
)
bicopy
(
reictx
->
r
[
i
],
r
[
i
],
to_segfault
);
#elif defined(__MACH__)
bicopy
(
reictx
->
pc
,
MCTX
(
->
__ss
.
__pc
),
to_segfault
);
for
(
int
i
=
0
;
i
<
15
;
i
++
)
bicopy
(
reictx
->
r
[
i
],
MCTX
(
->
__ss
.
__r
[
i
]),
to_segfault
);
#endif
#elif HOST_CPU == CPU_ARM64
bicopy
(
reictx
->
pc
,
MCTX
(.
pc
),
to_segfault
);
bicopy
(
reictx
->
x2
,
MCTX
(.
regs
[
2
]),
to_segfault
);
#elif HOST_CPU == CPU_X86
#ifdef __linux__
bicopy
(
reictx
->
pc
,
MCTX
(.
gregs
[
REG_EIP
]),
to_segfault
);
bicopy
(
reictx
->
esp
,
MCTX
(.
gregs
[
REG_ESP
]),
to_segfault
);
bicopy
(
reictx
->
eax
,
MCTX
(.
gregs
[
REG_EAX
]),
to_segfault
);
bicopy
(
reictx
->
ecx
,
MCTX
(.
gregs
[
REG_ECX
]),
to_segfault
);
#elif defined(__MACH__)
bicopy
(
reictx
->
pc
,
MCTX
(
->
__ss
.
__eip
),
to_segfault
);
bicopy
(
reictx
->
esp
,
MCTX
(
->
__ss
.
__esp
),
to_segfault
);
bicopy
(
reictx
->
eax
,
MCTX
(
->
__ss
.
__eax
),
to_segfault
);
bicopy
(
reictx
->
ecx
,
MCTX
(
->
__ss
.
__ecx
),
to_segfault
);
#endif
#elif HOST_CPU == CPU_X64
#ifdef __linux__
bicopy
(
reictx
->
pc
,
MCTX
(.
gregs
[
REG_RIP
]),
to_segfault
);
#elif defined(__MACH__)
bicopy
(
reictx
->
pc
,
MCTX
(
->
__ss
.
__rip
),
to_segfault
);
#endif
#elif HOST_CPU == CPU_MIPS
bicopy
(
reictx
->
pc
,
MCTX
(.
pc
),
to_segfault
);
#elif HOST_CPU == CPU_GENERIC
//nothing!
#else
#error Unsupported HOST_CPU
#endif
#endif
}
void
context_from_segfault
(
host_context_t
*
reictx
,
void
*
segfault_ctx
)
{
context_segfault
(
reictx
,
segfault_ctx
,
false
);
}
void
context_to_segfault
(
host_context_t
*
reictx
,
void
*
segfault_ctx
)
{
context_segfault
(
reictx
,
segfault_ctx
,
true
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment