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