annotate lib/cycle-check.h @ 17363:5a51fb7777a9

sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin Problem reported by Marco Atzeri in <http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>. * lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]: Simply delegate to the system <sys/select.h> in this case too. Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to be needed on Solaris either. * lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]: Simply delgate to the system <sys/time.h> in this case.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 19 Mar 2013 09:08:47 -0700
parents e542fd46ad6f
children 344018b6e5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5118
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 /* help detect directory cycles efficiently
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
3 Copyright (C) 2003-2004, 2006, 2009-2013 Free Software Foundation, Inc.
5118
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7162
diff changeset
5 This program is free software: you can redistribute it and/or modify
5118
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7162
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7162
diff changeset
8 (at your option) any later version.
5118
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
13 GNU General Public License for more details.
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
14
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7162
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
5118
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
17
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
18 /* Written by Jim Meyering */
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
20 #ifndef CYCLE_CHECK_H
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
21 # define CYCLE_CHECK_H 1
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
22
7162
19c2e5121b2f Add and change modules to make it easier for coreutils to use
Paul Eggert <eggert@cs.ucla.edu>
parents: 6915
diff changeset
23 # include <stdint.h>
5118
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
24 # include <stdbool.h>
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
25 # include "dev-ino.h"
6912
314715e0260d Merge from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
26 # include "same-inode.h"
5118
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
27
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
28 struct cycle_check_state
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
29 {
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
30 struct dev_ino dev_ino;
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
31 uintmax_t chdir_counter;
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
32 int magic;
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
33 };
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
34
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
35 void cycle_check_init (struct cycle_check_state *state);
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
36 bool cycle_check (struct cycle_check_state *state, struct stat const *sb);
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
37
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
38 # define CYCLE_CHECK_REFLECT_CHDIR_UP(State, SB_dir, SB_subdir) \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
39 do \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
40 { \
6915
85faf7df624e * cycle-check.h (CYCLE_CHECK_REFLECT_CHDIR_UP): Abort if this
Paul Eggert <eggert@cs.ucla.edu>
parents: 6912
diff changeset
41 /* You must call cycle_check at least once before using this macro. */ \
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
42 if ((State)->chdir_counter == 0) \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
43 abort (); \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
44 if (SAME_INODE ((State)->dev_ino, SB_subdir)) \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
45 { \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
46 (State)->dev_ino.st_dev = (SB_dir).st_dev; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
47 (State)->dev_ino.st_ino = (SB_dir).st_ino; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
48 } \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12069
diff changeset
49 } \
6912
314715e0260d Merge from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
50 while (0)
314715e0260d Merge from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
51
5118
20e26e1fcaec New cycle-check module imported from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
52 #endif