diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..395d1d7 --- /dev/null +++ b/src/common.h @@ -0,0 +1,37 @@ +/* + * The MIT License (MIT) + * + * Copyright © 2016 Franklin "Snaipe" Mathieu + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef COMMON_H_ +# define COMMON_H_ + +# if __STDC_VERSION__ >= 201112L +# include +# elif defined __GNUC__ +# define noreturn __attribute__((noreturn)) +# elif defined _MSC_VER +# define noreturn __declspec(noreturn) +# else +# define noreturn +# endif + +#endif /* !COMMON_H_ */ diff --git a/src/vitals.c b/src/vitals.c index f4ae926..9274183 100644 --- a/src/vitals.c +++ b/src/vitals.c @@ -131,7 +131,7 @@ void mmk_fprintf(FILE *f, const char *str, ...) va_end(vl); } -void mmk_panic(const char *str, ...) +noreturn void mmk_panic(const char *str, ...) { va_list vl; va_start(vl, str); diff --git a/src/vitals.h b/src/vitals.h index f7db9c6..5eef3f6 100644 --- a/src/vitals.h +++ b/src/vitals.h @@ -26,6 +26,7 @@ # include # include "mimick/unmocked.h" +# include "common.h" # include "plt.h" /* string functions that are notoriously replaced by sse2 variants are @@ -40,7 +41,7 @@ char *mmk_strncpy(char *dst, const char *src, size_t n); size_t mmk_strlen(const char *s); int mmk_isspace(int c); -void mmk_panic(const char *, ...); +noreturn void mmk_panic(const char *, ...); void mmk_init_vital_functions(plt_ctx ctx);