blob: 76779ab29d11ec40aad4d40b471d77339b307a54 [file] [log] [blame]
Dmitriy Ivanovf57874d2014-10-07 13:43:23 -07001/*
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 Rogerscf7f1912014-10-22 22:06:39 -070017#include <stdio.h>
18#include <stdlib.h>
19
Dmitriy Ivanovf57874d2014-10-07 13:43:23 -070020#ifdef HAVE_ANDROID_OS
21#include <android/log.h>
22#else
23#include <stdarg.h>
24#include <iostream>
25#endif
26
Dmitriy Ivanovf57874d2014-10-07 13:43:23 -070027#include "sigchain.h"
28
Andreas Gampe9d9cfa82014-11-03 20:25:24 -080029#define ATTRIBUTE_UNUSED __attribute__((__unused__))
30
Dmitriy Ivanovf57874d2014-10-07 13:43:23 -070031static 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 Gampe277ccbd2014-11-03 21:36:10 -080044namespace art {
45
46
Andreas Gampe9d9cfa82014-11-03 20:25:24 -080047extern "C" void ClaimSignalChain(int signal ATTRIBUTE_UNUSED,
48 struct sigaction* oldaction ATTRIBUTE_UNUSED) {
Dmitriy Ivanovf57874d2014-10-07 13:43:23 -070049 log("ClaimSignalChain is not exported by the main executable.");
50 abort();
51}
52
Andreas Gampe9d9cfa82014-11-03 20:25:24 -080053extern "C" void UnclaimSignalChain(int signal ATTRIBUTE_UNUSED) {
Dmitriy Ivanovf57874d2014-10-07 13:43:23 -070054 log("UnclaimSignalChain is not exported by the main executable.");
55 abort();
56}
57
Andreas Gampe9d9cfa82014-11-03 20:25:24 -080058extern "C" void InvokeUserSignalHandler(int sig ATTRIBUTE_UNUSED,
59 siginfo_t* info ATTRIBUTE_UNUSED,
60 void* context ATTRIBUTE_UNUSED) {
Dmitriy Ivanovf57874d2014-10-07 13:43:23 -070061 log("InvokeUserSignalHandler is not exported by the main executable.");
62 abort();
63}
64
65extern "C" void InitializeSignalChain() {
66 log("InitializeSignalChain is not exported by the main executable.");
67 abort();
68}
Mathieu Chartierd0004802014-10-15 16:59:47 -070069
Andreas Gampe9d9cfa82014-11-03 20:25:24 -080070extern "C" void EnsureFrontOfChain(int signal ATTRIBUTE_UNUSED,
71 struct sigaction* expected_action ATTRIBUTE_UNUSED) {
Mathieu Chartierd0004802014-10-15 16:59:47 -070072 log("EnsureFrontOfChain is not exported by the main executable.");
73 abort();
74}
Andreas Gampe277ccbd2014-11-03 21:36:10 -080075
76} // namespace art