From ec688b4723a041044226358bcd4dd6e2da39da49 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Thu, 23 Feb 2017 17:01:02 +0100 Subject: Initial commit: cframework. Longbow and Libparc Change-Id: I90378dbd30da6033b20fb1f829b3b822cf366c59 Signed-off-by: Luca Muscariello --- longbow/src/LongBow/longBow_EventType.c | 224 ++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100755 longbow/src/LongBow/longBow_EventType.c (limited to 'longbow/src/LongBow/longBow_EventType.c') diff --git a/longbow/src/LongBow/longBow_EventType.c b/longbow/src/LongBow/longBow_EventType.c new file mode 100755 index 00000000..7a99b0c3 --- /dev/null +++ b/longbow/src/LongBow/longBow_EventType.c @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * + */ +#include + +#include +#include +#include +#include +#include + +#include +#include + +/** @cond private */ +struct longbow_event_type { + const char *kind; + const char *name; + LongBowStatus statusCode; + bool suppressBacktrace; + bool suppressAlert; +}; +/** @endcond */ + +#define _eventType(_kind, _name, _code, _suppressBacktrace, _suppressAlert) { \ + .kind = _kind, \ + .name = _name, \ + .statusCode = _code, \ + .suppressBacktrace = _suppressBacktrace, \ + .suppressAlert = _suppressAlert \ +} + +LongBowEventType LongBowAssertEvent = _eventType("Assert", "Assert", LONGBOW_STATUS_FAILED, false, false); + +LongBowEventType LongBowTrapEvent = _eventType("Trap", "Trap", LONGBOW_STATUS_FAILED, false, false); + +LongBowEventType LongBowTrapOutOfBounds = _eventType("Trap", "OutOfBounds", LONGBOW_STATUS_FAILED, false, false); + +LongBowEventType LongBowTrapIllegalValue = _eventType("Trap", "IllegalValue", LONGBOW_STATUS_FAILED, false, false); + +LongBowEventType LongBowTrapInvalidValue = _eventType("Trap", "InvalidValue", LONGBOW_STATUS_FAILED, false, false); + +LongBowEventType LongBowTrapUnrecoverableState = _eventType("Trap", "UnrecoverableState", LONGBOW_STATUS_FAILED, false, false); + +LongBowEventType LongBowTrapNotImplemented = _eventType("Trap", "Implemented", LONGBOW_STATUS_FAILED, false, false); + +LongBowEventType LongBowTrapOutOfMemoryEvent = _eventType("Trap", "Out of Memory", LONGBOW_STATUS_FAILED, false, false); + +LongBowEventType LongBowTrapCannotObtainLockEvent = _eventType("Trap", "Cannot obtain lock", LONGBOW_STATUS_FAILED, false, false); + +LongBowEventType LongBowTrapUnexpectedStateEvent = _eventType("Trap", "Unexpected State", LONGBOW_STATUS_FAILED, false, false); + +LongBowEventType LongBowTestSkippedEvent = _eventType("Test", "Skipped", LONGBOW_STATUS_SKIPPED, true, false); + +LongBowEventType LongBowTestUnimplementedEvent = _eventType("Test", "Unimplemented", LongBowStatus_UNIMPLEMENTED, true, true); + +LongBowEventType LongBowEventSIGHUP = _eventType("Signal", "SIGHUP", LongBowStatus_SIGNAL(SIGHUP), false, false); + +LongBowEventType LongBowEventSIGINT = _eventType("Signal", "SIGINT", LongBowStatus_SIGNAL(SIGINT), false, false); + +LongBowEventType LongBowEventSIGQUIT = _eventType("Signal", "SIGQUIT", LongBowStatus_SIGNAL(SIGQUIT), false, false); + +LongBowEventType LongBowEventSIGILL = _eventType("Signal", "SIGILL", LongBowStatus_SIGNAL(SIGILL), false, false); + +LongBowEventType LongBowEventSIGTRAP = _eventType("Signal", "SIGTRAP", LongBowStatus_SIGNAL(SIGTRAP), false, false); + +LongBowEventType LongBowEventSIGABRT = _eventType("Signal", "SIGABRT", LongBowStatus_SIGNAL(SIGABRT), false, false); + +#ifdef _DARWIN_C_SOURCE +LongBowEventType LongBowEventSIGEMT = _eventType("Signal", "SIGEMT", LongBowStatus_SIGNAL(SIGEMT), false, false); +#else +LongBowEventType LongBowEventSIGEMT = _eventType("Signal", "SIGBUS", LongBowStatus_SIGNAL(SIGBUS), false, false); +#endif + +LongBowEventType LongBowEventSIGFPE = _eventType("Signal", "SIGFPE", LongBowStatus_SIGNAL(SIGFPE), false, false); + +LongBowEventType LongBowEventSIGKILL = _eventType("Signal", "SIGKILL", LongBowStatus_SIGNAL(SIGKILL), false, false); + +LongBowEventType LongBowEventSIGBUS = _eventType("Signal", "SIGBUS", LongBowStatus_SIGNAL(SIGBUS), false, false); + +LongBowEventType LongBowEventSIGSEGV = _eventType("Signal", "SIGSEGV", LongBowStatus_SIGNAL(SIGSEGV), false, false); + +LongBowEventType LongBowEventSIGSYS = _eventType("Signal", "SIGSYS", LongBowStatus_SIGNAL(SIGSYS), false, false); + +LongBowEventType LongBowEventSIGPIPE = _eventType("Signal", "SIGPIPE", LongBowStatus_SIGNAL(SIGPIPE), false, false); + +LongBowEventType LongBowEventSIGALRM = _eventType("Signal", "SIGALRM", LongBowStatus_SIGNAL(SIGALRM), false, false); + +LongBowEventType LongBowEventSIGTERM = _eventType("Signal", "SIGTERM", LongBowStatus_SIGNAL(SIGTERM), false, false); + +LongBowEventType LongBowEventSIGURG = _eventType("Signal", "SIGURG", LongBowStatus_SIGNAL(SIGURG), false, false); + +LongBowEventType LongBowEventSIGSTOP = _eventType("Signal", "SIGSTOP", LongBowStatus_SIGNAL(SIGSTOP), false, false); + +LongBowEventType LongBowEventSIGTSTP = _eventType("Signal", "SIGTSTP", LongBowStatus_SIGNAL(SIGTSTP), false, false); + +LongBowEventType LongBowEventSIGCONT = _eventType("Signal", "SIGCONT", LongBowStatus_SIGNAL(SIGCONT), false, false); + +LongBowEventType LongBowEventSIGCHLD = _eventType("Signal", "SIGCHLD", LongBowStatus_SIGNAL(SIGCHLD), false, false); + +LongBowEventType LongBowEventSIGTTIN = _eventType("Signal", "SIGTTIN", LongBowStatus_SIGNAL(SIGTTIN), false, false); + +LongBowEventType LongBowEventSIGTTOU = _eventType("Signal", "SIGTTOU", LongBowStatus_SIGNAL(SIGTTOU), false, false); + +LongBowEventType LongBowEventSIGIO = _eventType("Signal", "SIGIO", LongBowStatus_SIGNAL(SIGIO), false, false); + +LongBowEventType LongBowEventSIGXCPU = _eventType("Signal", "SIGXCPU", LongBowStatus_SIGNAL(SIGXCPU), false, false); + +LongBowEventType LongBowEventSIGXFSZ = _eventType("Signal", "SIGXFSZ", LongBowStatus_SIGNAL(SIGXFSZ), false, false); + +LongBowEventType LongBowEventSIGVTALRM = _eventType("Signal", "SIGVTALRM", LongBowStatus_SIGNAL(SIGVTALRM), false, false); + +LongBowEventType LongBowEventSIGPROF = _eventType("Signal", "SIGPROF", LongBowStatus_SIGNAL(SIGPROF), false, false); + +LongBowEventType LongBowEventSIGWINCH = _eventType("Signal", "SIGWINCH", LongBowStatus_SIGNAL(SIGWINCH), false, false); + +#if (!defined (_ANDROID_) && (!defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE)) +LongBowEventType LongBowEventSIGINFO = _eventType("Signal", "SIGINFO", LongBowStatus_SIGNAL(SIGINFO), false, false); +#else +LongBowEventType LongBowEventSIGINFO = _eventType("Signal", "SIGIO", LongBowStatus_SIGNAL(SIGIO), false, false); +#endif + +LongBowEventType LongBowEventSIGUSR1 = _eventType("Signal", "SIGUSR1", LongBowStatus_SIGNAL(SIGUSR1), false, false); + +LongBowEventType LongBowEventSIGUSR2 = _eventType("Signal", "SIGUSR2", LongBowStatus_SIGNAL(SIGUSR2), false, false); + +LongBowEventType LongBowTestEvent = _eventType("Test", "Test", LongBowStatus_WARNED, false, false); + +static LongBowEventType *signalToEventType[NSIG] = { + NULL, + &LongBowEventSIGHUP /* 1 */, + &LongBowEventSIGINT /* 2 */, + &LongBowEventSIGQUIT /* 3 */, + &LongBowEventSIGILL /* 4 */, + &LongBowEventSIGTRAP /* 5 */, + &LongBowEventSIGABRT /* 6 */, + &LongBowEventSIGEMT /* 7 */, + &LongBowEventSIGFPE /* 8 */, + &LongBowEventSIGKILL /* 9 */, + &LongBowEventSIGBUS /* 10 */, + &LongBowEventSIGSEGV /* 11 */, + &LongBowEventSIGSYS /* 12 */, + &LongBowEventSIGPIPE /* 13 */, + &LongBowEventSIGALRM /* 14 */, + &LongBowEventSIGTERM /* 15 */, + &LongBowEventSIGURG /* 16 */, + &LongBowEventSIGSTOP /* 17 */, + &LongBowEventSIGTSTP /* 18 */, + &LongBowEventSIGCONT /* 19 */, + &LongBowEventSIGCHLD /* 20 */, + &LongBowEventSIGTTIN /* 21 */, + &LongBowEventSIGTTOU /* 22 */, + &LongBowEventSIGIO /* 23 */, + &LongBowEventSIGXCPU /* 24 */, + &LongBowEventSIGXFSZ /* 25 */, + &LongBowEventSIGVTALRM /* 26 */, + &LongBowEventSIGPROF /* 27 */, + &LongBowEventSIGWINCH /* 28 */, + &LongBowEventSIGINFO /* 29 */, + &LongBowEventSIGUSR1 /* 30 */, + &LongBowEventSIGUSR2 /* 31 */ +}; + +const char * +longBowEventType_GetName(const LongBowEventType *eventType) +{ + return eventType->name; +} + +LongBowStatus +longBowEventType_GetStatus(const LongBowEventType *eventType) +{ + return eventType->statusCode; +} + +bool +longBowEventType_IsSuppressBacktrace(const LongBowEventType *eventType) +{ + return eventType->suppressBacktrace; +} + +bool +longBowEventType_IsSuppressAlert(const LongBowEventType *eventType) +{ + return eventType->suppressAlert; +} + +bool +longBowEventType_Equals(const LongBowEventType *x, const LongBowEventType *y) +{ + if (x == y) { + return true; + } + if (x == NULL || y == NULL) { + return false; + } + + if (strcmp(x->name, y->name) == 0) { + return true; + } + return false; +} + +LongBowEventType * +longBowEventType_GetEventTypeForSignal(const int signal) +{ + return signalToEventType[signal]; +} + -- cgit 1.2.3-korg From d05dd3d6d6dc8766a0f9423364434d4ae5997ffb Mon Sep 17 00:00:00 2001 From: Angelo Mantellini Date: Mon, 22 Jan 2018 16:43:17 +0100 Subject: correct __ANDROID__ define Change-Id: Ic6138edfdd8e13ed525c12327111d48d6e008166 Signed-off-by: Angelo Mantellini --- longbow/src/LongBow/longBow_EventType.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'longbow/src/LongBow/longBow_EventType.c') diff --git a/longbow/src/LongBow/longBow_EventType.c b/longbow/src/LongBow/longBow_EventType.c index 7a99b0c3..d1c24620 100755 --- a/longbow/src/LongBow/longBow_EventType.c +++ b/longbow/src/LongBow/longBow_EventType.c @@ -129,7 +129,7 @@ LongBowEventType LongBowEventSIGPROF = _eventType("Signal", "SIGPROF", LongBowSt LongBowEventType LongBowEventSIGWINCH = _eventType("Signal", "SIGWINCH", LongBowStatus_SIGNAL(SIGWINCH), false, false); -#if (!defined (_ANDROID_) && (!defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE)) +#if (!defined (__ANDROID__) && (!defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE)) LongBowEventType LongBowEventSIGINFO = _eventType("Signal", "SIGINFO", LongBowStatus_SIGNAL(SIGINFO), false, false); #else LongBowEventType LongBowEventSIGINFO = _eventType("Signal", "SIGIO", LongBowStatus_SIGNAL(SIGIO), false, false); -- cgit 1.2.3-korg