3 * VMS-specific C header file for perl5.
5 * Last revised: 01-Oct-1995 by Charles Bailey bailey@genetics.upenn.edu
9 #ifndef __vmsish_h_included
10 #define __vmsish_h_included
12 #include <descrip.h> /* for dirent struct definitions */
13 #include <libdef.h> /* status codes for various places */
14 #include <rmsdef.h> /* at which errno and vaxc$errno are */
15 #include <ssdef.h> /* explicitly set in the perl source code */
17 /* Suppress compiler warnings from DECC for VMS-specific extensions:
18 * GLOBALEXT, NOSHAREEXT: global[dr]ef declarations
19 * ADDRCONSTEXT: initialization of data with non-constant values
20 * (e.g. pointer fields of descriptors)
23 # pragma message disable (GLOBALEXT,NOSHAREEXT,ADDRCONSTEXT)
26 /* Suppress compiler warnings from DECC for VMS-specific extensions:
27 * GLOBALEXT, NOSHAREEXT: global[dr]ef declarations
28 * ADDRCONSTEXT,NEEDCONSTEXT: initialization of data with non-constant values
29 * (e.g. pointer fields of descriptors)
32 # pragma message disable (GLOBALEXT,NOSHAREEXT,ADDRCONSTEXT,NEEDCONSTEXT)
35 /* DEC's C compilers and gcc use incompatible definitions of _to(upp|low)er() */
39 #define _toupper(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) & ~040)
43 #define _tolower(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) | 040)
44 /* DECC 1.3 has a funny definition of abs; it's fixed in DECC 4.0, so this
45 * can go away once DECC 1.3 isn't in use any more. */
46 #if defined(__ALPHA) && defined(__DECC)
48 #define abs(__x) __ABS(__x)
50 #define labs(__x) __LABS(__x)
51 #endif /* __ALPHA && __DECC */
53 /* Assorted things to look like Unix */
55 #ifndef _IOLBF /* gcc's stdio.h doesn't define this */
59 #include <processes.h> /* for vfork() */
62 #include <file.h> /* it's not <sys/file.h>, so don't use I_SYS_FILE */
63 #define unlink kill_file
65 /* The VMS C RTL has vfork() but not fork(). Both actually work in a way
66 * that's somewhere between Unix vfork() and VMS lib$spawn(), so it's
67 * probably not a good idea to use them much. That said, we'll try to
68 * use vfork() in either case.
72 /* Macros to set errno using the VAX thread-safe calls, if present */
73 #if (defined(__DECC) || defined(__DECCXX)) && !defined(__ALPHA)
74 # define set_errno(v) (cma$tis_errno_set_value(v))
75 # define set_vaxc_errno(v) (vaxc$errno = (v))
77 # define set_errno(v) (errno = (v))
78 # define set_vaxc_errno(v) (vaxc$errno = (v))
81 /* Handy way to vet calls to VMS system services and RTL routines. */
82 #define _ckvmssts(call) do { register unsigned long int __ckvms_sts; \
83 if (!((__ckvms_sts=(call))&1)) { \
84 set_errno(EVMSERR); set_vaxc_errno(__ckvms_sts); \
85 croak("Fatal VMS error (status=%d) at %s, line %d", \
86 __ckvms_sts,__FILE__,__LINE__); } } while (0);
89 #include "sockadapt.h"
92 #define BIT_BUCKET "_NLA0:"
93 #define PERL_SYS_INIT(c,v) getredirection((c),(v))
98 * This symbol, if defined, indicates that the program is running under
99 * VMS. It's a symbol automagically defined by all VMS C compilers I've seen.
100 * Just in case, however . . . */
106 * This symbol, if defined, indicates that the ioctl() routine is
107 * available to set I/O characteristics
109 #undef HAS_IOCTL /**/
112 * This symbol, if defined, indicates that the routine utime() is
113 * available to update the access and modification times of files.
115 #define HAS_UTIME /**/
118 * This symbol, if defined, indicates that the getgrnam(),
119 * getgrgid(), and getgrent() routines are available to
122 #undef HAS_GROUP /**/
125 * This symbol, if defined, indicates that the getpwnam(),
126 * getpwuid(), and getpwent() routines are available to
127 * get password entries.
129 #define HAS_PASSWD /**/
135 * fwrite1() should be a routine with the same calling sequence as fwrite(),
136 * but which outputs all of the bytes requested as a single stream (unlike
137 * fwrite() itself, which on some systems outputs several distinct records
138 * if the number_of_items parameter is >1).
140 #define fwrite1 my_fwrite
142 /* Use our own rmdir() */
143 #define rmdir(name) do_rmdir(name)
145 /* Assorted fiddling with sigs . . . */
147 #define ABORT() abort()
149 /* Used with our my_utime() routine in vms.c */
154 #define utime my_utime
156 /* This is what times() returns, but <times.h> calls it tbuffer_t on VMS */
159 clock_t tms_utime; /* user time */
160 clock_t tms_stime; /* system time - always 0 on VMS */
161 clock_t tms_cutime; /* user time, children */
162 clock_t tms_cstime; /* system time, children - always 0 on VMS */
165 /* Prior to VMS 7.0, the CRTL gmtime() routine was a stub which always
166 * returned NULL. Substitute our own routine, which uses the logical
167 * SYS$TIMEZONE_DIFFERENTIAL, whcih the native UTC support routines
168 * in VMS 6.0 or later use.*
170 #define gmtime(t) my_gmtime(t)
172 /* VMS doesn't use a real sys_nerr, but we need this when scanning for error
173 * messages in text strings . . .
176 #define sys_nerr EVMSERR /* EVMSERR is as high as we can go. */
178 /* Look up new %ENV values on the fly */
179 #define DYNAMIC_ENV_FETCH 1
180 #define ENV_HV_NAME "%EnV%VmS%"
182 /* Thin jacket around cuserid() tomatch Unix' calling sequence */
183 #define getlogin my_getlogin
185 /* Ditto for sys$hash_passwrod() . . . */
186 #define crypt my_crypt
188 /* Use our own stat() clones, which handle Unix-style directory names */
189 #define Stat(name,bufptr) flex_stat(name,bufptr)
190 #define Fstat(fd,bufptr) flex_fstat(fd,bufptr)
192 /* Setup for the dirent routines:
193 * opendir(), closedir(), readdir(), seekdir(), telldir(), and
194 * vmsreaddirversions(), and preprocessor stuff on which these depend:
195 * Written by Rich $alz, <rsalz@bbn.com> in August, 1990.
196 * This code has no copyright.
198 /* Data structure returned by READDIR(). */
200 char d_name[256]; /* File name */
201 int d_namlen; /* Length of d_name */
202 int vms_verscount; /* Number of versions */
203 int vms_versions[20]; /* Version numbers */
206 /* Handle returned by opendir(), used by the other routines. You
207 * are not supposed to care what's inside this structure. */
208 typedef struct _dirdesc {
210 int vms_wantversions;
211 unsigned long int count;
214 struct dsc$descriptor_s pat;
217 #define rewinddir(dirp) seekdir((dirp), 0)
219 /* used for our emulation of getpw* */
221 char *pw_name; /* Username */
223 Uid_t pw_uid; /* UIC member number */
224 Gid_t pw_gid; /* UIC group number */
225 char *pw_comment; /* Default device/directory (Unix-style) */
226 char *pw_gecos; /* Owner */
227 char *pw_dir; /* Default device/directory (VMS-style) */
228 char *pw_shell; /* Default CLI name (eg. DCL) */
230 #define pw_unixdir pw_comment /* Default device/directory (Unix-style) */
231 #define getpwnam my_getpwnam
232 #define getpwuid my_getpwuid
233 #define getpwent my_getpwent
234 #define endpwent my_endpwent
235 #define setpwent my_endpwent
237 /* Our own stat_t substitute, since we play with st_dev and st_ino -
238 * we want atomic types so Unix-bound code which compares these fields
239 * for two files will work most of the time under VMS.
240 * N.B. 1. The st_ino hack assumes that sizeof(unsigned short[3]) ==
241 * sizeof(unsigned) + sizeof(unsigned short). We can't use a union type
242 * to map the unsigned int we want and the unsigned short[3] the CRTL
243 * returns into the same member, since gcc has different ideas than DECC
244 * and VAXC about sizing union types.
245 * N.B 2. The routine cando() in vms.c assumes that &stat.st_ino is the
248 /* First, grab the system types, so we don't clobber them later */
250 /* Since we've got to match the size of the CRTL's stat_t, we need
251 * to mimic DECC's alignment settings.
253 #if defined(__DECC) || defined(__DECCXX)
254 # pragma __member_alignment __save
255 # pragma __nomember_alignment
258 # pragma __message __save
259 # pragma __message disable (__MISALGNDSTRCT)
260 # pragma __message disable (__MISALGNDMEM)
264 char *st_devnam; /* pointer to device name */
265 unsigned st_ino; /* hack - CRTL uses unsigned short[3] for */
266 unsigned short rvn; /* FID (num,seq,rvn) */
267 unsigned short st_mode; /* file "mode" i.e. prot, dir, reg, etc. */
268 int st_nlink; /* for compatibility - not really used */
269 unsigned st_uid; /* from ACP - QIO uic field */
270 unsigned short st_gid; /* group number extracted from st_uid */
271 dev_t st_rdev; /* for compatibility - always zero */
272 off_t st_size; /* file size in bytes */
273 unsigned st_atime; /* file access time; always same as st_mtime */
274 unsigned st_mtime; /* last modification time */
275 unsigned st_ctime; /* file creation time */
276 char st_fab_rfm; /* record format */
277 char st_fab_rat; /* record attributes */
278 char st_fab_fsz; /* fixed header size */
279 unsigned st_dev; /* encoded device name */
282 typedef unsigned mydev_t;
283 #define dev_t mydev_t
284 typedef unsigned myino_t;
285 #define ino_t myino_t
286 #if defined(__DECC) || defined(__DECCXX)
287 # pragma __member_alignment __restore
290 # pragma __message __restore
292 /* Cons up a 'delete' bit for testing access */
293 #define S_IDUSR (S_IWUSR | S_IXUSR)
294 #define S_IDGRP (S_IWGRP | S_IXGRP)
295 #define S_IDOTH (S_IWOTH | S_IXOTH)
297 /* Prototypes for functions unique to vms.c. Don't include replacements
298 * for routines in the mainline source files excluded by #ifndef VMS;
299 * their prototypes are already in proto.h.
301 * In order to keep Gen_ShrFls.Pl happy, functions which are to be made
302 * available to images linked to PerlShr.Exe must be declared between the
303 * __VMS_PROTOTYPES__ and __VMS_SEPYTOTORP__ lines, and must be in the form
304 * <data type><TAB>name<WHITESPACE>_((<prototype args>));
306 /* prototype section start marker; `typedef' passes through cpp */
307 typedef char __VMS_PROTOTYPES__;
308 int my_trnlnm _((char *, char *, unsigned long int));
309 char * my_getenv _((char *));
310 char * my_crypt _((const char *, const char *));
311 unsigned long int waitpid _((unsigned long int, int *, int));
312 char * my_gconvert _((double, int, int, char *));
313 int do_rmdir _((char *));
314 int kill_file _((char *));
315 int my_utime _((char *, struct utimbuf *));
316 char * fileify_dirspec _((char *, char *));
317 char * fileify_dirspec_ts _((char *, char *));
318 char * pathify_dirspec _((char *, char *));
319 char * pathify_dirspec_ts _((char *, char *));
320 char * tounixspec _((char *, char *));
321 char * tounixspec_ts _((char *, char *));
322 char * tovmsspec _((char *, char *));
323 char * tovmsspec_ts _((char *, char *));
324 char * tounixpath _((char *, char *));
325 char * tounixpath_ts _((char *, char *));
326 char * tovmspath _((char *, char *));
327 char * tovmspath_ts _((char *, char *));
328 void getredirection _(());
329 DIR * opendir _((char *));
330 struct dirent * readdir _((DIR *));
331 long telldir _((DIR *));
332 void seekdir _((DIR *, long));
333 void closedir _((DIR *));
334 void vmsreaddirversions _((DIR *, int));
335 void getredirection _((int *, char ***));
336 struct tm *my_gmtime _((const time_t *));
337 I32 cando_by_name _((I32, I32, char *));
338 int flex_fstat _((int, struct stat *));
339 int flex_stat _((char *, struct stat *));
340 int trim_unixpath _((char *, char*));
341 bool vms_do_aexec _((SV *, SV **, SV **));
342 bool vms_do_exec _((char *));
343 unsigned long int do_aspawn _((SV *, SV **, SV **));
344 unsigned long int do_spawn _((char *));
345 int my_fwrite _((void *, size_t, size_t, FILE *));
346 struct passwd * my_getpwnam _((char *name));
347 struct passwd * my_getpwuid _((Uid_t uid));
348 struct passwd * my_getpwent _(());
349 void my_endpwent _(());
350 char * my_getlogin _(());
351 void init_os_extras _(());
352 typedef char __VMS_SEPYTOTORP__;
353 /* prototype section end marker; `typedef' passes through cpp */
355 #ifndef VMS_DO_SOCKETS
356 /* This relies on tricks in perl.h to pick up that these manifest constants
357 * are undefined and set up conversion routines. It will then redefine
358 * these manifest constants, so the actual values will match config.h
366 #define TMPPATH "sys$scratch:perl-eXXXXXX"
368 #endif /* __vmsish_h_included */