mirror of
https://github.com/ctm/executor.git
synced 2025-02-17 05:31:27 +00:00
Limps under Mac OS X (Intel)
This commit is contained in:
parent
5728ad456a
commit
99a2ca627c
12
README
12
README
@ -57,13 +57,23 @@ HOST_GCC = gcc -m32
|
||||
|
||||
|
||||
If you have SDL <http://libsdl.org/> installed and would like to use
|
||||
the SDL-based version of Executor, you can try:
|
||||
the SDL-based version of Executor on Linux, you can try:
|
||||
|
||||
mkdir -p build/debug-linux-sdl
|
||||
cd build/debug-linux-sdl
|
||||
../../util/configure.sh '--target=i486-linux' '--host=i486-linux' '--front-end=sdl' '--cflags=-fno-strict-aliasing -I/usr/X11R6/include -DNDEBUG -O0 -finline-functions -g -Wall -DRELEASE_INTERNAL -DERROR_SUPPORTED_MASK="(~0)"' '--root=../..' '--target-file-format=glibc' '--sound=sdl' '--syn68k-target=i486-linux-glibc'
|
||||
make
|
||||
|
||||
If you have SDL <http://libsdl.org/> installed and would like to play with
|
||||
the SDL-based version of Executor on Mac OS X Intel, you can try:
|
||||
|
||||
mkdir -p build/debug-macosx-sdl
|
||||
cd build/debug-macosx-sdl
|
||||
../../util/configure.sh '--target=i486-macosx' '--host=i486-macosx' '--front-end=sdl' '--cflags=-fno-strict-aliasing -I/usr/X11R6/include -DNDEBUG -O0 -finline-functions -g -Wall -DRELEASE_INTERNAL -DERROR_SUPPORTED_MASK="(~0)"' '--root=../..' '--target-file-format=glibc' '--sound=sdl' '--syn68k-target=i486-macosx-glibc'
|
||||
make
|
||||
|
||||
The Mac OS X version has problems, especially with quitting.
|
||||
|
||||
My email address is still <ctm@ardi.com>, although ARDI itself is
|
||||
defunct. I get a ridiculous amount of spam and will quite possibly
|
||||
not see email addressed to me. I'm ctm on github (http://github.com)
|
||||
|
3
TODO
3
TODO
@ -4,9 +4,6 @@
|
||||
Try building the mingw32 version using the mingw32 toolchain
|
||||
for Fedora 11 (mingw32 has been done before)
|
||||
|
||||
Try compiling a version for Mac OS X using SDL (Mac OS X hasn't been
|
||||
done before, although NEXTSTEP has)
|
||||
|
||||
Probably want to do an in-use / marked for deletion fix
|
||||
|
||||
of what data structure? I didn't write that down when
|
||||
|
@ -10,6 +10,7 @@ char ROMlib_rcsid_adb[] =
|
||||
#include "rsys/common.h"
|
||||
#include "EventMgr.h"
|
||||
#include "OSEvent.h"
|
||||
#include "ADB.h"
|
||||
#include "rsys/adb.h"
|
||||
#include "rsys/osevent.h"
|
||||
#include "rsys/pstuff.h"
|
||||
|
@ -98,7 +98,12 @@ TARGET_CFLAGS = $(DEFINES) $(INCLUDES) $(CONFIGURE_CFLAGS)
|
||||
ifobjc
|
||||
# `-traditional-cpp' is needed by NeXT cc to make sense of the
|
||||
# global asm a5 decl
|
||||
TARGET_OBJCFLAGS = -traditional-cpp $(TARGET_CFLAGS)
|
||||
# TARGET_OBJCFLAGS = -traditional-cpp $(TARGET_CFLAGS)
|
||||
# Haven't compiled NeXT based Executor in a very long time, but now that
|
||||
# we have the beginnings of a Mac OS X port, don't mess it up by requesting
|
||||
# -traditional-cpp. If we ever do support NEXT targets again it will be
|
||||
# after moving to a more modern GNU build system.
|
||||
TARGET_OBJCFLAGS = $(TARGET_CFLAGS)
|
||||
end ifobjc
|
||||
|
||||
.SUFFIXES: .map .psw .h .c .m .s .scpp .o
|
||||
|
@ -79,7 +79,16 @@ extern arch_type_t arch_type;
|
||||
#define I386_CC_OVERFLOW_MASK (1 << 11)
|
||||
|
||||
/* Note that we have an i386 implementation of these routines. */
|
||||
#define ARCH_PROVIDES_RAW_PATBLT
|
||||
#define ARCH_PROVIDES_RAW_SRCBLT
|
||||
|
||||
#if defined(MACOSX)
|
||||
/*
|
||||
* When doing the Proof-of-concept port on Mac OS X, the tricked out
|
||||
* blitters were causing Executor to crash. I haven't figured out
|
||||
* why yet, but most likely they can be rehabilitated.
|
||||
*/
|
||||
#else /* !defined(MACOSX) */
|
||||
# define ARCH_PROVIDES_RAW_PATBLT
|
||||
# define ARCH_PROVIDES_RAW_SRCBLT
|
||||
#endif /* !defined(MACOSX) */
|
||||
|
||||
#endif /* !_ARCH_I386_H_ */
|
||||
|
@ -1,5 +1,11 @@
|
||||
TARGET_ARCH_OBJ = i386.o
|
||||
|
||||
TARGET_ARCH_OBJ = i386.o x86patblt.o x86srcblt.o xdstubtables.o sbstubtables.o
|
||||
# In the first days of the Mac OS X port we can't use the tricked out blitters,
|
||||
# quite possibly due to register ebx smashage interfering with PIC.
|
||||
|
||||
ifneq (,$(findstring macosx,$(TARGET)))
|
||||
TARGET_ARCH_OBJ += x86patblt.o x86srcblt.o xdstubtables.o sbstubtables.o
|
||||
endif
|
||||
|
||||
pat-blitters-stamp pat-blitters.h pat-blitters.s: \
|
||||
opfind.c opfind.h metaasm.pl pat-blitters.meta
|
||||
|
387
src/config/front-ends/sdl/macosx_main.m
Normal file
387
src/config/front-ends/sdl/macosx_main.m
Normal file
@ -0,0 +1,387 @@
|
||||
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||
|
||||
Feel free to customize this file to suit your needs
|
||||
*/
|
||||
|
||||
#import "SDL/SDL.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <sys/param.h> /* for MAXPATHLEN */
|
||||
#import <unistd.h>
|
||||
|
||||
@interface SDLMain : NSObject
|
||||
@end
|
||||
|
||||
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
|
||||
but the method still is there and works. To avoid warnings, we declare
|
||||
it ourselves here. */
|
||||
@interface NSApplication(SDL_Missing_Methods)
|
||||
- (void)setAppleMenu:(NSMenu *)menu;
|
||||
@end
|
||||
|
||||
/* Use this flag to determine whether we use SDLMain.nib or not */
|
||||
#define SDL_USE_NIB_FILE 0
|
||||
|
||||
/* Use this flag to determine whether we use CPS (docking) or not */
|
||||
#define SDL_USE_CPS 1
|
||||
#ifdef SDL_USE_CPS
|
||||
/* Portions of CPS.h */
|
||||
typedef struct CPSProcessSerNum
|
||||
{
|
||||
UInt32 lo;
|
||||
UInt32 hi;
|
||||
} CPSProcessSerNum;
|
||||
|
||||
extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
|
||||
extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
|
||||
extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
|
||||
|
||||
#endif /* SDL_USE_CPS */
|
||||
|
||||
static int gArgc;
|
||||
static char **gArgv;
|
||||
static BOOL gFinderLaunch;
|
||||
static BOOL gCalledAppMainline = FALSE;
|
||||
|
||||
static NSString *getApplicationName(void)
|
||||
{
|
||||
NSDictionary *dict;
|
||||
NSString *appName = 0;
|
||||
|
||||
/* Determine the application name */
|
||||
dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
|
||||
if (dict)
|
||||
appName = [dict objectForKey: @"CFBundleName"];
|
||||
|
||||
if (![appName length])
|
||||
appName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
return appName;
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
/* A helper category for NSString */
|
||||
@interface NSString (ReplaceSubString)
|
||||
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface SDLApplication : NSApplication
|
||||
@end
|
||||
|
||||
@implementation SDLApplication
|
||||
/* Invoked from the Quit menu item */
|
||||
- (void)terminate:(id)sender
|
||||
{
|
||||
/* Post a SDL_QUIT event */
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
@end
|
||||
|
||||
/* The main class of the application, the application's delegate */
|
||||
@implementation SDLMain
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
- (void) setupWorkingDirectory:(BOOL)shouldChdir
|
||||
{
|
||||
if (shouldChdir)
|
||||
{
|
||||
char parentdir[MAXPATHLEN];
|
||||
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
|
||||
if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) {
|
||||
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
|
||||
}
|
||||
CFRelease(url);
|
||||
CFRelease(url2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
|
||||
/* Fix menu to contain the real app name instead of "SDL App" */
|
||||
- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
|
||||
{
|
||||
NSRange aRange;
|
||||
NSEnumerator *enumerator;
|
||||
NSMenuItem *menuItem;
|
||||
|
||||
aRange = [[aMenu title] rangeOfString:@"SDL App"];
|
||||
if (aRange.length != 0)
|
||||
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
|
||||
|
||||
enumerator = [[aMenu itemArray] objectEnumerator];
|
||||
while ((menuItem = [enumerator nextObject]))
|
||||
{
|
||||
aRange = [[menuItem title] rangeOfString:@"SDL App"];
|
||||
if (aRange.length != 0)
|
||||
[menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
|
||||
if ([menuItem hasSubmenu])
|
||||
[self fixMenu:[menuItem submenu] withAppName:appName];
|
||||
}
|
||||
[ aMenu sizeToFit ];
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void setApplicationMenu(void)
|
||||
{
|
||||
/* warning: this code is very odd */
|
||||
NSMenu *appleMenu;
|
||||
NSMenuItem *menuItem;
|
||||
NSString *title;
|
||||
NSString *appName;
|
||||
|
||||
appName = getApplicationName();
|
||||
appleMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||
|
||||
/* Add menu items */
|
||||
title = [@"About " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
|
||||
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
title = [@"Hide " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
|
||||
|
||||
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
|
||||
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
|
||||
|
||||
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
|
||||
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
title = [@"Quit " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
|
||||
|
||||
|
||||
/* Put menu into the menubar */
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
[menuItem setSubmenu:appleMenu];
|
||||
[[NSApp mainMenu] addItem:menuItem];
|
||||
|
||||
/* Tell the application object that this is now the application menu */
|
||||
[NSApp setAppleMenu:appleMenu];
|
||||
|
||||
/* Finally give up our references to the objects */
|
||||
[appleMenu release];
|
||||
[menuItem release];
|
||||
}
|
||||
|
||||
/* Create a window menu */
|
||||
static void setupWindowMenu(void)
|
||||
{
|
||||
NSMenu *windowMenu;
|
||||
NSMenuItem *windowMenuItem;
|
||||
NSMenuItem *menuItem;
|
||||
|
||||
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||
|
||||
/* "Minimize" item */
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
||||
[windowMenu addItem:menuItem];
|
||||
[menuItem release];
|
||||
|
||||
/* Put menu into the menubar */
|
||||
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||
[windowMenuItem setSubmenu:windowMenu];
|
||||
[[NSApp mainMenu] addItem:windowMenuItem];
|
||||
|
||||
/* Tell the application object that this is now the window menu */
|
||||
[NSApp setWindowsMenu:windowMenu];
|
||||
|
||||
/* Finally give up our references to the objects */
|
||||
[windowMenu release];
|
||||
[windowMenuItem release];
|
||||
}
|
||||
|
||||
/* Replacement for NSApplicationMain */
|
||||
static void CustomApplicationMain (int argc, char **argv)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SDLMain *sdlMain;
|
||||
|
||||
/* Ensure the application object is initialised */
|
||||
[SDLApplication sharedApplication];
|
||||
|
||||
#ifdef SDL_USE_CPS
|
||||
{
|
||||
CPSProcessSerNum PSN;
|
||||
/* Tell the dock about us */
|
||||
if (!CPSGetCurrentProcess(&PSN))
|
||||
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
|
||||
if (!CPSSetFrontProcess(&PSN))
|
||||
[SDLApplication sharedApplication];
|
||||
}
|
||||
#endif /* SDL_USE_CPS */
|
||||
|
||||
/* Set up the menubar */
|
||||
[NSApp setMainMenu:[[NSMenu alloc] init]];
|
||||
setApplicationMenu();
|
||||
setupWindowMenu();
|
||||
|
||||
/* Create SDLMain and make it the app delegate */
|
||||
sdlMain = [[SDLMain alloc] init];
|
||||
[NSApp setDelegate:sdlMain];
|
||||
|
||||
/* Start the main event loop */
|
||||
[NSApp run];
|
||||
|
||||
[sdlMain release];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Catch document open requests...this lets us notice files when the app
|
||||
* was launched by double-clicking a document, or when a document was
|
||||
* dragged/dropped on the app's icon. You need to have a
|
||||
* CFBundleDocumentsType section in your Info.plist to get this message,
|
||||
* apparently.
|
||||
*
|
||||
* Files are added to gArgv, so to the app, they'll look like command line
|
||||
* arguments. Previously, apps launched from the finder had nothing but
|
||||
* an argv[0].
|
||||
*
|
||||
* This message may be received multiple times to open several docs on launch.
|
||||
*
|
||||
* This message is ignored once the app's mainline has been called.
|
||||
*/
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
const char *temparg;
|
||||
size_t arglen;
|
||||
char *arg;
|
||||
char **newargv;
|
||||
|
||||
if (!gFinderLaunch) /* MacOS is passing command line args. */
|
||||
return FALSE;
|
||||
|
||||
if (gCalledAppMainline) /* app has started, ignore this document. */
|
||||
return FALSE;
|
||||
|
||||
temparg = [filename UTF8String];
|
||||
arglen = SDL_strlen(temparg) + 1;
|
||||
arg = (char *) SDL_malloc(arglen);
|
||||
if (arg == NULL)
|
||||
return FALSE;
|
||||
|
||||
newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
|
||||
if (newargv == NULL)
|
||||
{
|
||||
SDL_free(arg);
|
||||
return FALSE;
|
||||
}
|
||||
gArgv = newargv;
|
||||
|
||||
SDL_strlcpy(arg, temparg, arglen);
|
||||
gArgv[gArgc++] = arg;
|
||||
gArgv[gArgc] = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Called when the internal event loop has just started running */
|
||||
- (void) applicationDidFinishLaunching: (NSNotification *) note
|
||||
{
|
||||
int status;
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
[self setupWorkingDirectory:gFinderLaunch];
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
|
||||
#endif
|
||||
|
||||
/* Hand off to main application code */
|
||||
gCalledAppMainline = TRUE;
|
||||
status = SDL_main (gArgc, gArgv);
|
||||
|
||||
/* We're done, thank you for playing */
|
||||
exit(status);
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSString (ReplaceSubString)
|
||||
|
||||
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
|
||||
{
|
||||
unsigned int bufferSize;
|
||||
unsigned int selfLen = [self length];
|
||||
unsigned int aStringLen = [aString length];
|
||||
unichar *buffer;
|
||||
NSRange localRange;
|
||||
NSString *result;
|
||||
|
||||
bufferSize = selfLen + aStringLen - aRange.length;
|
||||
buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
|
||||
|
||||
/* Get first part into buffer */
|
||||
localRange.location = 0;
|
||||
localRange.length = aRange.location;
|
||||
[self getCharacters:buffer range:localRange];
|
||||
|
||||
/* Get middle part into buffer */
|
||||
localRange.location = 0;
|
||||
localRange.length = aStringLen;
|
||||
[aString getCharacters:(buffer+aRange.location) range:localRange];
|
||||
|
||||
/* Get last part into buffer */
|
||||
localRange.location = aRange.location + aRange.length;
|
||||
localRange.length = selfLen - localRange.location;
|
||||
[self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
|
||||
|
||||
/* Build output string */
|
||||
result = [NSString stringWithCharacters:buffer length:bufferSize];
|
||||
|
||||
NSDeallocateMemoryPages(buffer, bufferSize);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#ifdef main
|
||||
# undef main
|
||||
#endif
|
||||
|
||||
|
||||
/* Main entry point to executable - should *not* be SDL_main! */
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* Copy the arguments into a global variable */
|
||||
/* This is passed if we are launched by double-clicking */
|
||||
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
||||
gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
|
||||
gArgv[0] = argv[0];
|
||||
gArgv[1] = NULL;
|
||||
gArgc = 1;
|
||||
gFinderLaunch = YES;
|
||||
} else {
|
||||
int i;
|
||||
gArgc = argc;
|
||||
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
||||
for (i = 0; i <= argc; i++)
|
||||
gArgv[i] = argv[i];
|
||||
gFinderLaunch = NO;
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
[SDLApplication poseAsClass:[NSApplication class]];
|
||||
NSApplicationMain (argc, argv);
|
||||
#else
|
||||
CustomApplicationMain (argc, argv);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
@ -1,10 +1,19 @@
|
||||
INCLUDES += -I/usr/include/SDL
|
||||
|
||||
SDL_SRC = sdlwin.c sdlevents.c sdlwm.c sdlscrap.c sdlquit.c \
|
||||
syswm_map.c sdl_mem.c SDL_bmp.c sdlX.c
|
||||
syswm_map.c sdl_mem.c SDL_bmp.c
|
||||
|
||||
ifneq (,$(findstring linux,$(TARGET)))
|
||||
SDL_SRC += sdlX.c
|
||||
endif
|
||||
|
||||
FRONT_END_SRC = $(SDL_SRC)
|
||||
FRONT_END_OBJ = $(FRONT_END_SRC:.c=.o)
|
||||
FRONT_END_OBJ = $(FRONT_END_SRC:.c=.o)
|
||||
|
||||
ifneq (,$(findstring macosx,$(TARGET)))
|
||||
FRONT_END_OBJ += macosx_main.o
|
||||
endif
|
||||
|
||||
|
||||
ifneq (,$(findstring mingw,$(TARGET)))
|
||||
FRONT_END_LIBS += -lmingw32
|
||||
@ -18,7 +27,9 @@ endif
|
||||
# with the version of SDL on Fedora 9 (SDL 1.2.13)
|
||||
|
||||
# FRONT_END_LIBS += -lSDLmain -lSDL
|
||||
FRONT_END_LIBS += -lSDL
|
||||
ifeq (,$(findstring macosx,$(TARGET)))
|
||||
FRONT_END_LIBS += -lSDL
|
||||
endif
|
||||
#
|
||||
ifneq (,$(findstring linux,$(TARGET)))
|
||||
FRONT_END_LIBS += -ldl -L/usr/X11R6/lib -lX11 -lpthread
|
||||
@ -26,5 +37,10 @@ ifneq (,$(findstring linux,$(TARGET)))
|
||||
CFLAGS += -D_REENTRANT
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring macosx,$(TARGET)))
|
||||
FRONT_END_LIBS += -framework SDL -framework Cocoa
|
||||
CFLAGS += -D_REENTRANT
|
||||
endif
|
||||
|
||||
clean::
|
||||
rm -f $(FRONT_END_OBJ)
|
||||
|
@ -641,3 +641,23 @@ void PutScrapX(LONGINT type, LONGINT length, char *p, int scrap_count)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (MACOSX)
|
||||
#warning "Need to support clipboard"
|
||||
|
||||
PUBLIC boolean_t
|
||||
we_lost_clipboard(void)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
LONGINT GetScrapX(LONGINT type, char **h)
|
||||
{
|
||||
return -1; /* TODO */
|
||||
}
|
||||
void PutScrapX(LONGINT type, LONGINT length, char *p, int scrap_count)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -131,8 +131,12 @@ vdriver_set_mode (int width, int height, int bpp, boolean_t grayscale_p)
|
||||
if (width == 0)
|
||||
{
|
||||
width = VDRIVER_DEFAULT_SCREEN_WIDTH;
|
||||
#if true
|
||||
#warning "TODO: fixme so we can use fullscreen in Mac OS X"
|
||||
#else
|
||||
if (ROMlib_fullscreen_p)
|
||||
width = MAX (width, os_current_screen_width ());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,8 +146,12 @@ vdriver_set_mode (int width, int height, int bpp, boolean_t grayscale_p)
|
||||
if (height == 0)
|
||||
{
|
||||
height = VDRIVER_DEFAULT_SCREEN_HEIGHT;
|
||||
#if true
|
||||
#warning "TODO: fixme so we can use fullscreen in Mac OS X"
|
||||
#else
|
||||
if (ROMlib_fullscreen_p)
|
||||
height = MAX (height, os_current_screen_height ());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
extern int sdl_syswm_init(void);
|
||||
extern int sdl_syswm_event(const SDL_Event *event);
|
||||
|
||||
#if defined (__unix__)
|
||||
#if defined (__unix__) || defined (MACOSX)
|
||||
|
||||
extern int os_current_screen_width (void);
|
||||
extern int os_current_screen_height (void);
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "SDL/SDL_syswm.h"
|
||||
|
||||
/* System dependent variables */
|
||||
#if defined(__unix__)
|
||||
#if defined(__unix__) || defined (MACOSX)
|
||||
/* * */
|
||||
extern Display *SDL_Display;
|
||||
extern Window SDL_Window;
|
||||
|
@ -1,232 +1 @@
|
||||
/* Copyright 1995, 1996 by Abacus Research and
|
||||
* Development, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#if !defined (OMIT_RCSID_STRINGS)
|
||||
char ROMlib_rcsid_linux[] = "$Id: linux.c 119 2005-07-11 21:36:20Z ctm $";
|
||||
#endif
|
||||
|
||||
#include "rsys/common.h"
|
||||
#include "rsys/os.h"
|
||||
#include "rsys/memsize.h"
|
||||
#include "rsys/mman.h"
|
||||
#include "linux_except.h"
|
||||
#include "Gestalt.h"
|
||||
#include "rsys/gestalt.h"
|
||||
|
||||
#include "rsys/lockunlock.h"
|
||||
|
||||
static unsigned long
|
||||
physical_memory (void)
|
||||
{
|
||||
FILE *fp;
|
||||
unsigned long mem;
|
||||
|
||||
mem = 0;
|
||||
fp = fopen ("/proc/meminfo", "r");
|
||||
if (fp)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
while (fgets (buf, sizeof buf - 1, fp))
|
||||
if (!strncmp (buf, "Mem:", 4) && sscanf (buf + 4, "%lu", &mem))
|
||||
break;
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
replace_physgestalt_selector (gestaltPhysicalRAMSize, mem);
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
guess_good_memory_settings (void)
|
||||
{
|
||||
unsigned long new_appl_size;
|
||||
|
||||
new_appl_size = physical_memory () / 4;
|
||||
|
||||
#if defined (powerpc)
|
||||
|
||||
/* This hack prevents Photoshop 5.5 demo from complaining that we don't
|
||||
have enough memory when we run on a 64 MB Linux machine. Our division
|
||||
by four is a bit naive above, so there's really no harm, other than
|
||||
ugliness, to this hack. */
|
||||
|
||||
{
|
||||
enum { PHOTOSHOP_55_PREFERRED_SIZE = 16584 * 1024 };
|
||||
|
||||
if (new_appl_size < PHOTOSHOP_55_PREFERRED_SIZE &&
|
||||
new_appl_size >= PHOTOSHOP_55_PREFERRED_SIZE * 8 / 10)
|
||||
new_appl_size = PHOTOSHOP_55_PREFERRED_SIZE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (new_appl_size > ROMlib_applzone_size)
|
||||
ROMlib_applzone_size = MIN (MAX_APPLZONE_SIZE, new_appl_size);
|
||||
}
|
||||
|
||||
|
||||
boolean_t
|
||||
os_init (void)
|
||||
{
|
||||
guess_good_memory_settings ();
|
||||
#if defined (SDL)
|
||||
install_exception_handler ();
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PUBLIC int
|
||||
ROMlib_lockunlockrange (int fd, uint32 begin, uint32 count, lockunlock_t op)
|
||||
{
|
||||
int retval;
|
||||
struct flock flock;
|
||||
|
||||
warning_trace_info ("fd = %d, begin = %d, count = %d, op = %d",
|
||||
fd, begin, count, op);
|
||||
retval = noErr;
|
||||
switch (op)
|
||||
{
|
||||
case lock:
|
||||
flock.l_type = F_WRLCK;
|
||||
break;
|
||||
case unlock:
|
||||
flock.l_type = F_UNLCK;
|
||||
break;
|
||||
default:
|
||||
warning_unexpected ("op = %d", op);
|
||||
retval = paramErr;
|
||||
break;
|
||||
}
|
||||
|
||||
if (retval == noErr)
|
||||
{
|
||||
boolean_t success;
|
||||
|
||||
flock.l_whence = SEEK_SET;
|
||||
flock.l_start = begin;
|
||||
flock.l_len = count;
|
||||
|
||||
success = fcntl (fd, F_SETLK, &flock) != -1;
|
||||
if (success)
|
||||
retval = noErr;
|
||||
else
|
||||
{
|
||||
switch (errno)
|
||||
{
|
||||
case EAGAIN:
|
||||
case EACCES:
|
||||
retval = fLckdErr;
|
||||
break;
|
||||
#if 0
|
||||
case ERROR_NOT_LOCKED:
|
||||
retval = afpRangeNotLocked;
|
||||
break;
|
||||
#endif
|
||||
#if 0
|
||||
case ERROR_LOCK_FAILED:
|
||||
retval = afpRangeOverlap;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
warning_unexpected ("errno = %d", errno);
|
||||
retval = noErr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
PUBLIC int
|
||||
ROMlib_launch_native_app (int n_filenames, char **filenames)
|
||||
{
|
||||
char **v;
|
||||
|
||||
v = alloca (sizeof *v * (n_filenames + 1));
|
||||
memcpy (v, filenames, n_filenames * sizeof *v);
|
||||
v[n_filenames] = 0;
|
||||
if (fork () == 0)
|
||||
execv (filenames[0], v);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !(defined (__GNUC__) && defined (__GNUC_MINOR__) && ((__GNUC__ == 2 && __GNUC_MINOR__ == 7 && defined (__i386__)) || defined (RELEASE_INTERNAL) || defined (powerpc) || defined (__alpha)))
|
||||
#warning THIS IS NOT A PRODUCTION BUILD
|
||||
#endif
|
||||
|
||||
/*
|
||||
* There is a very bad problem associated with the use of the db
|
||||
* shared libraries under Linux. Specifically, the calling convention
|
||||
* for functions which return structs that are larger than 32 bits
|
||||
* somehow got changed when some of the Linux distributions switched
|
||||
* from gcc to egcs. Both compilers put an extra pointer on the stack
|
||||
* before calling the routine that returns the large struct, but gcc
|
||||
* expects the caller to pop that extra pointer, where egcs expects
|
||||
* the called to pop it. This means that if you compile the caller
|
||||
* with gcc and call a shared library that was called with egcs, the
|
||||
* stack pointer will be off by 4 bytes after the function returns and
|
||||
* the stack is adjusted. That can be a catastrophe if further code
|
||||
* expects the stack to be correct after adjustments. On the other
|
||||
* hand, if we make the questionable call and then do nothing else,
|
||||
* the "leave" instruction will restore the stack pointer by using the
|
||||
* frame pointer and we'll never be bothered by the extra pop.
|
||||
*
|
||||
* So, as a workaround, we can wrap the routines, then check the
|
||||
* assembly code that the compiler produces to make sure that it's
|
||||
* tolerant of the error, then call the wrappers. That makes the
|
||||
* wrapper routines look like voodoo code that was written by a
|
||||
* superstitious programmer, but the code (or some other workaround)
|
||||
* is absolutely necessary because we want to have one Executor
|
||||
* executable that can run with both the shared libraries from Red Hat
|
||||
* 5.2 as well as the new ones in SuSE 6.0 (and the new ones that will
|
||||
* probably be in Red Hat 6.0).
|
||||
*
|
||||
* These wrappers absolutely have to be compiled with enough
|
||||
* optimization so that the stack isn't adjusted before the leave
|
||||
* instruction. If it is adjusted, then any interrupt that occurs
|
||||
* between the adjustment and the transfering of the data from the
|
||||
* temporary stack space to the address passed will cause corruption.
|
||||
*
|
||||
* If you do not understand the above, or if you disagree with it,
|
||||
* please contact Cliff before changing the following code. Axing the
|
||||
* code alone and then testing the result is not sufficient, unless
|
||||
* you're sure that your test involves *both* db shared libaries.
|
||||
*
|
||||
*/
|
||||
|
||||
PUBLIC void
|
||||
_dbm_fetch (datum *datump, DBM *db, datum datum)
|
||||
{
|
||||
*datump = dbm_fetch (db, datum);
|
||||
}
|
||||
|
||||
PUBLIC void
|
||||
_dbm_firstkey (datum *datump, DBM *db)
|
||||
{
|
||||
*datump = dbm_firstkey (db);
|
||||
}
|
||||
|
||||
PUBLIC void
|
||||
_dbm_nextkey (datum *datump, DBM *db)
|
||||
{
|
||||
*datump = dbm_nextkey (db);
|
||||
}
|
||||
|
||||
PUBLIC boolean_t host_has_spfcommon (void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
PUBLIC boolean_t
|
||||
host_spfcommon (host_spf_reply_block *replyp, const char *prompt,
|
||||
const char *incoming_filename, void *fp, void *filef, int numt,
|
||||
void *tl, getorput_t getorput, sf_flavor_t flavor,
|
||||
void *activeList, void *activateproc, void *yourdatap)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/* Everything has been moved to unix_like.c for now */
|
||||
|
@ -2,8 +2,8 @@ LOWGLOBALS_LD_OPTION = lowglobals.o
|
||||
|
||||
TARGET_OS_LD_FLAGS = -Wl,-no-keep-memory # So we don't page so much
|
||||
|
||||
TARGET_OS_SRC = lowglobals-mem.c linux.c linux_except.c
|
||||
TARGET_OS_OBJ = lowglobals-mem.o linux.o linux_except.o
|
||||
TARGET_OS_SRC = lowglobals-mem.c linux.c
|
||||
TARGET_OS_OBJ = lowglobals-mem.o linux.o
|
||||
|
||||
TARGET_OS_LIBS = @libdb@ -lm @libg@
|
||||
|
||||
|
@ -1,51 +1,3 @@
|
||||
/* Copyright 1998 by Abacus Research and
|
||||
* Development, Inc. All rights reserved.
|
||||
*/
|
||||
/* Everything has been moved to unix_like.c for now */
|
||||
|
||||
#if !defined (OMIT_RCSID_STRINGS)
|
||||
char ROMlib_rcsid_linux_except[] = "$Id: linux_except.c 63 2004-12-24 18:19:43Z ctm $";
|
||||
#endif
|
||||
|
||||
#include "rsys/common.h"
|
||||
#include "rsys/system_error.h"
|
||||
|
||||
#include "SegmentLdr.h"
|
||||
|
||||
#include "linux_except.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
static void
|
||||
my_fault_proc( int sig )
|
||||
{
|
||||
// FIXME: Change this to an internal Executor dialog
|
||||
fprintf(stderr, "Unexpected Application Failure\n");
|
||||
|
||||
// If we are already in the browser, does this exit the program?
|
||||
C_ExitToShell ();
|
||||
}
|
||||
|
||||
static int except_list[] = { SIGSEGV, SIGBUS, 0 };
|
||||
|
||||
void
|
||||
install_exception_handler (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0; except_list[i]; ++i )
|
||||
{
|
||||
signal(except_list[i], my_fault_proc);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
uninstall_exception_handler (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0; except_list[i]; ++i )
|
||||
{
|
||||
signal(except_list[i], SIG_DFL);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1 @@
|
||||
#if !defined (__LINUX_EXCEPT_H__)
|
||||
#define __LINUX_EXCEPT_H__
|
||||
|
||||
/*
|
||||
* Copyright 1998 by Abacus Research and Development, Inc.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
extern void install_exception_handler (void);
|
||||
extern void uninstall_exception_handler (void);
|
||||
|
||||
#endif
|
||||
/* Everything has been moved to unix_like.c for now */
|
||||
|
@ -1,183 +1,3 @@
|
||||
/* Copyright 1994 - 1997 by Abacus Research and
|
||||
* Development, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#if !defined (OMIT_RCSID_STRINGS)
|
||||
char ROMlib_rcsid_lowglobals_mem[] = "$Id: lowglobals-mem.c 85 2005-05-24 22:06:13Z ctm $";
|
||||
#endif
|
||||
|
||||
#include "rsys/common.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "rsys/memory_layout.h"
|
||||
#include "rsys/assert.h"
|
||||
#include "rsys/lowglobals.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
void
|
||||
mmap_lowglobals (void)
|
||||
{
|
||||
if (!force_big_offset)
|
||||
{
|
||||
caddr_t addr;
|
||||
|
||||
addr = mmap ((caddr_t) PAGE_ZERO_START,
|
||||
PAGE_ZERO_SIZE,
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, -1, 0);
|
||||
gui_assert (addr == (caddr_t) PAGE_ZERO_START);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined (powerpc)
|
||||
PRIVATE caddr_t
|
||||
round_up_to_page_size (unsigned long addr)
|
||||
{
|
||||
caddr_t retval;
|
||||
size_t page_size;
|
||||
|
||||
page_size = getpagesize ();
|
||||
retval = (caddr_t) ((addr + page_size - 1) / page_size * page_size);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
static jmp_buf segv_return;
|
||||
|
||||
static void
|
||||
segv_handler (int signum_ignored __attribute__((unused)))
|
||||
{
|
||||
siglongjmp (segv_return, 1);
|
||||
}
|
||||
|
||||
static bool
|
||||
mmap_conflict (void *start, size_t length)
|
||||
{
|
||||
bool retval;
|
||||
long page_size;
|
||||
|
||||
retval = false;
|
||||
|
||||
page_size = sysconf(_SC_PAGESIZE);
|
||||
|
||||
if ((long) start % page_size != 0)
|
||||
{
|
||||
retval = true;
|
||||
warning_unexpected ("start = %p, page_size = %ld, "
|
||||
"start %% page_size = %ld",
|
||||
start, page_size, (long) start % page_size);
|
||||
}
|
||||
else if (length % page_size != 0)
|
||||
{
|
||||
retval = true;
|
||||
warning_unexpected ("length = %ld, page_size = %ld, "
|
||||
"length %% page_size = %ld",
|
||||
(long) length, page_size, (long) length % page_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
sig_t old_segv_handler;
|
||||
volatile int n_pages;
|
||||
volatile int n_failures;
|
||||
volatile char *volatile addr;
|
||||
char *stop;
|
||||
|
||||
n_pages = 0;
|
||||
n_failures = 0;
|
||||
stop = (char *) start + length;
|
||||
|
||||
old_segv_handler = signal (SIGSEGV, segv_handler);
|
||||
for (addr = start; addr < stop; addr += page_size)
|
||||
{
|
||||
++n_pages;
|
||||
if (sigsetjmp (segv_return, 1) != 0)
|
||||
++n_failures;
|
||||
else
|
||||
*addr;
|
||||
}
|
||||
signal (SIGSEGV, old_segv_handler);
|
||||
retval = n_failures < n_pages;
|
||||
if (retval)
|
||||
warning_unexpected ("%d pages were already mapped",
|
||||
n_pages - n_failures);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void *
|
||||
mmap_permanent_memory (unsigned long amount_wanted)
|
||||
{
|
||||
caddr_t addr_got;
|
||||
caddr_t badness_start;
|
||||
|
||||
/* Only do this if our text segment is up nice and high out of the way. */
|
||||
if (((unsigned long) mmap_permanent_memory & 0xFF000000L) == 0)
|
||||
return NULL;
|
||||
|
||||
{
|
||||
extern void *_start;
|
||||
|
||||
badness_start = (caddr_t) ((unsigned long) &_start
|
||||
/ (1024 * 1024) * (1024 * 1024));
|
||||
}
|
||||
|
||||
#if !defined (powerpc)
|
||||
{
|
||||
caddr_t addr_wanted;
|
||||
|
||||
addr_wanted = round_up_to_page_size (PAGE_ZERO_START + PAGE_ZERO_SIZE);
|
||||
|
||||
if (addr_wanted + amount_wanted > badness_start)
|
||||
{
|
||||
warning_unexpected ("addr_wanted = %p, amount_wanted = 0x%lx, "
|
||||
"badness_start = %p", addr_wanted, amount_wanted,
|
||||
badness_start);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mmap_conflict (addr_wanted, amount_wanted))
|
||||
addr_got = NULL;
|
||||
else
|
||||
{
|
||||
addr_got = mmap (addr_wanted, amount_wanted, PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, -1, 0);
|
||||
if (addr_got == (caddr_t) -1)
|
||||
addr_got = NULL;
|
||||
else if (addr_got != addr_wanted)
|
||||
warning_unexpected ("addr_wanted = %p, addr_got = %p",
|
||||
addr_wanted, addr_got);
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* Everything has been moved to unix_like.c for now */
|
||||
|
||||
|
||||
#warning THIS CODE IS PROBABLY WRONG
|
||||
|
||||
/*
|
||||
* I haven't tested a powerpc build in a while, but I just noticed that
|
||||
* we're trying to mmap from 0 and then we're returning addr_got. I think
|
||||
* that when we return 0, the caller believes that we weren't able to
|
||||
* mmap the low globals. As such, the code below PROBABLY DOESN'T DO
|
||||
* ANYTHING DIFFERENT THAN SIMPLY RETURNING NULL.
|
||||
*/
|
||||
|
||||
if (amount_wanted > badness_start)
|
||||
{
|
||||
warning_unexpected ("amount_wanted = 0x%x, badness_start = %p",
|
||||
amount_wanted, badness_start);
|
||||
addr_got = NULL;
|
||||
}
|
||||
else
|
||||
addr_got = mmap (0, amount_wanted, PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
|
||||
if (addr_got == (caddr_t) -1)
|
||||
addr_got = NULL;
|
||||
#endif
|
||||
|
||||
return addr_got;
|
||||
}
|
||||
|
105
src/config/os/macosx/macosx.h
Normal file
105
src/config/os/macosx/macosx.h
Normal file
@ -0,0 +1,105 @@
|
||||
#if !defined (__OS_MACOSX_H_)
|
||||
#define __OS_MACOSX_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#undef trap
|
||||
#include <signal.h>
|
||||
#define trap
|
||||
|
||||
#if !defined (__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
|
||||
|
||||
#undef GLIBC_DB1_INCLUDES_NDBM
|
||||
|
||||
#else
|
||||
|
||||
#define GLIBC_DB1_INCLUDES_NDBM
|
||||
#include <stdint.h>
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined (MACOSX)
|
||||
# define MACOSX
|
||||
#endif
|
||||
|
||||
#if !defined (O_BINARY)
|
||||
# define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#if !defined (PRIVATE)
|
||||
# define PRIVATE static
|
||||
#endif
|
||||
|
||||
#if !defined (MMAP_LOW_GLOBALS)
|
||||
/* define `MMAP_LOW_GLOBALS' if the zero page needs to be
|
||||
`mmap ()'ed for the low globals (see main:main.c) */
|
||||
#define MMAP_LOW_GLOBALS
|
||||
#endif /* !MMAP_LOW_GLOBALS */
|
||||
|
||||
extern void mmap_lowglobals (void);
|
||||
|
||||
#define TRY_TO_MMAP_ZONES
|
||||
extern void *mmap_permanent_memory (unsigned long amount_wanted);
|
||||
|
||||
#if !defined (REINSTALL_SIGNAL_HANDLER)
|
||||
/* define `REINSTALL_SIGNAL_HANDLER' if signal handlers are
|
||||
de-installed after the signals occur, and require reinstallation */
|
||||
#define REINSTALL_SIGNAL_HANDLER
|
||||
#endif /* !REINSTALL_SIGNAL_HANDLER */
|
||||
|
||||
/* These functions don't exist in the math library, so use some
|
||||
* approximately correct versions of our own.
|
||||
*/
|
||||
#define NEED_SCALB
|
||||
#define NEED_LOGB
|
||||
|
||||
#define HAVE_MMAP
|
||||
|
||||
#define CONFIG_OFFSET_P 0 /* don't normally use offset memory */
|
||||
|
||||
|
||||
extern int ROMlib_launch_native_app (int n_filenames, char **filenames);
|
||||
|
||||
/* #if !defined (GLIBC_DB1_INCLUDES_NDBM) */
|
||||
/* #include <ndbm.h> */
|
||||
/* #else */
|
||||
/* #include <db1/ndbm.h> */
|
||||
/* #endif */
|
||||
/* to be fixed, 12/08/03 */
|
||||
|
||||
// DO NOT COMMIT THESE UNCONDITIONAL HACKS
|
||||
// #define DB_DBM_HSEARCH 1
|
||||
// #include <db.h>
|
||||
|
||||
#include <ndbm.h>
|
||||
|
||||
#if !defined (COMPILE_FOR_HOST)
|
||||
|
||||
extern void _dbm_fetch (datum *datump, DBM *db, datum datum);
|
||||
extern void _dbm_firstkey (datum *datump, DBM *db);
|
||||
extern void _dbm_nextkey (datum *datump, DBM *db);
|
||||
|
||||
#define DBM_FETCH(datump, db, datum) _dbm_fetch ((datump), (db), (datum))
|
||||
#define DBM_FIRSTKEY(datump, db) _dbm_firstkey ((datump), (db))
|
||||
#define DBM_NEXTKEY(datump, db) _dbm_nextkey ((datump), (db))
|
||||
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/disk.h>
|
||||
|
||||
#endif /* !defined(__OS_MACOSX_H_) */
|
@ -9,10 +9,8 @@
|
||||
|
||||
#include "rsys/common.h"
|
||||
|
||||
#include <sys/soundcard.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
#include <linux/unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <signal.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -16,6 +16,7 @@ char ROMlib_rcsid_ctlInit[] =
|
||||
#include "ToolboxUtil.h"
|
||||
#include "ResourceMgr.h"
|
||||
#include "MemoryMgr.h"
|
||||
#include "OSUtil.h"
|
||||
|
||||
#include "rsys/ctl.h"
|
||||
#include "rsys/wind.h"
|
||||
|
@ -159,7 +159,8 @@ func_name (const void *raw_table, \
|
||||
({ \
|
||||
int smashed_ax_unused; \
|
||||
\
|
||||
asm volatile ("pushl %%ebp\n\t" \
|
||||
asm volatile ("pushl %%ebx\n\t" \
|
||||
"pushl %%ebp\n\t" \
|
||||
"movl %5,%%ebp\n\t" \
|
||||
"movl %%eax,%%ebx\n\t" \
|
||||
"testl $7,%%ebp\n\t" \
|
||||
@ -244,11 +245,12 @@ func_name (const void *raw_table, \
|
||||
\
|
||||
/* All done! */ \
|
||||
"3:\n\t" \
|
||||
"popl %%ebp" \
|
||||
"popl %%ebp\n\t" \
|
||||
"popl %%ebx\n\t" \
|
||||
: "=S" (inp), "=D" (outp), "=a" (smashed_ax_unused) \
|
||||
: "0" (inp), "1" (outp), "g" (byte_width), \
|
||||
"2" (table) \
|
||||
: "memory", "bx", "cx", "dx", "cc"); \
|
||||
: "memory", "cx", "dx", "cc"); \
|
||||
})
|
||||
|
||||
|
||||
@ -256,7 +258,8 @@ func_name (const void *raw_table, \
|
||||
({ \
|
||||
int smashed_ax, smashed_cx; \
|
||||
\
|
||||
asm volatile ("pushl %%ebp\n\t" \
|
||||
asm volatile ("pushl %%ebx\n\t" \
|
||||
"pushl %%ebp\n\t" \
|
||||
"xorl %%ebx,%%ebx\n\t" \
|
||||
"xorl %%edx,%%edx\n\t" \
|
||||
\
|
||||
@ -302,10 +305,11 @@ func_name (const void *raw_table, \
|
||||
\
|
||||
"3:\n\t" \
|
||||
"popl %%ebp\n\t" \
|
||||
"popl %%ebx\n\t" \
|
||||
: "=S" (inp), "=D" (outp), "=a" (smashed_ax), \
|
||||
"=c" (smashed_cx) \
|
||||
: "2" (table), "0" (inp), "1" (outp), "3" (byte_width) \
|
||||
: "bx", "dx", "cc", "memory"); \
|
||||
: "dx", "cc", "memory"); \
|
||||
})
|
||||
|
||||
|
||||
@ -313,7 +317,8 @@ func_name (const void *raw_table, \
|
||||
({ \
|
||||
int smashed_ax, smashed_cx; \
|
||||
\
|
||||
asm volatile ("pushl %%ebp\n\t" \
|
||||
asm volatile ("pushl %%ebx\n\t" \
|
||||
"pushl %%ebp\n\t" \
|
||||
"xorl %%ebx,%%ebx\n\t" \
|
||||
"xorl %%edx,%%edx\n\t" \
|
||||
\
|
||||
@ -361,10 +366,11 @@ func_name (const void *raw_table, \
|
||||
\
|
||||
"3:\n\t" \
|
||||
"popl %%ebp\n\t" \
|
||||
"popl %%ebx\n\t" \
|
||||
: "=S" (inp), "=D" (outp), "=a" (smashed_ax), \
|
||||
"=c" (smashed_cx) \
|
||||
: "2" (table), "0" (inp), "1" (outp), "3" (byte_width) \
|
||||
: "bx", "dx", "cc", "memory"); \
|
||||
: "dx", "cc", "memory"); \
|
||||
})
|
||||
|
||||
|
||||
@ -372,7 +378,8 @@ func_name (const void *raw_table, \
|
||||
({ \
|
||||
int smashed_ax, smashed_cx; \
|
||||
\
|
||||
asm volatile ("pushl %%ebp\n\t" \
|
||||
asm volatile ("pushl %%ebx\n\t" \
|
||||
"pushl %%ebp\n\t" \
|
||||
"xorl %%ebx,%%ebx\n\t" \
|
||||
"xorl %%edx,%%edx\n\t" \
|
||||
\
|
||||
@ -437,10 +444,11 @@ func_name (const void *raw_table, \
|
||||
\
|
||||
"3:\n\t" \
|
||||
"popl %%ebp\n\t" \
|
||||
"popl %%ebx\n\t" \
|
||||
: "=S" (inp), "=D" (outp), "=a" (smashed_ax), \
|
||||
"=c" (smashed_cx) \
|
||||
: "2" (table), "0" (inp), "1" (outp), "3" (byte_width) \
|
||||
: "bx", "dx", "cc", "memory"); \
|
||||
: "dx", "cc", "memory"); \
|
||||
})
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@ char ROMlib_rcsid_desk[] =
|
||||
#include "QuickDraw.h"
|
||||
#include "OSEvent.h"
|
||||
#include "ToolboxEvent.h"
|
||||
#include "OSUtil.h"
|
||||
|
||||
#include "rsys/cquick.h"
|
||||
#include "rsys/wind.h"
|
||||
|
@ -10,6 +10,9 @@ char ROMlib_rcsid_emutraptables[] =
|
||||
#include "rsys/common.h"
|
||||
#include "rsys/everything.h"
|
||||
|
||||
#include "OSUtil.h"
|
||||
#include "Gestalt.h"
|
||||
|
||||
#include "rsys/trapglue.h"
|
||||
#include "rsys/ptocflags.h"
|
||||
#include "rsys/stdfile.h"
|
||||
|
@ -74,7 +74,7 @@ AUX_SRC = \
|
||||
redrawscreen.c ini.c checkpoint.c qt.c cleanup.c paramline.c \
|
||||
fauxdbm.c custom.c commtool.c cfm.c local_charset.c pef_hash.c \
|
||||
mathlib.c interfacelib.c mixed_mode.c suffix_maps.c appearance.c \
|
||||
lockrange.c
|
||||
lockrange.c unix_like.c
|
||||
|
||||
ROMLIB_SRC = $(CTL_SRC) $(DIAL_SRC) $(FILE_SRC) $(HFS_SRC) $(LIST_SRC) \
|
||||
$(MENU_SRC) $(PR_SRC) $(QD_SRC) $(RES_SRC) $(TE_SRC) $(WIND_SRC) \
|
||||
|
@ -126,7 +126,7 @@ PUBLIC void ROMlib_hfsinit( void )
|
||||
* which is an ARDI written NEXTSTEP atrocity.
|
||||
*/
|
||||
|
||||
#if !defined(LINUX)
|
||||
#if !defined(LINUX) && !defined (MACOSX)
|
||||
#define EJECTABLE(buf) FALSE
|
||||
#else
|
||||
/* #warning this is not the proper way to tell if something is ejectable */
|
||||
@ -231,7 +231,7 @@ PUBLIC OSErr ROMlib_ejectfloppy( LONGINT floppyfd )
|
||||
eject_floppy_notify();
|
||||
} else {
|
||||
#endif
|
||||
#if defined(NEXTSTEP)
|
||||
#if defined(NEXTSTEP) || defined (MACOSX)
|
||||
if (floppyfd != -1 && ioctl(floppyfd, DKIOCEJECT, (char *) 0) < 0) {
|
||||
fprintf(stderr, "couldn't eject disk\n");
|
||||
err = ioErr;
|
||||
@ -239,7 +239,7 @@ PUBLIC OSErr ROMlib_ejectfloppy( LONGINT floppyfd )
|
||||
#endif
|
||||
if (floppyfd != -1)
|
||||
close(floppyfd);
|
||||
#if defined(LINUX)
|
||||
#if defined(LINUX) || defined (MACOSX)
|
||||
eject_floppy_notify();
|
||||
#endif
|
||||
#if defined(MSDOS) || defined (CYGWIN32)
|
||||
@ -259,7 +259,7 @@ PUBLIC void ROMlib_OurClose( void )
|
||||
if (Cx(vcbp->vcbCTRef)) {
|
||||
pbr.ioParam.ioVRefNum = vcbp->vcbVRefNum;
|
||||
PBUnmountVol(&pbr);
|
||||
#if defined (NEXTSTEP)
|
||||
#if defined (NEXTSTEP) || defined (MACOSX)
|
||||
if (!(Cx(vcbp->vcbAtrb) & VNONEJECTABLEBIT) && Cx(vcbp->vcbDrvNum))
|
||||
ROMlib_ejectfloppy(((VCBExtra *) vcbp)->u.hfs.fd);
|
||||
#endif
|
||||
@ -272,7 +272,7 @@ PUBLIC void ROMlib_OurClose( void )
|
||||
PRIVATE BOOLEAN isejectable( const charCx( *dname), LONGINT fd )
|
||||
{
|
||||
BOOLEAN retval;
|
||||
#if defined(NEXTSTEP)
|
||||
#if defined(NEXTSTEP) || defined (MACOSX)
|
||||
struct scsi_req sr;
|
||||
char inqbuf[sizeof(struct inquiry_reply) + 3];
|
||||
struct inquiry_replyCx( *inqp);
|
||||
@ -281,7 +281,7 @@ PRIVATE BOOLEAN isejectable( const charCx( *dname), LONGINT fd )
|
||||
|
||||
/* look for rfd[0-9] */
|
||||
retval = FALSE;
|
||||
#if defined(NEXTSTEP)
|
||||
#if defined(NEXTSTEP) || defined (MACOSX)
|
||||
for (p = dname; p = index(p, 'r'); ++p) {
|
||||
if (p[1] == 'f' && p[2] == 'd' && isdigit(p[3])) {
|
||||
retval = TRUE;
|
||||
@ -357,10 +357,10 @@ PRIVATE LONGINT try_to_open_disk( const char *dname,
|
||||
*bsizep = PHYSBSIZE;
|
||||
*maxbytesp = 1024L * 1024;
|
||||
}
|
||||
#else /* defined(NEXTSTEP) */
|
||||
#else
|
||||
*bsizep = PHYSBSIZE;
|
||||
*maxbytesp = 1024L * 1024;
|
||||
#endif /* defined(NEXTSTEP) */
|
||||
#endif
|
||||
}
|
||||
|
||||
if (floppyfd >= 0)
|
||||
@ -714,7 +714,7 @@ ROMlib_transphysblk (hfs_access_t *hfsp, LONGINT physblock, short nphysblocks,
|
||||
if (actp)
|
||||
*actp = pb.ioActCount;
|
||||
#else
|
||||
#if defined(NEXTSTEP)
|
||||
#if defined(NEXTSTEP) || defined (MACOSX)
|
||||
if ((LONGINT) bufp & 3) {
|
||||
newbufp = alloca( (LONGINT) nphysblocks * PHYSBSIZE + 4);
|
||||
newbufp = (Ptr) (((LONGINT) newbufp + 3) & ~3);
|
||||
@ -729,7 +729,7 @@ ROMlib_transphysblk (hfs_access_t *hfsp, LONGINT physblock, short nphysblocks,
|
||||
(LONGINT) nphysblocks * PHYSBSIZE,
|
||||
physblock + hfsp->offset, rw, hfsp->bsize,
|
||||
hfsp->maxbytes);
|
||||
#if defined(NEXTSTEP)
|
||||
#if defined(NEXTSTEP) || defined (MACOSX)
|
||||
if (rw == reading && bufp != newbufp && err == noErr)
|
||||
memmove(bufp, newbufp, (LONGINT) nphysblocks * PHYSBSIZE);
|
||||
#endif
|
||||
|
@ -10,7 +10,7 @@ char ROMlib_rcsid_ibm_keycodes[] =
|
||||
#include "rsys/common.h"
|
||||
#include "rsys/keyboard.h"
|
||||
|
||||
#if defined (MSDOS) || defined (EVENT_SVGALIB) || defined (CYGWIN32) || (defined (SDL) && defined (LINUX))
|
||||
#if defined (MSDOS) || defined (EVENT_SVGALIB) || defined (CYGWIN32) || (defined (SDL) && (defined (LINUX) || defined (MACOSX)))
|
||||
|
||||
unsigned char ibm_virt_to_mac_virt[] =
|
||||
{
|
||||
|
@ -23,7 +23,7 @@
|
||||
#undef USE_WINDOWS_NOT_MAC_TYPEDEFS_AND_DEFINES
|
||||
#endif
|
||||
|
||||
#if !defined (LINUX) && !defined (MSDOS) && !defined (NEXT) && !defined(CYGWIN32)
|
||||
#if !defined (LINUX) && !defined (MSDOS) && !defined (NEXT) && !defined(CYGWIN32) && !defined (MACOSX)
|
||||
# error "Unsupported host"
|
||||
#endif
|
||||
|
||||
|
@ -36,13 +36,15 @@ extern const char ROMlib_executor_build_time[];
|
||||
#define VERSION_SIG PLATFORM_CYGWIN32
|
||||
#elif defined(LINUX)
|
||||
#define VERSION_SIG PLATFORM_LINUX
|
||||
#elif defined(MACOSX)
|
||||
#define VERSION_SIG PLATFORM_MACOSX
|
||||
#else
|
||||
#error "Need VERSION_SIG #define"
|
||||
#endif
|
||||
|
||||
enum { CLASS_COMMERCIAL = 0, CLASS_EDUCATIONAL = 10, CLASS_STUDENT = 20 };
|
||||
enum { PLATFORM_NEXTSTEP = 0, PLATFORM_CYGWIN32 = 1, PLATFORM_DOS = 2,
|
||||
PLATFORM_LINUX = 3, PLATFORM_ANY = 4 };
|
||||
PLATFORM_LINUX = 3, PLATFORM_ANY = 4, PLATFORM_MACOSX = 5 };
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -1218,7 +1218,7 @@ A1(PRIVATE, void, setstartdir, char *, argv0)
|
||||
} else {
|
||||
close (p[1]);
|
||||
nread = read(p[0], buf, sizeof(buf)-1);
|
||||
wait4(pid, (union wait *) 0, 0, (struct rusage *) 0);
|
||||
wait4(pid, 0, 0, (struct rusage *) 0);
|
||||
if (nread)
|
||||
--nread; /* get rid of trailing \n */
|
||||
buf[nread] = 0;
|
||||
|
@ -9,7 +9,7 @@ char ROMlib_rcsid_protector[] =
|
||||
|
||||
#include "rsys/common.h"
|
||||
|
||||
#if defined(NEXTSTEP) || defined(LINUX)
|
||||
#if defined(NEXTSTEP) || defined(LINUX) || defined (MACOSX)
|
||||
|
||||
/*
|
||||
* TODO: make sure no one interferes with SIGIO
|
||||
|
@ -210,6 +210,7 @@ xdblt_canon_pattern (void)
|
||||
goto start_scanline;
|
||||
|
||||
done_with_scanlines:
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
@ -229,6 +229,7 @@ srcblt_bitmap (void)
|
||||
goto start_scanline;
|
||||
|
||||
done_with_scanlines:
|
||||
;
|
||||
}
|
||||
|
||||
#endif /* USE_PORTABLE_SRCBLT */
|
||||
|
@ -15,6 +15,11 @@ char ROMlib_rcsid_serial[] =
|
||||
#endif
|
||||
|
||||
#include "rsys/common.h"
|
||||
|
||||
#if defined (MACOSX)
|
||||
#warning "No serial support for now"
|
||||
#else /* !defined (MACOSX) */
|
||||
|
||||
#include "Serial.h"
|
||||
#include "DeviceMgr.h"
|
||||
#include "FileMgr.h"
|
||||
@ -1032,3 +1037,4 @@ A2(PUBLIC, OSErr, ROMlib_serialclose, ParmBlkPtr, pbp, /* INTERNAL */
|
||||
#endif
|
||||
DOCOMPLETION(pbp, err);
|
||||
}
|
||||
#endif /* !defined (MACOSX) */
|
||||
|
@ -9,7 +9,7 @@ char ROMlib_rcsid_sigio_multiplex[] =
|
||||
|
||||
#include "rsys/common.h"
|
||||
|
||||
#if defined (LINUX) || defined (NEXTSTEP)
|
||||
#if defined (LINUX) || defined (NEXTSTEP) || defined (MACOSX)
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
469
src/unix_like.c
Normal file
469
src/unix_like.c
Normal file
@ -0,0 +1,469 @@
|
||||
#include "rsys/common.h"
|
||||
|
||||
/*
|
||||
* This file is a quick hack to hoist code from config/os/linux to where it
|
||||
* can be shared with the Mac OS X port.
|
||||
*
|
||||
* Eventually everything should be rejiggered to use the GNU build system.
|
||||
*/
|
||||
|
||||
#if defined (LINUX) || defined (MACOSX)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "rsys/os.h"
|
||||
#include "rsys/memsize.h"
|
||||
#include "rsys/mman.h"
|
||||
#include "rsys/system_error.h"
|
||||
#include "rsys/memory_layout.h"
|
||||
#include "rsys/assert.h"
|
||||
#include "rsys/lowglobals.h"
|
||||
|
||||
#include "Gestalt.h"
|
||||
#include "SegmentLdr.h"
|
||||
|
||||
#include "rsys/gestalt.h"
|
||||
|
||||
#include "rsys/lockunlock.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#if defined (MACOSX)
|
||||
// The code in here should work for Mac OS X as well as Linux, although
|
||||
// in Mac OS X they use MAP_ANON instead of MAP_ANONYMOUS
|
||||
#warning "Fix this, the code isn't Linux specific"
|
||||
#define MAP_ANONYMOUS MAP_ANON
|
||||
#endif
|
||||
|
||||
static void
|
||||
my_fault_proc( int sig )
|
||||
{
|
||||
// FIXME: Change this to an internal Executor dialog
|
||||
fprintf(stderr, "Unexpected Application Failure\n");
|
||||
|
||||
// If we are already in the browser, does this exit the program?
|
||||
C_ExitToShell ();
|
||||
}
|
||||
|
||||
static int except_list[] = { SIGSEGV, SIGBUS, 0 };
|
||||
|
||||
void
|
||||
install_exception_handler (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0; except_list[i]; ++i )
|
||||
{
|
||||
signal(except_list[i], my_fault_proc);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
uninstall_exception_handler (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0; except_list[i]; ++i )
|
||||
{
|
||||
signal(except_list[i], SIG_DFL);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
physical_memory (void)
|
||||
{
|
||||
FILE *fp;
|
||||
unsigned long mem;
|
||||
|
||||
mem = 0;
|
||||
fp = fopen ("/proc/meminfo", "r");
|
||||
if (fp)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
while (fgets (buf, sizeof buf - 1, fp))
|
||||
if (!strncmp (buf, "Mem:", 4) && sscanf (buf + 4, "%lu", &mem))
|
||||
break;
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
replace_physgestalt_selector (gestaltPhysicalRAMSize, mem);
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
guess_good_memory_settings (void)
|
||||
{
|
||||
unsigned long new_appl_size;
|
||||
|
||||
new_appl_size = physical_memory () / 4;
|
||||
|
||||
#if defined (powerpc)
|
||||
|
||||
/* This hack prevents Photoshop 5.5 demo from complaining that we don't
|
||||
have enough memory when we run on a 64 MB Linux machine. Our division
|
||||
by four is a bit naive above, so there's really no harm, other than
|
||||
ugliness, to this hack. */
|
||||
|
||||
{
|
||||
enum { PHOTOSHOP_55_PREFERRED_SIZE = 16584 * 1024 };
|
||||
|
||||
if (new_appl_size < PHOTOSHOP_55_PREFERRED_SIZE &&
|
||||
new_appl_size >= PHOTOSHOP_55_PREFERRED_SIZE * 8 / 10)
|
||||
new_appl_size = PHOTOSHOP_55_PREFERRED_SIZE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (new_appl_size > ROMlib_applzone_size)
|
||||
ROMlib_applzone_size = MIN (MAX_APPLZONE_SIZE, new_appl_size);
|
||||
}
|
||||
|
||||
|
||||
boolean_t
|
||||
os_init (void)
|
||||
{
|
||||
guess_good_memory_settings ();
|
||||
#if defined (SDL)
|
||||
install_exception_handler ();
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PUBLIC int
|
||||
ROMlib_lockunlockrange (int fd, uint32 begin, uint32 count, lockunlock_t op)
|
||||
{
|
||||
int retval;
|
||||
struct flock flock;
|
||||
|
||||
warning_trace_info ("fd = %d, begin = %d, count = %d, op = %d",
|
||||
fd, begin, count, op);
|
||||
retval = noErr;
|
||||
switch (op)
|
||||
{
|
||||
case lock:
|
||||
flock.l_type = F_WRLCK;
|
||||
break;
|
||||
case unlock:
|
||||
flock.l_type = F_UNLCK;
|
||||
break;
|
||||
default:
|
||||
warning_unexpected ("op = %d", op);
|
||||
retval = paramErr;
|
||||
break;
|
||||
}
|
||||
|
||||
if (retval == noErr)
|
||||
{
|
||||
boolean_t success;
|
||||
|
||||
flock.l_whence = SEEK_SET;
|
||||
flock.l_start = begin;
|
||||
flock.l_len = count;
|
||||
|
||||
success = fcntl (fd, F_SETLK, &flock) != -1;
|
||||
if (success)
|
||||
retval = noErr;
|
||||
else
|
||||
{
|
||||
switch (errno)
|
||||
{
|
||||
case EAGAIN:
|
||||
case EACCES:
|
||||
retval = fLckdErr;
|
||||
break;
|
||||
#if 0
|
||||
case ERROR_NOT_LOCKED:
|
||||
retval = afpRangeNotLocked;
|
||||
break;
|
||||
#endif
|
||||
#if 0
|
||||
case ERROR_LOCK_FAILED:
|
||||
retval = afpRangeOverlap;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
warning_unexpected ("errno = %d", errno);
|
||||
retval = noErr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
PUBLIC int
|
||||
ROMlib_launch_native_app (int n_filenames, char **filenames)
|
||||
{
|
||||
char **v;
|
||||
|
||||
v = alloca (sizeof *v * (n_filenames + 1));
|
||||
memcpy (v, filenames, n_filenames * sizeof *v);
|
||||
v[n_filenames] = 0;
|
||||
if (fork () == 0)
|
||||
execv (filenames[0], v);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !(defined (__GNUC__) && defined (__GNUC_MINOR__) && ((__GNUC__ == 2 && __GNUC_MINOR__ == 7 && defined (__i386__)) || defined (RELEASE_INTERNAL) || defined (powerpc) || defined (__alpha)))
|
||||
#warning THIS IS NOT A PRODUCTION BUILD
|
||||
#endif
|
||||
|
||||
/*
|
||||
* There is a very bad problem associated with the use of the db
|
||||
* shared libraries under Linux. Specifically, the calling convention
|
||||
* for functions which return structs that are larger than 32 bits
|
||||
* somehow got changed when some of the Linux distributions switched
|
||||
* from gcc to egcs. Both compilers put an extra pointer on the stack
|
||||
* before calling the routine that returns the large struct, but gcc
|
||||
* expects the caller to pop that extra pointer, where egcs expects
|
||||
* the called to pop it. This means that if you compile the caller
|
||||
* with gcc and call a shared library that was called with egcs, the
|
||||
* stack pointer will be off by 4 bytes after the function returns and
|
||||
* the stack is adjusted. That can be a catastrophe if further code
|
||||
* expects the stack to be correct after adjustments. On the other
|
||||
* hand, if we make the questionable call and then do nothing else,
|
||||
* the "leave" instruction will restore the stack pointer by using the
|
||||
* frame pointer and we'll never be bothered by the extra pop.
|
||||
*
|
||||
* So, as a workaround, we can wrap the routines, then check the
|
||||
* assembly code that the compiler produces to make sure that it's
|
||||
* tolerant of the error, then call the wrappers. That makes the
|
||||
* wrapper routines look like voodoo code that was written by a
|
||||
* superstitious programmer, but the code (or some other workaround)
|
||||
* is absolutely necessary because we want to have one Executor
|
||||
* executable that can run with both the shared libraries from Red Hat
|
||||
* 5.2 as well as the new ones in SuSE 6.0 (and the new ones that will
|
||||
* probably be in Red Hat 6.0).
|
||||
*
|
||||
* These wrappers absolutely have to be compiled with enough
|
||||
* optimization so that the stack isn't adjusted before the leave
|
||||
* instruction. If it is adjusted, then any interrupt that occurs
|
||||
* between the adjustment and the transfering of the data from the
|
||||
* temporary stack space to the address passed will cause corruption.
|
||||
*
|
||||
* If you do not understand the above, or if you disagree with it,
|
||||
* please contact Cliff before changing the following code. Axing the
|
||||
* code alone and then testing the result is not sufficient, unless
|
||||
* you're sure that your test involves *both* db shared libaries.
|
||||
*
|
||||
*/
|
||||
|
||||
PUBLIC void
|
||||
_dbm_fetch (datum *datump, DBM *db, datum datum)
|
||||
{
|
||||
*datump = dbm_fetch (db, datum);
|
||||
}
|
||||
|
||||
PUBLIC void
|
||||
_dbm_firstkey (datum *datump, DBM *db)
|
||||
{
|
||||
*datump = dbm_firstkey (db);
|
||||
}
|
||||
|
||||
PUBLIC void
|
||||
_dbm_nextkey (datum *datump, DBM *db)
|
||||
{
|
||||
*datump = dbm_nextkey (db);
|
||||
}
|
||||
|
||||
PUBLIC boolean_t host_has_spfcommon (void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
PUBLIC boolean_t
|
||||
host_spfcommon (host_spf_reply_block *replyp, const char *prompt,
|
||||
const char *incoming_filename, void *fp, void *filef, int numt,
|
||||
void *tl, getorput_t getorput, sf_flavor_t flavor,
|
||||
void *activeList, void *activateproc, void *yourdatap)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mmap_lowglobals (void)
|
||||
{
|
||||
if (!force_big_offset)
|
||||
{
|
||||
caddr_t addr;
|
||||
|
||||
addr = mmap ((caddr_t) PAGE_ZERO_START,
|
||||
PAGE_ZERO_SIZE,
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, -1, 0);
|
||||
gui_assert (addr == (caddr_t) PAGE_ZERO_START);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined (powerpc)
|
||||
PRIVATE caddr_t
|
||||
round_up_to_page_size (unsigned long addr)
|
||||
{
|
||||
caddr_t retval;
|
||||
size_t page_size;
|
||||
|
||||
page_size = getpagesize ();
|
||||
retval = (caddr_t) ((addr + page_size - 1) / page_size * page_size);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
static jmp_buf segv_return;
|
||||
|
||||
static void
|
||||
segv_handler (int signum_ignored __attribute__((unused)))
|
||||
{
|
||||
siglongjmp (segv_return, 1);
|
||||
}
|
||||
|
||||
static bool
|
||||
mmap_conflict (void *start, size_t length)
|
||||
{
|
||||
bool retval;
|
||||
long page_size;
|
||||
|
||||
retval = false;
|
||||
|
||||
page_size = sysconf(_SC_PAGESIZE);
|
||||
|
||||
if ((long) start % page_size != 0)
|
||||
{
|
||||
retval = true;
|
||||
warning_unexpected ("start = %p, page_size = %ld, "
|
||||
"start %% page_size = %ld",
|
||||
start, page_size, (long) start % page_size);
|
||||
}
|
||||
else if (length % page_size != 0)
|
||||
{
|
||||
retval = true;
|
||||
warning_unexpected ("length = %ld, page_size = %ld, "
|
||||
"length %% page_size = %ld",
|
||||
(long) length, page_size, (long) length % page_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
sig_t old_segv_handler;
|
||||
volatile int n_pages;
|
||||
volatile int n_failures;
|
||||
volatile char *volatile addr;
|
||||
char *stop;
|
||||
|
||||
n_pages = 0;
|
||||
n_failures = 0;
|
||||
stop = (char *) start + length;
|
||||
|
||||
old_segv_handler = signal (SIGSEGV, segv_handler);
|
||||
for (addr = start; addr < stop; addr += page_size)
|
||||
{
|
||||
++n_pages;
|
||||
if (sigsetjmp (segv_return, 1) != 0)
|
||||
++n_failures;
|
||||
else
|
||||
*addr;
|
||||
}
|
||||
signal (SIGSEGV, old_segv_handler);
|
||||
retval = n_failures < n_pages;
|
||||
if (retval)
|
||||
warning_unexpected ("%d pages were already mapped",
|
||||
n_pages - n_failures);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* This code used to try to get us memory that we could use directly (meaning
|
||||
* it either included page 0 or was adjacent to page 0 and we could use some
|
||||
* other trick to get page 0) without having to offset the emulated addresses.
|
||||
*
|
||||
* I doubt it works on many (any?) platforms anymore, and since speed of
|
||||
* emulation isn't an issue, we really shouldn't care.
|
||||
*/
|
||||
|
||||
void *
|
||||
mmap_permanent_memory (unsigned long amount_wanted)
|
||||
{
|
||||
#if defined(MACOSX)
|
||||
return NULL;
|
||||
#else
|
||||
caddr_t addr_got;
|
||||
caddr_t badness_start;
|
||||
|
||||
/* Only do this if our text segment is up nice and high out of the way. */
|
||||
if (((unsigned long) mmap_permanent_memory & 0xFF000000L) == 0)
|
||||
return NULL;
|
||||
|
||||
{
|
||||
extern void *_start;
|
||||
|
||||
badness_start = (caddr_t) ((unsigned long) &_start
|
||||
/ (1024 * 1024) * (1024 * 1024));
|
||||
}
|
||||
|
||||
#if !defined (powerpc)
|
||||
{
|
||||
caddr_t addr_wanted;
|
||||
|
||||
addr_wanted = round_up_to_page_size (PAGE_ZERO_START + PAGE_ZERO_SIZE);
|
||||
|
||||
if (addr_wanted + amount_wanted > badness_start)
|
||||
{
|
||||
warning_unexpected ("addr_wanted = %p, amount_wanted = 0x%lx, "
|
||||
"badness_start = %p", addr_wanted, amount_wanted,
|
||||
badness_start);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mmap_conflict (addr_wanted, amount_wanted))
|
||||
addr_got = NULL;
|
||||
else
|
||||
{
|
||||
addr_got = mmap (addr_wanted, amount_wanted, PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, -1, 0);
|
||||
if (addr_got == (caddr_t) -1)
|
||||
addr_got = NULL;
|
||||
else if (addr_got != addr_wanted)
|
||||
warning_unexpected ("addr_wanted = %p, addr_got = %p",
|
||||
addr_wanted, addr_got);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
|
||||
#warning THIS CODE IS PROBABLY WRONG
|
||||
|
||||
/*
|
||||
* I haven't tested a powerpc build in a while, but I just noticed that
|
||||
* we're trying to mmap from 0 and then we're returning addr_got. I think
|
||||
* that when we return 0, the caller believes that we weren't able to
|
||||
* mmap the low globals. As such, the code below PROBABLY DOESN'T DO
|
||||
* ANYTHING DIFFERENT THAN SIMPLY RETURNING NULL.
|
||||
*/
|
||||
|
||||
if (amount_wanted > badness_start)
|
||||
{
|
||||
warning_unexpected ("amount_wanted = 0x%x, badness_start = %p",
|
||||
amount_wanted, badness_start);
|
||||
addr_got = NULL;
|
||||
}
|
||||
else
|
||||
addr_got = mmap (0, amount_wanted, PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
|
||||
if (addr_got == (caddr_t) -1)
|
||||
addr_got = NULL;
|
||||
#endif
|
||||
|
||||
return addr_got;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* defined (LINUX) || defined (MACOSX) */
|
2
util/config.sub
vendored
2
util/config.sub
vendored
@ -602,7 +602,7 @@ case $os in
|
||||
| -hiux* | -386bsd* | -netbsd* | -freebsd* | -riscix* \
|
||||
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta | -udi \
|
||||
| -cygwin32 | -mingw32) \
|
||||
| -cygwin32 | -mingw32 | -macosx) \
|
||||
;;
|
||||
-sunos5*)
|
||||
os=`echo $os | sed -e 's|sunos5|solaris2|'`
|
||||
|
@ -215,6 +215,16 @@ case ${canonical_target} in
|
||||
target_file_format='a.out'
|
||||
fi
|
||||
;;
|
||||
i[456]86-unknown-macosx)
|
||||
target_os='macosx'
|
||||
target_syn68k='macosx'
|
||||
target_arch='i386'
|
||||
if [ x"${target_file_format}" = x"" ]; then
|
||||
# default linux file format; this may change
|
||||
target_file_format='mach-o'
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
*)
|
||||
echo "Fatal error: unknown target \`${canonical_target}'. Exiting."
|
||||
@ -251,6 +261,11 @@ case ${canonical_host} in
|
||||
host_os='linux'
|
||||
host_arch='i386'
|
||||
;;
|
||||
i[456]86-unknown-macosx)
|
||||
host_os='macosx'
|
||||
host_arch='i386'
|
||||
objc='yes'
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Fatal error: unknown host \`${canonical_host}'. Exiting."
|
||||
|
Loading…
x
Reference in New Issue
Block a user