]> granicus.if.org Git - python/commitdiff
SF patch #474590 -- RISC OS support
authorGuido van Rossum <guido@python.org>
Wed, 24 Oct 2001 20:13:15 +0000 (20:13 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 24 Oct 2001 20:13:15 +0000 (20:13 +0000)
12 files changed:
RISCOS/Modules/config.c
RISCOS/Modules/drawfmodule.c
RISCOS/Modules/getpath_riscos.c
RISCOS/Modules/riscosmodule.c
RISCOS/Modules/swimodule.c
RISCOS/Python/dynload_riscos.c
RISCOS/Python/getmtime_riscos.c
RISCOS/README
RISCOS/sleep.c
RISCOS/support/!Boot
RISCOS/unixstuff.c
RISCOS/unixstuff.h

index 75e056fd4d07b2494470742b7efc552682c9c5f3..03f6e3ce46fa3c5b4de2069de1a1e51ce12ae014 100644 (file)
@@ -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}
index 1ac473658221f69aa9a04d8e42062f68fca8f0ce..db74d3625c4f4a2768bd838382010473e23e0a73 100644 (file)
@@ -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>
index 8b36952f3355ce406d316e9937ac255a943a5a21..8705e2c4e76e85d28f150e6870eebf2e1d72e95a 100644 (file)
@@ -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 */
index d5cdd94518be38b60ba2f4cccc1a45f88ebed15f..9d3510cc4c26a559e3a439fc9d7389497b186e01 100644 (file)
@@ -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"
 
 
 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);
index 12908d592cbe961973c2eb6654849ef09ee50f5a..ec02ae77b26c967b2b7a492d159fec986eecc58b 100644 (file)
    * 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)
 
index 3c4b1d7d674871858639e508605bf47ad1fcef79..6965647062621b4d2f5d81726f0d1b31f015b0fc 100644 (file)
@@ -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;
 }
index cbd1669275bbaa7d502a49e02184966e27a410b4..9153638ffe95031dd3e74b0484f7a44ce46f1c4b 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdio.h>
 
 #define __swi
-#include "osfile.h"
+#include "oslib/osfile.h"
 
 long PyOS_GetLastModificationTime(char *path, FILE *fp)
 {
index 8289880fe7dc39db1639974c673c14348c3516a0..850ff9529641cca0400cd528d1e02f2ceeace73e 100644 (file)
@@ -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
index 0aeba55b17a00f222825c2efa8f6cde706b2879b..60c376845c5755b1bf2b5d0f42a8bbf3b4b8b31d 100644 (file)
@@ -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"
 
 
index 668d6b1c49ae9d4e1f44a1a78b8d7de07f284615..c2c66445ab26ef1d48ce752bd8fb10df35a67269 100644 (file)
@@ -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
index 10648d264fd234c33b4eda5baf6a17bffbdd3570..83e6212c82d14dee698d208fb8b7f59202bed03f 100644 (file)
@@ -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;
 }
index 75104c29832be5e4249b3d51c82d396bb807bc3b..90c732b14f779120b8b7146facdd01844e60f863 100644 (file)
@@ -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);