2 Copyright (C) 2023-2025 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
23 /* Used to synchronize across multiple processes. */
26 /* Default constructor. */
29 /* Intended constructor for use. Filename should not be used for anything
30 other than locking to prevent unintentional unlock. */
31 lockfile (std::string filename
): lockfile ()
33 this->filename
= std::move (filename
);
35 lockfile (lockfile
const& o
): lockfile (o
.filename
)
38 void operator=(lockfile o
)
41 this->filename
= o
.filename
;
46 /* Unique write lock. No other lock can be held on this lockfile.
50 /* Unique write lock. No other lock can be held on this lockfile.
51 Only locks if this filelock is not locked by any other process.
52 Return whether locking was successful. */
53 int try_lock_write ();
55 /* Shared read lock. Only read lock can be held concurrently.
56 If write lock is already held by this process, it will be
61 /* Unlock all previously placed locks. */
64 /* Returns whether any lock is held. */
71 /* Are lockfiles supported? */
72 static bool lockfile_supported ();