summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-08-04 22:53:56 (GMT)
committerGuido van Rossum <guido@python.org>1998-08-04 22:53:56 (GMT)
commitbcc207484a0f8f27a684e11194e7430c0710f66d (patch)
tree506ce2d793a619a92e78faa89032878ea4a43461 /Modules
parent1a8791e0b875df8e9428c2d9969f64e5967ac0b4 (diff)
downloadcpython-bcc207484a0f8f27a684e11194e7430c0710f66d.zip
cpython-bcc207484a0f8f27a684e11194e7430c0710f66d.tar.gz
cpython-bcc207484a0f8f27a684e11194e7430c0710f66d.tar.bz2
Changes for BeOS, QNX and long long, by Chris Herborth.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Makefile.pre.in4
-rw-r--r--Modules/Setup.in1
-rw-r--r--Modules/_localemodule.c6
-rw-r--r--Modules/posixmodule.c5
-rw-r--r--Modules/pwdmodule.c12
-rw-r--r--Modules/readline.c9
-rw-r--r--Modules/selectmodule.c9
-rw-r--r--Modules/socketmodule.c43
-rw-r--r--Modules/syslogmodule.c2
-rw-r--r--Modules/termios.c4
-rw-r--r--Modules/threadmodule.c9
-rw-r--r--Modules/timemodule.c42
12 files changed, 132 insertions, 14 deletions
diff --git a/Modules/Makefile.pre.in b/Modules/Makefile.pre.in
index 637506f..ca728e0 100644
--- a/Modules/Makefile.pre.in
+++ b/Modules/Makefile.pre.in
@@ -82,7 +82,7 @@ SHELL= /bin/sh
MAKESETUP= $(srcdir)/makesetup
-# (The makesetup script inserts all variable definitions found
+# (The makesetup script inserts all variable definitions
# found in the Setup file just below the following line.
# This means that the Setup file can override any of the definitions
# given before this point, but not any given below.
@@ -112,7 +112,7 @@ all: $(OBJS)
add2lib: $(OBJS)
-for i in $(OBJS); do \
if test "$$i" = "signalmodule.o"; then \
- ar d $(LIBRARY) sigcheck.o intrcheck.o 2>/dev/null; \
+ $(AR) d $(LIBRARY) sigcheck.o intrcheck.o 2>/dev/null; \
break; \
fi; \
done
diff --git a/Modules/Setup.in b/Modules/Setup.in
index a1c6ec1..605c38b 100644
--- a/Modules/Setup.in
+++ b/Modules/Setup.in
@@ -142,6 +142,7 @@ pwd pwdmodule.c # pwd(3)
grp grpmodule.c # grp(3)
select selectmodule.c # select(2); not on ancient System V
socket socketmodule.c # socket(2); not on ancient System V
+#_socket socketmodule.c # socket(2); use this one for BeOS sockets
errno errnomodule.c # posix (UNIX) errno values
# The crypt module is now disabled by default because it breaks builds
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 1b4aa9d..2f7a42b 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -92,7 +92,7 @@ fixup_ulcase()
if (isupper(c))
ul[n++] = c;
}
- ulo=PyString_FromStringAndSize((char *)ul,n);
+ ulo=PyString_FromStringAndSize((const char *)ul,n);
if(!ulo)return;
if(string)
PyDict_SetItemString(string,"uppercase",ulo);
@@ -105,7 +105,7 @@ fixup_ulcase()
if (islower(c))
ul[n++] = c;
}
- ulo=PyString_FromStringAndSize((char *)ul,n);
+ ulo=PyString_FromStringAndSize((const char *)ul,n);
if(!ulo)return;
if(string)
PyDict_SetItemString(string,"lowercase",ulo);
@@ -118,7 +118,7 @@ fixup_ulcase()
if (isalpha(c))
ul[n++] = c;
}
- ulo=PyString_FromStringAndSize((char *)ul,n);
+ ulo=PyString_FromStringAndSize((const char *)ul,n);
if(!ulo)return;
if(string)
PyDict_SetItemString(string,"letters",ulo);
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 91cc3bf..6708df8 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2403,6 +2403,11 @@ static char posix_putenv__doc__[] =
"putenv(key, value) -> None\n\
Change or add an environment variable.";
+#ifdef __BEOS__
+/* We have putenv(), but not in the headers (as of PR2). - [cjh] */
+int putenv( const char *str );
+#endif
+
static PyObject *
posix_putenv(self, args)
PyObject *self;
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
index e37e5fd..732e4dc 100644
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -51,6 +51,13 @@ static PyObject *
mkpwent(p)
struct passwd *p;
{
+#ifdef __BEOS__
+ /* For faking the GECOS field. - [cjh] */
+ char *be_user = NULL;
+
+ be_user = getenv( "USER" );
+#endif
+
return Py_BuildValue(
"(ssllsss)",
p->pw_name,
@@ -64,7 +71,12 @@ mkpwent(p)
(long)p->pw_uid,
(long)p->pw_gid,
#endif
+#ifdef __BEOS__
+/* BeOS doesn't have a GECOS field, oddly enough. - [cjh] */
+ be_user ? be_user : "baron",
+#else
p->pw_gecos,
+#endif
p->pw_dir,
p->pw_shell);
}
diff --git a/Modules/readline.c b/Modules/readline.c
index 79b8870..899a223 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -17,6 +17,14 @@
#endif
/* GNU readline definitions */
+/* If you have string.h, you might need to add yourself to this #if... [cjh] */
+#if defined(__BEOS__)
+#undef HAVE_CONFIG_H
+/* At max warnings, we need protos for everything. [cjh] */
+#include <readline/readline.h>
+#include <readline/history.h>
+#include <unistd.h>
+#else
#include <readline/readline.h> /* You may need to add an -I option to Setup */
extern int rl_parse_and_bind();
@@ -26,6 +34,7 @@ extern int rl_bind_key();
extern int rl_bind_key_in_map();
extern int rl_initialize();
extern int add_history();
+#endif
/* Pointers needed from outside (but not declared in a header file). */
extern int (*PyOS_InputHook)();
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 3913181..dfc765c 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -33,6 +33,8 @@ PERFORMANCE OF THIS SOFTWARE.
Under Unix, the file descriptors are small integers.
Under Win32, select only exists for sockets, and sockets may
have any value except INVALID_SOCKET.
+ Under BeOS, we suffer the same dichotomy as Win32; sockets can be anything
+ >= 0.
*/
#include "Python.h"
@@ -56,9 +58,14 @@ extern void bzero();
#ifdef MS_WINDOWS
#include <winsock.h>
#else
+#ifdef __BEOS__
+#include <net/socket.h>
+#define SOCKET int
+#else
#include "myselect.h" /* Also includes mytime.h */
#define SOCKET int
#endif
+#endif
static PyObject *SelectError;
@@ -134,7 +141,7 @@ list2set(list, set, fd2obj)
"argument must be an int, or have a fileno() method.");
goto finally;
}
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BEOS__)
max = 0; /* not used for Win32 */
#else /* !_MSC_VER */
if (v < 0 || v >= FD_SETSIZE) {
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 58b2c98..8e039a1 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -94,7 +94,7 @@ Socket methods:
#include <unistd.h>
#endif
-#if !defined(MS_WINDOWS) && !defined(PYOS_OS2)
+#if !defined(MS_WINDOWS) && !defined(PYOS_OS2) && !defined(__BEOS__)
extern int gethostname(); /* For Solaris, at least */
#endif
@@ -113,6 +113,11 @@ extern int gethostname(); /* For Solaris, at least */
#include <os2.h>
#endif
+#if defined(__BEOS__)
+/* It's in the libs, but not the headers... - [cjh] */
+int shutdown( int, int );
+#endif
+
#include <sys/types.h>
#include "mytime.h"
@@ -147,7 +152,8 @@ extern int gethostname(); /* For Solaris, at least */
it must be compiled by the C++ compiler, as it takes the address of
a static data item exported from the main Python DLL.
*/
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__BEOS__)
+/* BeOS suffers from the same socket dichotomy as Win32... - [cjh] */
/* seem to be a few differences in the API */
#define close closesocket
#define NO_DUP /* Actually it exists on NT 3.5, but what the heck... */
@@ -407,6 +413,11 @@ BUILD_FUNC_DEF_2(makesockaddr,struct sockaddr *,addr, int,addrlen)
return Py_None;
}
+#ifdef __BEOS__
+ /* XXX: BeOS version of accept() doesn't set family coreectly */
+ addr->sa_family = AF_INET;
+#endif
+
switch (addr->sa_family) {
case AF_INET:
@@ -600,6 +611,11 @@ BUILD_FUNC_DEF_2(PySocketSock_setblocking,PySocketSockObject*,s,PyObject*,args)
if (!PyArg_Parse(args, "i", &block))
return NULL;
Py_BEGIN_ALLOW_THREADS
+#ifdef __BEOS__
+ block = !block;
+ setsockopt( s->sock_fd, SOL_SOCKET, SO_NONBLOCK,
+ (void *)(&block), sizeof( int ) );
+#else
#ifndef MS_WINDOWS
#ifdef PYOS_OS2
block = !block;
@@ -616,6 +632,7 @@ BUILD_FUNC_DEF_2(PySocketSock_setblocking,PySocketSockObject*,s,PyObject*,args)
block = !block;
ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block);
#endif /* MS_WINDOWS */
+#endif /* __BEOS__ */
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
@@ -682,6 +699,12 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args
PyObject *buf;
int buflen = 0;
+#ifdef __BEOS__
+/* We have incomplete socket support. */
+ PyErr_SetString( PySocket_Error, "getsockopt not supported" );
+ return NULL;
+#else
+
if (!PyArg_ParseTuple(args, "ii|i", &level, &optname, &buflen))
return NULL;
@@ -710,6 +733,7 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args
}
_PyString_Resize(&buf, buflen);
return buf;
+#endif /* __BEOS__ */
}
static char getsockopt_doc[] =
@@ -1506,6 +1530,11 @@ BUILD_FUNC_DEF_2(PySocket_getprotobyname,PyObject *,self, PyObject *,args)
{
char *name;
struct protoent *sp;
+#ifdef __BEOS__
+/* Not available in BeOS yet. - [cjh] */
+ PyErr_SetString( PySocket_Error, "getprotobyname not supported" );
+ return NULL;
+#else
if (!PyArg_Parse(args, "s", &name))
return NULL;
Py_BEGIN_ALLOW_THREADS
@@ -1516,6 +1545,7 @@ BUILD_FUNC_DEF_2(PySocket_getprotobyname,PyObject *,self, PyObject *,args)
return NULL;
}
return PyInt_FromLong((long) sp->p_proto);
+#endif
}
static char getprotobyname_doc[] =
@@ -1866,7 +1896,7 @@ shutdown() -- shut down traffic in one or both directions\n\
(*) not available on all platforms!)";
void
-#if defined(MS_WINDOWS) || defined(PYOS_OS2)
+#if defined(MS_WINDOWS) || defined(PYOS_OS2) || defined(__BEOS__)
init_socket()
#else
initsocket()
@@ -1883,7 +1913,11 @@ initsocket()
return;
m = Py_InitModule3("_socket", PySocket_methods, module_doc);
#else
+#if defined(__BEOS__)
+ m = Py_InitModule3("_socket", PySocket_methods, module_doc);
+#else
m = Py_InitModule3("socket", PySocket_methods, module_doc);
+#endif /* __BEOS__ */
#endif
#endif
d = PyModule_GetDict(m);
@@ -1903,9 +1937,12 @@ initsocket()
#endif /* AF_UNIX */
insint(d, "SOCK_STREAM", SOCK_STREAM);
insint(d, "SOCK_DGRAM", SOCK_DGRAM);
+#ifndef __BEOS__
+/* We have incomplete socket support. */
insint(d, "SOCK_RAW", SOCK_RAW);
insint(d, "SOCK_SEQPACKET", SOCK_SEQPACKET);
insint(d, "SOCK_RDM", SOCK_RDM);
+#endif
#ifdef SO_DEBUG
insint(d, "SO_DEBUG", SO_DEBUG);
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
index 96de3ac..f55a77c 100644
--- a/Modules/syslogmodule.c
+++ b/Modules/syslogmodule.c
@@ -207,7 +207,9 @@ initsyslog()
ins(d, "LOG_PID", LOG_PID);
ins(d, "LOG_CONS", LOG_CONS);
ins(d, "LOG_NDELAY", LOG_NDELAY);
+#ifdef LOG_NOWAIT
ins(d, "LOG_NOWAIT", LOG_NOWAIT);
+#endif
#ifdef LOG_PERROR
ins(d, "LOG_PERROR", LOG_PERROR);
#endif
diff --git a/Modules/termios.c b/Modules/termios.c
index d7afeae..e2ef5d0 100644
--- a/Modules/termios.c
+++ b/Modules/termios.c
@@ -21,6 +21,10 @@ This module should be used in conjunction with the TERMIOS module,\n\
which defines the relevant symbolic constants.";
+#ifdef __BEOS__
+#include <unistd.h>
+#endif
+
#define BAD "bad termios argument"
static PyObject *TermiosError;
diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c
index 2d8c863..52d2eb2 100644
--- a/Modules/threadmodule.c
+++ b/Modules/threadmodule.c
@@ -56,7 +56,7 @@ staticforward PyTypeObject Locktype;
#define is_lockobject(v) ((v)->ob_type == &Locktype)
-type_lock
+static type_lock
getlocklock(lock)
PyObject *lock;
{
@@ -252,7 +252,14 @@ t_bootstrap(boot_raw)
PyThreadState_Clear(tstate);
PyEval_ReleaseThread(tstate);
PyThreadState_Delete(tstate);
+#ifdef __BEOS__
+ /* Dunno if this will cause problems with other ports; the BeOS thread
+ * support features only 100% renamed functions. [cjh]
+ */
+ PyThread_exit_thread();
+#else
exit_thread();
+#endif
}
static PyObject *
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 43b247f..7feefbc 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -53,14 +53,17 @@ PERFORMANCE OF THIS SOFTWARE.
#include <unistd.h>
#endif
-#ifdef HAVE_SELECT
+#if defined(HAVE_SELECT) && !defined(__BEOS__)
#include "myselect.h"
#else
#include "mytime.h"
#endif
#ifdef HAVE_FTIME
+#ifndef __BEOS__
+/* We have ftime(), but not in the headers (PR2). - [cjh] */
#include <sys/timeb.h>
+#endif
#if !defined(MS_WINDOWS) && !defined(PYOS_OS2)
extern int ftime();
#endif /* MS_WINDOWS */
@@ -99,6 +102,12 @@ extern int ftime();
#define timezone _timezone
#endif
+#ifdef __BEOS__
+/* For bigtime_t, snooze(). - [cjh] */
+#include <support/SupportDefs.h>
+#include <kernel/OS.h>
+#endif
+
/* Forward declarations */
static int floatsleep Py_PROTO((double));
static double floattime Py_PROTO(());
@@ -670,7 +679,7 @@ floattime()
}
#endif /* !HAVE_GETTIMEOFDAY */
{
-#ifdef HAVE_FTIME
+#if defined(HAVE_FTIME) && !defined(__BEOS__)
struct timeb t;
ftime(&t);
return (double)t.time + (double)t.millitm * (double)0.001;
@@ -696,7 +705,7 @@ floatsleep(double secs)
#endif /* MPW */
{
/* XXX Should test for MS_WIN32 first! */
-#ifdef HAVE_SELECT
+#if defined(HAVE_SELECT) && !defined(__BEOS__)
struct timeval t;
double frac;
frac = fmod(secs, 1.0);
@@ -710,7 +719,7 @@ floatsleep(double secs)
return -1;
}
Py_END_ALLOW_THREADS
-#else /* !HAVE_SELECT */
+#else /* !HAVE_SELECT || __BEOS__ */
#ifdef macintosh
#define MacTicks (* (long *)0x16A)
long deadline;
@@ -773,10 +782,35 @@ floatsleep(double secs)
}
Py_END_ALLOW_THREADS
#else /* !PYOS_OS2 */
+#ifdef __BEOS__
+ /* This sleep *CAN BE* interrupted. */
+ {
+ bigtime_t frac, seconds;
+
+ extern double fmod Py_PROTO((double,double));
+ extern double floor Py_PROTO((double));
+
+ if( secs <= 0.0 ) {
+ return;
+ }
+
+ frac = (bigtime_t)fmod( secs, 1.0 );
+ seconds = (bigtime_t)floor( secs );
+
+ Py_BEGIN_ALLOW_THREADS
+ if( snooze( seconds * (bigtime_t)1000 + frac ) == B_INTERRUPTED ) {
+ Py_BLOCK_THREADS
+ PyErr_SetFromErrno( PyExc_IOError );
+ return -1;
+ }
+ Py_END_ALLOW_THREADS
+ }
+#else /* !__BEOS__ */
/* XXX Can't interrupt this sleep */
Py_BEGIN_ALLOW_THREADS
sleep((int)secs);
Py_END_ALLOW_THREADS
+#endif /* !__BEOS__ */
#endif /* !PYOS_OS2 */
#endif /* !MS_WIN32 */
#endif /* !MSDOS */