Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | |
Ian Rogers | cf7f191 | 2014-10-22 22:06:39 -0700 | [diff] [blame] | 17 | #include <stdio.h> |
| 18 | #include <stdlib.h> |
| 19 | |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 20 | #ifdef HAVE_ANDROID_OS |
| 21 | #include <android/log.h> |
| 22 | #else |
| 23 | #include <stdarg.h> |
| 24 | #include <iostream> |
| 25 | #endif |
| 26 | |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 27 | #include "sigchain.h" |
| 28 | |
Andreas Gampe | 9d9cfa8 | 2014-11-03 20:25:24 -0800 | [diff] [blame] | 29 | #define ATTRIBUTE_UNUSED __attribute__((__unused__)) |
| 30 | |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 31 | static void log(const char* format, ...) { |
| 32 | char buf[256]; |
| 33 | va_list ap; |
| 34 | va_start(ap, format); |
| 35 | vsnprintf(buf, sizeof(buf), format, ap); |
| 36 | #ifdef HAVE_ANDROID_OS |
| 37 | __android_log_write(ANDROID_LOG_ERROR, "libsigchain", buf); |
| 38 | #else |
| 39 | std::cout << buf << "\n"; |
| 40 | #endif |
| 41 | va_end(ap); |
| 42 | } |
| 43 | |
Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 44 | namespace art { |
| 45 | |
| 46 | |
Andreas Gampe | 9d9cfa8 | 2014-11-03 20:25:24 -0800 | [diff] [blame] | 47 | extern "C" void ClaimSignalChain(int signal ATTRIBUTE_UNUSED, |
| 48 | struct sigaction* oldaction ATTRIBUTE_UNUSED) { |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 49 | log("ClaimSignalChain is not exported by the main executable."); |
| 50 | abort(); |
| 51 | } |
| 52 | |
Andreas Gampe | 9d9cfa8 | 2014-11-03 20:25:24 -0800 | [diff] [blame] | 53 | extern "C" void UnclaimSignalChain(int signal ATTRIBUTE_UNUSED) { |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 54 | log("UnclaimSignalChain is not exported by the main executable."); |
| 55 | abort(); |
| 56 | } |
| 57 | |
Andreas Gampe | 9d9cfa8 | 2014-11-03 20:25:24 -0800 | [diff] [blame] | 58 | extern "C" void InvokeUserSignalHandler(int sig ATTRIBUTE_UNUSED, |
| 59 | siginfo_t* info ATTRIBUTE_UNUSED, |
| 60 | void* context ATTRIBUTE_UNUSED) { |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 61 | log("InvokeUserSignalHandler is not exported by the main executable."); |
| 62 | abort(); |
| 63 | } |
| 64 | |
| 65 | extern "C" void InitializeSignalChain() { |
| 66 | log("InitializeSignalChain is not exported by the main executable."); |
| 67 | abort(); |
| 68 | } |
Mathieu Chartier | d000480 | 2014-10-15 16:59:47 -0700 | [diff] [blame] | 69 | |
Andreas Gampe | 9d9cfa8 | 2014-11-03 20:25:24 -0800 | [diff] [blame] | 70 | extern "C" void EnsureFrontOfChain(int signal ATTRIBUTE_UNUSED, |
| 71 | struct sigaction* expected_action ATTRIBUTE_UNUSED) { |
Mathieu Chartier | d000480 | 2014-10-15 16:59:47 -0700 | [diff] [blame] | 72 | log("EnsureFrontOfChain is not exported by the main executable."); |
| 73 | abort(); |
| 74 | } |
Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 75 | |
| 76 | } // namespace art |