1a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand/*
2a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * Copyright (C) 2013 The Android Open Source Project
3a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * All rights reserved.
4a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand *
5a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * Redistribution and use in source and binary forms, with or without
6a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * modification, are permitted provided that the following conditions
7a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * are met:
8a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand *  * Redistributions of source code must retain the above copyright
9a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand *    notice, this list of conditions and the following disclaimer.
10a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand *  * Redistributions in binary form must reproduce the above copyright
11a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand *    notice, this list of conditions and the following disclaimer in
12a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand *    the documentation and/or other materials provided with the
13a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand *    distribution.
14a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand *
15a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand * SUCH DAMAGE.
27a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand */
28a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand
29a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand#include <sys/signalfd.h>
30a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand
315905d6f8797056ca4178d42bf1220b6692e557a5Elliott Hughes#include "private/SigSetConverter.h"
32a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand
335905d6f8797056ca4178d42bf1220b6692e557a5Elliott Hughesextern "C" int __signalfd4(int, const sigset64_t*, size_t, int);
34a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand
35c5d028fc913de84a781bd61084bf7ae2182fd48eElliott Hughesint signalfd(int fd, const sigset_t* mask, int flags) {
365905d6f8797056ca4178d42bf1220b6692e557a5Elliott Hughes  SigSetConverter set = {};
375905d6f8797056ca4178d42bf1220b6692e557a5Elliott Hughes  set.sigset = *mask;
385905d6f8797056ca4178d42bf1220b6692e557a5Elliott Hughes  return signalfd64(fd, &set.sigset64, flags);
395905d6f8797056ca4178d42bf1220b6692e557a5Elliott Hughes}
405905d6f8797056ca4178d42bf1220b6692e557a5Elliott Hughes
415905d6f8797056ca4178d42bf1220b6692e557a5Elliott Hughesint signalfd64(int fd, const sigset64_t* mask, int flags) {
425905d6f8797056ca4178d42bf1220b6692e557a5Elliott Hughes  return __signalfd4(fd, mask, sizeof(*mask), flags);
43a4b2dc016fa62bd172a73c3f8971c805700ffb0fRom Lemarchand}
44