Skip to content

Commit

Permalink
COMMON: Move NORETURN_* defines into their own noreturn.h
Browse files Browse the repository at this point in the history
So that we can use these macros without pulling in the rest of the
defines in system.h.
  • Loading branch information
DrMcCoy committed Oct 19, 2016
1 parent c1018fa commit e719e03
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
42 changes: 42 additions & 0 deletions src/common/noreturn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* xoreos is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* xoreos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xoreos. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* Compiler-specific defines to declare a function non-returning.
*/

#ifndef COMMON_NORETURN_H
#define COMMON_NORETURN_H

#if defined(_MSC_VER)
#define NORETURN_PRE __declspec(noreturn)
#elif defined(__GNUC__)
#define NORETURN_POST __attribute__((__noreturn__))
#endif

#ifndef NORETURN_PRE
#define NORETURN_PRE
#endif

#ifndef NORETURN_POST
#define NORETURN_POST
#endif

#endif // COMMON_NORETURN_H
1 change: 1 addition & 0 deletions src/common/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ src_common_libcommon_la_SOURCES =

src_common_libcommon_la_SOURCES += \
src/common/system.h \
src/common/noreturn.h \
src/common/types.h \
src/common/endianness.h \
src/common/maths.h \
Expand Down
12 changes: 2 additions & 10 deletions src/common/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
#include "config.h"
#endif

#include "src/common/noreturn.h"

#if defined(_MSC_VER)

#include <cstdarg>
Expand All @@ -78,7 +80,6 @@
#endif

#define FORCEINLINE __forceinline
#define NORETURN_PRE __declspec(noreturn)
#define PLUGIN_EXPORT __declspec(dllexport)

static FORCEINLINE int c99_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
Expand Down Expand Up @@ -141,7 +142,6 @@
// GCC specific stuff
//
#if defined(__GNUC__)
#define NORETURN_POST __attribute__((__noreturn__))
#define PACKED_STRUCT __attribute__((__packed__))
#define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y)))

Expand Down Expand Up @@ -403,14 +403,6 @@
#define FORCEINLINE inline
#endif

#ifndef NORETURN_PRE
#define NORETURN_PRE
#endif

#ifndef NORETURN_POST
#define NORETURN_POST
#endif

#ifndef STRINGBUFLEN
#define STRINGBUFLEN 1024
#endif
Expand Down

0 comments on commit e719e03

Please sign in to comment.