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
17 #include <stdio.h>
18 #include <stdlib.h>
19
20 #ifdef ART_TARGET_ANDROID
21 #include <android/log.h>
22 #else
23 #include <stdarg.h>
24 #include <iostream>
25 #endif
26
27 #include "sigchain.h"
28
29 #define ATTRIBUTE_UNUSED __attribute__((__unused__))
30
31 // We cannot annotate the declarations, as they are not no-return in the non-dummy version.
32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
34 #pragma GCC diagnostic ignored "-Wmissing-noreturn"
35
log(const char * format,...)36 static void log(const char* format, ...) {
37 char buf[256];
38 va_list ap;
39 va_start(ap, format);
40 vsnprintf(buf, sizeof(buf), format, ap);
41 #ifdef ART_TARGET_ANDROID
42 __android_log_write(ANDROID_LOG_ERROR, "libsigchain", buf);
43 #else
44 std::cout << buf << "\n";
45 #endif
46 va_end(ap);
47 }
48
49 namespace art {
50
EnsureFrontOfChain(int signal ATTRIBUTE_UNUSED)51 extern "C" void EnsureFrontOfChain(int signal ATTRIBUTE_UNUSED) {
52 log("EnsureFrontOfChain is not exported by the main executable.");
53 abort();
54 }
55
AddSpecialSignalHandlerFn(int signal ATTRIBUTE_UNUSED,SigchainAction * sa ATTRIBUTE_UNUSED)56 extern "C" void AddSpecialSignalHandlerFn(int signal ATTRIBUTE_UNUSED,
57 SigchainAction* sa ATTRIBUTE_UNUSED) {
58 log("SetSpecialSignalHandlerFn is not exported by the main executable.");
59 abort();
60 }
61
RemoveSpecialSignalHandlerFn(int signal ATTRIBUTE_UNUSED,bool (* fn)(int,siginfo_t *,void *)ATTRIBUTE_UNUSED)62 extern "C" void RemoveSpecialSignalHandlerFn(int signal ATTRIBUTE_UNUSED,
63 bool (*fn)(int, siginfo_t*, void*) ATTRIBUTE_UNUSED) {
64 log("SetSpecialSignalHandlerFn is not exported by the main executable.");
65 abort();
66 }
67
68 #pragma GCC diagnostic pop
69
70 } // namespace art
71