summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2003-05-10 07:36:56 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2003-05-10 07:36:56 (GMT)
commita94568a7535de60f1144e4eea0d027b87017a4b4 (patch)
tree5a8f696ca440a296b18521be17920b48f2021e4c /Modules
parent5467d4c0e31e9db305a4899a44d7978f83e96649 (diff)
downloadcpython-a94568a7535de60f1144e4eea0d027b87017a4b4.zip
cpython-a94568a7535de60f1144e4eea0d027b87017a4b4.tar.gz
cpython-a94568a7535de60f1144e4eea0d027b87017a4b4.tar.bz2
Patch #734231: Update RiscOS support. In particular, correct
riscospath.extsep, and use os.extsep throughout.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c44
-rw-r--r--Modules/timemodule.c6
-rw-r--r--Modules/zipimport.c10
3 files changed, 51 insertions, 9 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index fc5ea8f..956c59e 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -221,9 +221,11 @@ typedef size_t socklen_t;
# ifndef RISCOS
# include <fcntl.h>
# else
-# include <sys/fcntl.h>
+# include <sys/ioctl.h>
+# include <socklib.h>
# define NO_DUP
int h_errno; /* not used */
+# define INET_ADDRSTRLEN 16
# endif
#else
@@ -464,6 +466,18 @@ set_error(void)
}
#endif
+#if defined(RISCOS)
+ if (_inet_error.errnum != NULL) {
+ PyObject *v;
+ v = Py_BuildValue("(is)", errno, _inet_err());
+ if (v != NULL) {
+ PyErr_SetObject(socket_error, v);
+ Py_DECREF(v);
+ }
+ return NULL;
+ }
+#endif
+
return PyErr_SetFromErrno(socket_error);
}
@@ -548,8 +562,11 @@ internal_setblocking(PySocketSockObject *s, int block)
block = !block;
ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block);
#endif /* MS_WINDOWS */
-#endif /* __BEOS__ */
+#else /* RISCOS */
+ block = !block;
+ socketioctl(s->sock_fd, FIONBIO, (u_long*)&block);
#endif /* RISCOS */
+#endif /* __BEOS__ */
Py_END_ALLOW_THREADS
/* Since these don't return anything */
@@ -1211,11 +1228,11 @@ operations are disabled.");
/* s.sleeptaskw(1 | 0) method */
static PyObject *
-sock_sleeptaskw(PySocketSockObject *s,PyObject *args)
+sock_sleeptaskw(PySocketSockObject *s,PyObject *arg)
{
int block;
- int delay_flag;
- if (!PyArg_Parse(args, "i", &block))
+ block = PyInt_AsLong(arg);
+ if (block == -1 && PyErr_Occurred())
return NULL;
Py_BEGIN_ALLOW_THREADS
socketioctl(s->sock_fd, 0x80046679, (u_long*)&block);
@@ -2056,7 +2073,7 @@ static PyMethodDef sock_methods[] = {
{"shutdown", (PyCFunction)sock_shutdown, METH_O,
shutdown_doc},
#ifdef RISCOS
- {"sleeptaskw", (PyCFunction)sock_sleeptaskw, METH_VARARGS,
+ {"sleeptaskw", (PyCFunction)sock_sleeptaskw, METH_O,
sleeptaskw_doc},
#endif
{NULL, NULL} /* sentinel */
@@ -2858,8 +2875,11 @@ socket_inet_pton(PyObject *self, PyObject *args)
int af;
char* ip;
int retval;
+#ifdef ENABLE_IPV6
char packed[MAX(sizeof(struct in_addr), sizeof(struct in6_addr))];
-
+#else
+ char packed[sizeof(struct in_addr)];
+#endif
if (!PyArg_ParseTuple(args, "is:inet_pton", &af, &ip)) {
return NULL;
}
@@ -2875,9 +2895,11 @@ socket_inet_pton(PyObject *self, PyObject *args)
} else if (af == AF_INET) {
return PyString_FromStringAndSize(packed,
sizeof(struct in_addr));
+#ifdef ENABLE_IPV6
} else if (af == AF_INET6) {
return PyString_FromStringAndSize(packed,
sizeof(struct in6_addr));
+#endif
} else {
PyErr_SetString(socket_error, "unknown address family");
return NULL;
@@ -2896,7 +2918,11 @@ socket_inet_ntop(PyObject *self, PyObject *args)
char* packed;
int len;
const char* retval;
+#ifdef ENABLE_IPV6
char ip[MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) + 1];
+#else
+ char ip[INET_ADDRSTRLEN + 1];
+#endif
/* Guarantee NUL-termination for PyString_FromString() below */
memset((void *) &ip[0], '\0', sizeof(ip) + 1);
@@ -2911,12 +2937,14 @@ socket_inet_ntop(PyObject *self, PyObject *args)
"invalid length of packed IP address string");
return NULL;
}
+#ifdef ENABLE_IPV6
} else if (af == AF_INET6) {
if (len != sizeof(struct in6_addr)) {
PyErr_SetString(PyExc_ValueError,
"invalid length of packed IP address string");
return NULL;
}
+#endif
} else {
PyErr_Format(PyExc_ValueError,
"unknown address family %d", af);
@@ -3235,7 +3263,7 @@ os_init(void)
_kernel_swi(0x43380, &r, &r);
taskwindow = r.r[0];
- return 0;
+ return 1;
}
#endif /* RISCOS */
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 2e28d95..ce25281 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -78,6 +78,10 @@ static long main_thread;
#include <kernel/OS.h>
#endif
+#ifdef RISCOS
+extern int riscos_sleep(double);
+#endif
+
/* Forward declarations */
static int floatsleep(double);
static double floattime(void);
@@ -944,7 +948,7 @@ floatsleep(double secs)
return 0;
Py_BEGIN_ALLOW_THREADS
/* This sleep *CAN BE* interrupted. */
- if ( sleep(secs) )
+ if ( riscos_sleep(secs) )
return -1;
Py_END_ALLOW_THREADS
#elif defined(PLAN9)
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index 9f7da72..f0eaef5 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -91,6 +91,7 @@ zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds)
path = NULL;
prefix = NULL;
for (;;) {
+#ifndef RISCOS
struct stat statbuf;
int rv;
@@ -102,6 +103,15 @@ zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds)
path = buf;
break;
}
+#else
+ if (object_exists(buf)) {
+ /* it exists */
+ if (isfile(buf))
+ /* it's a file */
+ path = buf;
+ break;
+ }
+#endif
/* back up one path element */
p = strrchr(buf, SEP);
if (prefix != NULL)