From bceccf5f43b51d166951ea97cff086c8828b745b Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 10 Apr 2001 22:07:43 +0000 Subject: Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger --- Lib/plat-riscos/riscospath.py | 15 ++- Modules/main.c | 20 +-- Modules/timemodule.c | 12 +- Python/sysmodule.c | 4 + RISCOS/Makefile | 302 +++++++++++++++++++++--------------------- RISCOS/sleep.c | 41 ++++++ RISCOS/support/!Boot | 12 ++ RISCOS/support/!Run | 2 + RISCOS/support/!Sprites | Bin 0 -> 1532 bytes RISCOS/support/!Sprites22 | Bin 0 -> 2876 bytes RISCOS/support/AddToPath | Bin 0 -> 256 bytes 11 files changed, 243 insertions(+), 165 deletions(-) create mode 100644 RISCOS/sleep.c create mode 100644 RISCOS/support/!Boot create mode 100644 RISCOS/support/!Run create mode 100644 RISCOS/support/!Sprites create mode 100644 RISCOS/support/!Sprites22 create mode 100644 RISCOS/support/AddToPath diff --git a/Lib/plat-riscos/riscospath.py b/Lib/plat-riscos/riscospath.py index b83c632..a38b22c 100644 --- a/Lib/plat-riscos/riscospath.py +++ b/Lib/plat-riscos/riscospath.py @@ -203,21 +203,30 @@ def exists(p): """ Test whether a path exists. """ - return swi.swi('OS_File', '5s;i', p)!=0 + try: + return swi.swi('OS_File', '5s;i', p)!=0 + except swi.error: + return 0 def isdir(p): """ Is a path a directory? Includes image files. """ - return swi.swi('OS_File', '5s;i', p) in [2, 3] + try: + return swi.swi('OS_File', '5s;i', p) in [2, 3] + except swi.error: + return 0 def isfile(p): """ Test whether a path is a file, including image files. """ - return swi.swi('OS_File', '5s;i', p) in [1, 3] + try: + return swi.swi('OS_File', '5s;i', p) in [1, 3] + except swi.error: + return 0 def islink(p): diff --git a/Modules/main.c b/Modules/main.c index b4566c9..0183647 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -26,10 +26,18 @@ static char **orig_argv; static int orig_argc; -/* For my_readline when running under RISCOS */ -#ifdef RISCOS +/* command line options */ +#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; -#endif +#endif /*RISCOS*/ /* Short usage message (with %s for argv0) */ static char *usage_line = @@ -115,11 +123,7 @@ Py_Main(int argc, char **argv) PySys_ResetWarnOptions(); -#ifdef RISCOS - while ((c = getopt(argc, argv, "c:diOStuUvwxXhV")) != EOF) { -#else - while ((c = _PyOS_GetOpt(argc, argv, "c:diOStuUvxXhVW:")) != EOF) { -#endif + while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) { if (c == 'c') { /* -c is the last option; following arguments that look like options are left for the diff --git a/Modules/timemodule.c b/Modules/timemodule.c index cfce06b..0c5c257 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -756,9 +756,7 @@ floatsleep(double secs) #if defined(__WATCOMC__) && !defined(__QNX__) /* XXX Can't interrupt this sleep */ Py_BEGIN_ALLOW_THREADS -#ifndef RISCOS delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */ -#endif Py_END_ALLOW_THREADS #else /* !__WATCOMC__ || __QNX__ */ #ifdef MSDOS @@ -831,10 +829,20 @@ floatsleep(double secs) Py_END_ALLOW_THREADS } #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 */ Py_BEGIN_ALLOW_THREADS sleep((int)secs); Py_END_ALLOW_THREADS +#endif /* !RISCOS */ #endif /* !__BEOS__ */ #endif /* !PYOS_OS2 */ #endif /* !MS_WIN32 */ diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 9a0a43b..52fbbc8 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -808,7 +808,11 @@ PySys_SetArgv(int argc, char **argv) if (argc > 0 && argv0 != NULL) p = strrchr(argv0, SEP); if (p != NULL) { +#ifndef RISCOS n = p + 1 - argv0; +#else /* don't include trailing separator */ + n = p - argv0; +#endif /* RISCOS */ #if SEP == '/' /* Special case for Unix filename syntax */ if (n > 1) n--; /* Drop trailing separator */ diff --git a/RISCOS/Makefile b/RISCOS/Makefile index 38973f0..e970d13 100644 --- a/RISCOS/Makefile +++ b/RISCOS/Makefile @@ -12,9 +12,9 @@ EXPAT = $(LIBSROOT).expat.lib OBJSCAN = $(DLKLIB).objscan MAKEDLK = $(DLKLIB).makedlk -# change from time to time +# change from time to time (don't forget to change !Boot also) TARGET=Python21 -BUILD=10 +BUILD=12 # @@ -23,7 +23,7 @@ BUILD=10 OSLIBS = OSLib:Computer,OSLib:Core,OSLib:User DLKFLAG= -DDLK -DLKOBJS = $(DLKLIB).o.dlk_load o.linktab +DLKOBJS = $(DLKLIB).o.dlk_load @.o.linktab 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 LINK = link -LINKFLAGS = -aif -NOUNUSED #-d +LINKFLAGS = -aif #-NOUNUSED #-d LOADLIBS = $(CLIB).o.Stubs $(OSLIB).o.OSLib $(DLKOBJS) @@ -41,143 +41,135 @@ LOADLIBS = $(CLIB).o.Stubs $(OSLIB).o.OSLib $(DLKOBJS) # code for main Python binary -MODULES_STATIC = \ - @.^.Modules.o.python \ - @.^.Modules.o.main \ - Modules.o.config \ - @.^.Modules.o.getbuildinfo \ - Modules.o.getpath_riscos \ - Modules.o.riscosmodule \ - @.^.Modules.o._sre +MODULES_STATIC =\ + @.^.Modules.o.python\ + @.^.Modules.o.main\ + Modules.o.config\ + @.^.Modules.o.getbuildinfo\ + Modules.o.getpath_riscos\ + Modules.o.riscosmodule # dynamic Modules -MODULES_DYNAMIC = \ - @.^.Lib.array/pyd \ - @.^.Lib.audioop/pyd \ - @.^.Lib.binascii/pyd \ - @.^.Lib.cmath/pyd \ - @.^.Lib.cPickle/pyd \ - @.^.Lib.cStringIO/pyd \ - @.^.Lib.errno/pyd \ - @.^.Lib.imageop/pyd \ - @.^.Lib.math/pyd \ - @.^.Lib.md5/pyd \ - @.^.Lib.new/pyd \ - @.^.Lib.operator/pyd \ - @.^.Lib.parser/pyd \ - @.^.Lib.pcre/pyd \ - @.^.Lib.regex/pyd \ - @.^.Lib.rgbimg/pyd \ - @.^.Lib.rotor/pyd \ - @.^.Lib.sha/pyd \ - @.^.Lib.signal/pyd \ - @.^.Lib.struct/pyd \ - @.^.Lib.time/pyd \ - @.^.Lib._locale/pyd \ - @.^.Lib.zlib/pyd \ - @.^.Lib.select/pyd \ - @.^.Lib._socket/pyd \ - @.^.Lib._codecs/pyd \ - @.^.Lib._weakref/pyd \ - @.^.Lib._testcapi/pyd \ - @.^.Lib.unicodedata/pyd \ - @.^.Lib.xreadlines/pyd \ - @.^.Lib.pyexpat/pyd \ - @.^.Lib.plat-riscos.drawf/pyd \ - @.^.Lib.plat-riscos.swi/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 = \ - @.^.Python.o.traceback \ - @.^.Python.o.sysmodule \ - @.^.Python.o.structmember \ - @.^.Python.o.strdup \ - @.^.Python.o.sigcheck \ - @.^.Python.o.pythonrun \ - @.^.Python.o.pystate \ - @.^.Python.o.pyfpe \ - @.^.Python.o.mystrtoul \ - @.^.Python.o.modsupport \ - @.^.Python.o.marshal \ - @.^.Python.o.importdl \ - @.^.Python.o.import \ - @.^.Python.o.graminit \ - @.^.Python.o.getversion \ - @.^.Python.o.getplatform \ - @.^.Python.o.getopt \ - @.^.Python.o.getcopyright \ - @.^.Python.o.getcompiler \ - @.^.Python.o.getargs \ - @.^.Python.o.frozenmain \ - @.^.Python.o.frozen \ - @.^.Python.o.errors \ - @.^.Python.o.compile \ - @.^.Python.o.ceval \ - @.^.Python.o.bltinmodule \ - @.^.Python.o.exceptions \ - @.^.Python.o.hypot \ - @.^.Python.o.codecs \ - @.^.Python.o.symtable -# @.^.Python.o.atof @.^.Python.o.strerror - - -OBJECTS_RISCOS = \ - @.Python.o.dynload_riscos \ - @.Python.o.getcwd_riscos \ - @.Python.o.getmtime_riscos \ +MODULES_DYNAMIC =\ + @.^.Lib.array/pyd\ + @.^.Lib.audioop/pyd\ + @.^.Lib.binascii/pyd\ + @.^.Lib.cmath/pyd\ + @.^.Lib.cPickle/pyd\ + @.^.Lib.cStringIO/pyd\ + @.^.Lib.errno/pyd\ + @.^.Lib.imageop/pyd\ + @.^.Lib.math/pyd\ + @.^.Lib.md5/pyd\ + @.^.Lib.new/pyd\ + @.^.Lib.operator/pyd\ + @.^.Lib.parser/pyd\ + @.^.Lib.pcre/pyd\ + @.^.Lib.regex/pyd\ + @.^.Lib.rgbimg/pyd\ + @.^.Lib.rotor/pyd\ + @.^.Lib.sha/pyd\ + @.^.Lib.signal/pyd\ + @.^.Lib.struct/pyd\ + @.^.Lib.time/pyd\ + @.^.Lib._locale/pyd\ + @.^.Lib.zlib/pyd\ + @.^.Lib.select/pyd\ + @.^.Lib._socket/pyd\ + @.^.Lib._codecs/pyd\ + @.^.Lib._weakref/pyd\ + @.^.Lib._testcapi/pyd\ + @.^.Lib.unicodedata/pyd\ + @.^.Lib.xreadlines/pyd\ + @.^.Lib.pyexpat/pyd\ + @.^.Lib.plat-riscos.drawf/pyd\ + @.^.Lib.plat-riscos.swi/pyd\ + @.^.Lib._sre/pyd + + +OBJECTS_PYTHON =\ + @.^.Python.o.traceback\ + @.^.Python.o.sysmodule\ + @.^.Python.o.structmember\ + @.^.Python.o.strdup\ + @.^.Python.o.sigcheck\ + @.^.Python.o.pythonrun\ + @.^.Python.o.pystate\ + @.^.Python.o.pyfpe\ + @.^.Python.o.mystrtoul\ + @.^.Python.o.modsupport\ + @.^.Python.o.marshal\ + @.^.Python.o.importdl\ + @.^.Python.o.import\ + @.^.Python.o.graminit\ + @.^.Python.o.getversion\ + @.^.Python.o.getplatform\ + @.^.Python.o.getopt\ + @.^.Python.o.getcopyright\ + @.^.Python.o.getcompiler\ + @.^.Python.o.getargs\ + @.^.Python.o.frozenmain\ + @.^.Python.o.frozen\ + @.^.Python.o.errors\ + @.^.Python.o.compile\ + @.^.Python.o.ceval\ + @.^.Python.o.bltinmodule\ + @.^.Python.o.exceptions\ + @.^.Python.o.hypot\ + @.^.Python.o.codecs\ + @.^.Python.o.symtable\ + @.^.Python.o.future + + +OBJECTS_RISCOS = \ + @.Python.o.dynload_riscos\ + @.Python.o.getcwd_riscos\ + @.Python.o.getmtime_riscos\ @.o.unixstuff -OBJECTS_OBJECTS = \ - @.^.Objects.o.typeobject \ - @.^.Objects.o.tupleobject \ - @.^.Objects.o.stringobject \ - @.^.Objects.o.sliceobject \ - @.^.Objects.o.rangeobject \ - @.^.Objects.o.object \ - @.^.Objects.o.moduleobject \ - @.^.Objects.o.methodobject \ - @.^.Objects.o.longobject \ - @.^.Objects.o.listobject \ - @.^.Objects.o.intobject \ - @.^.Objects.o.funcobject \ - @.^.Objects.o.frameobject \ - @.^.Objects.o.floatobject \ - @.^.Objects.o.fileobject \ - @.^.Objects.o.dictobject \ - @.^.Objects.o.complexobject \ - @.^.Objects.o.cobject \ - @.^.Objects.o.classobject \ - @.^.Objects.o.cellobject \ - @.^.Objects.o.bufferobject \ - @.^.Objects.o.abstract \ - @.^.Objects.o.unicodectype \ +OBJECTS_OBJECTS =\ + @.^.Objects.o.typeobject\ + @.^.Objects.o.tupleobject\ + @.^.Objects.o.stringobject\ + @.^.Objects.o.sliceobject\ + @.^.Objects.o.rangeobject\ + @.^.Objects.o.object\ + @.^.Objects.o.moduleobject\ + @.^.Objects.o.methodobject\ + @.^.Objects.o.longobject\ + @.^.Objects.o.listobject\ + @.^.Objects.o.intobject\ + @.^.Objects.o.funcobject\ + @.^.Objects.o.frameobject\ + @.^.Objects.o.floatobject\ + @.^.Objects.o.fileobject\ + @.^.Objects.o.dictobject\ + @.^.Objects.o.complexobject\ + @.^.Objects.o.cobject\ + @.^.Objects.o.classobject\ + @.^.Objects.o.cellobject\ + @.^.Objects.o.bufferobject\ + @.^.Objects.o.abstract\ + @.^.Objects.o.unicodectype\ @.^.Objects.o.unicodeobject -OBJECTS_PARSER = \ - @.^.Parser.o.tokenizer \ - @.^.Parser.o.printgrammar \ - @.^.Parser.o.parsetok \ - @.^.Parser.o.parser \ - @.^.Parser.o.node \ - @.^.Parser.o.myreadline \ - @.^.Parser.o.metagrammar \ - @.^.Parser.o.listnode \ - @.^.Parser.o.intrcheck \ - @.^.Parser.o.grammar1 \ - @.^.Parser.o.grammar \ - @.^.Parser.o.firstsets \ - @.^.Parser.o.bitset \ +OBJECTS_PARSER =\ + @.^.Parser.o.tokenizer\ + @.^.Parser.o.printgrammar\ + @.^.Parser.o.parsetok\ + @.^.Parser.o.parser\ + @.^.Parser.o.node\ + @.^.Parser.o.myreadline\ + @.^.Parser.o.metagrammar\ + @.^.Parser.o.listnode\ + @.^.Parser.o.intrcheck\ + @.^.Parser.o.grammar1\ + @.^.Parser.o.grammar\ + @.^.Parser.o.firstsets\ + @.^.Parser.o.bitset\ @.^.Parser.o.acceler SUPPORT_FILES = @.^.!Boot @.^.!Run @.^.!Sprites @.^.!Sprites22 @.^.AddToPath @@ -196,7 +188,8 @@ all: @.^.$(TARGET) $(MODULES_DYNAMIC) $(SUPPORT_FILES) ######################################################################### -# Support files +# RISC OS support files +# @.^.!Boot: support.!Boot copy support.!Boot @.^.!Boot ~C~VF 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 $(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 $(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 -##@.^.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 @@ -353,6 +339,11 @@ all: @.^.$(TARGET) $(MODULES_DYNAMIC) $(SUPPORT_FILES) $(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 $(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 @@ -362,35 +353,42 @@ all: @.^.$(TARGET) $(MODULES_DYNAMIC) $(SUPPORT_FILES) ########################################################################## - +# dynamic linking symbol table +# o.linktab: s.linktab ObjAsm s.linktab o.linktab s.linktab: $(OBJECTS) $(OBJSCAN) -s s.linktab -o $(OBJECTS) $(clib).o.stubs +########################################################################## +# special targets +# +libclean: + create @.^.Lib.dummy/pyc + create @.^.Lib.dummy/pyo + create @.^.Lib.plat-riscos.dummy/pyc + create @.^.Lib.plat-riscos.dummy/pyo + create @.^.Lib.test.dummy/pyc + create @.^.Lib.test.dummy/pyo + wipe @.^.Lib.*/pyc ~C~V + wipe @.^.Lib.*/pyo ~C~V + wipe @.^.Lib.plat-riscos.*/pyc ~C~V + wipe @.^.Lib.plat-riscos.*/pyo ~C~V + wipe @.^.Lib.test.*/pyc ~C~V + wipe @.^.Lib.test.*/pyo ~C~V -clean: +clean: libclean create @.^.Objects.o.dummy create @.^.Parser.o.dummy create @.^.Modules.o.dummy create o.dummy create @.^.Python.o.dummy - create @.^.Lib.dummy/pyc - create @.^.Lib.dummy/pyo - create @.^.Lib.plat-riscos.dummy/pyc - create @.^.Lib.plat-riscos.dummy/pyo - create @.^.Lib.test.dummy/pyc wipe @.^.Modules.o.* ~C ~V 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.*/pyo ~C~V - wipe @.^.Lib.plat-riscos.*/pyc ~C~V - wipe @.^.Lib.plat-riscos.*/pyo ~C~V - wipe @.^.Lib.test.*/pyc ~C~V rebuild: clean create @.^.Lib.dummy/pyd diff --git a/RISCOS/sleep.c b/RISCOS/sleep.c new file mode 100644 index 0000000..0aeba55 --- /dev/null +++ b/RISCOS/sleep.c @@ -0,0 +1,41 @@ +#include "osmodule.h" +#include +#include "kernel.h" +#include +#include +#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=starttime ) { + xupcall_sleep (pollword, &claimed); + if (PyErr_CheckSignals()) { + ret = 1; + break; + } + time = os_read_monotonic_time(); + } + + /* deallocate pollword */ + osmodule_free(pollword); + return ret; +} diff --git a/RISCOS/support/!Boot b/RISCOS/support/!Boot new file mode 100644 index 0000000..668d6b1 --- /dev/null +++ b/RISCOS/support/!Boot @@ -0,0 +1,12 @@ +set Python$Dir +set PythonApp$Path . + +IconSprites .!Sprites + +.AddToPath Python$Path PythonApp:Lib +.AddToPath Python$Path PythonApp:Lib.plat-riscos +.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 .python21 %*0 \ No newline at end of file diff --git a/RISCOS/support/!Run b/RISCOS/support/!Run new file mode 100644 index 0000000..6919579 --- /dev/null +++ b/RISCOS/support/!Run @@ -0,0 +1,2 @@ +.!Boot +TaskWindow "python" -name "Python" -quit -display \ No newline at end of file diff --git a/RISCOS/support/!Sprites b/RISCOS/support/!Sprites new file mode 100644 index 0000000..cdf4a65 Binary files /dev/null and b/RISCOS/support/!Sprites differ diff --git a/RISCOS/support/!Sprites22 b/RISCOS/support/!Sprites22 new file mode 100644 index 0000000..5ca88f5 Binary files /dev/null and b/RISCOS/support/!Sprites22 differ diff --git a/RISCOS/support/AddToPath b/RISCOS/support/AddToPath new file mode 100644 index 0000000..a16e3ad Binary files /dev/null and b/RISCOS/support/AddToPath differ -- cgit v0.12