Kaydet (Commit) 7bf6833e authored tarafından Andrew MacIntyre's avatar Andrew MacIntyre

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
üst 38b504e9
...@@ -26,7 +26,7 @@ typedef __int64 hs_time; ...@@ -26,7 +26,7 @@ typedef __int64 hs_time;
#ifndef HAVE_GETTIMEOFDAY #ifndef HAVE_GETTIMEOFDAY
#error "This module requires gettimeofday() on non-Windows platforms!" #error "This module requires gettimeofday() on non-Windows platforms!"
#endif #endif
#ifdef macintosh #if defined(macintosh) || (defined(PYOS_OS2) && defined(PYCC_GCC))
#include <sys/time.h> #include <sys/time.h>
#else #else
#include <sys/resource.h> #include <sys/resource.h>
...@@ -51,6 +51,10 @@ typedef struct timeval hs_time; ...@@ -51,6 +51,10 @@ typedef struct timeval hs_time;
#define PATH_MAX 254 #define PATH_MAX 254
#endif #endif
#if defined(PYOS_OS2) && defined(PYCC_GCC)
#define PATH_MAX 260
#endif
#ifndef PATH_MAX #ifndef PATH_MAX
# ifdef MAX_PATH # ifdef MAX_PATH
# define PATH_MAX MAX_PATH # define PATH_MAX MAX_PATH
...@@ -987,7 +991,7 @@ calibrate(void) ...@@ -987,7 +991,7 @@ calibrate(void)
} }
#endif #endif
} }
#if defined(MS_WIN32) || defined(macintosh) #if defined(MS_WIN32) || defined(macintosh) || defined(PYOS_OS2)
rusage_diff = -1; rusage_diff = -1;
#else #else
{ {
......
...@@ -13,7 +13,11 @@ ...@@ -13,7 +13,11 @@
*/ */
#if defined(HAVE_NDBM_H) #if defined(HAVE_NDBM_H)
#include <ndbm.h> #include <ndbm.h>
#if defined(PYOS_OS2) && !defined(PYCC_GCC)
static char *which_dbm = "ndbm"; static char *which_dbm = "ndbm";
#else
static char *which_dbm = "GNU gdbm"; /* EMX port of GDBM */
#endif
#elif defined(HAVE_DB1_NDBM_H) #elif defined(HAVE_DB1_NDBM_H)
#include <db1/ndbm.h> #include <db1/ndbm.h>
static char *which_dbm = "BSD db"; static char *which_dbm = "BSD db";
......
...@@ -222,12 +222,17 @@ fcntl_lockf(PyObject *self, PyObject *args) ...@@ -222,12 +222,17 @@ fcntl_lockf(PyObject *self, PyObject *args)
&lenobj, &startobj, &whence)) &lenobj, &startobj, &whence))
return NULL; return NULL;
#if defined(PYOS_OS2) && defined(PYCC_GCC)
PyErr_SetString(PyExc_NotImplementedError,
"lockf not supported on OS/2 (EMX)");
return NULL;
#else
#ifndef LOCK_SH #ifndef LOCK_SH
#define LOCK_SH 1 /* shared lock */ #define LOCK_SH 1 /* shared lock */
#define LOCK_EX 2 /* exclusive lock */ #define LOCK_EX 2 /* exclusive lock */
#define LOCK_NB 4 /* don't block when locking */ #define LOCK_NB 4 /* don't block when locking */
#define LOCK_UN 8 /* unlock */ #define LOCK_UN 8 /* unlock */
#endif #endif /* LOCK_SH */
{ {
struct flock l; struct flock l;
if (code == LOCK_UN) if (code == LOCK_UN)
...@@ -275,6 +280,7 @@ fcntl_lockf(PyObject *self, PyObject *args) ...@@ -275,6 +280,7 @@ fcntl_lockf(PyObject *self, PyObject *args)
} }
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */
} }
static char lockf_doc [] = static char lockf_doc [] =
......
...@@ -8,11 +8,15 @@ ...@@ -8,11 +8,15 @@
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#if defined(PYOS_OS2) || defined(MS_WINDOWS) #if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS)
#define PYTHONHOMEHELP "<prefix>\\lib" #define PYTHONHOMEHELP "<prefix>\\lib"
#else #else
#if defined(PYOS_OS2) && defined(PYCC_GCC)
#define PYTHONHOMEHELP "<prefix>/Lib"
#else
#define PYTHONHOMEHELP "<prefix>/pythonX.X" #define PYTHONHOMEHELP "<prefix>/pythonX.X"
#endif #endif
#endif
#include "pygetopt.h" #include "pygetopt.h"
......
...@@ -128,8 +128,12 @@ pwd_getpwall(PyObject *self, PyObject *args) ...@@ -128,8 +128,12 @@ pwd_getpwall(PyObject *self, PyObject *args)
return NULL; return NULL;
if ((d = PyList_New(0)) == NULL) if ((d = PyList_New(0)) == NULL)
return NULL; return NULL;
#if defined(PYOS_OS2) && defined(PYCC_GCC)
if ((p = getpwuid(0)) != NULL) {
#else
setpwent(); setpwent();
while ((p = getpwent()) != NULL) { while ((p = getpwent()) != NULL) {
#endif
PyObject *v = mkpwent(p); PyObject *v = mkpwent(p);
if (v == NULL || PyList_Append(d, v) != 0) { if (v == NULL || PyList_Append(d, v) != 0) {
Py_XDECREF(v); Py_XDECREF(v);
......
...@@ -507,6 +507,10 @@ static void ...@@ -507,6 +507,10 @@ static void
setup_readline(void) setup_readline(void)
{ {
rl_readline_name = "python"; rl_readline_name = "python";
#if defined(PYOS_OS2) && defined(PYCC_GCC)
/* Allow $if term= in .inputrc to work */
rl_terminal_name = getenv("TERM");
#endif
/* Force rebind of TAB to insert-tab */ /* Force rebind of TAB to insert-tab */
rl_bind_key('\t', rl_insert); rl_bind_key('\t', rl_insert);
/* Bind both ESC-TAB and ESC-ESC to the completion function */ /* Bind both ESC-TAB and ESC-ESC to the completion function */
......
...@@ -33,7 +33,7 @@ extern void bzero(void *, int); ...@@ -33,7 +33,7 @@ extern void bzero(void *, int);
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#if defined(PYOS_OS2) #if defined(PYOS_OS2) && !defined(PYCC_GCC)
#include <sys/time.h> #include <sys/time.h>
#include <utils.h> #include <utils.h>
#endif #endif
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#define SIG_ERR ((PyOS_sighandler_t)(-1)) #define SIG_ERR ((PyOS_sighandler_t)(-1))
#endif #endif
#if defined(PYOS_OS2) #if defined(PYOS_OS2) && !defined(PYCC_GCC)
#define NSIG 12 #define NSIG 12
#include <process.h> #include <process.h>
#endif #endif
......
...@@ -384,7 +384,9 @@ static struct constant { ...@@ -384,7 +384,9 @@ static struct constant {
#ifdef OLCUC #ifdef OLCUC
{"OLCUC", OLCUC}, {"OLCUC", OLCUC},
#endif #endif
#ifdef ONLCR
{"ONLCR", ONLCR}, {"ONLCR", ONLCR},
#endif
#ifdef OCRNL #ifdef OCRNL
{"OCRNL", OCRNL}, {"OCRNL", OCRNL},
#endif #endif
...@@ -552,7 +554,9 @@ static struct constant { ...@@ -552,7 +554,9 @@ static struct constant {
#ifdef VLNEXT #ifdef VLNEXT
{"VLNEXT", VLNEXT}, {"VLNEXT", VLNEXT},
#endif #endif
#ifdef VEOL2
{"VEOL2", VEOL2}, {"VEOL2", VEOL2},
#endif
#ifdef B460800 #ifdef B460800
......
...@@ -54,6 +54,12 @@ extern int ftime(struct timeb *); ...@@ -54,6 +54,12 @@ extern int ftime(struct timeb *);
#undef HAVE_CLOCK /* We have our own version down below */ #undef HAVE_CLOCK /* We have our own version down below */
#endif /* MS_WIN32 && !MS_WIN64 */ #endif /* MS_WIN32 && !MS_WIN64 */
#if defined(PYOS_OS2)
#define INCL_DOS
#define INCL_ERRORS
#include <os2.h>
#endif
#if defined(PYCC_VACPP) #if defined(PYCC_VACPP)
#include <sys/time.h> #include <sys/time.h>
#endif #endif
...@@ -752,7 +758,7 @@ static int ...@@ -752,7 +758,7 @@ static int
floatsleep(double secs) floatsleep(double secs)
{ {
/* XXX Should test for MS_WIN32 first! */ /* XXX Should test for MS_WIN32 first! */
#if defined(HAVE_SELECT) && !defined(__BEOS__) #if defined(HAVE_SELECT) && !defined(__BEOS__) && !defined(__EMX__)
struct timeval t; struct timeval t;
double frac; double frac;
frac = fmod(secs, 1.0); frac = fmod(secs, 1.0);
......
...@@ -277,7 +277,7 @@ _gethash(const char *s, int len, int scale) ...@@ -277,7 +277,7 @@ _gethash(const char *s, int len, int scale)
} }
static int static int
_getname(Py_UCS4 code, char* buffer, int buflen) _Py_getname(Py_UCS4 code, char* buffer, int buflen)
{ {
int offset; int offset;
int i; int i;
...@@ -334,7 +334,7 @@ _cmpname(int code, const char* name, int namelen) ...@@ -334,7 +334,7 @@ _cmpname(int code, const char* name, int namelen)
/* check if code corresponds to the given name */ /* check if code corresponds to the given name */
int i; int i;
char buffer[NAME_MAXLEN]; char buffer[NAME_MAXLEN];
if (!_getname(code, buffer, sizeof(buffer))) if (!_Py_getname(code, buffer, sizeof(buffer)))
return 0; return 0;
for (i = 0; i < namelen; i++) { for (i = 0; i < namelen; i++) {
if (toupper(name[i]) != buffer[i]) if (toupper(name[i]) != buffer[i])
...@@ -384,7 +384,7 @@ _getcode(const char* name, int namelen, Py_UCS4* code) ...@@ -384,7 +384,7 @@ _getcode(const char* name, int namelen, Py_UCS4* code)
static const _PyUnicode_Name_CAPI hashAPI = static const _PyUnicode_Name_CAPI hashAPI =
{ {
sizeof(_PyUnicode_Name_CAPI), sizeof(_PyUnicode_Name_CAPI),
_getname, _Py_getname,
_getcode _getcode
}; };
...@@ -407,7 +407,7 @@ unicodedata_name(PyObject* self, PyObject* args) ...@@ -407,7 +407,7 @@ unicodedata_name(PyObject* self, PyObject* args)
return NULL; return NULL;
} }
if (!_getname((Py_UCS4) *PyUnicode_AS_UNICODE(v), if (!_Py_getname((Py_UCS4) *PyUnicode_AS_UNICODE(v),
name, sizeof(name))) { name, sizeof(name))) {
if (defobj == NULL) { if (defobj == NULL) {
PyErr_SetString(PyExc_ValueError, "no such name"); PyErr_SetString(PyExc_ValueError, "no such name");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment