macosx: Remove unnecessary variable and llabs call
[vlc.git] / compat / sigwait.c
blobe5a082d2d667ae0fbd1cfd03c368c728eaed9dab
1 /*****************************************************************************
2 * sigwait.c: POSIX sigwait() replacement
3 *****************************************************************************
4 * Copyright © 2017 VLC authors and VideoLAN
6 * Author: Julian Scheel <julian@jusst.de>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
27 #ifdef __native_client__
28 /* NaCl has no working sigwait, but SIGPIPE, for which vlc uses sigwait
29 * currently, is never generated in NaCl. So for SIGPIPE it's safe to instantly
30 * return, for all others run into an assertion. */
32 #include <assert.h>
33 #include <signal.h>
35 int sigwait(const sigset_t *set, int *sig)
37 sigset_t s = *set;
38 if (sigemptyset(&s))
39 return 0;
40 assert(sigismember(&s, SIGPIPE));
41 sigdelset(&s, SIGPIPE);
42 assert(sigemptyset(&s));
44 *sig = SIGPIPE;
45 return 0;
47 #else
48 # error sigwait not implemented on your platform!
49 #endif