]> granicus.if.org Git - python/commitdiff
Changes for BeOS, QNX and long long, by Chris Herborth.
authorGuido van Rossum <guido@python.org>
Tue, 4 Aug 1998 22:53:56 +0000 (22:53 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 4 Aug 1998 22:53:56 +0000 (22:53 +0000)
12 files changed:
Modules/Makefile.pre.in
Modules/Setup.in
Modules/_localemodule.c
Modules/posixmodule.c
Modules/pwdmodule.c
Modules/readline.c
Modules/selectmodule.c
Modules/socketmodule.c
Modules/syslogmodule.c
Modules/termios.c
Modules/threadmodule.c
Modules/timemodule.c

index 637506f4b1907b8a0c28333887f20de98cb8db1c..ca728e050f6d697045c93448517a02a07af45d50 100644 (file)
@@ -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
index a1c6ec193f06ef1413db9b7ee385a00895ce0ff2..605c38b220c0d90dc438d1ac1fcda711d46dde7a 100644 (file)
@@ -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
index 1b4aa9d8ea7285db590a5476715266b58f0fc44b..2f7a42b7b373ccf41f4103b746b87ee676d3f058 100644 (file)
@@ -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);
index 91cc3bf712d89ab7115c8e7a65640eacab12b508..6708df8d81252ceea81b33dfc8bf506c435bedee 100644 (file)
@@ -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;
index e37e5fdd07833f70e95156bf9dddd30a9b91f00f..732e4dcbf1d91cf79818756b8b0754660c67c10f 100644 (file)
@@ -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);
 }
index 79b8870ce2aaf06b9c4ce89edd6c58024d6bcd5f..899a2232b6104465110482f006ada703f56fa7e8 100644 (file)
 #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)();
index 391318199c005e7ca974e8521a0d569e2f50db8c..dfc765c498f9b799cf9d4307ecea41bd0d2ca52a 100644 (file)
@@ -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) {
index 58b2c987aff4c4ab0d282ef2e18daa109ceea59c..8e039a1f23b366eb0c878603a047de713f5beca0 100644 (file)
@@ -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()
@@ -1882,8 +1912,12 @@ initsocket()
        if (!OS2init())
                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);
index 96de3ac308f8863c2de8153fb2cc9ba442382a9e..f55a77c5bf33baaa3370ae736e066c6ce7577de4 100644 (file)
@@ -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
index d7afeaec685334b6d9b040afd3c650710b888974..e2ef5d0b7ab4c7e9849260e7ec0fec69ceab7a1b 100644 (file)
@@ -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;
index 2d8c863e125fa81cfd6d3f146d25274b76b41a2a..52d2eb2c9cf0447db7c0292374fafa91c20abf98 100644 (file)
@@ -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 *
index 43b247f1f50c2843999eaf8e305b789e25c41445..7feefbcb26238ab57a5b201b4dd13f37eb6bbb89 100644 (file)
@@ -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 */