develooper Front page | perl.perl5.porters | Postings from November 2000

[PATCH perl@7573] configure.com and st-lock.t changes ford_fcntl_can_lock

From:
Craig A. Berry
Date:
November 6, 2000 21:50
Subject:
[PATCH perl@7573] configure.com and st-lock.t changes ford_fcntl_can_lock
Message ID:
p04330101b62d442df937@[172.16.52.1]
Thanks to Andy for laying the foundation.  This provides the VMS
equivalent to his recent Configure changes.  I've tested this on VMS
7.1, where it correctly says no to d_fcntl_can_lock because fcntl()
doesn't exist, and on VMS 7.2-1, where it correctly says no because
the function exists but doesn't do locking.  If I've written it right
we should automatically be in business when the C RTL catches up and
*can* do locking.

--- configure.com;-0    Wed Oct 25 23:36:59 2000
+++ configure.com       Mon Nov  6 17:33:57 2000
@@ -3476,6 +3476,54 @@
  $ GOSUB inlibc
  $ d_fcntl = tmp
  $!
+$! Check for fcntl locking capability
+$!
+$ echo4 "Checking if fcntl-based file locking works... "
+$ tmp = "undef"
+$ IF d_fcntl .EQS. "define"
+$ THEN
+$   OS
+$   WS "#include <stdio.h>"
+$   WS "#if defined(__DECC) || defined(__DECCXX)"
+$   WS "#include <stdlib.h>"
+$   WS "#endif"
+$   WS "#include <fcntl.h>"
+$   WS "#include <unistd.h>"
+$   WS "int main() {"
+$   WS "#if defined(F_SETLK) && defined(F_SETLKW)"
+$   WS "     struct flock flock;"
+$   WS "     int retval, fd;"
+$   WS "     fd = open(""try.c"", O_RDONLY);"
+$   WS "     flock.l_type = F_RDLCK;"
+$   WS "     flock.l_whence = SEEK_SET;"
+$   WS "     flock.l_start = flock.l_len = 0;"
+$   WS "     retval = fcntl(fd, F_SETLK, &flock);"
+$   WS "     close(fd);"
+$   WS "     (retval < 0 ? printf(""undef\n"") : printf(""define\n""));"
+$   WS "#else"
+$   WS "     printf(""undef\n"");"
+$   WS "#endif"
+$   WS "}"
+$   CS
+$   GOSUB link_ok
+$   IF compile_status .EQ. good_compile .AND. link_status .EQ. good_link
+$   THEN
+$     GOSUB just_mcr_it
+$     IF tmp .EQS. "define"
+$     THEN
+$       echo4 "Yes, it seems to work."
+$     ELSE
+$       echo4 "Nope, it didn't work."
+$     ENDIF
+$   ELSE
+$     echo4 "I'm unable to compile the test program, so I'll assume not."
+$     tmp = "undef"
+$   ENDIF
+$ ELSE
+$   echo4 "Nope, since you don't even have fcntl()."
+$ ENDIF
+$ d_fcntl_can_lock = tmp
+$!
  $! Check for memchr
  $!
  $ OS
@@ -4753,6 +4801,7 @@
  $ WC "d_fchmod='undef'"
  $ WC "d_fchown='undef'"
  $ WC "d_fcntl='" + d_fcntl + "'"
+$ WC "d_fcntl_can_lock='" + d_fcntl_can_lock + "'"
  $ WC "d_fd_set='" + d_fd_set + "'"
  $ WC "d_fgetpos='define'"
  $ WC "d_flexfnam='define'"
[END OF PATCH]

Also a small patch to that wicked little test that got us started
down this path:

--- t/lib/st-lock.t;-0  Thu Oct 26 19:12:45 2000
+++ t/lib/st-lock.t     Mon Nov  6 23:30:16 2000
@@ -25,7 +25,7 @@
          print "1..0 # Skip: Storable was not built\n";
          exit 0;
      }
-    if (!$Config{'d_flock'} && !$Config{'d_fcntl'} && !$Config{'d_lockf'}) {
+    if (!$Config{'d_flock'} && !$Config{'d_fcntl_can_lock'} && 
!$Config{'d_lockf'}) {
          print "1..0 # Skip: no flock or flock emulation on this platform\n";
          exit 0;
      }
[END OF PATCH]

-- 
____________________________________________
Craig A. Berry
mailto:craig.berry@psinetcs.com

"Literary critics usually know what they're
talking about. Even if they're wrong."
	-- Perl creator Larry Wall



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About