diff options
author | 2012-04-09 19:55:43 +0000 | |
---|---|---|
committer | 2012-04-09 19:55:43 +0000 | |
commit | 6711559e87f917df9f789f56722d987b3ba78d50 (patch) | |
tree | 8b75bd484d7c264b89b7f60cd156b8b33a2ee952 /src/osd/sdl | |
parent | 49f47372a86a4cb9de3ef74b0010c0f1465cf9e1 (diff) |
SDL: Got rid of some code duplication between the _unix and _macosx implementations for sdlptty and sdlmisc. (nw)
Diffstat (limited to 'src/osd/sdl')
-rw-r--r-- | src/osd/sdl/sdl.mak | 58 | ||||
-rw-r--r-- | src/osd/sdl/sdlmisc_macosx.c | 62 | ||||
-rw-r--r-- | src/osd/sdl/sdlmisc_unix.c | 2 | ||||
-rw-r--r-- | src/osd/sdl/sdlptty_macosx.c | 87 | ||||
-rw-r--r-- | src/osd/sdl/sdlptty_unix.c | 6 |
5 files changed, 37 insertions, 178 deletions
diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index 9c2251fa5e8..735bcebf57c 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -190,7 +190,7 @@ SYNC_IMPLEMENTATION = tc endif ifeq ($(TARGETOS),macosx) -BASE_TARGETOS = macosx +BASE_TARGETOS = unix DEFS += -DSDLMAME_UNIX -DSDLMAME_MACOSX -DSDLMAME_DARWIN DEBUGOBJS = $(SDLOBJ)/debugosx.o SYNC_IMPLEMENTATION = ntc @@ -292,7 +292,7 @@ OSDCOREOBJS = \ $(SDLOBJ)/sdlptty_$(BASE_TARGETOS).o \ $(SDLOBJ)/sdlsocket.o \ $(SDLOBJ)/sdlmisc_$(BASE_TARGETOS).o \ - $(SDLOBJ)/sdlos_$(BASE_TARGETOS).o \ + $(SDLOBJ)/sdlos_$(SDLOS_TARGETOS).o \ $(SDLOBJ)/sdlsync_$(SYNC_IMPLEMENTATION).o \ $(SDLOBJ)/sdlwork.o @@ -334,11 +334,40 @@ INCPATH += -include $(SDLSRC)/sdlprefix.h # BASE_TARGETOS specific configurations #------------------------------------------------- +SDLOS_TARGETOS = $(BASE_TARGETOS) + #------------------------------------------------- # Unix #------------------------------------------------- ifeq ($(BASE_TARGETOS),unix) +#------------------------------------------------- +# Mac OS X +#------------------------------------------------- + +ifeq ($(TARGETOS),macosx) +OSDCOREOBJS += $(SDLOBJ)/osxutils.o +SDLOS_TARGETOS = macosx + +ifndef MACOSX_USE_LIBSDL +# Compile using framework (compile using libSDL is the exception) +LIBS += -framework SDL -framework Cocoa -framework OpenGL -lpthread +else +# Compile using installed libSDL (Fink or MacPorts): +# +# Remove the "/SDL" component from the include path so that we can compile +# files (header files are #include "SDL/something.h", so the extra "/SDL" +# causes a significant problem) +INCPATH += `sdl-config --cflags | sed 's:/SDL::'` +CCOMFLAGS += -DNO_SDL_GLEXT +# Remove libSDLmain, as its symbols conflict with SDLMain_tmpl.m +LIBS += `sdl-config --libs | sed 's/-lSDLmain//'` -lpthread +DEFS += -DMACOSX_USE_LIBSDL +endif + +endif # Mac OS X +else + DEFS += -DSDLMAME_UNIX DEBUGOBJS = $(SDLOBJ)/debugwin.o $(SDLOBJ)/dview.o $(SDLOBJ)/debug-sup.o $(SDLOBJ)/debug-intf.o LIBGL = -lGL @@ -427,31 +456,6 @@ LIBS += -luser32 -lgdi32 -lddraw -ldsound -ldxguid -lwinmm -ladvapi32 -lcomctl32 endif # Win32 #------------------------------------------------- -# Mac OS X -#------------------------------------------------- - -ifeq ($(BASE_TARGETOS),macosx) -OSDCOREOBJS += $(SDLOBJ)/osxutils.o - -ifndef MACOSX_USE_LIBSDL -# Compile using framework (compile using libSDL is the exception) -LIBS += -framework SDL -framework Cocoa -framework OpenGL -lpthread -else -# Compile using installed libSDL (Fink or MacPorts): -# -# Remove the "/SDL" component from the include path so that we can compile -# files (header files are #include "SDL/something.h", so the extra "/SDL" -# causes a significant problem) -INCPATH += `sdl-config --cflags | sed 's:/SDL::'` -CCOMFLAGS += -DNO_SDL_GLEXT -# Remove libSDLmain, as its symbols conflict with SDLMain_tmpl.m -LIBS += `sdl-config --libs | sed 's/-lSDLmain//'` -lpthread -DEFS += -DMACOSX_USE_LIBSDL -endif - -endif # Mac OS X - -#------------------------------------------------- # OS/2 #------------------------------------------------- diff --git a/src/osd/sdl/sdlmisc_macosx.c b/src/osd/sdl/sdlmisc_macosx.c deleted file mode 100644 index 9596db11389..00000000000 --- a/src/osd/sdl/sdlmisc_macosx.c +++ /dev/null @@ -1,62 +0,0 @@ -//============================================================ -// -// sdlos_*.c - OS specific low level code -// -// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -// SDLMAME by Olivier Galibert and R. Belmont -// -//============================================================ - -// standard sdl header -#include "sdlinc.h" -#include <sys/types.h> -#include <sys/mman.h> -#include <signal.h> -#ifdef MAME_DEBUG -#include <unistd.h> -#endif - - -// MAME headers -#include "osdcore.h" - -//============================================================ -// osd_alloc_executable -// -// allocates "size" bytes of executable memory. this must take -// things like NX support into account. -//============================================================ - -void *osd_alloc_executable(size_t size) -{ - return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); -} - -//============================================================ -// osd_free_executable -// -// frees memory allocated with osd_alloc_executable -//============================================================ - -void osd_free_executable(void *ptr, size_t size) -{ - munmap(ptr, size); -} - -//============================================================ -// osd_break_into_debugger -//============================================================ - -void osd_break_into_debugger(const char *message) -{ - #ifdef MAME_DEBUG - printf("MAME exception: %s\n", message); - printf("Attempting to fall into debugger\n"); - kill(getpid(), SIGTRAP); - #else - printf("Ignoring MAME exception: %s\n", message); - #endif -} - diff --git a/src/osd/sdl/sdlmisc_unix.c b/src/osd/sdl/sdlmisc_unix.c index f133f8c6ec7..94b2f09ae2a 100644 --- a/src/osd/sdl/sdlmisc_unix.c +++ b/src/osd/sdl/sdlmisc_unix.c @@ -28,7 +28,7 @@ void *osd_alloc_executable(size_t size) { -#if defined(SDLMAME_BSD) +#if defined(SDLMAME_BSD) || defined(SDLMAME_MACOSX) return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); #elif defined(SDLMAME_UNIX) return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0); diff --git a/src/osd/sdl/sdlptty_macosx.c b/src/osd/sdl/sdlptty_macosx.c deleted file mode 100644 index 93a70b3c3f5..00000000000 --- a/src/osd/sdl/sdlptty_macosx.c +++ /dev/null @@ -1,87 +0,0 @@ -//============================================================ -// -// sdlptty_macos.c - SDL psuedo tty access functions -// -// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -// SDLMAME by Olivier Galibert and R. Belmont -// -//============================================================ - -#include <sys/types.h> -#include <sys/uio.h> -#include <unistd.h> -#include <util.h> -#include <fcntl.h> -#include <errno.h> - -#include "sdlfile.h" - -const char *sdlfile_ptty_identifier = "/dev/pty"; - -file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize) -{ - int master; - int aslave; - char name[100]; - - if( openpty(&master, &aslave, name, NULL, NULL) >= 0 ) - { - printf("Slave of device %s is %s\n", path, name ); - fcntl(master, F_SETFL, O_NONBLOCK); - (*file)->handle = master; - *filesize = 0; - } - else - { - return FILERR_ACCESS_DENIED; - } - - return FILERR_NONE; -} - -file_error sdl_read_ptty(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) -{ - ssize_t result; - - result = read(file->handle, buffer, count); - - if (result < 0) - { - return error_to_file_error(errno); - } - - if (actual != NULL ) - { - *actual = result; - } - - return FILERR_NONE; -} - -file_error sdl_write_ptty(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) -{ - UINT32 result; - result = write(file->handle, buffer, count); - - if (result < 0) - { - return error_to_file_error(errno); - } - - if (actual != NULL ) - { - *actual = result; - } - - return FILERR_NONE; -} - -file_error sdl_close_ptty(osd_file *file) -{ - close(file->handle); - osd_free(file); - - return FILERR_NONE; -} diff --git a/src/osd/sdl/sdlptty_unix.c b/src/osd/sdl/sdlptty_unix.c index 3d7262dbed3..778f1aefc0c 100644 --- a/src/osd/sdl/sdlptty_unix.c +++ b/src/osd/sdl/sdlptty_unix.c @@ -17,7 +17,7 @@ #if defined(SDLMAME_FREEBSD) || defined(SDLMAME_DRAGONFLY) # include <termios.h> # include <libutil.h> -#elif defined(SDLMAME_NETBSD) +#elif defined(SDLMAME_NETBSD) || defined(SDLMAME_MACOSX) # include <util.h> #elif defined(SDLMAME_OPENBSD) # include <termios.h> @@ -28,7 +28,11 @@ #include "sdlfile.h" +#if defined(SDLMAME_MACOSX) +const char *sdlfile_ptty_identifier = "/dev/pty"; +#else const char *sdlfile_ptty_identifier = "/dev/pts"; +#endif file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize) { |