summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/lib
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-01-29 00:51:28 +1100
committer Vas Crabb <vas@vastheman.com>2021-01-29 00:51:28 +1100
commit86666f388eb8ee809a953e320acb828f2bd574c1 (patch)
treeeead887b37a9fd071fb505e640bba2fe11f6387c /src/osd/modules/lib
parent1832b25ad131c25c9f85cf68ef9ff053a74c0341 (diff)
Bug fixes and usablility enhancements:
* Declare intent when requesting virtual memory (for NetBSD, 7712) * Improve scrolling behaviour in Qt debugger (MT07795) * Added prompts to input mapping menu to make it less intimidating
Diffstat (limited to 'src/osd/modules/lib')
-rw-r--r--src/osd/modules/lib/osdlib.h14
-rw-r--r--src/osd/modules/lib/osdlib_macosx.cpp6
-rw-r--r--src/osd/modules/lib/osdlib_unix.cpp22
-rw-r--r--src/osd/modules/lib/osdlib_uwp.cpp6
-rw-r--r--src/osd/modules/lib/osdlib_win32.cpp2
5 files changed, 32 insertions, 18 deletions
diff --git a/src/osd/modules/lib/osdlib.h b/src/osd/modules/lib/osdlib.h
index 59b5291b0a8..cb3c2dcdce8 100644
--- a/src/osd/modules/lib/osdlib.h
+++ b/src/osd/modules/lib/osdlib.h
@@ -34,7 +34,7 @@
None.
-----------------------------------------------------------------------------*/
-void osd_process_kill(void);
+void osd_process_kill();
/*-----------------------------------------------------------------------------
@@ -57,7 +57,8 @@ int osd_setenv(const char *name, const char *value, int overwrite);
/*-----------------------------------------------------------------------------
osd_get_clipboard_text: retrieves text from the clipboard
-----------------------------------------------------------------------------*/
-std::string osd_get_clipboard_text(void);
+std::string osd_get_clipboard_text();
+
namespace osd {
@@ -74,16 +75,17 @@ public:
WRITE = 0x02,
EXECUTE = 0x04,
READ_WRITE = READ | WRITE,
- READ_EXECUTE = READ | EXECUTE
+ READ_EXECUTE = READ | EXECUTE,
+ READ_WRITE_EXECUTE = READ | WRITE | EXECUTE
};
virtual_memory_allocation(virtual_memory_allocation const &) = delete;
virtual_memory_allocation &operator=(virtual_memory_allocation const &) = delete;
virtual_memory_allocation() { }
- virtual_memory_allocation(std::initializer_list<std::size_t> blocks)
+ virtual_memory_allocation(std::initializer_list<std::size_t> blocks, unsigned intent)
{
- m_memory = do_alloc(blocks, m_size, m_page_size);
+ m_memory = do_alloc(blocks, intent, m_size, m_page_size);
}
virtual_memory_allocation(virtual_memory_allocation &&that) : m_memory(that.m_memory), m_size(that.m_size), m_page_size(that.m_page_size)
{
@@ -134,7 +136,7 @@ public:
}
private:
- static void *do_alloc(std::initializer_list<std::size_t> blocks, std::size_t &size, std::size_t &page_size);
+ static void *do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size);
static void do_free(void *start, std::size_t size);
static bool do_set_access(void *start, std::size_t size, unsigned access);
diff --git a/src/osd/modules/lib/osdlib_macosx.cpp b/src/osd/modules/lib/osdlib_macosx.cpp
index 0b4c30bc14a..27124b6ef2e 100644
--- a/src/osd/modules/lib/osdlib_macosx.cpp
+++ b/src/osd/modules/lib/osdlib_macosx.cpp
@@ -85,7 +85,7 @@ void osd_break_into_debugger(const char *message)
// osd_get_clipboard_text
//============================================================
-std::string osd_get_clipboard_text(void)
+std::string osd_get_clipboard_text()
{
std::string result;
bool has_result = false;
@@ -161,7 +161,7 @@ std::string osd_get_clipboard_text(void)
// osd_getpid
//============================================================
-int osd_getpid(void)
+int osd_getpid()
{
return getpid();
}
@@ -234,7 +234,7 @@ bool invalidate_instruction_cache(void const *start, std::size_t size)
}
-void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, std::size_t &size, std::size_t &page_size)
+void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size)
{
long const p(sysconf(_SC_PAGE_SIZE));
if (0 >= p)
diff --git a/src/osd/modules/lib/osdlib_unix.cpp b/src/osd/modules/lib/osdlib_unix.cpp
index 5b182eb6a9c..4b091450116 100644
--- a/src/osd/modules/lib/osdlib_unix.cpp
+++ b/src/osd/modules/lib/osdlib_unix.cpp
@@ -69,7 +69,7 @@ void osd_break_into_debugger(const char *message)
}
#ifdef SDLMAME_ANDROID
-std::string osd_get_clipboard_text(void)
+std::string osd_get_clipboard_text()
{
return std::string();
}
@@ -78,7 +78,7 @@ std::string osd_get_clipboard_text(void)
// osd_get_clipboard_text
//============================================================
-std::string osd_get_clipboard_text(void)
+std::string osd_get_clipboard_text()
{
std::string result;
@@ -97,7 +97,7 @@ std::string osd_get_clipboard_text(void)
// osd_getpid
//============================================================
-int osd_getpid(void)
+int osd_getpid()
{
return getpid();
}
@@ -172,7 +172,7 @@ bool invalidate_instruction_cache(void const *start, std::size_t size)
}
-void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, std::size_t &size, std::size_t &page_size)
+void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size)
{
long const p(sysconf(_SC_PAGE_SIZE));
if (0 >= p)
@@ -183,13 +183,25 @@ void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blo
s *= p;
if (!s)
return nullptr;
+#if defined __NetBSD__
+ int req((NONE == intent) ? PROT_NONE : 0);
+ if (intent & READ)
+ req |= PROT_READ;
+ if (intent & WRITE)
+ req |= PROT_WRITE;
+ if (intent & EXECUTE)
+ req |= PROT_EXEC;
+ int const prot(PROT_MPROTECT(req));
+#else
+ int const prot(PROT_NONE);
+#endif
#if defined(SDLMAME_BSD) || defined(SDLMAME_MACOSX) || defined(SDLMAME_EMSCRIPTEN)
int const fd(-1);
#else
// TODO: portable applications are supposed to use -1 for anonymous mappings - detect whatever requires 0 specifically
int const fd(0);
#endif
- void *const result(mmap(nullptr, s, PROT_NONE, MAP_ANON | MAP_SHARED, fd, 0));
+ void *const result(mmap(nullptr, s, prot, MAP_ANON | MAP_SHARED, fd, 0));
if (result == (void *)-1)
return nullptr;
size = s;
diff --git a/src/osd/modules/lib/osdlib_uwp.cpp b/src/osd/modules/lib/osdlib_uwp.cpp
index f9a3e6a5cf9..87035e9db97 100644
--- a/src/osd/modules/lib/osdlib_uwp.cpp
+++ b/src/osd/modules/lib/osdlib_uwp.cpp
@@ -138,7 +138,7 @@ static std::string convert_ansi(LPCVOID data)
// osd_get_clipboard_text
//============================================================
-std::string osd_get_clipboard_text(void)
+std::string osd_get_clipboard_text()
{
std::string result;
@@ -156,7 +156,7 @@ std::string osd_get_clipboard_text(void)
// osd_getpid
//============================================================
-int osd_getpid(void)
+int osd_getpid()
{
return GetCurrentProcessId();
}
@@ -170,7 +170,7 @@ bool invalidate_instruction_cache(void const *start, std::size_t size)
}
-void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, std::size_t &size, std::size_t &page_size)
+void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size)
{
SYSTEM_INFO info;
GetSystemInfo(&info);
diff --git a/src/osd/modules/lib/osdlib_win32.cpp b/src/osd/modules/lib/osdlib_win32.cpp
index 768b71463d2..b75500deee9 100644
--- a/src/osd/modules/lib/osdlib_win32.cpp
+++ b/src/osd/modules/lib/osdlib_win32.cpp
@@ -268,7 +268,7 @@ bool invalidate_instruction_cache(void const *start, std::size_t size)
}
-void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, std::size_t &size, std::size_t &page_size)
+void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size)
{
SYSTEM_INFO info;
GetSystemInfo(&info);