src/osd/sdl/sdlptty_macosx.c
| r14885 | r14886 | |
| 1 | | //============================================================ |
| 2 | | // |
| 3 | | // sdlptty_macos.c - SDL psuedo tty access functions |
| 4 | | // |
| 5 | | // Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. |
| 6 | | // Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | | // |
| 8 | | // SDLMAME by Olivier Galibert and R. Belmont |
| 9 | | // |
| 10 | | //============================================================ |
| 11 | | |
| 12 | | #include <sys/types.h> |
| 13 | | #include <sys/uio.h> |
| 14 | | #include <unistd.h> |
| 15 | | #include <util.h> |
| 16 | | #include <fcntl.h> |
| 17 | | #include <errno.h> |
| 18 | | |
| 19 | | #include "sdlfile.h" |
| 20 | | |
| 21 | | const char *sdlfile_ptty_identifier = "/dev/pty"; |
| 22 | | |
| 23 | | file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize) |
| 24 | | { |
| 25 | | int master; |
| 26 | | int aslave; |
| 27 | | char name[100]; |
| 28 | | |
| 29 | | if( openpty(&master, &aslave, name, NULL, NULL) >= 0 ) |
| 30 | | { |
| 31 | | printf("Slave of device %s is %s\n", path, name ); |
| 32 | | fcntl(master, F_SETFL, O_NONBLOCK); |
| 33 | | (*file)->handle = master; |
| 34 | | *filesize = 0; |
| 35 | | } |
| 36 | | else |
| 37 | | { |
| 38 | | return FILERR_ACCESS_DENIED; |
| 39 | | } |
| 40 | | |
| 41 | | return FILERR_NONE; |
| 42 | | } |
| 43 | | |
| 44 | | file_error sdl_read_ptty(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) |
| 45 | | { |
| 46 | | ssize_t result; |
| 47 | | |
| 48 | | result = read(file->handle, buffer, count); |
| 49 | | |
| 50 | | if (result < 0) |
| 51 | | { |
| 52 | | return error_to_file_error(errno); |
| 53 | | } |
| 54 | | |
| 55 | | if (actual != NULL ) |
| 56 | | { |
| 57 | | *actual = result; |
| 58 | | } |
| 59 | | |
| 60 | | return FILERR_NONE; |
| 61 | | } |
| 62 | | |
| 63 | | file_error sdl_write_ptty(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) |
| 64 | | { |
| 65 | | UINT32 result; |
| 66 | | result = write(file->handle, buffer, count); |
| 67 | | |
| 68 | | if (result < 0) |
| 69 | | { |
| 70 | | return error_to_file_error(errno); |
| 71 | | } |
| 72 | | |
| 73 | | if (actual != NULL ) |
| 74 | | { |
| 75 | | *actual = result; |
| 76 | | } |
| 77 | | |
| 78 | | return FILERR_NONE; |
| 79 | | } |
| 80 | | |
| 81 | | file_error sdl_close_ptty(osd_file *file) |
| 82 | | { |
| 83 | | close(file->handle); |
| 84 | | osd_free(file); |
| 85 | | |
| 86 | | return FILERR_NONE; |
| 87 | | } |
src/osd/sdl/sdlmisc_macosx.c
| r14885 | r14886 | |
| 1 | | //============================================================ |
| 2 | | // |
| 3 | | // sdlos_*.c - OS specific low level code |
| 4 | | // |
| 5 | | // Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. |
| 6 | | // Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | | // |
| 8 | | // SDLMAME by Olivier Galibert and R. Belmont |
| 9 | | // |
| 10 | | //============================================================ |
| 11 | | |
| 12 | | // standard sdl header |
| 13 | | #include "sdlinc.h" |
| 14 | | #include <sys/types.h> |
| 15 | | #include <sys/mman.h> |
| 16 | | #include <signal.h> |
| 17 | | #ifdef MAME_DEBUG |
| 18 | | #include <unistd.h> |
| 19 | | #endif |
| 20 | | |
| 21 | | |
| 22 | | // MAME headers |
| 23 | | #include "osdcore.h" |
| 24 | | |
| 25 | | //============================================================ |
| 26 | | // osd_alloc_executable |
| 27 | | // |
| 28 | | // allocates "size" bytes of executable memory. this must take |
| 29 | | // things like NX support into account. |
| 30 | | //============================================================ |
| 31 | | |
| 32 | | void *osd_alloc_executable(size_t size) |
| 33 | | { |
| 34 | | return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); |
| 35 | | } |
| 36 | | |
| 37 | | //============================================================ |
| 38 | | // osd_free_executable |
| 39 | | // |
| 40 | | // frees memory allocated with osd_alloc_executable |
| 41 | | //============================================================ |
| 42 | | |
| 43 | | void osd_free_executable(void *ptr, size_t size) |
| 44 | | { |
| 45 | | munmap(ptr, size); |
| 46 | | } |
| 47 | | |
| 48 | | //============================================================ |
| 49 | | // osd_break_into_debugger |
| 50 | | //============================================================ |
| 51 | | |
| 52 | | void osd_break_into_debugger(const char *message) |
| 53 | | { |
| 54 | | #ifdef MAME_DEBUG |
| 55 | | printf("MAME exception: %s\n", message); |
| 56 | | printf("Attempting to fall into debugger\n"); |
| 57 | | kill(getpid(), SIGTRAP); |
| 58 | | #else |
| 59 | | printf("Ignoring MAME exception: %s\n", message); |
| 60 | | #endif |
| 61 | | } |
| 62 | | |
src/osd/sdl/sdl.mak
| r14885 | r14886 | |
| 190 | 190 | endif |
| 191 | 191 | |
| 192 | 192 | ifeq ($(TARGETOS),macosx) |
| 193 | | BASE_TARGETOS = macosx |
| 193 | BASE_TARGETOS = unix |
| 194 | 194 | DEFS += -DSDLMAME_UNIX -DSDLMAME_MACOSX -DSDLMAME_DARWIN |
| 195 | 195 | DEBUGOBJS = $(SDLOBJ)/debugosx.o |
| 196 | 196 | SYNC_IMPLEMENTATION = ntc |
| r14885 | r14886 | |
| 292 | 292 | $(SDLOBJ)/sdlptty_$(BASE_TARGETOS).o \ |
| 293 | 293 | $(SDLOBJ)/sdlsocket.o \ |
| 294 | 294 | $(SDLOBJ)/sdlmisc_$(BASE_TARGETOS).o \ |
| 295 | | $(SDLOBJ)/sdlos_$(BASE_TARGETOS).o \ |
| 295 | $(SDLOBJ)/sdlos_$(SDLOS_TARGETOS).o \ |
| 296 | 296 | $(SDLOBJ)/sdlsync_$(SYNC_IMPLEMENTATION).o \ |
| 297 | 297 | $(SDLOBJ)/sdlwork.o |
| 298 | 298 | |
| r14885 | r14886 | |
| 334 | 334 | # BASE_TARGETOS specific configurations |
| 335 | 335 | #------------------------------------------------- |
| 336 | 336 | |
| 337 | SDLOS_TARGETOS = $(BASE_TARGETOS) |
| 338 | |
| 337 | 339 | #------------------------------------------------- |
| 338 | 340 | # Unix |
| 339 | 341 | #------------------------------------------------- |
| 340 | 342 | ifeq ($(BASE_TARGETOS),unix) |
| 341 | 343 | |
| 344 | #------------------------------------------------- |
| 345 | # Mac OS X |
| 346 | #------------------------------------------------- |
| 347 | |
| 348 | ifeq ($(TARGETOS),macosx) |
| 349 | OSDCOREOBJS += $(SDLOBJ)/osxutils.o |
| 350 | SDLOS_TARGETOS = macosx |
| 351 | |
| 352 | ifndef MACOSX_USE_LIBSDL |
| 353 | # Compile using framework (compile using libSDL is the exception) |
| 354 | LIBS += -framework SDL -framework Cocoa -framework OpenGL -lpthread |
| 355 | else |
| 356 | # Compile using installed libSDL (Fink or MacPorts): |
| 357 | # |
| 358 | # Remove the "/SDL" component from the include path so that we can compile |
| 359 | # files (header files are #include "SDL/something.h", so the extra "/SDL" |
| 360 | # causes a significant problem) |
| 361 | INCPATH += `sdl-config --cflags | sed 's:/SDL::'` |
| 362 | CCOMFLAGS += -DNO_SDL_GLEXT |
| 363 | # Remove libSDLmain, as its symbols conflict with SDLMain_tmpl.m |
| 364 | LIBS += `sdl-config --libs | sed 's/-lSDLmain//'` -lpthread |
| 365 | DEFS += -DMACOSX_USE_LIBSDL |
| 366 | endif |
| 367 | |
| 368 | endif # Mac OS X |
| 369 | else |
| 370 | |
| 342 | 371 | DEFS += -DSDLMAME_UNIX |
| 343 | 372 | DEBUGOBJS = $(SDLOBJ)/debugwin.o $(SDLOBJ)/dview.o $(SDLOBJ)/debug-sup.o $(SDLOBJ)/debug-intf.o |
| 344 | 373 | LIBGL = -lGL |
| r14885 | r14886 | |
| 427 | 456 | endif # Win32 |
| 428 | 457 | |
| 429 | 458 | #------------------------------------------------- |
| 430 | | # Mac OS X |
| 431 | | #------------------------------------------------- |
| 432 | | |
| 433 | | ifeq ($(BASE_TARGETOS),macosx) |
| 434 | | OSDCOREOBJS += $(SDLOBJ)/osxutils.o |
| 435 | | |
| 436 | | ifndef MACOSX_USE_LIBSDL |
| 437 | | # Compile using framework (compile using libSDL is the exception) |
| 438 | | LIBS += -framework SDL -framework Cocoa -framework OpenGL -lpthread |
| 439 | | else |
| 440 | | # Compile using installed libSDL (Fink or MacPorts): |
| 441 | | # |
| 442 | | # Remove the "/SDL" component from the include path so that we can compile |
| 443 | | # files (header files are #include "SDL/something.h", so the extra "/SDL" |
| 444 | | # causes a significant problem) |
| 445 | | INCPATH += `sdl-config --cflags | sed 's:/SDL::'` |
| 446 | | CCOMFLAGS += -DNO_SDL_GLEXT |
| 447 | | # Remove libSDLmain, as its symbols conflict with SDLMain_tmpl.m |
| 448 | | LIBS += `sdl-config --libs | sed 's/-lSDLmain//'` -lpthread |
| 449 | | DEFS += -DMACOSX_USE_LIBSDL |
| 450 | | endif |
| 451 | | |
| 452 | | endif # Mac OS X |
| 453 | | |
| 454 | | #------------------------------------------------- |
| 455 | 459 | # OS/2 |
| 456 | 460 | #------------------------------------------------- |
| 457 | 461 | |