Skip to content

Commit 94d3efe

Browse files
author
neal.norwitz
committed
Patch #1516912: improve Modules support for OpenVMS.
git-svn-id: http://svn.python.org/projects/python/trunk@50504 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 2f96f77 commit 94d3efe

File tree

9 files changed

+154
-63
lines changed

9 files changed

+154
-63
lines changed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ Extension Modules
108108
- Bug #1296433: parsing XML with a non-default encoding and
109109
a CharacterDataHandler could crash the interpreter in pyexpat.
110110

111+
- Patch #1516912: improve Modules support for OpenVMS.
112+
111113
Build
112114
-----
113115

Modules/bz2module.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,11 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
13111311
break;
13121312

13131313
case 'U':
1314+
#ifdef __VMS
1315+
self->f_univ_newline = 0;
1316+
#else
13141317
self->f_univ_newline = 1;
1318+
#endif
13151319
break;
13161320

13171321
default:

Modules/cryptmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55

66
#include <sys/types.h>
77

8+
#ifdef __VMS
9+
#include <openssl/des.h>
10+
#endif
811

912
/* Module crypt */
1013

1114

1215
static PyObject *crypt_crypt(PyObject *self, PyObject *args)
1316
{
1417
char *word, *salt;
18+
#ifndef __VMS
1519
extern char * crypt(const char *, const char *);
20+
#endif
1621

1722
if (!PyArg_ParseTuple(args, "ss:crypt", &word, &salt)) {
1823
return NULL;

Modules/dlmodule.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
#include <dlfcn.h>
77

8+
#ifdef __VMS
9+
#include <unistd.h>
10+
#endif
11+
812
#ifndef RTLD_LAZY
913
#define RTLD_LAZY 1
1014
#endif
@@ -186,6 +190,24 @@ dl_open(PyObject *self, PyObject *args)
186190
PyErr_SetString(Dlerror, dlerror());
187191
return NULL;
188192
}
193+
#ifdef __VMS
194+
/* Under OpenVMS dlopen doesn't do any check, just save the name
195+
* for later use, so we have to check if the file is readable,
196+
* the name can be a logical or a file from SYS$SHARE.
197+
*/
198+
if (access(name, R_OK)) {
199+
char fname[strlen(name) + 20];
200+
strcpy(fname, "SYS$SHARE:");
201+
strcat(fname, name);
202+
strcat(fname, ".EXE");
203+
if (access(fname, R_OK)) {
204+
dlclose(handle);
205+
PyErr_SetString(Dlerror,
206+
"File not found or protection violation");
207+
return NULL;
208+
}
209+
}
210+
#endif
189211
return newdlobject(handle);
190212
}
191213

Modules/fpectlmodule.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ extern "C" {
7070

7171
#if defined(__FreeBSD__)
7272
# include <ieeefp.h>
73+
#elif defined(__VMS)
74+
#define __NEW_STARLET
75+
#include <starlet.h>
76+
#include <ieeedef.h>
7377
#endif
7478

7579
#ifndef WANT_SIGFPE_HANDLER
@@ -190,6 +194,19 @@ static void fpe_reset(Sigfunc *handler)
190194

191195
/*-- DEC ALPHA VMS --------------------------------------------------------*/
192196
#elif defined(__ALPHA) && defined(__VMS)
197+
IEEE clrmsk;
198+
IEEE setmsk;
199+
clrmsk.ieee$q_flags =
200+
IEEE$M_TRAP_ENABLE_UNF | IEEE$M_TRAP_ENABLE_INE |
201+
IEEE$M_MAP_UMZ;
202+
setmsk.ieee$q_flags =
203+
IEEE$M_TRAP_ENABLE_INV | IEEE$M_TRAP_ENABLE_DZE |
204+
IEEE$M_TRAP_ENABLE_OVF;
205+
sys$ieee_set_fp_control(&clrmsk, &setmsk, 0);
206+
PyOS_setsig(SIGFPE, handler);
207+
208+
/*-- HP IA64 VMS --------------------------------------------------------*/
209+
#elif defined(__ia64) && defined(__VMS)
193210
PyOS_setsig(SIGFPE, handler);
194211

195212
/*-- Cray Unicos ----------------------------------------------------------*/
@@ -244,6 +261,14 @@ static PyObject *turnoff_sigfpe(PyObject *self,PyObject *args)
244261
#ifdef __FreeBSD__
245262
fpresetsticky(fpgetsticky());
246263
fpsetmask(0);
264+
#elif defined(__VMS)
265+
IEEE clrmsk;
266+
clrmsk.ieee$q_flags =
267+
IEEE$M_TRAP_ENABLE_UNF | IEEE$M_TRAP_ENABLE_INE |
268+
IEEE$M_MAP_UMZ | IEEE$M_TRAP_ENABLE_INV |
269+
IEEE$M_TRAP_ENABLE_DZE | IEEE$M_TRAP_ENABLE_OVF |
270+
IEEE$M_INHERIT;
271+
sys$ieee_set_fp_control(&clrmsk, 0, 0);
247272
#else
248273
fputs("Operation not implemented\n", stderr);
249274
#endif

Modules/getpath.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,19 @@
9797

9898

9999
#ifndef VERSION
100-
#if defined(__VMS)
101-
#define VERSION "2_1"
102-
#else
103100
#define VERSION "2.1"
104101
#endif
105-
#endif
106102

107103
#ifndef VPATH
108104
#define VPATH "."
109105
#endif
110106

111107
#ifndef PREFIX
112-
#define PREFIX "/usr/local"
108+
# ifdef __VMS
109+
# define PREFIX ""
110+
# else
111+
# define PREFIX "/usr/local"
112+
# endif
113113
#endif
114114

115115
#ifndef EXEC_PREFIX

Modules/posixmodule.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7882,6 +7882,42 @@ win32_urandom(PyObject *self, PyObject *args)
78827882
}
78837883
#endif
78847884

7885+
#ifdef __VMS
7886+
/* Use openssl random routine */
7887+
#include <openssl/rand.h>
7888+
PyDoc_STRVAR(vms_urandom__doc__,
7889+
"urandom(n) -> str\n\n\
7890+
Return a string of n random bytes suitable for cryptographic use.");
7891+
7892+
static PyObject*
7893+
vms_urandom(PyObject *self, PyObject *args)
7894+
{
7895+
int howMany;
7896+
PyObject* result;
7897+
7898+
/* Read arguments */
7899+
if (! PyArg_ParseTuple(args, "i:urandom", &howMany))
7900+
return NULL;
7901+
if (howMany < 0)
7902+
return PyErr_Format(PyExc_ValueError,
7903+
"negative argument not allowed");
7904+
7905+
/* Allocate bytes */
7906+
result = PyString_FromStringAndSize(NULL, howMany);
7907+
if (result != NULL) {
7908+
/* Get random data */
7909+
if (RAND_pseudo_bytes((unsigned char*)
7910+
PyString_AS_STRING(result),
7911+
howMany) < 0) {
7912+
Py_DECREF(result);
7913+
return PyErr_Format(PyExc_ValueError,
7914+
"RAND_pseudo_bytes");
7915+
}
7916+
}
7917+
return result;
7918+
}
7919+
#endif
7920+
78857921
static PyMethodDef posix_methods[] = {
78867922
{"access", posix_access, METH_VARARGS, posix_access__doc__},
78877923
#ifdef HAVE_TTYNAME
@@ -8174,6 +8210,9 @@ static PyMethodDef posix_methods[] = {
81748210
#endif
81758211
#ifdef MS_WINDOWS
81768212
{"urandom", win32_urandom, METH_VARARGS, win32_urandom__doc__},
8213+
#endif
8214+
#ifdef __VMS
8215+
{"urandom", vms_urandom, METH_VARARGS, vms_urandom__doc__},
81778216
#endif
81788217
{NULL, NULL} /* Sentinel */
81798218
};

Modules/selectmodule.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ extern void bzero(void *, int);
4646
#endif
4747

4848
#ifdef MS_WINDOWS
49-
#include <winsock.h>
49+
# include <winsock.h>
5050
#else
51-
#ifdef __BEOS__
52-
#include <net/socket.h>
53-
#define SOCKET int
54-
#else
55-
#define SOCKET int
56-
#endif
51+
# define SOCKET int
52+
# ifdef __BEOS__
53+
# include <net/socket.h>
54+
# elif defined(__VMS)
55+
# include <socket.h>
56+
# endif
5757
#endif
5858

5959

@@ -668,7 +668,7 @@ arguments; each contains the subset of the corresponding file descriptors\n\
668668
that are ready.\n\
669669
\n\
670670
*** IMPORTANT NOTICE ***\n\
671-
On Windows, only sockets are supported; on Unix, all file descriptors.");
671+
On Windows and OpenVMS, only sockets are supported; on Unix, all file descriptors.");
672672

673673
static PyMethodDef select_methods[] = {
674674
{"select", select_select, METH_VARARGS, select_doc},
@@ -682,7 +682,7 @@ PyDoc_STRVAR(module_doc,
682682
"This module supports asynchronous I/O on multiple file descriptors.\n\
683683
\n\
684684
*** IMPORTANT NOTICE ***\n\
685-
On Windows, only sockets are supported; on Unix, all file descriptors.");
685+
On Windows and OpenVMS, only sockets are supported; on Unix, all file descriptors.");
686686

687687
PyMODINIT_FUNC
688688
initselect(void)

0 commit comments

Comments
 (0)