summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2015-02-24 20:52:16 +1100
committer Vas Crabb <vas@vastheman.com>2015-02-24 20:52:46 +1100
commitc0be42503cbf233b36fa65a056339acebd73a365 (patch)
treecdbc7c31281692aad410566b94ed774fc694722f
parent3fd95a53ca9a44dd1c56badfaabc9fcea3e7ac0c (diff)
OS/2 patches for SDLMAME v0.158 [KO Myung-Hun]
-rw-r--r--3rdparty/mongoose/mongoose.c36
-rw-r--r--3rdparty/sqlite3/sqlite3.c6
-rw-r--r--src/mame/video/chihiro.c7
-rw-r--r--src/osd/modules/lib/osdlib_os2.c5
-rw-r--r--src/osd/modules/sync/sync_os2.c12
-rw-r--r--src/osd/sdl/sdl.mak1
-rw-r--r--src/osd/sdl/sdlfile.c4
-rw-r--r--src/osd/sdl/sdlos_os2.c66
8 files changed, 55 insertions, 82 deletions
diff --git a/3rdparty/mongoose/mongoose.c b/3rdparty/mongoose/mongoose.c
index 9c7ca165271..9014b90bf79 100644
--- a/3rdparty/mongoose/mongoose.c
+++ b/3rdparty/mongoose/mongoose.c
@@ -124,7 +124,12 @@ typedef struct _stati64 ns_stat_t;
#include <sys/socket.h>
#include <sys/select.h>
#define closesocket(x) close(x)
+#ifndef __OS2__
#define __cdecl
+#else
+#include <sys/time.h>
+typedef int socklen_t;
+#endif
#define INVALID_SOCKET (-1)
#define to64(x) strtoll(x, NULL, 10)
typedef int sock_t;
@@ -1554,6 +1559,37 @@ static void *mmap(void *addr, int64_t len, int prot, int flags, int fd,
#define MAP_FAILED NULL
#define MAP_PRIVATE 0
#define PROT_READ 0
+#elif defined(__OS2__)
+static void *mmap(void *addr, int64_t len, int prot, int flags, int fd,
+ int offset) {
+ void *p;
+
+ int pos = lseek( fd, 0, SEEK_CUR ); /* Get a current position */
+
+ if (pos == -1)
+ return NULL;
+
+ /* Seek to offset offset */
+ if (lseek( fd, offset, SEEK_SET) == -1)
+ return NULL;
+
+ p = malloc(len);
+
+ /* Read in a file */
+ if (!p || read(fd, p, len) == -1) {
+ free(p);
+ p = NULL;
+ }
+
+ /* Restore the position */
+ lseek(fd, pos, SEEK_SET);
+
+ return p;
+}
+#define munmap(x, y) free(x)
+#define MAP_FAILED NULL
+#define MAP_PRIVATE 0
+#define PROT_READ 0
#else
#include <sys/mman.h>
#endif
diff --git a/3rdparty/sqlite3/sqlite3.c b/3rdparty/sqlite3/sqlite3.c
index 33fb95c96a9..eee15296b9d 100644
--- a/3rdparty/sqlite3/sqlite3.c
+++ b/3rdparty/sqlite3/sqlite3.c
@@ -8706,11 +8706,15 @@ SQLITE_PRIVATE const int sqlite3one;
/*
** Disable MMAP on platforms where it is known to not work
*/
-#if defined(__OpenBSD__) || defined(__QNXNTO__)
+#if defined(__OpenBSD__) || defined(__QNXNTO__) || defined(__OS2__)
# undef SQLITE_MAX_MMAP_SIZE
# define SQLITE_MAX_MMAP_SIZE 0
#endif
+#ifdef __OS2__
+# define SQLITE_OMIT_WAL
+#endif
+
/*
** Default maximum size of memory used by memory-mapped I/O in the VFS
*/
diff --git a/src/mame/video/chihiro.c b/src/mame/video/chihiro.c
index 69a6e50e812..951fa0d7562 100644
--- a/src/mame/video/chihiro.c
+++ b/src/mame/video/chihiro.c
@@ -837,7 +837,14 @@ void vertex_program_simulator::compute_scalar_operation(float t_out[4], int inst
case 6: // "LOG"
t_out[1] = frexp(par_in[p3_C + 0], &e)*2.0; // frexp gives mantissa as 0.5....1
t_out[0] = e - 1;
+#ifndef __OS2__
t.f = log2(abs(par_in[p3_C + 0]));
+#else
+ static double log_2 = 0.0;
+ if (log_2 == 0.0)
+ log_2 = log(2);
+ t.f = log(abs(par_in[p3_C + 0])) / log_2;
+#endif
t.i = t.i & 0xffffff00;
t_out[2] = t.f;
t_out[3] = 1.0;
diff --git a/src/osd/modules/lib/osdlib_os2.c b/src/osd/modules/lib/osdlib_os2.c
index 9e1ab8fd52d..93f1ca97f44 100644
--- a/src/osd/modules/lib/osdlib_os2.c
+++ b/src/osd/modules/lib/osdlib_os2.c
@@ -49,7 +49,10 @@ int osd_setenv(const char *name, const char *value, int overwrite)
void osd_process_kill(void)
{
- fprintf(stderr,"osd_process_kill missing in OS/2 build\n");
+ PPIB ppib;
+
+ DosGetInfoBlocks(NULL, &ppib);
+ DosKillProcess(DKP_PROCESSTREE, ppib->pib_ulpid);
}
//============================================================
diff --git a/src/osd/modules/sync/sync_os2.c b/src/osd/modules/sync/sync_os2.c
index 9c0612c1288..5526b26cf3b 100644
--- a/src/osd/modules/sync/sync_os2.c
+++ b/src/osd/modules/sync/sync_os2.c
@@ -479,15 +479,3 @@ void osd_thread_wait_free(osd_thread *thread)
DosWaitThread(&tid, 0);
free(thread);
}
-
-//============================================================
-// osd_process_kill
-//============================================================
-
-void osd_process_kill(void)
-{
- PPIB ppib;
-
- DosGetInfoBlocks(NULL, &ppib);
- DosKillProcess(DKP_PROCESSTREE, ppib->pib_ulpid);
-}
diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak
index 479abdd6624..5fe16406090 100644
--- a/src/osd/sdl/sdl.mak
+++ b/src/osd/sdl/sdl.mak
@@ -752,6 +752,7 @@ SDLLIBS := $(shell sdl-config --libs)
INCPATH += $(SDLCFLAGS)
LIBS += $(SDLLIBS) -lpthread
+BASELIBS += += $(SDLLIBS) -lpthread
endif # OS2
diff --git a/src/osd/sdl/sdlfile.c b/src/osd/sdl/sdlfile.c
index 5dc2b309cc9..a010c02776a 100644
--- a/src/osd/sdl/sdlfile.c
+++ b/src/osd/sdl/sdlfile.c
@@ -507,13 +507,13 @@ osd_directory_entry *osd_stat(const char *path)
{
int err;
osd_directory_entry *result = NULL;
- #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN)
+ #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN) || defined(SDLMAME_OS2)
struct stat st;
#else
struct stat64 st;
#endif
- #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN)
+ #if defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_DARWIN) || defined(SDLMAME_OS2)
err = stat(path, &st);
#else
err = stat64(path, &st);
diff --git a/src/osd/sdl/sdlos_os2.c b/src/osd/sdl/sdlos_os2.c
index 2137bace1b4..4aa5450bcb7 100644
--- a/src/osd/sdl/sdlos_os2.c
+++ b/src/osd/sdl/sdlos_os2.c
@@ -23,7 +23,6 @@
// MAME headers
#include "osdcore.h"
-#include "osdlib.h"
//============================================================
// osd_get_clipboard_text
@@ -36,68 +35,3 @@ char *osd_get_clipboard_text(void)
return result;
}
-
-//============================================================
-// osd_stat
-//============================================================
-
-osd_directory_entry *osd_stat(const char *path)
-{
- int err;
- osd_directory_entry *result = NULL;
- struct stat st;
-
- err = stat(path, &st);
-
- if( err == -1) return NULL;
-
- // create an osd_directory_entry; be sure to make sure that the caller can
- // free all resources by just freeing the resulting osd_directory_entry
- result = (osd_directory_entry *) osd_malloc_array(sizeof(*result) + strlen(path) + 1);
- strcpy(((char *) result) + sizeof(*result), path);
- result->name = ((char *) result) + sizeof(*result);
- result->type = S_ISDIR(st.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE;
- result->size = (UINT64)st.st_size;
-
- return result;
-}
-
-//============================================================
-// osd_get_volume_name
-//============================================================
-
-const char *osd_get_volume_name(int idx)
-{
- static char szDrive[] = "A:\\";
-
- ULONG ulCurDisk;
- ULONG ulDriveMap;
-
- DosQueryCurrentDisk(&ulCurDisk, &ulDriveMap);
-
- szDrive[ 0 ] = 'A';
- while(idx--) {
- do
- {
- ulDriveMap >>= 1;
- szDrive[ 0 ]++;
- } while(ulDriveMap && (ulDriveMap & 1) == 0);
- if (!ulDriveMap) return NULL;
- }
-
- return szDrive;
-}
-
-//============================================================
-// osd_get_full_path
-//============================================================
-
-file_error osd_get_full_path(char **dst, const char *path)
-{
- *dst = (char *)osd_malloc_array(CCHMAXPATH + 1);
- if (*dst == NULL)
- return FILERR_OUT_OF_MEMORY;
-
- _abspath(*dst, path, CCHMAXPATH + 1);
- return FILERR_NONE;
-}