qapi: Fix malformed "Since:" section tags (again)
[qemu/armbru.git] / bsd-user / freebsd / os-misc.h
blob71145764a4d1c41c1ead547628c5ef314086cf86
1 /*
2 * miscellaneous FreeBSD system call shims
4 * Copyright (c) 2013-14 Stacey D. Son
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef OS_MISC_H
21 #define OS_MISC_H
23 #include <sys/cpuset.h>
24 #include <sys/random.h>
25 #include <sched.h>
28 * shm_open2 isn't exported, but the __sys_ alias is. We can use either for the
29 * static version, but to dynamically link we have to use the sys version.
31 int __sys_shm_open2(const char *path, int flags, mode_t mode, int shmflags,
32 const char *);
34 #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048
35 /* shm_open2(2) */
36 static inline abi_long do_freebsd_shm_open2(abi_ulong pathptr, abi_ulong flags,
37 abi_long mode, abi_ulong shmflags, abi_ulong nameptr)
39 int ret;
40 void *uname, *upath;
42 if (pathptr == (uintptr_t)SHM_ANON) {
43 upath = SHM_ANON;
44 } else {
45 upath = lock_user_string(pathptr);
46 if (upath == NULL) {
47 return -TARGET_EFAULT;
51 uname = NULL;
52 if (nameptr != 0) {
53 uname = lock_user_string(nameptr);
54 if (uname == NULL) {
55 unlock_user(upath, pathptr, 0);
56 return -TARGET_EFAULT;
59 ret = get_errno(__sys_shm_open2(upath,
60 target_to_host_bitmask(flags, fcntl_flags_tbl), mode,
61 target_to_host_bitmask(shmflags, shmflag_flags_tbl), uname));
63 if (upath != SHM_ANON) {
64 unlock_user(upath, pathptr, 0);
66 if (uname != NULL) {
67 unlock_user(uname, nameptr, 0);
69 return ret;
71 #endif /* __FreeBSD_version >= 1300048 */
73 #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300049
74 /* shm_rename(2) */
75 static inline abi_long do_freebsd_shm_rename(abi_ulong fromptr, abi_ulong toptr,
76 abi_ulong flags)
78 int ret;
79 void *ufrom, *uto;
81 ufrom = lock_user_string(fromptr);
82 if (ufrom == NULL) {
83 return -TARGET_EFAULT;
85 uto = lock_user_string(toptr);
86 if (uto == NULL) {
87 unlock_user(ufrom, fromptr, 0);
88 return -TARGET_EFAULT;
90 ret = get_errno(shm_rename(ufrom, uto, flags));
91 unlock_user(ufrom, fromptr, 0);
92 unlock_user(uto, toptr, 0);
94 return ret;
96 #endif /* __FreeBSD_version >= 1300049 */
98 #endif /* OS_MISC_H */