Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e877f8ba
Commit
e877f8ba
authored
Oct 24, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF patch #474590 -- RISC OS support
parent
622cc03f
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
140 additions
and
72 deletions
+140
-72
RISCOS/Modules/config.c
RISCOS/Modules/config.c
+11
-4
RISCOS/Modules/drawfmodule.c
RISCOS/Modules/drawfmodule.c
+3
-3
RISCOS/Modules/getpath_riscos.c
RISCOS/Modules/getpath_riscos.c
+3
-3
RISCOS/Modules/riscosmodule.c
RISCOS/Modules/riscosmodule.c
+66
-18
RISCOS/Modules/swimodule.c
RISCOS/Modules/swimodule.c
+2
-3
RISCOS/Python/dynload_riscos.c
RISCOS/Python/dynload_riscos.c
+3
-2
RISCOS/Python/getmtime_riscos.c
RISCOS/Python/getmtime_riscos.c
+1
-1
RISCOS/README
RISCOS/README
+5
-5
RISCOS/sleep.c
RISCOS/sleep.c
+2
-2
RISCOS/support/!Boot
RISCOS/support/!Boot
+1
-1
RISCOS/unixstuff.c
RISCOS/unixstuff.c
+39
-27
RISCOS/unixstuff.h
RISCOS/unixstuff.h
+4
-3
No files found.
RISCOS/Modules/config.c
View file @
e877f8ba
...
...
@@ -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
}
...
...
RISCOS/Modules/drawfmodule.c
View file @
e877f8ba
/* 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>
...
...
RISCOS/Modules/getpath_riscos.c
View file @
e877f8ba
...
...
@@ -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 */
...
...
RISCOS/Modules/riscosmodule.c
View file @
e877f8ba
/* 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
(
Riscos
Error
);
if
(
remove
(
path1
))
return
PyErr_SetFromErrno
(
PyExc_OS
Error
);
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
);
...
...
RISCOS/Modules/swimodule.c
View file @
e877f8ba
...
...
@@ -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)
...
...
RISCOS/Python/dynload_riscos.c
View file @
e877f8ba
...
...
@@ -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
;
}
RISCOS/Python/getmtime_riscos.c
View file @
e877f8ba
#include <stdio.h>
#define __swi
#include "osfile.h"
#include "os
lib/os
file.h"
long
PyOS_GetLastModificationTime
(
char
*
path
,
FILE
*
fp
)
{
...
...
RISCOS/README
View file @
e877f8ba
...
...
@@ -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
RISCOS/sleep.c
View file @
e877f8ba
#include "osmodule.h"
#include "os
lib/os
module.h"
#include <stdio.h>
#include "kernel.h"
#include <limits.h>
#include <errno.h>
#include "taskwindow.h"
#include "
oslib/
taskwindow.h"
#include "Python.h"
...
...
RISCOS/support/!Boot
View file @
e877f8ba
...
...
@@ -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
RISCOS/unixstuff.c
View file @
e877f8ba
/* 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
<
185554
80
04U
)
ld
--
;
if
(
ex
<
185554
79
04U
)
ld
--
;
ex
-=
1855548004U
;
return
ex
/
100
+
4294967
2
*
ld
+
(
95
*
ld
)
/
100
;
return
ex
/
100
+
4294967
3U
*
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
;
}
RISCOS/unixstuff.h
View file @
e877f8ba
/* 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
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment