mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
This commit is contained in:
parent
13aa70679e
commit
bceccf5f43
11 changed files with 240 additions and 162 deletions
|
@ -203,21 +203,30 @@ def exists(p):
|
||||||
"""
|
"""
|
||||||
Test whether a path exists.
|
Test whether a path exists.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
return swi.swi('OS_File', '5s;i', p)!=0
|
return swi.swi('OS_File', '5s;i', p)!=0
|
||||||
|
except swi.error:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def isdir(p):
|
def isdir(p):
|
||||||
"""
|
"""
|
||||||
Is a path a directory? Includes image files.
|
Is a path a directory? Includes image files.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
return swi.swi('OS_File', '5s;i', p) in [2, 3]
|
return swi.swi('OS_File', '5s;i', p) in [2, 3]
|
||||||
|
except swi.error:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def isfile(p):
|
def isfile(p):
|
||||||
"""
|
"""
|
||||||
Test whether a path is a file, including image files.
|
Test whether a path is a file, including image files.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
return swi.swi('OS_File', '5s;i', p) in [1, 3]
|
return swi.swi('OS_File', '5s;i', p) in [1, 3]
|
||||||
|
except swi.error:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def islink(p):
|
def islink(p):
|
||||||
|
|
|
@ -26,10 +26,18 @@
|
||||||
static char **orig_argv;
|
static char **orig_argv;
|
||||||
static int orig_argc;
|
static int orig_argc;
|
||||||
|
|
||||||
/* For my_readline when running under RISCOS */
|
/* command line options */
|
||||||
#ifdef RISCOS
|
#define BASE_OPTS "c:diOStuUvxXhVW:"
|
||||||
|
|
||||||
|
#ifndef RISCOS
|
||||||
|
#define PROGRAM_OPTS BASE_OPTS
|
||||||
|
#else /*RISCOS*/
|
||||||
|
/* extra option saying that we are running under a special task window
|
||||||
|
frontend; especially my_readline will behave different */
|
||||||
|
#define PROGRAM_OPTS BASE_OPTS "w"
|
||||||
|
/* corresponding flag */
|
||||||
extern int Py_RISCOSWimpFlag;
|
extern int Py_RISCOSWimpFlag;
|
||||||
#endif
|
#endif /*RISCOS*/
|
||||||
|
|
||||||
/* Short usage message (with %s for argv0) */
|
/* Short usage message (with %s for argv0) */
|
||||||
static char *usage_line =
|
static char *usage_line =
|
||||||
|
@ -115,11 +123,7 @@ Py_Main(int argc, char **argv)
|
||||||
|
|
||||||
PySys_ResetWarnOptions();
|
PySys_ResetWarnOptions();
|
||||||
|
|
||||||
#ifdef RISCOS
|
while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
|
||||||
while ((c = getopt(argc, argv, "c:diOStuUvwxXhV")) != EOF) {
|
|
||||||
#else
|
|
||||||
while ((c = _PyOS_GetOpt(argc, argv, "c:diOStuUvxXhVW:")) != EOF) {
|
|
||||||
#endif
|
|
||||||
if (c == 'c') {
|
if (c == 'c') {
|
||||||
/* -c is the last option; following arguments
|
/* -c is the last option; following arguments
|
||||||
that look like options are left for the
|
that look like options are left for the
|
||||||
|
|
|
@ -756,9 +756,7 @@ floatsleep(double secs)
|
||||||
#if defined(__WATCOMC__) && !defined(__QNX__)
|
#if defined(__WATCOMC__) && !defined(__QNX__)
|
||||||
/* XXX Can't interrupt this sleep */
|
/* XXX Can't interrupt this sleep */
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
#ifndef RISCOS
|
|
||||||
delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */
|
delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */
|
||||||
#endif
|
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
#else /* !__WATCOMC__ || __QNX__ */
|
#else /* !__WATCOMC__ || __QNX__ */
|
||||||
#ifdef MSDOS
|
#ifdef MSDOS
|
||||||
|
@ -831,10 +829,20 @@ floatsleep(double secs)
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
}
|
}
|
||||||
#else /* !__BEOS__ */
|
#else /* !__BEOS__ */
|
||||||
|
#ifdef RISCOS
|
||||||
|
if (secs <= 0.0)
|
||||||
|
return 0;
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
/* This sleep *CAN BE* interrupted. */
|
||||||
|
if ( sleep(secs) )
|
||||||
|
return -1;
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
#else /* !RISCOS */
|
||||||
/* XXX Can't interrupt this sleep */
|
/* XXX Can't interrupt this sleep */
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
sleep((int)secs);
|
sleep((int)secs);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
#endif /* !RISCOS */
|
||||||
#endif /* !__BEOS__ */
|
#endif /* !__BEOS__ */
|
||||||
#endif /* !PYOS_OS2 */
|
#endif /* !PYOS_OS2 */
|
||||||
#endif /* !MS_WIN32 */
|
#endif /* !MS_WIN32 */
|
||||||
|
|
|
@ -808,7 +808,11 @@ PySys_SetArgv(int argc, char **argv)
|
||||||
if (argc > 0 && argv0 != NULL)
|
if (argc > 0 && argv0 != NULL)
|
||||||
p = strrchr(argv0, SEP);
|
p = strrchr(argv0, SEP);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
|
#ifndef RISCOS
|
||||||
n = p + 1 - argv0;
|
n = p + 1 - argv0;
|
||||||
|
#else /* don't include trailing separator */
|
||||||
|
n = p - argv0;
|
||||||
|
#endif /* RISCOS */
|
||||||
#if SEP == '/' /* Special case for Unix filename syntax */
|
#if SEP == '/' /* Special case for Unix filename syntax */
|
||||||
if (n > 1)
|
if (n > 1)
|
||||||
n--; /* Drop trailing separator */
|
n--; /* Drop trailing separator */
|
||||||
|
|
|
@ -12,9 +12,9 @@ EXPAT = $(LIBSROOT).expat.lib
|
||||||
OBJSCAN = $(DLKLIB).objscan
|
OBJSCAN = $(DLKLIB).objscan
|
||||||
MAKEDLK = $(DLKLIB).makedlk
|
MAKEDLK = $(DLKLIB).makedlk
|
||||||
|
|
||||||
# change from time to time
|
# change from time to time (don't forget to change !Boot also)
|
||||||
TARGET=Python21
|
TARGET=Python21
|
||||||
BUILD=10
|
BUILD=12
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -23,7 +23,7 @@ BUILD=10
|
||||||
OSLIBS = OSLib:Computer,OSLib:Core,OSLib:User
|
OSLIBS = OSLib:Computer,OSLib:Core,OSLib:User
|
||||||
|
|
||||||
DLKFLAG= -DDLK
|
DLKFLAG= -DDLK
|
||||||
DLKOBJS = $(DLKLIB).o.dlk_load o.linktab
|
DLKOBJS = $(DLKLIB).o.dlk_load @.o.linktab
|
||||||
|
|
||||||
HEADERS = @,@.^.Include,@.^.Modules,@.^.Objects,@.^.Python,$(CLIB),$(OSLIBS),$(DLKLIB)
|
HEADERS = @,@.^.Include,@.^.Modules,@.^.Objects,@.^.Python,$(CLIB),$(OSLIBS),$(DLKLIB)
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ CC = cc -c -j$(HEADERS) $(DLKFLAG) -DRISCOS -DHAVE_CONFIG_H -wad -throwback
|
||||||
CCEXPAT = cc -c -j$(HEADERS),$(EXPAT) $(DLKFLAG) -DHAVE_EXPAT_H -DRISCOS -DHAVE_CONFIG_H -wad -throwback
|
CCEXPAT = cc -c -j$(HEADERS),$(EXPAT) $(DLKFLAG) -DHAVE_EXPAT_H -DRISCOS -DHAVE_CONFIG_H -wad -throwback
|
||||||
|
|
||||||
LINK = link
|
LINK = link
|
||||||
LINKFLAGS = -aif -NOUNUSED #-d
|
LINKFLAGS = -aif #-NOUNUSED #-d
|
||||||
LOADLIBS = $(CLIB).o.Stubs $(OSLIB).o.OSLib $(DLKOBJS)
|
LOADLIBS = $(CLIB).o.Stubs $(OSLIB).o.OSLib $(DLKOBJS)
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,8 +47,7 @@ MODULES_STATIC = \
|
||||||
Modules.o.config\
|
Modules.o.config\
|
||||||
@.^.Modules.o.getbuildinfo\
|
@.^.Modules.o.getbuildinfo\
|
||||||
Modules.o.getpath_riscos\
|
Modules.o.getpath_riscos\
|
||||||
Modules.o.riscosmodule \
|
Modules.o.riscosmodule
|
||||||
@.^.Modules.o._sre
|
|
||||||
|
|
||||||
|
|
||||||
# dynamic Modules
|
# dynamic Modules
|
||||||
|
@ -85,15 +84,8 @@ MODULES_DYNAMIC = \
|
||||||
@.^.Lib.xreadlines/pyd\
|
@.^.Lib.xreadlines/pyd\
|
||||||
@.^.Lib.pyexpat/pyd\
|
@.^.Lib.pyexpat/pyd\
|
||||||
@.^.Lib.plat-riscos.drawf/pyd\
|
@.^.Lib.plat-riscos.drawf/pyd\
|
||||||
@.^.Lib.plat-riscos.swi/pyd
|
@.^.Lib.plat-riscos.swi/pyd\
|
||||||
|
@.^.Lib._sre/pyd
|
||||||
# @.^.Lib.soundex/pyd \
|
|
||||||
# leave strop out? It's no longer in use for string operations
|
|
||||||
# @.^.Lib.mmap/pyd would it make sense? I read about a mmap
|
|
||||||
# implementation for RISC OS recently in usenet news.
|
|
||||||
|
|
||||||
#@.^.Lib.strop/pyd \
|
|
||||||
#@.^.Lib._sre/pyd \
|
|
||||||
|
|
||||||
|
|
||||||
OBJECTS_PYTHON =\
|
OBJECTS_PYTHON =\
|
||||||
|
@ -126,8 +118,8 @@ OBJECTS_PYTHON = \
|
||||||
@.^.Python.o.exceptions\
|
@.^.Python.o.exceptions\
|
||||||
@.^.Python.o.hypot\
|
@.^.Python.o.hypot\
|
||||||
@.^.Python.o.codecs\
|
@.^.Python.o.codecs\
|
||||||
@.^.Python.o.symtable
|
@.^.Python.o.symtable\
|
||||||
# @.^.Python.o.atof @.^.Python.o.strerror
|
@.^.Python.o.future
|
||||||
|
|
||||||
|
|
||||||
OBJECTS_RISCOS = \
|
OBJECTS_RISCOS = \
|
||||||
|
@ -196,7 +188,8 @@ all: @.^.$(TARGET) $(MODULES_DYNAMIC) $(SUPPORT_FILES)
|
||||||
|
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
# Support files
|
# RISC OS support files
|
||||||
|
#
|
||||||
@.^.!Boot: support.!Boot
|
@.^.!Boot: support.!Boot
|
||||||
copy support.!Boot @.^.!Boot ~C~VF
|
copy support.!Boot @.^.!Boot ~C~VF
|
||||||
settype @.^.!Boot feb
|
settype @.^.!Boot feb
|
||||||
|
@ -297,9 +290,6 @@ all: @.^.$(TARGET) $(MODULES_DYNAMIC) $(SUPPORT_FILES)
|
||||||
$(LINK) -aof -o Modules.o.swilink Modules.o.swimodule $(OSLIB).o.OSLIB
|
$(LINK) -aof -o Modules.o.swilink Modules.o.swimodule $(OSLIB).o.OSLIB
|
||||||
$(MAKEDLK) -d @.^.Lib.plat-riscos.swi/pyd -s s.linktab -o Modules.o.swilink -e initswi
|
$(MAKEDLK) -d @.^.Lib.plat-riscos.swi/pyd -s s.linktab -o Modules.o.swilink -e initswi
|
||||||
|
|
||||||
@.^.Lib.time/pyd: @.^.Modules.o.timemodule s.linktab
|
|
||||||
$(MAKEDLK) -d @.^.Lib.time/pyd -s s.linktab -o @.^.Modules.o.timemodule -e inittime
|
|
||||||
|
|
||||||
@.^.Lib._locale/pyd: @.^.Modules.o._localemodule s.linktab
|
@.^.Lib._locale/pyd: @.^.Modules.o._localemodule s.linktab
|
||||||
$(MAKEDLK) -d @.^.Lib._locale/pyd -s s.linktab -o @.^.Modules.o._localemodule -e init_locale
|
$(MAKEDLK) -d @.^.Lib._locale/pyd -s s.linktab -o @.^.Modules.o._localemodule -e init_locale
|
||||||
|
|
||||||
|
@ -322,10 +312,6 @@ all: @.^.$(TARGET) $(MODULES_DYNAMIC) $(SUPPORT_FILES)
|
||||||
$(MAKEDLK) -d @.^.Lib.xreadlines/pyd -s s.linktab -o @.^.Modules.o.xreadlinesmodule -e initxreadlines
|
$(MAKEDLK) -d @.^.Lib.xreadlines/pyd -s s.linktab -o @.^.Modules.o.xreadlinesmodule -e initxreadlines
|
||||||
|
|
||||||
|
|
||||||
##@.^.Lib.mmap/pyd: @.^.Modules.o.mmapmodule s.linktab
|
|
||||||
## $(MAKEDLK) -d @.^.Lib.mmap/pyd -s s.linktab -o @.^.Modules.o.mmapmodule -e initmmap
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
# Dynamic Modules with other dependencies
|
# Dynamic Modules with other dependencies
|
||||||
|
@ -353,6 +339,11 @@ all: @.^.$(TARGET) $(MODULES_DYNAMIC) $(SUPPORT_FILES)
|
||||||
$(CC) -I$(ZLIB) -o $@ @.^.Modules.c.zlibmodule
|
$(CC) -I$(ZLIB) -o $@ @.^.Modules.c.zlibmodule
|
||||||
|
|
||||||
|
|
||||||
|
@.^.Lib.time/pyd: @.^.Modules.o.timemodule s.linktab @.o.sleep
|
||||||
|
$(LINK) -aof -o @.^.Modules.o.timelink @.^.Modules.o.timemodule @.o.sleep $(OSLIB).o.OSLib
|
||||||
|
$(MAKEDLK) -d @.^.Lib.time/pyd -s s.linktab -o @.^.Modules.o.timelink -e inittime
|
||||||
|
|
||||||
|
|
||||||
@.^.Lib.pyexpat/pyd: @.^.Modules.o.pyexpat s.linktab
|
@.^.Lib.pyexpat/pyd: @.^.Modules.o.pyexpat s.linktab
|
||||||
$(LINK) -aof -o @.^.Modules.o.pyexpatlink @.^.Modules.o.pyexpat $(EXPAT).expat_lib
|
$(LINK) -aof -o @.^.Modules.o.pyexpatlink @.^.Modules.o.pyexpat $(EXPAT).expat_lib
|
||||||
$(MAKEDLK) -d @.^.Lib.pyexpat/pyd -s s.linktab -o @.^.Modules.o.pyexpatlink -e initpyexpat
|
$(MAKEDLK) -d @.^.Lib.pyexpat/pyd -s s.linktab -o @.^.Modules.o.pyexpatlink -e initpyexpat
|
||||||
|
@ -362,35 +353,42 @@ all: @.^.$(TARGET) $(MODULES_DYNAMIC) $(SUPPORT_FILES)
|
||||||
|
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
# dynamic linking symbol table
|
||||||
|
#
|
||||||
o.linktab: s.linktab
|
o.linktab: s.linktab
|
||||||
ObjAsm s.linktab o.linktab
|
ObjAsm s.linktab o.linktab
|
||||||
|
|
||||||
s.linktab: $(OBJECTS)
|
s.linktab: $(OBJECTS)
|
||||||
$(OBJSCAN) -s s.linktab -o $(OBJECTS) $(clib).o.stubs
|
$(OBJSCAN) -s s.linktab -o $(OBJECTS) $(clib).o.stubs
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
clean:
|
# special targets
|
||||||
create @.^.Objects.o.dummy
|
#
|
||||||
create @.^.Parser.o.dummy
|
libclean:
|
||||||
create @.^.Modules.o.dummy
|
|
||||||
create o.dummy
|
|
||||||
create @.^.Python.o.dummy
|
|
||||||
create @.^.Lib.dummy/pyc
|
create @.^.Lib.dummy/pyc
|
||||||
create @.^.Lib.dummy/pyo
|
create @.^.Lib.dummy/pyo
|
||||||
create @.^.Lib.plat-riscos.dummy/pyc
|
create @.^.Lib.plat-riscos.dummy/pyc
|
||||||
create @.^.Lib.plat-riscos.dummy/pyo
|
create @.^.Lib.plat-riscos.dummy/pyo
|
||||||
create @.^.Lib.test.dummy/pyc
|
create @.^.Lib.test.dummy/pyc
|
||||||
wipe @.^.Modules.o.* ~C ~V
|
create @.^.Lib.test.dummy/pyo
|
||||||
wipe @.^.Objects.o.* ~C ~V
|
|
||||||
wipe @.^.Parser.o.* ~C ~V
|
|
||||||
wipe @.^.Python.o.* ~C ~V
|
|
||||||
wipe o.* ~C ~V
|
|
||||||
wipe @.^.Lib.*/pyc ~C~V
|
wipe @.^.Lib.*/pyc ~C~V
|
||||||
wipe @.^.Lib.*/pyo ~C~V
|
wipe @.^.Lib.*/pyo ~C~V
|
||||||
wipe @.^.Lib.plat-riscos.*/pyc ~C~V
|
wipe @.^.Lib.plat-riscos.*/pyc ~C~V
|
||||||
wipe @.^.Lib.plat-riscos.*/pyo ~C~V
|
wipe @.^.Lib.plat-riscos.*/pyo ~C~V
|
||||||
wipe @.^.Lib.test.*/pyc ~C~V
|
wipe @.^.Lib.test.*/pyc ~C~V
|
||||||
|
wipe @.^.Lib.test.*/pyo ~C~V
|
||||||
|
|
||||||
|
clean: libclean
|
||||||
|
create @.^.Objects.o.dummy
|
||||||
|
create @.^.Parser.o.dummy
|
||||||
|
create @.^.Modules.o.dummy
|
||||||
|
create o.dummy
|
||||||
|
create @.^.Python.o.dummy
|
||||||
|
wipe @.^.Modules.o.* ~C ~V
|
||||||
|
wipe @.^.Objects.o.* ~C ~V
|
||||||
|
wipe @.^.Parser.o.* ~C ~V
|
||||||
|
wipe @.^.Python.o.* ~C ~V
|
||||||
|
wipe o.* ~C ~V
|
||||||
|
|
||||||
rebuild: clean
|
rebuild: clean
|
||||||
create @.^.Lib.dummy/pyd
|
create @.^.Lib.dummy/pyd
|
||||||
|
|
41
RISCOS/sleep.c
Normal file
41
RISCOS/sleep.c
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#include "osmodule.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "kernel.h"
|
||||||
|
#include <limits.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include "taskwindow.h"
|
||||||
|
#include "Python.h"
|
||||||
|
|
||||||
|
|
||||||
|
int sleep(double delay)
|
||||||
|
{
|
||||||
|
os_t starttime, endtime, time; /* monotonic times (centiseconds) */
|
||||||
|
int *pollword, ret;
|
||||||
|
bool claimed;
|
||||||
|
|
||||||
|
/* calculate end time */
|
||||||
|
starttime = os_read_monotonic_time();
|
||||||
|
if (starttime + 100.0*delay >INT_MAX)
|
||||||
|
endtime = INT_MAX;
|
||||||
|
else
|
||||||
|
endtime = (os_t)(starttime + 100.0*delay);
|
||||||
|
|
||||||
|
/* allocate (in RMA) and set pollword for xupcall_sleep */
|
||||||
|
pollword = osmodule_alloc(4);
|
||||||
|
*pollword = 1;
|
||||||
|
|
||||||
|
time = starttime;
|
||||||
|
ret = 0;
|
||||||
|
while ( time<endtime && time>=starttime ) {
|
||||||
|
xupcall_sleep (pollword, &claimed);
|
||||||
|
if (PyErr_CheckSignals()) {
|
||||||
|
ret = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
time = os_read_monotonic_time();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* deallocate pollword */
|
||||||
|
osmodule_free(pollword);
|
||||||
|
return ret;
|
||||||
|
}
|
12
RISCOS/support/!Boot
Normal file
12
RISCOS/support/!Boot
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
set Python$Dir <Obey$Dir>
|
||||||
|
set PythonApp$Path <Obey$Dir>.
|
||||||
|
|
||||||
|
IconSprites <Obey$Dir>.!Sprites
|
||||||
|
|
||||||
|
<Obey$Dir>.AddToPath Python$Path PythonApp:Lib
|
||||||
|
<Obey$Dir>.AddToPath Python$Path PythonApp:Lib.plat-riscos
|
||||||
|
<Obey$Dir>.AddToPath Python$Path PythonApp:Lib.site-packages
|
||||||
|
set Alias$@RunType_ae5 TaskWindow |"python %%*0|" -name |"Python|" -quit
|
||||||
|
| -display
|
||||||
|
set File$Type_ae5 Python
|
||||||
|
set Alias$Python Run <Python$Dir>.python21 %*0
|
2
RISCOS/support/!Run
Normal file
2
RISCOS/support/!Run
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<Obey$Dir>.!Boot
|
||||||
|
TaskWindow "python" -name "Python" -quit -display
|
BIN
RISCOS/support/!Sprites
Normal file
BIN
RISCOS/support/!Sprites
Normal file
Binary file not shown.
BIN
RISCOS/support/!Sprites22
Normal file
BIN
RISCOS/support/!Sprites22
Normal file
Binary file not shown.
BIN
RISCOS/support/AddToPath
Normal file
BIN
RISCOS/support/AddToPath
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue