diff options
author | Guido van Rossum <guido@python.org> | 2001-10-24 20:13:15 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-10-24 20:13:15 (GMT) |
commit | e877f8ba3306be0c76476c1f841d6f5388b675b7 (patch) | |
tree | 58535b7aab583873d072c7f76849ccbc7141f852 /RISCOS | |
parent | 622cc03f0b5ba8e8e51aaa73c137350fe81564a8 (diff) | |
download | cpython-e877f8ba3306be0c76476c1f841d6f5388b675b7.zip cpython-e877f8ba3306be0c76476c1f841d6f5388b675b7.tar.gz cpython-e877f8ba3306be0c76476c1f841d6f5388b675b7.tar.bz2 |
SF patch #474590 -- RISC OS support
Diffstat (limited to 'RISCOS')
-rw-r--r-- | RISCOS/Modules/config.c | 15 | ||||
-rw-r--r-- | RISCOS/Modules/drawfmodule.c | 6 | ||||
-rw-r--r-- | RISCOS/Modules/getpath_riscos.c | 6 | ||||
-rw-r--r-- | RISCOS/Modules/riscosmodule.c | 84 | ||||
-rw-r--r-- | RISCOS/Modules/swimodule.c | 5 | ||||
-rw-r--r-- | RISCOS/Python/dynload_riscos.c | 5 | ||||
-rw-r--r-- | RISCOS/Python/getmtime_riscos.c | 2 | ||||
-rw-r--r-- | RISCOS/README | 10 | ||||
-rw-r--r-- | RISCOS/sleep.c | 4 | ||||
-rw-r--r-- | RISCOS/support/!Boot | 2 | ||||
-rw-r--r-- | RISCOS/unixstuff.c | 66 | ||||
-rw-r--r-- | RISCOS/unixstuff.h | 7 |
12 files changed, 140 insertions, 72 deletions
diff --git a/RISCOS/Modules/config.c b/RISCOS/Modules/config.c index 75e056f..03f6e3c 100644 --- a/RISCOS/Modules/config.c +++ b/RISCOS/Modules/config.c @@ -41,10 +41,11 @@ PERFORMANCE OF THIS SOFTWARE. /* -- ADDMODULE MARKER 1 -- */ -extern void PyMarshal_Init(); -extern void initimp(); -extern void initriscos(); -extern void initswi(); +extern void PyMarshal_Init(void); +extern void initimp(void); +extern void initgc(void); +extern void initriscos(void); +extern void initswi(void); struct _inittab _PyImport_Inittab[] = { @@ -62,6 +63,12 @@ struct _inittab _PyImport_Inittab[] = { {"__main__", NULL}, {"__builtin__", NULL}, {"sys", NULL}, + {"exceptions", NULL}, + +#ifdef WITH_CYCLE_GC + /* This lives in gcmodule.c */ + {"gc", initgc}, +#endif /* Sentinel */ {0, 0} diff --git a/RISCOS/Modules/drawfmodule.c b/RISCOS/Modules/drawfmodule.c index 1ac4736..db74d36 100644 --- a/RISCOS/Modules/drawfmodule.c +++ b/RISCOS/Modules/drawfmodule.c @@ -1,8 +1,8 @@ /* drawf DrawFile functions */ -#include "h.os" -#include "h.osfile" -#include "h.drawfile" +#include "oslib/os.h" +#include "oslib/osfile.h" +#include "oslib/drawfile.h" #include "Python.h" #include <limits.h> diff --git a/RISCOS/Modules/getpath_riscos.c b/RISCOS/Modules/getpath_riscos.c index 8b36952..8705e2c 100644 --- a/RISCOS/Modules/getpath_riscos.c +++ b/RISCOS/Modules/getpath_riscos.c @@ -5,7 +5,7 @@ static char *prefix,*exec_prefix,*progpath,*module_search_path=0; static void calculate_path() -{ char *pypath=Py_GETENV("Python$Path"); +{ char *pypath=getenv("Python$Path"); if(pypath) { module_search_path=malloc(strlen(pypath)+1); if (module_search_path) sprintf(module_search_path,"%s",pypath); @@ -16,9 +16,9 @@ calculate_path() } } if(!module_search_path) module_search_path = "<Python$Dir>.Lib"; - prefix=""; + prefix="<Python$Dir>"; exec_prefix=prefix; - progpath="<Python$Dir>"; + progpath=Py_GetProgramName(); } /* External interface */ diff --git a/RISCOS/Modules/riscosmodule.c b/RISCOS/Modules/riscosmodule.c index d5cdd94..9d3510c 100644 --- a/RISCOS/Modules/riscosmodule.c +++ b/RISCOS/Modules/riscosmodule.c @@ -1,9 +1,10 @@ /* RISCOS module implementation */ -#include "h.osfscontrol" -#include "h.osgbpb" -#include "h.os" -#include "h.osfile" +#include "oslib/osfscontrol.h" +#include "oslib/osgbpb.h" +#include "oslib/os.h" +#include "oslib/osfile.h" +#include "unixstuff.h" #include "Python.h" @@ -11,21 +12,26 @@ static os_error *e; -static PyObject *RiscosError; /* Exception riscos.error */ +/*static PyObject *RiscosError;*/ /* Exception riscos.error */ + +static PyObject *riscos_error(char *s) +{ + PyErr_SetString(PyExc_OSError, s); + return NULL; +} static PyObject *riscos_oserror(void) -{ PyErr_SetString(RiscosError,e->errmess); - return 0; +{ + return riscos_error(e->errmess); } -static PyObject *riscos_error(char *s) { PyErr_SetString(RiscosError,s);return 0;} /* RISCOS file commands */ static PyObject *riscos_remove(PyObject *self,PyObject *args) { char *path1; if (!PyArg_Parse(args, "s", &path1)) return NULL; - if (remove(path1)) return PyErr_SetFromErrno(RiscosError); + if (remove(path1)) return PyErr_SetFromErrno(PyExc_OSError); Py_INCREF(Py_None); return Py_None; } @@ -33,7 +39,7 @@ static PyObject *riscos_remove(PyObject *self,PyObject *args) static PyObject *riscos_rename(PyObject *self,PyObject *args) { char *path1, *path2; if (!PyArg_Parse(args, "(ss)", &path1, &path2)) return NULL; - if (rename(path1,path2)) return PyErr_SetFromErrno(RiscosError);; + if (rename(path1,path2)) return PyErr_SetFromErrno(PyExc_OSError); Py_INCREF(Py_None); return Py_None; } @@ -211,12 +217,56 @@ static PyObject *riscos_chmod(PyObject *self,PyObject *args) return Py_None; } + static PyObject *riscos_utime(PyObject *self,PyObject *args) -{ char *path; - int x,y; - if (!PyArg_Parse(args, "(s(ii))", &path,&x,&y)) return NULL; - e=xosfile_stamp(path); - if(e) return riscos_oserror(); +{ + char *path; + long atime, mtime; + PyObject* arg; + + if (!PyArg_ParseTuple(args, "sO:utime", &path, &arg)) + return NULL; + + if (arg == Py_None) { + /* optional time values not given */ + Py_BEGIN_ALLOW_THREADS + e=xosfile_stamp(path); + Py_END_ALLOW_THREADS + if(e) return riscos_oserror(); + } + else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) { + PyErr_SetString(PyExc_TypeError, + "utime() arg 2 must be a tuple (atime, mtime)"); + return NULL; + } + else { + /* catalogue info*/ + fileswitch_object_type obj_type; + bits load_addr, exec_addr; + int size; + fileswitch_attr attr; + + /* read old catalogue info */ + Py_BEGIN_ALLOW_THREADS + e=xosfile_read_no_path(path, &obj_type, &load_addr, &exec_addr, &size, &attr); + Py_END_ALLOW_THREADS + if(e) return riscos_oserror(); + + /* check if load and exec address really contain filetype and date */ + if ( (load_addr & 0xFFF00000U) != 0xFFF00000U) + return riscos_error("can't set date for object with load and exec addresses"); + + /* convert argument mtime to RISC OS load and exec address */ + if(acorntime(&exec_addr, &load_addr, (time_t) mtime)) + return riscos_oserror(); + + /* write new load and exec address */ + Py_BEGIN_ALLOW_THREADS + e = xosfile_write(path, load_addr, exec_addr, attr); + Py_END_ALLOW_THREADS + if(e) return riscos_oserror(); + } + Py_INCREF(Py_None); return Py_None; } @@ -328,9 +378,7 @@ initriscos() d = PyModule_GetDict(m); /* Initialize riscos.error exception */ - RiscosError = PyString_FromString("riscos.error"); - if (RiscosError == NULL || PyDict_SetItemString(d, "error", RiscosError) != 0) - Py_FatalError("can't define riscos.error"); + PyDict_SetItemString(d, "error", PyExc_OSError); PyStructSequence_InitType(&StatResultType, &stat_result_desc); PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType); diff --git a/RISCOS/Modules/swimodule.c b/RISCOS/Modules/swimodule.c index 12908d5..ec02ae7 100644 --- a/RISCOS/Modules/swimodule.c +++ b/RISCOS/Modules/swimodule.c @@ -13,11 +13,10 @@ * Added "errnum" attribute to swi.error, so one can now check to see what the error number was */ -#include "h.os" -#include "h.kernel" +#include "oslib/os.h" +#include <kernel.h> #include "Python.h" -#include <errno.h> #define PyBlock_Check(op) ((op)->ob_type == &PyBlockType) diff --git a/RISCOS/Python/dynload_riscos.c b/RISCOS/Python/dynload_riscos.c index 3c4b1d7..6965647 100644 --- a/RISCOS/Python/dynload_riscos.c +++ b/RISCOS/Python/dynload_riscos.c @@ -52,12 +52,13 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, { int err; char errstr[256]; + void (*init_function)(void); - err = dlk_load(pathname); + err = dlk_load_no_init(pathname, &init_function); if (err) { sprintf(errstr, "dlk failure %d", err); PyErr_SetString(PyExc_ImportError, errstr); } - return dynload_init_dummy; + return init_function; } diff --git a/RISCOS/Python/getmtime_riscos.c b/RISCOS/Python/getmtime_riscos.c index cbd1669..9153638 100644 --- a/RISCOS/Python/getmtime_riscos.c +++ b/RISCOS/Python/getmtime_riscos.c @@ -1,7 +1,7 @@ #include <stdio.h> #define __swi -#include "osfile.h" +#include "oslib/osfile.h" long PyOS_GetLastModificationTime(char *path, FILE *fp) { diff --git a/RISCOS/README b/RISCOS/README index 8289880..850ff95 100644 --- a/RISCOS/README +++ b/RISCOS/README @@ -17,20 +17,20 @@ Compiling: 3. Create missing directories with 'amu cdirs'. 4. Build with 'amu'. -I've only tested Acorn C/C++ 5.06 and amu. +I've only tested Acorn/Norcroft C/C++ 5.30 and amu. +Python now uses the 32 bit libraries from Pace as well as the 32 bit +version of OSLib. You will also need some additional libraries: - DLK - ftp://ftp.infc.ulst.ac.uk/pub/users/chris/ + DLK (patched version) + http://www.schwertberger.de OSLib http://www.mk-net.demon.co.uk/oslib zlib (optional) ftp://ftp.freesoftware.com/pub/infozip/zlib/ - sockets (optional) - http://www.mirror.ac.uk/sites/ftp.acorn.co.uk/pub/riscos/releases/networking/tcpip/sockets.arc expat (optional) http://sourceforge.net/projects/expat/ (makefile and config.h available from http://www.schwertberger.de/riscos_expat.zip diff --git a/RISCOS/sleep.c b/RISCOS/sleep.c index 0aeba55..60c3768 100644 --- a/RISCOS/sleep.c +++ b/RISCOS/sleep.c @@ -1,9 +1,9 @@ -#include "osmodule.h" +#include "oslib/osmodule.h" #include <stdio.h> #include "kernel.h" #include <limits.h> #include <errno.h> -#include "taskwindow.h" +#include "oslib/taskwindow.h" #include "Python.h" diff --git a/RISCOS/support/!Boot b/RISCOS/support/!Boot index 668d6b1..c2c6644 100644 --- a/RISCOS/support/!Boot +++ b/RISCOS/support/!Boot @@ -9,4 +9,4 @@ IconSprites <Obey$Dir>.!Sprites set Alias$@RunType_ae5 TaskWindow |"python %%*0|" -name |"Python|" -quit | -display set File$Type_ae5 Python -set Alias$Python Run <Python$Dir>.python21 %*0
\ No newline at end of file +set Alias$Python Run <Python$Dir>.python22 %*0
\ No newline at end of file diff --git a/RISCOS/unixstuff.c b/RISCOS/unixstuff.c index 10648d2..83e6212 100644 --- a/RISCOS/unixstuff.c +++ b/RISCOS/unixstuff.c @@ -1,8 +1,9 @@ /* Fudge unix isatty and fileno for RISCOS */ -#include "h.unixstuff" +#include "unixstuff.h" #include <math.h> -#include "h.osfile" +#include <time.h> +#include "oslib/osfile.h" int fileno(FILE *f) { return (int)f; @@ -15,48 +16,59 @@ int isatty(int fn) bits unixtime(bits ld,bits ex) { ld&=0xFF; ld-=51; - if(ex<1855548004U) ld--; + if(ex<1855547904U) ld--; ex-=1855548004U; - return ex/100+42949672*ld+(95*ld)/100; + return ex/100+42949673U*ld-ld/25; } -int unlink(char *fname) -{ remove(fname); - return 0; -} +/* from RISC OS infozip, preserves filetype in ld */ +int acorntime(bits *ex, bits *ld, time_t utime) +{ + unsigned timlo; /* 3 lower bytes of acorn file-time plus carry byte */ + unsigned timhi; /* 2 high bytes of acorn file-time */ + + timlo = ((unsigned)utime & 0x00ffffffU) * 100 + 0x00996a00U; + timhi = ((unsigned)utime >> 24); + timhi = timhi * 100 + 0x0000336eU + (timlo >> 24); + if (timhi & 0xffff0000U) + return 1; /* calculation overflow, do not change time */ + + /* insert the five time bytes into loadaddr and execaddr variables */ + *ex = (timlo & 0x00ffffffU) | ((timhi & 0x000000ffU) << 24); + *ld = (*ld & 0xffffff00U) | ((timhi >> 8) & 0x000000ffU); + + return 0; /* subject to future extension to signal overflow */ +} -/*#define RET(k) {printf(" %d\n",k);return k;}*/ -#define RET(k) return k int isdir(char *fn) { int ob; -/* printf("isdir %s",fn);*/ - if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0); + if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) return 0; switch (ob) - { case osfile_IS_DIR:RET(1); - case osfile_IS_IMAGE:RET(1); + { case osfile_IS_DIR:return 1; + case osfile_IS_IMAGE:return 1; } - RET(0); + return 0; } int isfile(char *fn) -{ int ob; /*printf("isfile %s",fn);*/ - if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0); +{ int ob; + if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) return 0; switch (ob) - { case osfile_IS_FILE:RET(1); - case osfile_IS_IMAGE:RET(1); + { case osfile_IS_FILE:return 1; + case osfile_IS_IMAGE:return 1; } - RET(0); + return 0; } -int exists(char *fn) -{ int ob; /*printf("exists %s",fn);*/ - if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0); +int object_exists(char *fn) +{ int ob; + if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) return 0; switch (ob) - { case osfile_IS_FILE:RET(1); - case osfile_IS_DIR:RET(1); - case osfile_IS_IMAGE:RET(1); + { case osfile_IS_FILE:return 1; + case osfile_IS_DIR:return 1; + case osfile_IS_IMAGE:return 1; } - RET(0); + return 0; } diff --git a/RISCOS/unixstuff.h b/RISCOS/unixstuff.h index 75104c2..90c732b1 100644 --- a/RISCOS/unixstuff.h +++ b/RISCOS/unixstuff.h @@ -1,13 +1,14 @@ /* Fudge unix isatty and fileno for RISCOS */ #include <stdio.h> +#include <time.h> int fileno(FILE *f); int isatty(int fn); unsigned int unixtime(unsigned int ld,unsigned int ex); -/*long PyOS_GetLastModificationTime(char *name);*/ -int unlink(char *fname); +int acorntime(unsigned int *ex, unsigned int *ld, time_t ut); + int isdir(char *fn); int isfile(char *fn); -int exists(char *fn); +int object_exists(char *fn); |