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/>.
23 #include <sys/cpuset.h>
24 #include <sys/random.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
,
34 #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048
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
)
42 if (pathptr
== (uintptr_t)SHM_ANON
) {
45 upath
= lock_user_string(pathptr
);
47 return -TARGET_EFAULT
;
53 uname
= lock_user_string(nameptr
);
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);
67 unlock_user(uname
, nameptr
, 0);
71 #endif /* __FreeBSD_version >= 1300048 */
73 #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300049
75 static inline abi_long
do_freebsd_shm_rename(abi_ulong fromptr
, abi_ulong toptr
,
81 ufrom
= lock_user_string(fromptr
);
83 return -TARGET_EFAULT
;
85 uto
= lock_user_string(toptr
);
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);
96 #endif /* __FreeBSD_version >= 1300049 */
98 #endif /* OS_MISC_H */