Remove redundant functions UNIVERSAL::{class,is_instance}
[p5sagit/p5-mst-13.2.git] / vms / vmsish.h
CommitLineData
a0d0e21e 1/* vmsish.h
2 *
3 * VMS-specific C header file for perl5.
4 *
e518068a 5 * Last revised: 01-Oct-1995 by Charles Bailey bailey@genetics.upenn.edu
c07a80fd 6 * Version: 5.1.6
a0d0e21e 7 */
8
9#ifndef __vmsish_h_included
10#define __vmsish_h_included
11
12#include <descrip.h> /* for dirent struct definitions */
748a9306 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 */
4fdae800 16#include <stsdef.h> /* bitmasks for exit status testing */
748a9306 17
4633a7c4 18/* Suppress compiler warnings from DECC for VMS-specific extensions:
36477c24 19 * GLOBALEXT, NOSHAREEXT, READONLYEXT: global[dr]ef declarations
e518068a 20 * ADDRCONSTEXT,NEEDCONSTEXT: initialization of data with non-constant values
21 * (e.g. pointer fields of descriptors)
22 */
23#ifdef __DECC
36477c24 24# pragma message disable (GLOBALEXT,NOSHAREEXT,READONLYEXT,ADDRCONSTEXT,NEEDCONSTEXT)
e518068a 25#endif
26
748a9306 27/* DEC's C compilers and gcc use incompatible definitions of _to(upp|low)er() */
28#ifdef _toupper
29# undef _toupper
30#endif
31#define _toupper(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) & ~040)
32#ifdef _tolower
33# undef _tolower
34#endif
35#define _tolower(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) | 040)
4633a7c4 36/* DECC 1.3 has a funny definition of abs; it's fixed in DECC 4.0, so this
37 * can go away once DECC 1.3 isn't in use any more. */
38#if defined(__ALPHA) && defined(__DECC)
39#undef abs
40#define abs(__x) __ABS(__x)
41#undef labs
42#define labs(__x) __LABS(__x)
43#endif /* __ALPHA && __DECC */
a0d0e21e 44
45/* Assorted things to look like Unix */
46#ifdef __GNUC__
47#ifndef _IOLBF /* gcc's stdio.h doesn't define this */
48#define _IOLBF 1
49#endif
748a9306 50#endif
a0d0e21e 51#include <processes.h> /* for vfork() */
52#include <unixio.h>
a0d0e21e 53#include <unixlib.h>
54#include <file.h> /* it's not <sys/file.h>, so don't use I_SYS_FILE */
774d564b 55#if defined(__DECC) && defined(__DECC_VER) && __DECC_VER > 20000000
bbce6d69 56# include <unistd.h> /* DECC has this; VAXC and gcc don't */
57#endif
bf109933 58
4fdae800 59/* DECC introduces this routine in the RTL as of VMS 7.0; for now,
60 * we'll use ours, since it gives us the full VMS exit status. */
61#ifdef __PID_T
62# define Pid_t pid_t
63#else
64# define Pid_t unsigned int
65#endif
66#define waitpid my_waitpid
67
bf109933 68/* Our own contribution to PerlShr's global symbols . . . */
69#ifdef EMBED
70# define my_trnlnm Perl_my_trnlnm
71# define my_getenv Perl_my_getenv
94c456c4 72# define prime_env_iter Perl_prime_env_iter
73# define my_setenv Perl_my_setenv
bf109933 74# define my_crypt Perl_my_crypt
4fdae800 75# define my_waitpid Perl_my_waitpid
bf109933 76# define my_gconvert Perl_my_gconvert
77# define do_rmdir Perl_do_rmdir
78# define kill_file Perl_kill_file
79# define my_utime Perl_my_utime
bbce6d69 80# define rmsexpand Perl_rmsexpand
81# define rmsexpand_ts Perl_rmsexpand_ts
bf109933 82# define fileify_dirspec Perl_fileify_dirspec
83# define fileify_dirspec_ts Perl_fileify_dirspec_ts
84# define pathify_dirspec Perl_pathify_dirspec
85# define pathify_dirspec_ts Perl_pathify_dirspec_ts
86# define tounixspec Perl_tounixspec
87# define tounixspec_ts Perl_tounixspec_ts
88# define tovmsspec Perl_tovmsspec
89# define tovmsspec_ts Perl_tovmsspec_ts
90# define tounixpath Perl_tounixpath
91# define tounixpath_ts Perl_tounixpath_ts
92# define tovmspath Perl_tovmspath
93# define tovmspath_ts Perl_tovmspath_ts
94# define getredirection Perl_getredirection
95# define opendir Perl_opendir
96# define readdir Perl_readdir
97# define telldir Perl_telldir
98# define seekdir Perl_seekdir
99# define closedir Perl_closedir
100# define vmsreaddirversions Perl_vmsreaddirversions
101# define getredirection Perl_getredirection
102# define my_gmtime Perl_my_gmtime
103# define cando_by_name Perl_cando_by_name
104# define flex_fstat Perl_flex_fstat
105# define flex_stat Perl_flex_stat
106# define trim_unixpath Perl_trim_unixpath
0414b1a0 107# define my_vfork Perl_my_vfork
bf109933 108# define vms_do_aexec Perl_vms_do_aexec
109# define vms_do_exec Perl_vms_do_exec
110# define do_aspawn Perl_do_aspawn
111# define do_spawn Perl_do_spawn
112# define my_fwrite Perl_my_fwrite
0414b1a0 113# define my_binmode Perl_my_binmode
bf109933 114# define my_getpwnam Perl_my_getpwnam
115# define my_getpwuid Perl_my_getpwuid
116# define my_getpwent Perl_my_getpwent
117# define my_endpwent Perl_my_endpwent
118# define my_getlogin Perl_my_getlogin
119# define rmscopy Perl_rmscopy
120# define init_os_extras Perl_init_os_extras
121#endif
122
123/* Delete if at all possible, changing protections if necessary. */
748a9306 124#define unlink kill_file
125
0414b1a0 126/*
127 * Intercept calls to fork, so we know whether subsequent calls to
128 * exec should be handled in VMSish or Unixish style.
129 */
130#define fork my_vfork
131#ifndef __DONT_MASK_VFORK /* #defined in vms.c so we see real vfork */
132# ifdef vfork
133# undef vfork
134# endif
135# define vfork my_vfork
136#endif
137
138/* BIG_TIME:
139 * This symbol is defined if Time_t is an unsigned type on this system.
140 */
141#define BIG_TIME
142
143/* USE_STAT_RDEV:
144 * This symbol is defined if this system has a stat structure declaring
145 * st_rdev
e518068a 146 */
0414b1a0 147#define USE_STAT_RDEV /**/
148
149/* ACME_MESS:
150 * This symbol, if defined, indicates that error messages should be
151 * should be generated in a format that allows the use of the Acme
152 * GUI/editor's autofind feature.
153 */
154#undef ACME_MESS /**/
e518068a 155
44a8e56a 156/* ALTERNATE_SHEBANG:
157 * This symbol, if defined, contains a "magic" string which may be used
158 * as the first line of a Perl program designed to be executed directly
159 * by name, instead of the standard Unix #!. If ALTERNATE_SHEBANG
160 * begins with a character other then #, then Perl will only treat
161 * it as a command line if if finds the string "perl" in the first
162 * word; otherwise it's treated as the first line of code in the script.
163 * (IOW, Perl won't hand off to another interpreter via an alternate
164 * shebang sequence that might be legal Perl code.)
165 */
166#define ALTERNATE_SHEBANG "$"
167
748a9306 168/* Macros to set errno using the VAX thread-safe calls, if present */
169#if (defined(__DECC) || defined(__DECCXX)) && !defined(__ALPHA)
170# define set_errno(v) (cma$tis_errno_set_value(v))
774d564b 171 void cma$tis_errno_set_value(int __value); /* missing in some errno.h */
748a9306 172# define set_vaxc_errno(v) (vaxc$errno = (v))
173#else
174# define set_errno(v) (errno = (v))
175# define set_vaxc_errno(v) (vaxc$errno = (v))
176#endif
177
178/* Handy way to vet calls to VMS system services and RTL routines. */
bf109933 179#define _ckvmssts(call) STMT_START { register unsigned long int __ckvms_sts; \
748a9306 180 if (!((__ckvms_sts=(call))&1)) { \
181 set_errno(EVMSERR); set_vaxc_errno(__ckvms_sts); \
e518068a 182 croak("Fatal VMS error (status=%d) at %s, line %d", \
bf109933 183 __ckvms_sts,__FILE__,__LINE__); } } STMT_END
a0d0e21e 184
0414b1a0 185/* Same thing, but don't call back to Perl's croak(); useful for errors
186 * occurring during startup, before Perl's state is initialized */
187#define _ckvmssts_noperl(call) STMT_START { register unsigned long int __ckvms_sts; \
188 if (!((__ckvms_sts=(call))&1)) { \
189 set_errno(EVMSERR); set_vaxc_errno(__ckvms_sts); \
190 fprintf(Perl_debug_log,"Fatal VMS error (status=%d) at %s, line %d", \
191 __ckvms_sts,__FILE__,__LINE__); lib$signal(__ckvms_sts); } } STMT_END
192
a0d0e21e 193#ifdef VMS_DO_SOCKETS
194#include "sockadapt.h"
195#endif
196
c07a80fd 197#define BIT_BUCKET "_NLA0:"
198#define PERL_SYS_INIT(c,v) getredirection((c),(v))
bf109933 199#define PERL_SYS_TERM()
200#define dXSUB_SYS int dummy
a0d0e21e 201#define HAS_KILL
202#define HAS_WAIT
203
e518068a 204/* VMS:
205 * This symbol, if defined, indicates that the program is running under
206 * VMS. It's a symbol automagically defined by all VMS C compilers I've seen.
207 * Just in case, however . . . */
208#ifndef VMS
209#define VMS /**/
210#endif
211
212/* HAS_IOCTL:
213 * This symbol, if defined, indicates that the ioctl() routine is
214 * available to set I/O characteristics
a0d0e21e 215 */
e518068a 216#undef HAS_IOCTL /**/
217
218/* HAS_UTIME:
219 * This symbol, if defined, indicates that the routine utime() is
220 * available to update the access and modification times of files.
221 */
222#define HAS_UTIME /**/
a0d0e21e 223
e518068a 224/* HAS_GROUP
225 * This symbol, if defined, indicates that the getgrnam(),
226 * getgrgid(), and getgrent() routines are available to
227 * get group entries.
228 */
229#undef HAS_GROUP /**/
230
231/* HAS_PASSWD
232 * This symbol, if defined, indicates that the getpwnam(),
233 * getpwuid(), and getpwent() routines are available to
234 * get password entries.
235 */
236#define HAS_PASSWD /**/
237
238#define HAS_KILL
239#define HAS_WAIT
240
0414b1a0 241/* USEMYBINMODE
242 * This symbol, if defined, indicates that the program should
243 * use the routine my_binmode(FILE *fp, char iotype) to insure
244 * that a file is in "binary" mode -- that is, that no translation
245 * of bytes occurs on read or write operations.
246 */
247#define USEMYBINMODE
248
a0d0e21e 249/*
250 * fwrite1() should be a routine with the same calling sequence as fwrite(),
251 * but which outputs all of the bytes requested as a single stream (unlike
252 * fwrite() itself, which on some systems outputs several distinct records
253 * if the number_of_items parameter is >1).
254 */
255#define fwrite1 my_fwrite
256
257/* Use our own rmdir() */
258#define rmdir(name) do_rmdir(name)
259
260/* Assorted fiddling with sigs . . . */
261# include <signal.h>
262#define ABORT() abort()
5f05dabc 263 /* VAXC's signal.h doesn't #define SIG_ERR, but provides BADSIG instead. */
264#if !defined(SIG_ERR) && defined(BADSIG)
265# define SIG_ERR BADSIG
266#endif
267
a0d0e21e 268
748a9306 269/* Used with our my_utime() routine in vms.c */
270struct utimbuf {
271 time_t actime;
272 time_t modtime;
273};
274#define utime my_utime
275
0414b1a0 276/* This is what times() returns, but <times.h> calls it tbuffer_t on VMS
277 * prior to v7.0. We check the DECC manifest to see whether it's already
278 * done this for us, relying on the fact that perl.h #includes <time.h>
279 * before it #includes "vmsish.h".
280 */
a0d0e21e 281
0414b1a0 282#ifndef __TMS
283 struct tms {
284 clock_t tms_utime; /* user time */
285 clock_t tms_stime; /* system time - always 0 on VMS */
286 clock_t tms_cutime; /* user time, children */
287 clock_t tms_cstime; /* system time, children - always 0 on VMS */
288 };
5f05dabc 289#else
290 /* The new headers change the times() prototype to tms from tbuffer */
291# define tbuffer_t struct tms
0414b1a0 292#endif
a0d0e21e 293
e518068a 294/* Prior to VMS 7.0, the CRTL gmtime() routine was a stub which always
295 * returned NULL. Substitute our own routine, which uses the logical
296 * SYS$TIMEZONE_DIFFERENTIAL, whcih the native UTC support routines
297 * in VMS 6.0 or later use.*
298 */
299#define gmtime(t) my_gmtime(t)
300
a0d0e21e 301/* VMS doesn't use a real sys_nerr, but we need this when scanning for error
302 * messages in text strings . . .
303 */
304
305#define sys_nerr EVMSERR /* EVMSERR is as high as we can go. */
306
307/* Look up new %ENV values on the fly */
308#define DYNAMIC_ENV_FETCH 1
309#define ENV_HV_NAME "%EnV%VmS%"
310
c07a80fd 311/* Thin jacket around cuserid() tomatch Unix' calling sequence */
312#define getlogin my_getlogin
313
314/* Ditto for sys$hash_passwrod() . . . */
315#define crypt my_crypt
316
a0d0e21e 317/* Use our own stat() clones, which handle Unix-style directory names */
318#define Stat(name,bufptr) flex_stat(name,bufptr)
319#define Fstat(fd,bufptr) flex_fstat(fd,bufptr)
320
a5f75d66 321/* By default, flush data all the way to disk, not just to RMS buffers */
322#define Fflush(fp) ((fflush(fp) || fsync(fileno(fp))) ? EOF : 0)
323
a0d0e21e 324/* Setup for the dirent routines:
325 * opendir(), closedir(), readdir(), seekdir(), telldir(), and
326 * vmsreaddirversions(), and preprocessor stuff on which these depend:
327 * Written by Rich $alz, <rsalz@bbn.com> in August, 1990.
328 * This code has no copyright.
329 */
330 /* Data structure returned by READDIR(). */
331struct dirent {
332 char d_name[256]; /* File name */
333 int d_namlen; /* Length of d_name */
334 int vms_verscount; /* Number of versions */
335 int vms_versions[20]; /* Version numbers */
336};
337
338 /* Handle returned by opendir(), used by the other routines. You
339 * are not supposed to care what's inside this structure. */
340typedef struct _dirdesc {
341 long context;
342 int vms_wantversions;
343 unsigned long int count;
344 char *pattern;
345 struct dirent entry;
346 struct dsc$descriptor_s pat;
347} DIR;
348
349#define rewinddir(dirp) seekdir((dirp), 0)
350
748a9306 351/* used for our emulation of getpw* */
352struct passwd {
353 char *pw_name; /* Username */
354 char *pw_passwd;
355 Uid_t pw_uid; /* UIC member number */
356 Gid_t pw_gid; /* UIC group number */
357 char *pw_comment; /* Default device/directory (Unix-style) */
358 char *pw_gecos; /* Owner */
359 char *pw_dir; /* Default device/directory (VMS-style) */
360 char *pw_shell; /* Default CLI name (eg. DCL) */
361};
362#define pw_unixdir pw_comment /* Default device/directory (Unix-style) */
363#define getpwnam my_getpwnam
364#define getpwuid my_getpwuid
365#define getpwent my_getpwent
366#define endpwent my_endpwent
367#define setpwent my_endpwent
368
369/* Our own stat_t substitute, since we play with st_dev and st_ino -
370 * we want atomic types so Unix-bound code which compares these fields
c07a80fd 371 * for two files will work most of the time under VMS.
372 * N.B. 1. The st_ino hack assumes that sizeof(unsigned short[3]) ==
373 * sizeof(unsigned) + sizeof(unsigned short). We can't use a union type
374 * to map the unsigned int we want and the unsigned short[3] the CRTL
375 * returns into the same member, since gcc has different ideas than DECC
376 * and VAXC about sizing union types.
377 * N.B 2. The routine cando() in vms.c assumes that &stat.st_ino is the
378 * address of a FID.
748a9306 379 */
380/* First, grab the system types, so we don't clobber them later */
381#include <stat.h>
382/* Since we've got to match the size of the CRTL's stat_t, we need
383 * to mimic DECC's alignment settings.
384 */
385#if defined(__DECC) || defined(__DECCXX)
386# pragma __member_alignment __save
387# pragma __nomember_alignment
388#endif
389#if defined(__DECC)
390# pragma __message __save
391# pragma __message disable (__MISALGNDSTRCT)
392# pragma __message disable (__MISALGNDMEM)
393#endif
394struct mystat
395{
396 char *st_devnam; /* pointer to device name */
c07a80fd 397 unsigned st_ino; /* hack - CRTL uses unsigned short[3] for */
398 unsigned short rvn; /* FID (num,seq,rvn) */
748a9306 399 unsigned short st_mode; /* file "mode" i.e. prot, dir, reg, etc. */
400 int st_nlink; /* for compatibility - not really used */
401 unsigned st_uid; /* from ACP - QIO uic field */
402 unsigned short st_gid; /* group number extracted from st_uid */
403 dev_t st_rdev; /* for compatibility - always zero */
404 off_t st_size; /* file size in bytes */
405 unsigned st_atime; /* file access time; always same as st_mtime */
406 unsigned st_mtime; /* last modification time */
407 unsigned st_ctime; /* file creation time */
408 char st_fab_rfm; /* record format */
409 char st_fab_rat; /* record attributes */
410 char st_fab_fsz; /* fixed header size */
411 unsigned st_dev; /* encoded device name */
412};
748a9306 413#define stat mystat
414typedef unsigned mydev_t;
415#define dev_t mydev_t
c07a80fd 416typedef unsigned myino_t;
748a9306 417#define ino_t myino_t
418#if defined(__DECC) || defined(__DECCXX)
419# pragma __member_alignment __restore
420#endif
421#if defined(__DECC)
422# pragma __message __restore
423#endif
424/* Cons up a 'delete' bit for testing access */
425#define S_IDUSR (S_IWUSR | S_IXUSR)
426#define S_IDGRP (S_IWGRP | S_IXGRP)
427#define S_IDOTH (S_IWOTH | S_IXOTH)
a0d0e21e 428
429/* Prototypes for functions unique to vms.c. Don't include replacements
430 * for routines in the mainline source files excluded by #ifndef VMS;
431 * their prototypes are already in proto.h.
432 *
433 * In order to keep Gen_ShrFls.Pl happy, functions which are to be made
434 * available to images linked to PerlShr.Exe must be declared between the
435 * __VMS_PROTOTYPES__ and __VMS_SEPYTOTORP__ lines, and must be in the form
436 * <data type><TAB>name<WHITESPACE>_((<prototype args>));
437 */
94c456c4 438
44a8e56a 439#ifdef NO_PERL_TYPEDEFS
440 /* We don't have Perl typedefs available (e.g. when building a2p), so
441 we fake them here. N.B. There is *no* guarantee that the faked
442 prototypes will actually match the real routines. If you want to
443 call Perl routines, include perl.h to get the real typedefs. */
444# ifndef bool
445# define bool int
446# define __MY_BOOL_TYPE_FAKE
447# endif
448# ifndef I32
449# define I32 int
450# define __MY_I32_TYPE_FAKE
451# endif
452# ifndef SV
453# define SV void /* Since we only see SV * in prototypes */
454# define __MY_SV_TYPE_FAKE
455# endif
456#endif
457
94c456c4 458void prime_env_iter _((void));
459void getredirection _((int *, char ***));
460void init_os_extras _(());
c07a80fd 461/* prototype section start marker; `typedef' passes through cpp */
462typedef char __VMS_PROTOTYPES__;
463int my_trnlnm _((char *, char *, unsigned long int));
a0d0e21e 464char * my_getenv _((char *));
c07a80fd 465char * my_crypt _((const char *, const char *));
4fdae800 466Pid_t my_waitpid _((Pid_t, int *, int));
a0d0e21e 467char * my_gconvert _((double, int, int, char *));
468int do_rmdir _((char *));
469int kill_file _((char *));
748a9306 470int my_utime _((char *, struct utimbuf *));
bbce6d69 471char * rmsexpand _((char *, char *, char *, unsigned));
472char * rmsexpand_ts _((char *, char *, char *, unsigned));
a0d0e21e 473char * fileify_dirspec _((char *, char *));
474char * fileify_dirspec_ts _((char *, char *));
475char * pathify_dirspec _((char *, char *));
476char * pathify_dirspec_ts _((char *, char *));
477char * tounixspec _((char *, char *));
478char * tounixspec_ts _((char *, char *));
479char * tovmsspec _((char *, char *));
480char * tovmsspec_ts _((char *, char *));
481char * tounixpath _((char *, char *));
482char * tounixpath_ts _((char *, char *));
483char * tovmspath _((char *, char *));
484char * tovmspath_ts _((char *, char *));
485void getredirection _(());
486DIR * opendir _((char *));
487struct dirent * readdir _((DIR *));
488long telldir _((DIR *));
489void seekdir _((DIR *, long));
490void closedir _((DIR *));
491void vmsreaddirversions _((DIR *, int));
e518068a 492struct tm *my_gmtime _((const time_t *));
748a9306 493I32 cando_by_name _((I32, I32, char *));
494int flex_fstat _((int, struct stat *));
495int flex_stat _((char *, struct stat *));
f86702cc 496int trim_unixpath _((char *, char*, int));
0414b1a0 497int my_vfork _(());
748a9306 498bool vms_do_aexec _((SV *, SV **, SV **));
a0d0e21e 499bool vms_do_exec _((char *));
748a9306 500unsigned long int do_aspawn _((SV *, SV **, SV **));
a0d0e21e 501unsigned long int do_spawn _((char *));
502int my_fwrite _((void *, size_t, size_t, FILE *));
0414b1a0 503FILE * my_binmode _((FILE *, char));
748a9306 504struct passwd * my_getpwnam _((char *name));
505struct passwd * my_getpwuid _((Uid_t uid));
506struct passwd * my_getpwent _(());
507void my_endpwent _(());
c07a80fd 508char * my_getlogin _(());
bf109933 509int rmscopy _((char *, char *, int));
c07a80fd 510typedef char __VMS_SEPYTOTORP__;
511/* prototype section end marker; `typedef' passes through cpp */
a0d0e21e 512
44a8e56a 513#ifdef NO_PERL_TYPEDEFS /* We'll try not to scramble later files */
514# ifdef __MY_BOOL_TYPE_FAKE
515# undef bool
516# undef __MY_BOOL_TYPE_FAKE
517# endif
518# ifdef __MY_I32_TYPE_FAKE
519# undef I32
520# undef __MY_I32_TYPE_FAKE
521# endif
522# ifdef __MY_SV_TYPE_FAKE
523# undef SV
524# undef __MY_SV_TYPE_FAKE
525# endif
526#endif
527
a0d0e21e 528#ifndef VMS_DO_SOCKETS
748a9306 529/* This relies on tricks in perl.h to pick up that these manifest constants
530 * are undefined and set up conversion routines. It will then redefine
531 * these manifest constants, so the actual values will match config.h
532 */
533#undef HAS_HTONS
534#undef HAS_NTOHS
535#undef HAS_HTONL
536#undef HAS_NTOHL
a0d0e21e 537#endif
538
482b294c 539#define TMPPATH "sys$scratch:perl-eXXXXXX"
540
a0d0e21e 541#endif /* __vmsish_h_included */