Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bcc2074

Browse files
committed
Changes for BeOS, QNX and long long, by Chris Herborth.
1 parent 1a8791e commit bcc2074

12 files changed

Lines changed: 132 additions & 14 deletions

Modules/Makefile.pre.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ SHELL= /bin/sh
8282

8383
MAKESETUP= $(srcdir)/makesetup
8484

85-
# (The makesetup script inserts all variable definitions found
85+
# (The makesetup script inserts all variable definitions
8686
# found in the Setup file just below the following line.
8787
# This means that the Setup file can override any of the definitions
8888
# given before this point, but not any given below.
@@ -112,7 +112,7 @@ all: $(OBJS)
112112
add2lib: $(OBJS)
113113
-for i in $(OBJS); do \
114114
if test "$$i" = "signalmodule.o"; then \
115-
ar d $(LIBRARY) sigcheck.o intrcheck.o 2>/dev/null; \
115+
$(AR) d $(LIBRARY) sigcheck.o intrcheck.o 2>/dev/null; \
116116
break; \
117117
fi; \
118118
done

Modules/Setup.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ pwd pwdmodule.c # pwd(3)
142142
grp grpmodule.c # grp(3)
143143
select selectmodule.c # select(2); not on ancient System V
144144
socket socketmodule.c # socket(2); not on ancient System V
145+
#_socket socketmodule.c # socket(2); use this one for BeOS sockets
145146
errno errnomodule.c # posix (UNIX) errno values
146147

147148
# The crypt module is now disabled by default because it breaks builds

Modules/_localemodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fixup_ulcase()
9292
if (isupper(c))
9393
ul[n++] = c;
9494
}
95-
ulo=PyString_FromStringAndSize((char *)ul,n);
95+
ulo=PyString_FromStringAndSize((const char *)ul,n);
9696
if(!ulo)return;
9797
if(string)
9898
PyDict_SetItemString(string,"uppercase",ulo);
@@ -105,7 +105,7 @@ fixup_ulcase()
105105
if (islower(c))
106106
ul[n++] = c;
107107
}
108-
ulo=PyString_FromStringAndSize((char *)ul,n);
108+
ulo=PyString_FromStringAndSize((const char *)ul,n);
109109
if(!ulo)return;
110110
if(string)
111111
PyDict_SetItemString(string,"lowercase",ulo);
@@ -118,7 +118,7 @@ fixup_ulcase()
118118
if (isalpha(c))
119119
ul[n++] = c;
120120
}
121-
ulo=PyString_FromStringAndSize((char *)ul,n);
121+
ulo=PyString_FromStringAndSize((const char *)ul,n);
122122
if(!ulo)return;
123123
if(string)
124124
PyDict_SetItemString(string,"letters",ulo);

Modules/posixmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,6 +2403,11 @@ static char posix_putenv__doc__[] =
24032403
"putenv(key, value) -> None\n\
24042404
Change or add an environment variable.";
24052405

2406+
#ifdef __BEOS__
2407+
/* We have putenv(), but not in the headers (as of PR2). - [cjh] */
2408+
int putenv( const char *str );
2409+
#endif
2410+
24062411
static PyObject *
24072412
posix_putenv(self, args)
24082413
PyObject *self;

Modules/pwdmodule.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ static PyObject *
5151
mkpwent(p)
5252
struct passwd *p;
5353
{
54+
#ifdef __BEOS__
55+
/* For faking the GECOS field. - [cjh] */
56+
char *be_user = NULL;
57+
58+
be_user = getenv( "USER" );
59+
#endif
60+
5461
return Py_BuildValue(
5562
"(ssllsss)",
5663
p->pw_name,
@@ -64,7 +71,12 @@ mkpwent(p)
6471
(long)p->pw_uid,
6572
(long)p->pw_gid,
6673
#endif
74+
#ifdef __BEOS__
75+
/* BeOS doesn't have a GECOS field, oddly enough. - [cjh] */
76+
be_user ? be_user : "baron",
77+
#else
6778
p->pw_gecos,
79+
#endif
6880
p->pw_dir,
6981
p->pw_shell);
7082
}

Modules/readline.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
#endif
1818

1919
/* GNU readline definitions */
20+
/* If you have string.h, you might need to add yourself to this #if... [cjh] */
21+
#if defined(__BEOS__)
22+
#undef HAVE_CONFIG_H
23+
/* At max warnings, we need protos for everything. [cjh] */
24+
#include <readline/readline.h>
25+
#include <readline/history.h>
26+
#include <unistd.h>
27+
#else
2028
#include <readline/readline.h> /* You may need to add an -I option to Setup */
2129

2230
extern int rl_parse_and_bind();
@@ -26,6 +34,7 @@ extern int rl_bind_key();
2634
extern int rl_bind_key_in_map();
2735
extern int rl_initialize();
2836
extern int add_history();
37+
#endif
2938

3039
/* Pointers needed from outside (but not declared in a header file). */
3140
extern int (*PyOS_InputHook)();

Modules/selectmodule.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ PERFORMANCE OF THIS SOFTWARE.
3333
Under Unix, the file descriptors are small integers.
3434
Under Win32, select only exists for sockets, and sockets may
3535
have any value except INVALID_SOCKET.
36+
Under BeOS, we suffer the same dichotomy as Win32; sockets can be anything
37+
>= 0.
3638
*/
3739

3840
#include "Python.h"
@@ -56,9 +58,14 @@ extern void bzero();
5658
#ifdef MS_WINDOWS
5759
#include <winsock.h>
5860
#else
61+
#ifdef __BEOS__
62+
#include <net/socket.h>
63+
#define SOCKET int
64+
#else
5965
#include "myselect.h" /* Also includes mytime.h */
6066
#define SOCKET int
6167
#endif
68+
#endif
6269

6370
static PyObject *SelectError;
6471

@@ -134,7 +141,7 @@ list2set(list, set, fd2obj)
134141
"argument must be an int, or have a fileno() method.");
135142
goto finally;
136143
}
137-
#ifdef _MSC_VER
144+
#if defined(_MSC_VER) || defined(__BEOS__)
138145
max = 0; /* not used for Win32 */
139146
#else /* !_MSC_VER */
140147
if (v < 0 || v >= FD_SETSIZE) {

Modules/socketmodule.c

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Socket methods:
9494
#include <unistd.h>
9595
#endif
9696

97-
#if !defined(MS_WINDOWS) && !defined(PYOS_OS2)
97+
#if !defined(MS_WINDOWS) && !defined(PYOS_OS2) && !defined(__BEOS__)
9898
extern int gethostname(); /* For Solaris, at least */
9999
#endif
100100

@@ -113,6 +113,11 @@ extern int gethostname(); /* For Solaris, at least */
113113
#include <os2.h>
114114
#endif
115115

116+
#if defined(__BEOS__)
117+
/* It's in the libs, but not the headers... - [cjh] */
118+
int shutdown( int, int );
119+
#endif
120+
116121
#include <sys/types.h>
117122
#include "mytime.h"
118123

@@ -147,7 +152,8 @@ extern int gethostname(); /* For Solaris, at least */
147152
it must be compiled by the C++ compiler, as it takes the address of
148153
a static data item exported from the main Python DLL.
149154
*/
150-
#ifdef MS_WINDOWS
155+
#if defined(MS_WINDOWS) || defined(__BEOS__)
156+
/* BeOS suffers from the same socket dichotomy as Win32... - [cjh] */
151157
/* seem to be a few differences in the API */
152158
#define close closesocket
153159
#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)
407413
return Py_None;
408414
}
409415

416+
#ifdef __BEOS__
417+
/* XXX: BeOS version of accept() doesn't set family coreectly */
418+
addr->sa_family = AF_INET;
419+
#endif
420+
410421
switch (addr->sa_family) {
411422

412423
case AF_INET:
@@ -600,6 +611,11 @@ BUILD_FUNC_DEF_2(PySocketSock_setblocking,PySocketSockObject*,s,PyObject*,args)
600611
if (!PyArg_Parse(args, "i", &block))
601612
return NULL;
602613
Py_BEGIN_ALLOW_THREADS
614+
#ifdef __BEOS__
615+
block = !block;
616+
setsockopt( s->sock_fd, SOL_SOCKET, SO_NONBLOCK,
617+
(void *)(&block), sizeof( int ) );
618+
#else
603619
#ifndef MS_WINDOWS
604620
#ifdef PYOS_OS2
605621
block = !block;
@@ -616,6 +632,7 @@ BUILD_FUNC_DEF_2(PySocketSock_setblocking,PySocketSockObject*,s,PyObject*,args)
616632
block = !block;
617633
ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block);
618634
#endif /* MS_WINDOWS */
635+
#endif /* __BEOS__ */
619636
Py_END_ALLOW_THREADS
620637

621638
Py_INCREF(Py_None);
@@ -682,6 +699,12 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args
682699
PyObject *buf;
683700
int buflen = 0;
684701

702+
#ifdef __BEOS__
703+
/* We have incomplete socket support. */
704+
PyErr_SetString( PySocket_Error, "getsockopt not supported" );
705+
return NULL;
706+
#else
707+
685708
if (!PyArg_ParseTuple(args, "ii|i", &level, &optname, &buflen))
686709
return NULL;
687710

@@ -710,6 +733,7 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args
710733
}
711734
_PyString_Resize(&buf, buflen);
712735
return buf;
736+
#endif /* __BEOS__ */
713737
}
714738

715739
static char getsockopt_doc[] =
@@ -1506,6 +1530,11 @@ BUILD_FUNC_DEF_2(PySocket_getprotobyname,PyObject *,self, PyObject *,args)
15061530
{
15071531
char *name;
15081532
struct protoent *sp;
1533+
#ifdef __BEOS__
1534+
/* Not available in BeOS yet. - [cjh] */
1535+
PyErr_SetString( PySocket_Error, "getprotobyname not supported" );
1536+
return NULL;
1537+
#else
15091538
if (!PyArg_Parse(args, "s", &name))
15101539
return NULL;
15111540
Py_BEGIN_ALLOW_THREADS
@@ -1516,6 +1545,7 @@ BUILD_FUNC_DEF_2(PySocket_getprotobyname,PyObject *,self, PyObject *,args)
15161545
return NULL;
15171546
}
15181547
return PyInt_FromLong((long) sp->p_proto);
1548+
#endif
15191549
}
15201550

15211551
static char getprotobyname_doc[] =
@@ -1866,7 +1896,7 @@ shutdown() -- shut down traffic in one or both directions\n\
18661896
(*) not available on all platforms!)";
18671897

18681898
void
1869-
#if defined(MS_WINDOWS) || defined(PYOS_OS2)
1899+
#if defined(MS_WINDOWS) || defined(PYOS_OS2) || defined(__BEOS__)
18701900
init_socket()
18711901
#else
18721902
initsocket()
@@ -1882,8 +1912,12 @@ initsocket()
18821912
if (!OS2init())
18831913
return;
18841914
m = Py_InitModule3("_socket", PySocket_methods, module_doc);
1915+
#else
1916+
#if defined(__BEOS__)
1917+
m = Py_InitModule3("_socket", PySocket_methods, module_doc);
18851918
#else
18861919
m = Py_InitModule3("socket", PySocket_methods, module_doc);
1920+
#endif /* __BEOS__ */
18871921
#endif
18881922
#endif
18891923
d = PyModule_GetDict(m);
@@ -1903,9 +1937,12 @@ initsocket()
19031937
#endif /* AF_UNIX */
19041938
insint(d, "SOCK_STREAM", SOCK_STREAM);
19051939
insint(d, "SOCK_DGRAM", SOCK_DGRAM);
1940+
#ifndef __BEOS__
1941+
/* We have incomplete socket support. */
19061942
insint(d, "SOCK_RAW", SOCK_RAW);
19071943
insint(d, "SOCK_SEQPACKET", SOCK_SEQPACKET);
19081944
insint(d, "SOCK_RDM", SOCK_RDM);
1945+
#endif
19091946

19101947
#ifdef SO_DEBUG
19111948
insint(d, "SO_DEBUG", SO_DEBUG);

Modules/syslogmodule.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ initsyslog()
207207
ins(d, "LOG_PID", LOG_PID);
208208
ins(d, "LOG_CONS", LOG_CONS);
209209
ins(d, "LOG_NDELAY", LOG_NDELAY);
210+
#ifdef LOG_NOWAIT
210211
ins(d, "LOG_NOWAIT", LOG_NOWAIT);
212+
#endif
211213
#ifdef LOG_PERROR
212214
ins(d, "LOG_PERROR", LOG_PERROR);
213215
#endif

Modules/termios.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ This module should be used in conjunction with the TERMIOS module,\n\
2121
which defines the relevant symbolic constants.";
2222

2323

24+
#ifdef __BEOS__
25+
#include <unistd.h>
26+
#endif
27+
2428
#define BAD "bad termios argument"
2529

2630
static PyObject *TermiosError;

0 commit comments

Comments
 (0)