3 * VMS-specific C header file for perl5.
5 * Last revised: 12-Dec-1994 by Charles Bailey bailey@genetics.upenn.edu
8 #ifndef __vmsish_h_included
9 #define __vmsish_h_included
11 #include <descrip.h> /* for dirent struct definitions */
12 #include <libdef.h> /* status codes for various places */
13 #include <rmsdef.h> /* at which errno and vaxc$errno are */
14 #include <ssdef.h> /* explicitly set in the perl source code */
16 /* Suppress compiler warnings from DECC for VMS-specific extensions:
17 * GLOBALEXT, NOSHAREEXT: global[dr]ef declarations
18 * ADDRCONSTEXT: initialization of data with non-constant values
19 * (e.g. pointer fields of descriptors)
22 # pragma message disable (GLOBALEXT,NOSHAREEXT,ADDRCONSTEXT)
25 /* DEC's C compilers and gcc use incompatible definitions of _to(upp|low)er() */
29 #define _toupper(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) & ~040)
33 #define _tolower(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) | 040)
34 /* DECC 1.3 has a funny definition of abs; it's fixed in DECC 4.0, so this
35 * can go away once DECC 1.3 isn't in use any more. */
36 #if defined(__ALPHA) && defined(__DECC)
38 #define abs(__x) __ABS(__x)
40 #define labs(__x) __LABS(__x)
41 #endif /* __ALPHA && __DECC */
43 /* Assorted things to look like Unix */
45 #ifndef _IOLBF /* gcc's stdio.h doesn't define this */
49 #include <processes.h> /* for vfork() */
52 #include <file.h> /* it's not <sys/file.h>, so don't use I_SYS_FILE */
53 #define unlink kill_file
55 /* Macros to set errno using the VAX thread-safe calls, if present */
56 #if (defined(__DECC) || defined(__DECCXX)) && !defined(__ALPHA)
57 # define set_errno(v) (cma$tis_errno_set_value(v))
58 # define set_vaxc_errno(v) (vaxc$errno = (v))
60 # define set_errno(v) (errno = (v))
61 # define set_vaxc_errno(v) (vaxc$errno = (v))
64 /* Handy way to vet calls to VMS system services and RTL routines. */
65 #define _ckvmssts(call) { register unsigned long int __ckvms_sts; \
66 if (!((__ckvms_sts=(call))&1)) { \
67 set_errno(EVMSERR); set_vaxc_errno(__ckvms_sts); \
68 croak("Fatal VMS error at %s, line %d",__FILE__,__LINE__); } }
71 #include "sockadapt.h"
75 * The following symbols are defined (or undefined) according to the RTL
76 * support VMS provides for the corresponding functions. These don't
77 * appear in config.h, so they're dealt with here.
82 /* The VMS C RTL has vfork() but not fork(). Both actually work in a way
83 * that's somewhere between Unix vfork() and VMS lib$spawn(), so it's
84 * probably not a good idea to use them much. That said, we'll try to
85 * use vfork() in either case.
90 * fwrite1() should be a routine with the same calling sequence as fwrite(),
91 * but which outputs all of the bytes requested as a single stream (unlike
92 * fwrite() itself, which on some systems outputs several distinct records
93 * if the number_of_items parameter is >1).
95 #define fwrite1 my_fwrite
97 /* Use our own rmdir() */
98 #define rmdir(name) do_rmdir(name)
100 /* Assorted fiddling with sigs . . . */
102 #define ABORT() abort()
104 /* Used with our my_utime() routine in vms.c */
109 #define utime my_utime
111 /* This is what times() returns, but <times.h> calls it tbuffer_t on VMS */
114 clock_t tms_utime; /* user time */
115 clock_t tms_stime; /* system time - always 0 on VMS */
116 clock_t tms_cutime; /* user time, children */
117 clock_t tms_cstime; /* system time, children - always 0 on VMS */
120 /* VMS doesn't use a real sys_nerr, but we need this when scanning for error
121 * messages in text strings . . .
124 #define sys_nerr EVMSERR /* EVMSERR is as high as we can go. */
126 /* Look up new %ENV values on the fly */
127 #define DYNAMIC_ENV_FETCH 1
128 #define ENV_HV_NAME "%EnV%VmS%"
130 /* Use our own stat() clones, which handle Unix-style directory names */
131 #define Stat(name,bufptr) flex_stat(name,bufptr)
132 #define Fstat(fd,bufptr) flex_fstat(fd,bufptr)
134 /* Setup for the dirent routines:
135 * opendir(), closedir(), readdir(), seekdir(), telldir(), and
136 * vmsreaddirversions(), and preprocessor stuff on which these depend:
137 * Written by Rich $alz, <rsalz@bbn.com> in August, 1990.
138 * This code has no copyright.
140 /* Data structure returned by READDIR(). */
142 char d_name[256]; /* File name */
143 int d_namlen; /* Length of d_name */
144 int vms_verscount; /* Number of versions */
145 int vms_versions[20]; /* Version numbers */
148 /* Handle returned by opendir(), used by the other routines. You
149 * are not supposed to care what's inside this structure. */
150 typedef struct _dirdesc {
152 int vms_wantversions;
153 unsigned long int count;
156 struct dsc$descriptor_s pat;
159 #define rewinddir(dirp) seekdir((dirp), 0)
161 /* used for our emulation of getpw* */
163 char *pw_name; /* Username */
165 Uid_t pw_uid; /* UIC member number */
166 Gid_t pw_gid; /* UIC group number */
167 char *pw_comment; /* Default device/directory (Unix-style) */
168 char *pw_gecos; /* Owner */
169 char *pw_dir; /* Default device/directory (VMS-style) */
170 char *pw_shell; /* Default CLI name (eg. DCL) */
172 #define pw_unixdir pw_comment /* Default device/directory (Unix-style) */
173 #define getpwnam my_getpwnam
174 #define getpwuid my_getpwuid
175 #define getpwent my_getpwent
176 #define endpwent my_endpwent
177 #define setpwent my_endpwent
179 /* Our own stat_t substitute, since we play with st_dev and st_ino -
180 * we want atomic types so Unix-bound code which compares these fields
181 * for two files will work most of the time under VMS
183 /* First, grab the system types, so we don't clobber them later */
185 /* Since we've got to match the size of the CRTL's stat_t, we need
186 * to mimic DECC's alignment settings.
188 #if defined(__DECC) || defined(__DECCXX)
189 # pragma __member_alignment __save
190 # pragma __nomember_alignment
193 # pragma __message __save
194 # pragma __message disable (__MISALGNDSTRCT)
195 # pragma __message disable (__MISALGNDMEM)
199 char *st_devnam; /* pointer to device name */
201 unsigned short fid[3];
202 unsigned long st_ino_mostly;
204 unsigned short st_mode; /* file "mode" i.e. prot, dir, reg, etc. */
205 int st_nlink; /* for compatibility - not really used */
206 unsigned st_uid; /* from ACP - QIO uic field */
207 unsigned short st_gid; /* group number extracted from st_uid */
208 dev_t st_rdev; /* for compatibility - always zero */
209 off_t st_size; /* file size in bytes */
210 unsigned st_atime; /* file access time; always same as st_mtime */
211 unsigned st_mtime; /* last modification time */
212 unsigned st_ctime; /* file creation time */
213 char st_fab_rfm; /* record format */
214 char st_fab_rat; /* record attributes */
215 char st_fab_fsz; /* fixed header size */
216 unsigned st_dev; /* encoded device name */
221 #define st_ino st_inode_u.st_ino_mostly
223 typedef unsigned mydev_t;
224 #define dev_t mydev_t
225 typedef unsigned long myino_t;
226 #define ino_t myino_t
227 #if defined(__DECC) || defined(__DECCXX)
228 # pragma __member_alignment __restore
231 # pragma __message __restore
233 /* Cons up a 'delete' bit for testing access */
234 #define S_IDUSR (S_IWUSR | S_IXUSR)
235 #define S_IDGRP (S_IWGRP | S_IXGRP)
236 #define S_IDOTH (S_IWOTH | S_IXOTH)
238 /* Prototypes for functions unique to vms.c. Don't include replacements
239 * for routines in the mainline source files excluded by #ifndef VMS;
240 * their prototypes are already in proto.h.
242 * In order to keep Gen_ShrFls.Pl happy, functions which are to be made
243 * available to images linked to PerlShr.Exe must be declared between the
244 * __VMS_PROTOTYPES__ and __VMS_SEPYTOTORP__ lines, and must be in the form
245 * <data type><TAB>name<WHITESPACE>_((<prototype args>));
247 typedef char __VMS_PROTOTYPES__; /* prototype section start marker */
248 char * my_getenv _((char *));
249 unsigned long int waitpid _((unsigned long int, int *, int));
250 char * my_gconvert _((double, int, int, char *));
251 int do_rmdir _((char *));
252 int kill_file _((char *));
253 int my_utime _((char *, struct utimbuf *));
254 char * fileify_dirspec _((char *, char *));
255 char * fileify_dirspec_ts _((char *, char *));
256 char * pathify_dirspec _((char *, char *));
257 char * pathify_dirspec_ts _((char *, char *));
258 char * tounixspec _((char *, char *));
259 char * tounixspec_ts _((char *, char *));
260 char * tovmsspec _((char *, char *));
261 char * tovmsspec_ts _((char *, char *));
262 char * tounixpath _((char *, char *));
263 char * tounixpath_ts _((char *, char *));
264 char * tovmspath _((char *, char *));
265 char * tovmspath_ts _((char *, char *));
266 void getredirection _(());
267 DIR * opendir _((char *));
268 struct dirent * readdir _((DIR *));
269 long telldir _((DIR *));
270 void seekdir _((DIR *, long));
271 void closedir _((DIR *));
272 void vmsreaddirversions _((DIR *, int));
273 void getredirection _((int *, char ***));
274 I32 cando_by_name _((I32, I32, char *));
275 int flex_fstat _((int, struct stat *));
276 int flex_stat _((char *, struct stat *));
277 int trim_unixpath _((char *, char*));
278 bool vms_do_aexec _((SV *, SV **, SV **));
279 bool vms_do_exec _((char *));
280 unsigned long int do_aspawn _((SV *, SV **, SV **));
281 unsigned long int do_spawn _((char *));
282 int my_fwrite _((void *, size_t, size_t, FILE *));
283 struct passwd * my_getpwnam _((char *name));
284 struct passwd * my_getpwuid _((Uid_t uid));
285 struct passwd * my_getpwent _(());
286 void my_endpwent _(());
287 void init_os_extras _(());
288 typedef char __VMS_SEPYTOTORP__; /* prototype section end marker */
290 #ifndef VMS_DO_SOCKETS
291 /* This relies on tricks in perl.h to pick up that these manifest constants
292 * are undefined and set up conversion routines. It will then redefine
293 * these manifest constants, so the actual values will match config.h
301 #endif /* __vmsish_h_included */