Commit c16f3bd8 authored by Martin v. Löwis's avatar Martin v. Löwis

Patch #708495: Port more stuff to OpenVMS.

parent e59e2bab
...@@ -1309,7 +1309,9 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs) ...@@ -1309,7 +1309,9 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
break; break;
case 'U': case 'U':
#ifdef WITH_UNIVERSAL_NEWLINES
self->f_univ_newline = 1; self->f_univ_newline = 1;
#endif
break; break;
default: default:
......
...@@ -182,7 +182,11 @@ fcntl_ioctl(PyObject *self, PyObject *args) ...@@ -182,7 +182,11 @@ fcntl_ioctl(PyObject *self, PyObject *args)
return NULL; return NULL;
} }
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
#ifdef __VMS
ret = ioctl(fd, code, (void *)arg);
#else
ret = ioctl(fd, code, arg); ret = ioctl(fd, code, arg);
#endif
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (ret < 0) { if (ret < 0) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
......
...@@ -188,6 +188,10 @@ static void fpe_reset(Sigfunc *handler) ...@@ -188,6 +188,10 @@ static void fpe_reset(Sigfunc *handler)
ieee_set_fp_control(fp_control); ieee_set_fp_control(fp_control);
PyOS_setsig(SIGFPE, handler); PyOS_setsig(SIGFPE, handler);
/*-- DEC ALPHA VMS --------------------------------------------------------*/
#elif defined(__ALPHA) && defined(__VMS)
PyOS_setsig(SIGFPE, handler);
/*-- Cray Unicos ----------------------------------------------------------*/ /*-- Cray Unicos ----------------------------------------------------------*/
#elif defined(cray) #elif defined(cray)
/* UNICOS delivers SIGFPE by default, but no matherr */ /* UNICOS delivers SIGFPE by default, but no matherr */
......
...@@ -58,12 +58,17 @@ mkgrent(struct group *p) ...@@ -58,12 +58,17 @@ mkgrent(struct group *p)
#define SET(i,val) PyStructSequence_SET_ITEM(v, i, val) #define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
SET(setIndex++, PyString_FromString(p->gr_name)); SET(setIndex++, PyString_FromString(p->gr_name));
#ifdef __VMS
SET(setIndex++, Py_None);
Py_INCREF(Py_None);
#else
if (p->gr_passwd) if (p->gr_passwd)
SET(setIndex++, PyString_FromString(p->gr_passwd)); SET(setIndex++, PyString_FromString(p->gr_passwd));
else { else {
SET(setIndex++, Py_None); SET(setIndex++, Py_None);
Py_INCREF(Py_None); Py_INCREF(Py_None);
} }
#endif
SET(setIndex++, PyInt_FromLong((long) p->gr_gid)); SET(setIndex++, PyInt_FromLong((long) p->gr_gid));
SET(setIndex++, w); SET(setIndex++, w);
#undef SET #undef SET
......
...@@ -897,6 +897,10 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) ...@@ -897,6 +897,10 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
} }
#ifdef HAVE_FSTAT #ifdef HAVE_FSTAT
# ifdef __VMS
/* on OpenVMS we must ensure that all bytes are written to the file */
fsync(fd);
# endif
if (fstat(fd, &st) == 0 && (size_t)map_size > st.st_size) { if (fstat(fd, &st) == 0 && (size_t)map_size > st.st_size) {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"mmap length is greater than file size"); "mmap length is greater than file size");
......
...@@ -17,18 +17,7 @@ ...@@ -17,18 +17,7 @@
#include "structseq.h" #include "structseq.h"
#if defined(__VMS) #if defined(__VMS)
# include <ctype.h> /* tolower() */
# include <descrip.h> /* string descriptors */
# include <dvidef.h> /* DVI$_name */
# include <file.h> /* -> O_RDWR */
# include <jpidef.h> /* JPI$_name */
# include <lib$routines.h> /* LIB$name */
# include <ots$routines.h> /* OTS$name */
# include <ssdef.h> /* SS$_name */
# include <unixio.h> # include <unixio.h>
# include <unixlib.h>
# include <stat.h>
# include <wait.h> /* define wait() */
#endif /* defined(__VMS) */ #endif /* defined(__VMS) */
PyDoc_STRVAR(posix__doc__, PyDoc_STRVAR(posix__doc__,
...@@ -325,63 +314,6 @@ static char **environ; ...@@ -325,63 +314,6 @@ static char **environ;
extern char **environ; extern char **environ;
#endif /* !_MSC_VER */ #endif /* !_MSC_VER */
#if defined(__VMS)
/* add some values to provide a similar environment like POSIX */
static
void
vms_add_posix_env(PyObject *d)
{
PyObject *o;
char* str;
str = getenv("LINES");
o = Py_BuildValue("s", str);
if (o != NULL) {
(void)PyDict_SetItemString(d, "LINES", o);
Py_DECREF(o);
}
str = getenv("COLUMNS");
o = Py_BuildValue("s", str);
if (o != NULL) {
(void)PyDict_SetItemString(d, "COLUMNS", o);
Py_DECREF(o);
}
str = getenv("USER");
o = Py_BuildValue("s", str);
if (o != NULL) {
(void)PyDict_SetItemString(d, "USERNAME", o);
Py_DECREF(o);
}
o = Py_BuildValue("s", str);
if (o != NULL) {
(void)PyDict_SetItemString(d, "LOGNAME", o);
Py_DECREF(o);
}
str = getenv("HOME");
o = Py_BuildValue("s", str);
if (o != NULL) {
(void)PyDict_SetItemString(d, "HOME", o);
Py_DECREF(o);
}
str = getenv("PATH");
o = Py_BuildValue("s", str);
if (o != NULL) {
(void)PyDict_SetItemString(d, "PATH", o);
Py_DECREF(o);
}
/* OS = "OpenVMS" */
o = PyString_FromString ("OpenVMS");
if (o != NULL) {
(void)PyDict_SetItemString(d, "OS", o);
Py_DECREF(o);
}
}
#endif /* __VMS */
static PyObject * static PyObject *
convertenviron(void) convertenviron(void)
{ {
...@@ -421,9 +353,7 @@ convertenviron(void) ...@@ -421,9 +353,7 @@ convertenviron(void)
Py_DECREF(k); Py_DECREF(k);
Py_DECREF(v); Py_DECREF(v);
} }
#if defined(__VMS) #if defined(PYOS_OS2)
vms_add_posix_env(d);
#elif defined(PYOS_OS2)
{ {
APIRET rc; APIRET rc;
char buffer[1024]; /* OS/2 Provides a Documented Max of 1024 Chars */ char buffer[1024]; /* OS/2 Provides a Documented Max of 1024 Chars */
...@@ -1133,7 +1063,7 @@ posix_ttyname(PyObject *self, PyObject *args) ...@@ -1133,7 +1063,7 @@ posix_ttyname(PyObject *self, PyObject *args)
return NULL; return NULL;
#if defined(__VMS) #if defined(__VMS)
/* DECC V5.0 - only about FD= 0 @@ try getname()+$getdvi(dvi$_devnam) */ /* file descriptor 0 only, the default input device (stdin) */
if (id == 0) { if (id == 0) {
ret = ttyname(); ret = ttyname();
} }
...@@ -1339,9 +1269,6 @@ posix_getcwd(PyObject *self, PyObject *noargs) ...@@ -1339,9 +1269,6 @@ posix_getcwd(PyObject *self, PyObject *noargs)
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
#if defined(PYOS_OS2) && defined(PYCC_GCC) #if defined(PYOS_OS2) && defined(PYCC_GCC)
res = _getcwd2(buf, sizeof buf); res = _getcwd2(buf, sizeof buf);
#elif defined(__VMS)
/* 0 = force Unix-style path if in the VMS DCL environment! */
res = getcwd(buf, sizeof buf, 0);
#else #else
res = getcwd(buf, sizeof buf); res = getcwd(buf, sizeof buf);
#endif #endif
...@@ -1378,9 +1305,6 @@ posix_getcwdu(PyObject *self, PyObject *noargs) ...@@ -1378,9 +1305,6 @@ posix_getcwdu(PyObject *self, PyObject *noargs)
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
#if defined(PYOS_OS2) && defined(PYCC_GCC) #if defined(PYOS_OS2) && defined(PYCC_GCC)
res = _getcwd2(buf, sizeof buf); res = _getcwd2(buf, sizeof buf);
#elif defined(__VMS)
/* 0 = force Unix-style path if in the VMS DCL environment! */
res = getcwd(buf, sizeof buf, 0);
#else #else
res = getcwd(buf, sizeof buf); res = getcwd(buf, sizeof buf);
#endif #endif
...@@ -5183,11 +5107,7 @@ posix_pipe(PyObject *self, PyObject *noargs) ...@@ -5183,11 +5107,7 @@ posix_pipe(PyObject *self, PyObject *noargs)
int fds[2]; int fds[2];
int res; int res;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
#if defined(__VMS)
res = pipe(fds,0,2100); /* bigger mailbox quota than 512 */
#else
res = pipe(fds); res = pipe(fds);
#endif
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (res != 0) if (res != 0)
return posix_error(); return posix_error();
......
...@@ -2199,7 +2199,11 @@ static PyObject * ...@@ -2199,7 +2199,11 @@ static PyObject *
socket_gethostbyname(PyObject *self, PyObject *args) socket_gethostbyname(PyObject *self, PyObject *args)
{ {
char *name; char *name;
#ifdef ENABLE_IPV6
struct sockaddr_storage addrbuf; struct sockaddr_storage addrbuf;
#else
struct sockaddr_in addrbuf;
#endif
if (!PyArg_ParseTuple(args, "s:gethostbyname", &name)) if (!PyArg_ParseTuple(args, "s:gethostbyname", &name))
return NULL; return NULL;
...@@ -2357,7 +2361,11 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args) ...@@ -2357,7 +2361,11 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args)
{ {
char *name; char *name;
struct hostent *h; struct hostent *h;
struct sockaddr_storage addr; #ifdef ENABLE_IPV6
struct sockaddr_storage addr;
#else
struct sockaddr_in addr;
#endif
struct sockaddr *sa; struct sockaddr *sa;
PyObject *ret; PyObject *ret;
#ifdef HAVE_GETHOSTBYNAME_R #ifdef HAVE_GETHOSTBYNAME_R
......
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
/* Includes needed for the sockaddr_* symbols below */ /* Includes needed for the sockaddr_* symbols below */
#ifndef MS_WINDOWS #ifndef MS_WINDOWS
# include <sys/socket.h> #ifdef __VMS
# include <socket.h>
# else
# include <sys/socket.h>
# endif
# include <netinet/in.h> # include <netinet/in.h>
# if !(defined(__BEOS__) || defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP))) # if !(defined(__BEOS__) || defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP)))
# include <netinet/tcp.h> # include <netinet/tcp.h>
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
#include "windows.h" #include "windows.h"
#endif /* MS_WINDOWS */ #endif /* MS_WINDOWS */
#ifdef __VMS
extern char* vms__StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt);
#endif
int (*PyOS_InputHook)(void) = NULL; int (*PyOS_InputHook)(void) = NULL;
#ifdef RISCOS #ifdef RISCOS
...@@ -159,7 +163,11 @@ PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) ...@@ -159,7 +163,11 @@ PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
char *rv; char *rv;
if (PyOS_ReadlineFunctionPointer == NULL) { if (PyOS_ReadlineFunctionPointer == NULL) {
#ifdef __VMS
PyOS_ReadlineFunctionPointer = vms__StdioReadline;
#else
PyOS_ReadlineFunctionPointer = PyOS_StdioReadline; PyOS_ReadlineFunctionPointer = PyOS_StdioReadline;
#endif
} }
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
......
...@@ -39,17 +39,28 @@ const struct filedescr _PyImport_DynLoadFiletab[] = { ...@@ -39,17 +39,28 @@ const struct filedescr _PyImport_DynLoadFiletab[] = {
#if defined(PYOS_OS2) && defined(PYCC_GCC) #if defined(PYOS_OS2) && defined(PYCC_GCC)
{".pyd", "rb", C_EXTENSION}, {".pyd", "rb", C_EXTENSION},
{".dll", "rb", C_EXTENSION}, {".dll", "rb", C_EXTENSION},
#else
#ifdef __VMS
{".exe", "rb", C_EXTENSION},
{".EXE", "rb", C_EXTENSION},
{"module.exe", "rb", C_EXTENSION},
{"MODULE.EXE", "rb", C_EXTENSION},
#else #else
{".so", "rb", C_EXTENSION}, {".so", "rb", C_EXTENSION},
{"module.so", "rb", C_EXTENSION}, {"module.so", "rb", C_EXTENSION},
#endif #endif
#endif
#endif #endif
{0, 0} {0, 0}
}; };
static struct { static struct {
dev_t dev; dev_t dev;
#ifdef __VMS
ino_t ino[3];
#else
ino_t ino; ino_t ino;
#endif
void *handle; void *handle;
} handles[128]; } handles[128];
static int nhandles = 0; static int nhandles = 0;
...@@ -87,7 +98,13 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, ...@@ -87,7 +98,13 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
} }
if (nhandles < 128) { if (nhandles < 128) {
handles[nhandles].dev = statb.st_dev; handles[nhandles].dev = statb.st_dev;
#ifdef __VMS
handles[nhandles].ino[0] = statb.st_ino[0];
handles[nhandles].ino[1] = statb.st_ino[1];
handles[nhandles].ino[2] = statb.st_ino[2];
#else
handles[nhandles].ino = statb.st_ino; handles[nhandles].ino = statb.st_ino;
#endif
} }
} }
...@@ -98,6 +115,17 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, ...@@ -98,6 +115,17 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
if (Py_VerboseFlag) if (Py_VerboseFlag)
printf("dlopen(\"%s\", %x);\n", pathname, dlopenflags); printf("dlopen(\"%s\", %x);\n", pathname, dlopenflags);
#ifdef __VMS
/* VMS currently don't allow a pathname, use a logical name instead */
/* Concatenate 'python_module_' and shortname */
/* so "import vms.bar" will use the logical python_module_bar */
/* As C module use only one name space this is probably not a */
/* important limitation */
PyOS_snprintf(pathbuf, sizeof(pathbuf), "python_module_%-.200s",
shortname);
pathname = pathbuf;
#endif
handle = dlopen(pathname, dlopenflags); handle = dlopen(pathname, dlopenflags);
if (handle == NULL) { if (handle == NULL) {
......
...@@ -32,6 +32,10 @@ extern void *PyWin_DLLhModule; ...@@ -32,6 +32,10 @@ extern void *PyWin_DLLhModule;
extern const char *PyWin_DLLVersionString; extern const char *PyWin_DLLVersionString;
#endif #endif
#ifdef __VMS
#include <unixlib.h>
#endif
PyObject * PyObject *
PySys_GetObject(char *name) PySys_GetObject(char *name)
{ {
...@@ -1050,7 +1054,22 @@ makeargvobject(int argc, char **argv) ...@@ -1050,7 +1054,22 @@ makeargvobject(int argc, char **argv)
if (av != NULL) { if (av != NULL) {
int i; int i;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
#ifdef __VMS
PyObject *v;
/* argv[0] is the script pathname if known */
if (i == 0) {
char* fn = decc$translate_vms(argv[0]);
if ((fn == (char *)0) || fn == (char *)-1)
v = PyString_FromString(argv[0]);
else
v = PyString_FromString(
decc$translate_vms(argv[0]));
} else
v = PyString_FromString(argv[i]);
#else
PyObject *v = PyString_FromString(argv[i]); PyObject *v = PyString_FromString(argv[i]);
#endif
if (v == NULL) { if (v == NULL) {
Py_DECREF(av); Py_DECREF(av);
av = NULL; av = NULL;
......
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