Skip to content

Commit 7bf6833

Browse files
author
Andrew MacIntyre
committed
OS/2 EMX port changes (Modules part of patch #450267):
Modules/ _hotshot.c dbmmodule.c fcntlmodule.c main.c pwdmodule.c readline.c selectmodule.c signalmodule.c termios.c timemodule.c unicodedata.c
1 parent 38b504e commit 7bf6833

11 files changed

+47
-11
lines changed

Modules/_hotshot.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef __int64 hs_time;
2626
#ifndef HAVE_GETTIMEOFDAY
2727
#error "This module requires gettimeofday() on non-Windows platforms!"
2828
#endif
29-
#ifdef macintosh
29+
#if defined(macintosh) || (defined(PYOS_OS2) && defined(PYCC_GCC))
3030
#include <sys/time.h>
3131
#else
3232
#include <sys/resource.h>
@@ -51,6 +51,10 @@ typedef struct timeval hs_time;
5151
#define PATH_MAX 254
5252
#endif
5353

54+
#if defined(PYOS_OS2) && defined(PYCC_GCC)
55+
#define PATH_MAX 260
56+
#endif
57+
5458
#ifndef PATH_MAX
5559
# ifdef MAX_PATH
5660
# define PATH_MAX MAX_PATH
@@ -987,7 +991,7 @@ calibrate(void)
987991
}
988992
#endif
989993
}
990-
#if defined(MS_WIN32) || defined(macintosh)
994+
#if defined(MS_WIN32) || defined(macintosh) || defined(PYOS_OS2)
991995
rusage_diff = -1;
992996
#else
993997
{

Modules/dbmmodule.c

+4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
*/
1414
#if defined(HAVE_NDBM_H)
1515
#include <ndbm.h>
16+
#if defined(PYOS_OS2) && !defined(PYCC_GCC)
1617
static char *which_dbm = "ndbm";
18+
#else
19+
static char *which_dbm = "GNU gdbm"; /* EMX port of GDBM */
20+
#endif
1721
#elif defined(HAVE_DB1_NDBM_H)
1822
#include <db1/ndbm.h>
1923
static char *which_dbm = "BSD db";

Modules/fcntlmodule.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,17 @@ fcntl_lockf(PyObject *self, PyObject *args)
222222
&lenobj, &startobj, &whence))
223223
return NULL;
224224

225+
#if defined(PYOS_OS2) && defined(PYCC_GCC)
226+
PyErr_SetString(PyExc_NotImplementedError,
227+
"lockf not supported on OS/2 (EMX)");
228+
return NULL;
229+
#else
225230
#ifndef LOCK_SH
226231
#define LOCK_SH 1 /* shared lock */
227232
#define LOCK_EX 2 /* exclusive lock */
228233
#define LOCK_NB 4 /* don't block when locking */
229234
#define LOCK_UN 8 /* unlock */
230-
#endif
235+
#endif /* LOCK_SH */
231236
{
232237
struct flock l;
233238
if (code == LOCK_UN)
@@ -275,6 +280,7 @@ fcntl_lockf(PyObject *self, PyObject *args)
275280
}
276281
Py_INCREF(Py_None);
277282
return Py_None;
283+
#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */
278284
}
279285

280286
static char lockf_doc [] =

Modules/main.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
#include <fcntl.h>
99
#endif
1010

11-
#if defined(PYOS_OS2) || defined(MS_WINDOWS)
11+
#if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS)
1212
#define PYTHONHOMEHELP "<prefix>\\lib"
1313
#else
14+
#if defined(PYOS_OS2) && defined(PYCC_GCC)
15+
#define PYTHONHOMEHELP "<prefix>/Lib"
16+
#else
1417
#define PYTHONHOMEHELP "<prefix>/pythonX.X"
1518
#endif
19+
#endif
1620

1721
#include "pygetopt.h"
1822

Modules/pwdmodule.c

+4
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ pwd_getpwall(PyObject *self, PyObject *args)
128128
return NULL;
129129
if ((d = PyList_New(0)) == NULL)
130130
return NULL;
131+
#if defined(PYOS_OS2) && defined(PYCC_GCC)
132+
if ((p = getpwuid(0)) != NULL) {
133+
#else
131134
setpwent();
132135
while ((p = getpwent()) != NULL) {
136+
#endif
133137
PyObject *v = mkpwent(p);
134138
if (v == NULL || PyList_Append(d, v) != 0) {
135139
Py_XDECREF(v);

Modules/readline.c

+4
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,10 @@ static void
507507
setup_readline(void)
508508
{
509509
rl_readline_name = "python";
510+
#if defined(PYOS_OS2) && defined(PYCC_GCC)
511+
/* Allow $if term= in .inputrc to work */
512+
rl_terminal_name = getenv("TERM");
513+
#endif
510514
/* Force rebind of TAB to insert-tab */
511515
rl_bind_key('\t', rl_insert);
512516
/* Bind both ESC-TAB and ESC-ESC to the completion function */

Modules/selectmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern void bzero(void *, int);
3333
#include <sys/types.h>
3434
#endif
3535

36-
#if defined(PYOS_OS2)
36+
#if defined(PYOS_OS2) && !defined(PYCC_GCC)
3737
#include <sys/time.h>
3838
#include <utils.h>
3939
#endif

Modules/signalmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define SIG_ERR ((PyOS_sighandler_t)(-1))
1717
#endif
1818

19-
#if defined(PYOS_OS2)
19+
#if defined(PYOS_OS2) && !defined(PYCC_GCC)
2020
#define NSIG 12
2121
#include <process.h>
2222
#endif

Modules/termios.c

+4
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ static struct constant {
384384
#ifdef OLCUC
385385
{"OLCUC", OLCUC},
386386
#endif
387+
#ifdef ONLCR
387388
{"ONLCR", ONLCR},
389+
#endif
388390
#ifdef OCRNL
389391
{"OCRNL", OCRNL},
390392
#endif
@@ -552,7 +554,9 @@ static struct constant {
552554
#ifdef VLNEXT
553555
{"VLNEXT", VLNEXT},
554556
#endif
557+
#ifdef VEOL2
555558
{"VEOL2", VEOL2},
559+
#endif
556560

557561

558562
#ifdef B460800

Modules/timemodule.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ extern int ftime(struct timeb *);
5454
#undef HAVE_CLOCK /* We have our own version down below */
5555
#endif /* MS_WIN32 && !MS_WIN64 */
5656

57+
#if defined(PYOS_OS2)
58+
#define INCL_DOS
59+
#define INCL_ERRORS
60+
#include <os2.h>
61+
#endif
62+
5763
#if defined(PYCC_VACPP)
5864
#include <sys/time.h>
5965
#endif
@@ -752,7 +758,7 @@ static int
752758
floatsleep(double secs)
753759
{
754760
/* XXX Should test for MS_WIN32 first! */
755-
#if defined(HAVE_SELECT) && !defined(__BEOS__)
761+
#if defined(HAVE_SELECT) && !defined(__BEOS__) && !defined(__EMX__)
756762
struct timeval t;
757763
double frac;
758764
frac = fmod(secs, 1.0);

Modules/unicodedata.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ _gethash(const char *s, int len, int scale)
277277
}
278278

279279
static int
280-
_getname(Py_UCS4 code, char* buffer, int buflen)
280+
_Py_getname(Py_UCS4 code, char* buffer, int buflen)
281281
{
282282
int offset;
283283
int i;
@@ -334,7 +334,7 @@ _cmpname(int code, const char* name, int namelen)
334334
/* check if code corresponds to the given name */
335335
int i;
336336
char buffer[NAME_MAXLEN];
337-
if (!_getname(code, buffer, sizeof(buffer)))
337+
if (!_Py_getname(code, buffer, sizeof(buffer)))
338338
return 0;
339339
for (i = 0; i < namelen; i++) {
340340
if (toupper(name[i]) != buffer[i])
@@ -384,7 +384,7 @@ _getcode(const char* name, int namelen, Py_UCS4* code)
384384
static const _PyUnicode_Name_CAPI hashAPI =
385385
{
386386
sizeof(_PyUnicode_Name_CAPI),
387-
_getname,
387+
_Py_getname,
388388
_getcode
389389
};
390390

@@ -407,7 +407,7 @@ unicodedata_name(PyObject* self, PyObject* args)
407407
return NULL;
408408
}
409409

410-
if (!_getname((Py_UCS4) *PyUnicode_AS_UNICODE(v),
410+
if (!_Py_getname((Py_UCS4) *PyUnicode_AS_UNICODE(v),
411411
name, sizeof(name))) {
412412
if (defobj == NULL) {
413413
PyErr_SetString(PyExc_ValueError, "no such name");

0 commit comments

Comments
 (0)