- int lockfd;
- char *filen = "/tmp/conftest.lock";
- char *resn = "test";
- int fd;
-
- unlink(filen);
- if ((lockfd = open(filen, O_RDONLY|O_CREAT|O_EXCL, 0600)) == -1) {
- perror (filen);
- exit(10);
- }
-
- if (amroflock(lockfd, resn) != 0) {
- perror ("amroflock");
- exit(1);
- }
- if (amfunlock(lockfd, resn) != 0) {
- perror ("amfunlock/2");
- exit(2);
- }
-
- /*
- * Do not use aclose() here. During configure we do not have
- * areads_relbuf() available and it makes configure think all
- * the tests have failed.
- */
- close(lockfd);
-
- unlink(filen);
- if ((lockfd = open(filen, O_WRONLY|O_CREAT|O_EXCL, 0600)) == -1) {
- perror (filen);
- exit(20);
- }
-
- if (amflock(lockfd, resn) != 0) {
- perror ("amflock");
- exit(3);
- }
- if (amfunlock(lockfd, resn) != 0) {
- perror ("amfunlock/4");
- exit(4);
- }
+ if (!amflock_impls[0]) return 0; /* no locking */
+ return amflock_impls[0]->amflock_impl(fd, resource);
+}