mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Changes for BeOS, QNX and long long, by Chris Herborth.
This commit is contained in:
parent
1a8791e0b8
commit
bcc207484a
12 changed files with 132 additions and 14 deletions
|
@ -82,7 +82,7 @@ SHELL= /bin/sh
|
||||||
|
|
||||||
MAKESETUP= $(srcdir)/makesetup
|
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.
|
# found in the Setup file just below the following line.
|
||||||
# This means that the Setup file can override any of the definitions
|
# This means that the Setup file can override any of the definitions
|
||||||
# given before this point, but not any given below.
|
# given before this point, but not any given below.
|
||||||
|
@ -112,7 +112,7 @@ all: $(OBJS)
|
||||||
add2lib: $(OBJS)
|
add2lib: $(OBJS)
|
||||||
-for i in $(OBJS); do \
|
-for i in $(OBJS); do \
|
||||||
if test "$$i" = "signalmodule.o"; then \
|
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; \
|
break; \
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
|
|
@ -142,6 +142,7 @@ pwd pwdmodule.c # pwd(3)
|
||||||
grp grpmodule.c # grp(3)
|
grp grpmodule.c # grp(3)
|
||||||
select selectmodule.c # select(2); not on ancient System V
|
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); not on ancient System V
|
||||||
|
#_socket socketmodule.c # socket(2); use this one for BeOS sockets
|
||||||
errno errnomodule.c # posix (UNIX) errno values
|
errno errnomodule.c # posix (UNIX) errno values
|
||||||
|
|
||||||
# The crypt module is now disabled by default because it breaks builds
|
# The crypt module is now disabled by default because it breaks builds
|
||||||
|
|
|
@ -92,7 +92,7 @@ fixup_ulcase()
|
||||||
if (isupper(c))
|
if (isupper(c))
|
||||||
ul[n++] = c;
|
ul[n++] = c;
|
||||||
}
|
}
|
||||||
ulo=PyString_FromStringAndSize((char *)ul,n);
|
ulo=PyString_FromStringAndSize((const char *)ul,n);
|
||||||
if(!ulo)return;
|
if(!ulo)return;
|
||||||
if(string)
|
if(string)
|
||||||
PyDict_SetItemString(string,"uppercase",ulo);
|
PyDict_SetItemString(string,"uppercase",ulo);
|
||||||
|
@ -105,7 +105,7 @@ fixup_ulcase()
|
||||||
if (islower(c))
|
if (islower(c))
|
||||||
ul[n++] = c;
|
ul[n++] = c;
|
||||||
}
|
}
|
||||||
ulo=PyString_FromStringAndSize((char *)ul,n);
|
ulo=PyString_FromStringAndSize((const char *)ul,n);
|
||||||
if(!ulo)return;
|
if(!ulo)return;
|
||||||
if(string)
|
if(string)
|
||||||
PyDict_SetItemString(string,"lowercase",ulo);
|
PyDict_SetItemString(string,"lowercase",ulo);
|
||||||
|
@ -118,7 +118,7 @@ fixup_ulcase()
|
||||||
if (isalpha(c))
|
if (isalpha(c))
|
||||||
ul[n++] = c;
|
ul[n++] = c;
|
||||||
}
|
}
|
||||||
ulo=PyString_FromStringAndSize((char *)ul,n);
|
ulo=PyString_FromStringAndSize((const char *)ul,n);
|
||||||
if(!ulo)return;
|
if(!ulo)return;
|
||||||
if(string)
|
if(string)
|
||||||
PyDict_SetItemString(string,"letters",ulo);
|
PyDict_SetItemString(string,"letters",ulo);
|
||||||
|
|
|
@ -2403,6 +2403,11 @@ static char posix_putenv__doc__[] =
|
||||||
"putenv(key, value) -> None\n\
|
"putenv(key, value) -> None\n\
|
||||||
Change or add an environment variable.";
|
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 *
|
static PyObject *
|
||||||
posix_putenv(self, args)
|
posix_putenv(self, args)
|
||||||
PyObject *self;
|
PyObject *self;
|
||||||
|
|
|
@ -51,6 +51,13 @@ static PyObject *
|
||||||
mkpwent(p)
|
mkpwent(p)
|
||||||
struct passwd *p;
|
struct passwd *p;
|
||||||
{
|
{
|
||||||
|
#ifdef __BEOS__
|
||||||
|
/* For faking the GECOS field. - [cjh] */
|
||||||
|
char *be_user = NULL;
|
||||||
|
|
||||||
|
be_user = getenv( "USER" );
|
||||||
|
#endif
|
||||||
|
|
||||||
return Py_BuildValue(
|
return Py_BuildValue(
|
||||||
"(ssllsss)",
|
"(ssllsss)",
|
||||||
p->pw_name,
|
p->pw_name,
|
||||||
|
@ -64,7 +71,12 @@ mkpwent(p)
|
||||||
(long)p->pw_uid,
|
(long)p->pw_uid,
|
||||||
(long)p->pw_gid,
|
(long)p->pw_gid,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __BEOS__
|
||||||
|
/* BeOS doesn't have a GECOS field, oddly enough. - [cjh] */
|
||||||
|
be_user ? be_user : "baron",
|
||||||
|
#else
|
||||||
p->pw_gecos,
|
p->pw_gecos,
|
||||||
|
#endif
|
||||||
p->pw_dir,
|
p->pw_dir,
|
||||||
p->pw_shell);
|
p->pw_shell);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,14 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* GNU readline definitions */
|
/* 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 */
|
#include <readline/readline.h> /* You may need to add an -I option to Setup */
|
||||||
|
|
||||||
extern int rl_parse_and_bind();
|
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_bind_key_in_map();
|
||||||
extern int rl_initialize();
|
extern int rl_initialize();
|
||||||
extern int add_history();
|
extern int add_history();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Pointers needed from outside (but not declared in a header file). */
|
/* Pointers needed from outside (but not declared in a header file). */
|
||||||
extern int (*PyOS_InputHook)();
|
extern int (*PyOS_InputHook)();
|
||||||
|
|
|
@ -33,6 +33,8 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
Under Unix, the file descriptors are small integers.
|
Under Unix, the file descriptors are small integers.
|
||||||
Under Win32, select only exists for sockets, and sockets may
|
Under Win32, select only exists for sockets, and sockets may
|
||||||
have any value except INVALID_SOCKET.
|
have any value except INVALID_SOCKET.
|
||||||
|
Under BeOS, we suffer the same dichotomy as Win32; sockets can be anything
|
||||||
|
>= 0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
@ -56,9 +58,14 @@ extern void bzero();
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
#else
|
#else
|
||||||
|
#ifdef __BEOS__
|
||||||
|
#include <net/socket.h>
|
||||||
|
#define SOCKET int
|
||||||
|
#else
|
||||||
#include "myselect.h" /* Also includes mytime.h */
|
#include "myselect.h" /* Also includes mytime.h */
|
||||||
#define SOCKET int
|
#define SOCKET int
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static PyObject *SelectError;
|
static PyObject *SelectError;
|
||||||
|
|
||||||
|
@ -134,7 +141,7 @@ list2set(list, set, fd2obj)
|
||||||
"argument must be an int, or have a fileno() method.");
|
"argument must be an int, or have a fileno() method.");
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) || defined(__BEOS__)
|
||||||
max = 0; /* not used for Win32 */
|
max = 0; /* not used for Win32 */
|
||||||
#else /* !_MSC_VER */
|
#else /* !_MSC_VER */
|
||||||
if (v < 0 || v >= FD_SETSIZE) {
|
if (v < 0 || v >= FD_SETSIZE) {
|
||||||
|
|
|
@ -94,7 +94,7 @@ Socket methods:
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(MS_WINDOWS) && !defined(PYOS_OS2)
|
#if !defined(MS_WINDOWS) && !defined(PYOS_OS2) && !defined(__BEOS__)
|
||||||
extern int gethostname(); /* For Solaris, at least */
|
extern int gethostname(); /* For Solaris, at least */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -113,6 +113,11 @@ extern int gethostname(); /* For Solaris, at least */
|
||||||
#include <os2.h>
|
#include <os2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__BEOS__)
|
||||||
|
/* It's in the libs, but not the headers... - [cjh] */
|
||||||
|
int shutdown( int, int );
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "mytime.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
|
it must be compiled by the C++ compiler, as it takes the address of
|
||||||
a static data item exported from the main Python DLL.
|
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 */
|
/* seem to be a few differences in the API */
|
||||||
#define close closesocket
|
#define close closesocket
|
||||||
#define NO_DUP /* Actually it exists on NT 3.5, but what the heck... */
|
#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;
|
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) {
|
switch (addr->sa_family) {
|
||||||
|
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
@ -600,6 +611,11 @@ BUILD_FUNC_DEF_2(PySocketSock_setblocking,PySocketSockObject*,s,PyObject*,args)
|
||||||
if (!PyArg_Parse(args, "i", &block))
|
if (!PyArg_Parse(args, "i", &block))
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
#ifdef __BEOS__
|
||||||
|
block = !block;
|
||||||
|
setsockopt( s->sock_fd, SOL_SOCKET, SO_NONBLOCK,
|
||||||
|
(void *)(&block), sizeof( int ) );
|
||||||
|
#else
|
||||||
#ifndef MS_WINDOWS
|
#ifndef MS_WINDOWS
|
||||||
#ifdef PYOS_OS2
|
#ifdef PYOS_OS2
|
||||||
block = !block;
|
block = !block;
|
||||||
|
@ -616,6 +632,7 @@ BUILD_FUNC_DEF_2(PySocketSock_setblocking,PySocketSockObject*,s,PyObject*,args)
|
||||||
block = !block;
|
block = !block;
|
||||||
ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block);
|
ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block);
|
||||||
#endif /* MS_WINDOWS */
|
#endif /* MS_WINDOWS */
|
||||||
|
#endif /* __BEOS__ */
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
|
@ -682,6 +699,12 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args
|
||||||
PyObject *buf;
|
PyObject *buf;
|
||||||
int buflen = 0;
|
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))
|
if (!PyArg_ParseTuple(args, "ii|i", &level, &optname, &buflen))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -710,6 +733,7 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args
|
||||||
}
|
}
|
||||||
_PyString_Resize(&buf, buflen);
|
_PyString_Resize(&buf, buflen);
|
||||||
return buf;
|
return buf;
|
||||||
|
#endif /* __BEOS__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
static char getsockopt_doc[] =
|
static char getsockopt_doc[] =
|
||||||
|
@ -1506,6 +1530,11 @@ BUILD_FUNC_DEF_2(PySocket_getprotobyname,PyObject *,self, PyObject *,args)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
struct protoent *sp;
|
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))
|
if (!PyArg_Parse(args, "s", &name))
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
@ -1516,6 +1545,7 @@ BUILD_FUNC_DEF_2(PySocket_getprotobyname,PyObject *,self, PyObject *,args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return PyInt_FromLong((long) sp->p_proto);
|
return PyInt_FromLong((long) sp->p_proto);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static char getprotobyname_doc[] =
|
static char getprotobyname_doc[] =
|
||||||
|
@ -1866,7 +1896,7 @@ shutdown() -- shut down traffic in one or both directions\n\
|
||||||
(*) not available on all platforms!)";
|
(*) not available on all platforms!)";
|
||||||
|
|
||||||
void
|
void
|
||||||
#if defined(MS_WINDOWS) || defined(PYOS_OS2)
|
#if defined(MS_WINDOWS) || defined(PYOS_OS2) || defined(__BEOS__)
|
||||||
init_socket()
|
init_socket()
|
||||||
#else
|
#else
|
||||||
initsocket()
|
initsocket()
|
||||||
|
@ -1882,8 +1912,12 @@ initsocket()
|
||||||
if (!OS2init())
|
if (!OS2init())
|
||||||
return;
|
return;
|
||||||
m = Py_InitModule3("_socket", PySocket_methods, module_doc);
|
m = Py_InitModule3("_socket", PySocket_methods, module_doc);
|
||||||
|
#else
|
||||||
|
#if defined(__BEOS__)
|
||||||
|
m = Py_InitModule3("_socket", PySocket_methods, module_doc);
|
||||||
#else
|
#else
|
||||||
m = Py_InitModule3("socket", PySocket_methods, module_doc);
|
m = Py_InitModule3("socket", PySocket_methods, module_doc);
|
||||||
|
#endif /* __BEOS__ */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
|
@ -1903,9 +1937,12 @@ initsocket()
|
||||||
#endif /* AF_UNIX */
|
#endif /* AF_UNIX */
|
||||||
insint(d, "SOCK_STREAM", SOCK_STREAM);
|
insint(d, "SOCK_STREAM", SOCK_STREAM);
|
||||||
insint(d, "SOCK_DGRAM", SOCK_DGRAM);
|
insint(d, "SOCK_DGRAM", SOCK_DGRAM);
|
||||||
|
#ifndef __BEOS__
|
||||||
|
/* We have incomplete socket support. */
|
||||||
insint(d, "SOCK_RAW", SOCK_RAW);
|
insint(d, "SOCK_RAW", SOCK_RAW);
|
||||||
insint(d, "SOCK_SEQPACKET", SOCK_SEQPACKET);
|
insint(d, "SOCK_SEQPACKET", SOCK_SEQPACKET);
|
||||||
insint(d, "SOCK_RDM", SOCK_RDM);
|
insint(d, "SOCK_RDM", SOCK_RDM);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SO_DEBUG
|
#ifdef SO_DEBUG
|
||||||
insint(d, "SO_DEBUG", SO_DEBUG);
|
insint(d, "SO_DEBUG", SO_DEBUG);
|
||||||
|
|
|
@ -207,7 +207,9 @@ initsyslog()
|
||||||
ins(d, "LOG_PID", LOG_PID);
|
ins(d, "LOG_PID", LOG_PID);
|
||||||
ins(d, "LOG_CONS", LOG_CONS);
|
ins(d, "LOG_CONS", LOG_CONS);
|
||||||
ins(d, "LOG_NDELAY", LOG_NDELAY);
|
ins(d, "LOG_NDELAY", LOG_NDELAY);
|
||||||
|
#ifdef LOG_NOWAIT
|
||||||
ins(d, "LOG_NOWAIT", LOG_NOWAIT);
|
ins(d, "LOG_NOWAIT", LOG_NOWAIT);
|
||||||
|
#endif
|
||||||
#ifdef LOG_PERROR
|
#ifdef LOG_PERROR
|
||||||
ins(d, "LOG_PERROR", LOG_PERROR);
|
ins(d, "LOG_PERROR", LOG_PERROR);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,6 +21,10 @@ This module should be used in conjunction with the TERMIOS module,\n\
|
||||||
which defines the relevant symbolic constants.";
|
which defines the relevant symbolic constants.";
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __BEOS__
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BAD "bad termios argument"
|
#define BAD "bad termios argument"
|
||||||
|
|
||||||
static PyObject *TermiosError;
|
static PyObject *TermiosError;
|
||||||
|
|
|
@ -56,7 +56,7 @@ staticforward PyTypeObject Locktype;
|
||||||
|
|
||||||
#define is_lockobject(v) ((v)->ob_type == &Locktype)
|
#define is_lockobject(v) ((v)->ob_type == &Locktype)
|
||||||
|
|
||||||
type_lock
|
static type_lock
|
||||||
getlocklock(lock)
|
getlocklock(lock)
|
||||||
PyObject *lock;
|
PyObject *lock;
|
||||||
{
|
{
|
||||||
|
@ -252,7 +252,14 @@ t_bootstrap(boot_raw)
|
||||||
PyThreadState_Clear(tstate);
|
PyThreadState_Clear(tstate);
|
||||||
PyEval_ReleaseThread(tstate);
|
PyEval_ReleaseThread(tstate);
|
||||||
PyThreadState_Delete(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();
|
exit_thread();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -53,14 +53,17 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SELECT
|
#if defined(HAVE_SELECT) && !defined(__BEOS__)
|
||||||
#include "myselect.h"
|
#include "myselect.h"
|
||||||
#else
|
#else
|
||||||
#include "mytime.h"
|
#include "mytime.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_FTIME
|
#ifdef HAVE_FTIME
|
||||||
|
#ifndef __BEOS__
|
||||||
|
/* We have ftime(), but not in the headers (PR2). - [cjh] */
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
|
#endif
|
||||||
#if !defined(MS_WINDOWS) && !defined(PYOS_OS2)
|
#if !defined(MS_WINDOWS) && !defined(PYOS_OS2)
|
||||||
extern int ftime();
|
extern int ftime();
|
||||||
#endif /* MS_WINDOWS */
|
#endif /* MS_WINDOWS */
|
||||||
|
@ -99,6 +102,12 @@ extern int ftime();
|
||||||
#define timezone _timezone
|
#define timezone _timezone
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __BEOS__
|
||||||
|
/* For bigtime_t, snooze(). - [cjh] */
|
||||||
|
#include <support/SupportDefs.h>
|
||||||
|
#include <kernel/OS.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
static int floatsleep Py_PROTO((double));
|
static int floatsleep Py_PROTO((double));
|
||||||
static double floattime Py_PROTO(());
|
static double floattime Py_PROTO(());
|
||||||
|
@ -670,7 +679,7 @@ floattime()
|
||||||
}
|
}
|
||||||
#endif /* !HAVE_GETTIMEOFDAY */
|
#endif /* !HAVE_GETTIMEOFDAY */
|
||||||
{
|
{
|
||||||
#ifdef HAVE_FTIME
|
#if defined(HAVE_FTIME) && !defined(__BEOS__)
|
||||||
struct timeb t;
|
struct timeb t;
|
||||||
ftime(&t);
|
ftime(&t);
|
||||||
return (double)t.time + (double)t.millitm * (double)0.001;
|
return (double)t.time + (double)t.millitm * (double)0.001;
|
||||||
|
@ -696,7 +705,7 @@ floatsleep(double secs)
|
||||||
#endif /* MPW */
|
#endif /* MPW */
|
||||||
{
|
{
|
||||||
/* XXX Should test for MS_WIN32 first! */
|
/* XXX Should test for MS_WIN32 first! */
|
||||||
#ifdef HAVE_SELECT
|
#if defined(HAVE_SELECT) && !defined(__BEOS__)
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
double frac;
|
double frac;
|
||||||
frac = fmod(secs, 1.0);
|
frac = fmod(secs, 1.0);
|
||||||
|
@ -710,7 +719,7 @@ floatsleep(double secs)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
#else /* !HAVE_SELECT */
|
#else /* !HAVE_SELECT || __BEOS__ */
|
||||||
#ifdef macintosh
|
#ifdef macintosh
|
||||||
#define MacTicks (* (long *)0x16A)
|
#define MacTicks (* (long *)0x16A)
|
||||||
long deadline;
|
long deadline;
|
||||||
|
@ -773,10 +782,35 @@ floatsleep(double secs)
|
||||||
}
|
}
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
#else /* !PYOS_OS2 */
|
#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 */
|
/* XXX Can't interrupt this sleep */
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
sleep((int)secs);
|
sleep((int)secs);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
#endif /* !__BEOS__ */
|
||||||
#endif /* !PYOS_OS2 */
|
#endif /* !PYOS_OS2 */
|
||||||
#endif /* !MS_WIN32 */
|
#endif /* !MS_WIN32 */
|
||||||
#endif /* !MSDOS */
|
#endif /* !MSDOS */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue