Changeset View
Changeset View
Standalone View
Standalone View
tools/build/cross-build/include/linux/fcntl.h
/*- | /*- | ||||
* SPDX-License-Identifier: BSD-2-Clause | * SPDX-License-Identifier: BSD-2-Clause | ||||
* | * | ||||
* Copyright 2018-2020 Alex Richardson <arichardson@FreeBSD.org> | * Copyright 2018-2021 Alex Richardson <arichardson@FreeBSD.org> | ||||
* | * | ||||
* This software was developed by SRI International and the University of | * This software was developed by SRI International and the University of | ||||
* Cambridge Computer Laboratory (Department of Computer Science and | * Cambridge Computer Laboratory (Department of Computer Science and | ||||
* Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the | * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the | ||||
* DARPA SSITH research programme. | * DARPA SSITH research programme. | ||||
* | * | ||||
* This software was developed by SRI International and the University of | * This software was developed by SRI International and the University of | ||||
* Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) | * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) | ||||
* ("CTSRD"), as part of the DARPA CRASH research programme. | * ("CTSRD"), as part of the DARPA CRASH research programme. | ||||
* | * | ||||
* This work was supported by Innovate UK project 105694, "Digital Security by | |||||
* Design (DSbD) Technology Platform Prototype". | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
* notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||
* documentation and/or other materials provided with the distribution. | * documentation and/or other materials provided with the distribution. | ||||
Show All 9 Lines | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#pragma once | #pragma once | ||||
/* <bits/fcntl.h> includes <bits/stat.h> which contains a member __unused */ | /* <bits/fcntl.h> includes <bits/stat.h> which contains a member __unused */ | ||||
#include "__unused_workaround_start.h" | #include "__unused_workaround_start.h" | ||||
#include_next <fcntl.h> | #include_next <fcntl.h> | ||||
#include "__unused_workaround_end.h" | #include "__unused_workaround_end.h" | ||||
#ifdef __unused_undefd | |||||
#undef __unused_undefd | |||||
#define __unused __attribute__((unused)) | |||||
#endif | |||||
#include <sys/file.h> | #include <sys/file.h> | ||||
#ifndef O_EXLOCK | |||||
#define O_EXLOCK (1 << 30) | |||||
#endif | |||||
#ifndef O_SHLOCK | |||||
#define O_SHLOCK (1 << 31) | |||||
#endif | |||||
#undef open | |||||
#define open(path, flags, ...) ({ \ | |||||
int __fd = (open)(path, flags, ##__VA_ARGS__); \ | |||||
if (flags & O_EXLOCK) flock(__fd, LOCK_EX); \ | |||||
if (flags & O_SHLOCK) flock(__fd, LOCK_SH); \ | |||||
__fd; }) |