| Elliott Hughes | c5d028f | 2013-01-10 14:42:14 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2013 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #ifndef LIBC_PRIVATE_KERNEL_SIGSET_T_H_ | 
|  | 18 | #define LIBC_PRIVATE_KERNEL_SIGSET_T_H_ | 
|  | 19 |  | 
| Dan Albert | 75ef63d | 2014-11-21 00:18:07 -0800 | [diff] [blame] | 20 | #include <signal.h> | 
|  | 21 |  | 
| Elliott Hughes | c5d028f | 2013-01-10 14:42:14 -0800 | [diff] [blame] | 22 | // Our sigset_t is wrong for ARM and x86. It's 32-bit but the kernel expects 64 bits. | 
|  | 23 | // This means we can't support real-time signals correctly until we can change the ABI. | 
|  | 24 | // In the meantime, we can use this union to pass an appropriately-sized block of memory | 
|  | 25 | // to the kernel, at the cost of not being able to refer to real-time signals. | 
|  | 26 | union kernel_sigset_t { | 
|  | 27 | kernel_sigset_t() { | 
|  | 28 | clear(); | 
|  | 29 | } | 
|  | 30 |  | 
|  | 31 | kernel_sigset_t(const sigset_t* value) { | 
|  | 32 | clear(); | 
|  | 33 | set(value); | 
|  | 34 | } | 
|  | 35 |  | 
|  | 36 | void clear() { | 
| Elliott Hughes | 1195207 | 2013-10-24 15:15:14 -0700 | [diff] [blame] | 37 | __builtin_memset(this, 0, sizeof(*this)); | 
| Elliott Hughes | c5d028f | 2013-01-10 14:42:14 -0800 | [diff] [blame] | 38 | } | 
|  | 39 |  | 
|  | 40 | void set(const sigset_t* value) { | 
|  | 41 | bionic = *value; | 
|  | 42 | } | 
|  | 43 |  | 
|  | 44 | sigset_t* get() { | 
|  | 45 | return &bionic; | 
|  | 46 | } | 
|  | 47 |  | 
|  | 48 | sigset_t bionic; | 
|  | 49 | #ifndef __mips__ | 
|  | 50 | uint32_t kernel[2]; | 
|  | 51 | #endif | 
|  | 52 | }; | 
|  | 53 |  | 
|  | 54 | #endif |