140d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes/*
240d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * Copyright (C) 2013 The Android Open Source Project
340d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * All rights reserved.
440d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes *
540d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * Redistribution and use in source and binary forms, with or without
640d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * modification, are permitted provided that the following conditions
740d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * are met:
840d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes *  * Redistributions of source code must retain the above copyright
940d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes *    notice, this list of conditions and the following disclaimer.
1040d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes *  * Redistributions in binary form must reproduce the above copyright
1140d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes *    notice, this list of conditions and the following disclaimer in
1240d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes *    the documentation and/or other materials provided with the
1340d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes *    distribution.
1440d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes *
1540d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1640d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1740d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
1840d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
1940d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
2040d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
2140d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
2240d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2340d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2440d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
2540d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2640d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes * SUCH DAMAGE.
2740d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes */
2840d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes
2940d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes#include <signal.h>
3040d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes
3140d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes#include "private/kernel_sigset_t.h"
3240d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes
3340d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughesextern "C" int __rt_sigpending(const kernel_sigset_t*, size_t);
3440d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes
3540d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughesint sigpending(sigset_t* bionic_set) {
3640d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes  kernel_sigset_t set;
3740d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes  int result = __rt_sigpending(&set, sizeof(set));
3840d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes  if (result != -1) {
3940d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes    *bionic_set = set.bionic;
4040d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes  }
4140d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes  return result;
4240d105ccb3e6283566ce54b693b3088f31aa4f26Elliott Hughes}
43