hr_HR locale: fix thousands_sep and mon_thousands_sep
[glibc.git] / hurd / fcntl-internal.h
blobd795e4089c623f780790a922adacc846dd5193c1
1 /* Helper functions for translating between O_* and SOCK_* flags.
2 Copyright (C) 2008-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
20 #include <fcntl.h>
21 #include <sys/socket.h>
23 /* Do some compile-time checks for the SOCK_* constants, which we rely on. */
24 _Static_assert (SOCK_CLOEXEC == O_CLOEXEC,
25 "SOCK_CLOEXEC is assumed to be the same as O_CLOEXEC");
26 _Static_assert (((SOCK_MAX - 1) | SOCK_TYPE_MASK) == SOCK_TYPE_MASK,
27 "SOCK_TYPE_MASK must contain SOCK_MAX - 1");
28 _Static_assert ((SOCK_CLOEXEC & SOCK_TYPE_MASK) == 0,
29 "SOCK_TYPE_MASK must not contain SOCK_CLOEXEC");
30 _Static_assert ((SOCK_NONBLOCK & SOCK_TYPE_MASK) == 0,
31 "SOCK_TYPE_MASK must not contain SOCK_NONBLOCK");
34 /* Convert from SOCK_* flags to O_* flags. */
35 __extern_always_inline
36 int
37 sock_to_o_flags (int in)
39 int out = 0;
41 if (in & SOCK_NONBLOCK)
42 out |= O_NONBLOCK;
43 /* Others are passed through unfiltered. */
44 out |= in & ~(SOCK_NONBLOCK);
46 return out;
49 /* Convert from O_* flags to SOCK_* flags. */
50 __extern_always_inline
51 int
52 o_to_sock_flags (int in)
54 int out = 0;
56 if (in & O_NONBLOCK)
57 out |= SOCK_NONBLOCK;
58 /* Others are passed through unfiltered. */
59 out |= in & ~(O_NONBLOCK);
61 return out;