Previous 15994 Revisions Next

r14886 Monday 9th April, 2012 at 19:55:48 UTC by Wilbert Pol
Sync with MAME (nw)
[src/osd/sdl]sdl.mak sdlmisc_macosx.c sdlmisc_unix.c sdlptty_macosx.c sdlptty_unix.c

src/osd/sdl/sdlptty_macosx.c
r14885r14886
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
21const char *sdlfile_ptty_identifier  = "/dev/pty";
22
23file_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
44file_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
63file_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
81file_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
r14885r14886
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
32void *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
43void osd_free_executable(void *ptr, size_t size)
44{
45   munmap(ptr, size);
46}
47
48//============================================================
49//  osd_break_into_debugger
50//============================================================
51
52void 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/sdlmisc_unix.c
r14885r14886
2828
2929void *osd_alloc_executable(size_t size)
3030{
31#if defined(SDLMAME_BSD)
31#if defined(SDLMAME_BSD) || defined(SDLMAME_MACOSX)
3232   return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
3333#elif defined(SDLMAME_UNIX)
3434   return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0);
src/osd/sdl/sdlptty_unix.c
r14885r14886
1717#if defined(SDLMAME_FREEBSD) || defined(SDLMAME_DRAGONFLY)
1818# include <termios.h>
1919# include <libutil.h>
20#elif defined(SDLMAME_NETBSD)
20#elif defined(SDLMAME_NETBSD) || defined(SDLMAME_MACOSX)
2121# include <util.h>
2222#elif defined(SDLMAME_OPENBSD)
2323# include <termios.h>
r14885r14886
2828
2929#include "sdlfile.h"
3030
31#if defined(SDLMAME_MACOSX)
32const char *sdlfile_ptty_identifier  = "/dev/pty";
33#else
3134const char *sdlfile_ptty_identifier  = "/dev/pts";
35#endif
3236
3337file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize)
3438{
src/osd/sdl/sdl.mak
r14885r14886
190190endif
191191
192192ifeq ($(TARGETOS),macosx)
193BASE_TARGETOS = macosx
193BASE_TARGETOS = unix
194194DEFS += -DSDLMAME_UNIX -DSDLMAME_MACOSX -DSDLMAME_DARWIN
195195DEBUGOBJS = $(SDLOBJ)/debugosx.o
196196SYNC_IMPLEMENTATION = ntc
r14885r14886
292292   $(SDLOBJ)/sdlptty_$(BASE_TARGETOS).o   \
293293   $(SDLOBJ)/sdlsocket.o   \
294294   $(SDLOBJ)/sdlmisc_$(BASE_TARGETOS).o   \
295   $(SDLOBJ)/sdlos_$(BASE_TARGETOS).o   \
295   $(SDLOBJ)/sdlos_$(SDLOS_TARGETOS).o   \
296296   $(SDLOBJ)/sdlsync_$(SYNC_IMPLEMENTATION).o     \
297297   $(SDLOBJ)/sdlwork.o
298298
r14885r14886
334334# BASE_TARGETOS specific configurations
335335#-------------------------------------------------
336336
337SDLOS_TARGETOS = $(BASE_TARGETOS)
338
337339#-------------------------------------------------
338340# Unix
339341#-------------------------------------------------
340342ifeq ($(BASE_TARGETOS),unix)
341343
344#-------------------------------------------------
345# Mac OS X
346#-------------------------------------------------
347
348ifeq ($(TARGETOS),macosx)
349OSDCOREOBJS += $(SDLOBJ)/osxutils.o
350SDLOS_TARGETOS = macosx
351
352ifndef MACOSX_USE_LIBSDL
353# Compile using framework (compile using libSDL is the exception)
354LIBS += -framework SDL -framework Cocoa -framework OpenGL -lpthread
355else
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)
361INCPATH += `sdl-config --cflags | sed 's:/SDL::'`
362CCOMFLAGS += -DNO_SDL_GLEXT
363# Remove libSDLmain, as its symbols conflict with SDLMain_tmpl.m
364LIBS += `sdl-config --libs | sed 's/-lSDLmain//'` -lpthread
365DEFS += -DMACOSX_USE_LIBSDL
366endif
367
368endif   # Mac OS X
369else
370
342371DEFS += -DSDLMAME_UNIX
343372DEBUGOBJS = $(SDLOBJ)/debugwin.o $(SDLOBJ)/dview.o $(SDLOBJ)/debug-sup.o $(SDLOBJ)/debug-intf.o
344373LIBGL = -lGL
r14885r14886
427456endif   # Win32
428457
429458#-------------------------------------------------
430# Mac OS X
431#-------------------------------------------------
432
433ifeq ($(BASE_TARGETOS),macosx)
434OSDCOREOBJS += $(SDLOBJ)/osxutils.o
435
436ifndef MACOSX_USE_LIBSDL
437# Compile using framework (compile using libSDL is the exception)
438LIBS += -framework SDL -framework Cocoa -framework OpenGL -lpthread
439else
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)
445INCPATH += `sdl-config --cflags | sed 's:/SDL::'`
446CCOMFLAGS += -DNO_SDL_GLEXT
447# Remove libSDLmain, as its symbols conflict with SDLMain_tmpl.m
448LIBS += `sdl-config --libs | sed 's/-lSDLmain//'` -lpthread
449DEFS += -DMACOSX_USE_LIBSDL
450endif
451
452endif   # Mac OS X
453
454#-------------------------------------------------
455459# OS/2
456460#-------------------------------------------------
457461

Previous 15994 Revisions Next


© 1998-2018 The MESS Team