This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Further ANSI changes now builds and passes (most) tests
[perl5.git] / ext / POSIX / POSIX.xs
index 2575ca1..57efb83 100644 (file)
@@ -40,7 +40,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <time.h>
-#include <unistd.h>
+#include <unistd.h>    /* see hints/sunos_4_1.sh */
 #include <fcntl.h>
 
 #if defined(__VMS) && !defined(__POSIX_SOURCE)
 #  define mkfifo(a,b) (not_here("mkfifo"),-1)
 #  define tzset() not_here("tzset")
 
-#  if __VMS_VER < 70000000
-     /* The default VMS emulation of Unix signals isn't very POSIXish */
-     typedef int sigset_t;
-#    define sigpending(a) (not_here("sigpending"),0)
-
-     /* sigset_t is atomic under VMS, so these routines are easy */
-     int sigemptyset(sigset_t *set) {
-       if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
-       *set = 0; return 0;
-     }
-     int sigfillset(sigset_t *set) {
-       int i;
-       if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
-       for (i = 0; i < NSIG; i++) *set |= (1 << i);
-       return 0;
-     }
-     int sigaddset(sigset_t *set, int sig) {
-       if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
-       if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
-       *set |= (1 << (sig - 1));
-       return 0;
-     }
-     int sigdelset(sigset_t *set, int sig) {
-       if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
-       if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
-       *set &= ~(1 << (sig - 1));
-       return 0;
-     }
-     int sigismember(sigset_t *set, int sig) {
-       if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
-       if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
-       *set & (1 << (sig - 1));
-     }
-     /* The tools for sigprocmask() are there, just not the routine itself */
-#    ifndef SIG_UNBLOCK
-#      define SIG_UNBLOCK 1
-#    endif
-#    ifndef SIG_BLOCK
-#      define SIG_BLOCK 2
-#    endif
-#    ifndef SIG_SETMASK
-#      define SIG_SETMASK 3
-#    endif
-     int sigprocmask(int how, sigset_t *set, sigset_t *oset) {
-       if (!set || !oset) {
-         set_errno(EFAULT); set_vaxc_errno(SS$_ACCVIO);
-         return -1;
-       }
-       switch (how) {
-         case SIG_SETMASK:
-           *oset = sigsetmask(*set);
-           break;
-         case SIG_BLOCK:
-           *oset = sigblock(*set);
-           break;
-         case SIG_UNBLOCK:
-           *oset = sigblock(0);
-           sigsetmask(*oset & ~*set);
-           break;
-         default:
-           set_errno(EINVAL); set_vaxc_errno(LIB$_INVARG);
-           return -1;
-       }
-       return 0;
-     }
-#    define sigaction sigvec
-#    define sa_flags sv_onstack
-#    define sa_handler sv_handler
-#    define sa_mask sv_mask
-#    define sigsuspend(set) sigpause(*set)
-#  else
-#    define HAS_TZNAME  /* shows up in VMS 7.0 */
-#  endif /* __VMS_VER < 70000000 */
+#if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
+#    define HAS_TZNAME  /* shows up in VMS 7.0 or Dec C 5.6 */
+#    include <utsname.h>
+#  endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
 
    /* The POSIX notion of ttyname() is better served by getname() under VMS */
    static char ttnambuf[64];
@@ -344,17 +275,14 @@ init_tm(ptm)              /* see mktime, strftime and asctime     */
 #endif
 
 static int
-not_here(s)
-char *s;
+not_here(char *s)
 {
     croak("POSIX::%s not implemented on this architecture", s);
     return -1;
 }
 
 static double
-constant(name, arg)
-char *name;
-int arg;
+constant(char *name, int arg)
 {
     errno = 0;
     switch (*name) {
@@ -1731,13 +1659,13 @@ int arg;
                    goto not_there;
 #endif
 #ifdef SIG_DFL
-               if (strEQ(name, "SIG_DFL")) return (int)SIG_DFL;
+               if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
 #endif
 #ifdef SIG_ERR
-               if (strEQ(name, "SIG_ERR")) return (int)SIG_ERR;
+               if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
 #endif
 #ifdef SIG_IGN
-               if (strEQ(name, "SIG_IGN")) return (int)SIG_IGN;
+               if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
 #endif
                if (strEQ(name, "SIG_SETMASK"))
 #ifdef SIG_SETMASK