Skip to content

Commit

Permalink
Prepend VMM_ macro to macros in compiler.h to avoid clashing with our…
Browse files Browse the repository at this point in the history
… environment. Also removed the ones we don't use.
  • Loading branch information
blitz committed Aug 13, 2013
1 parent 77a784a commit b37d519
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 43 deletions.
2 changes: 1 addition & 1 deletion host/hostvga.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class HostVga : public StaticReceiver<HostVga>
}


static void do_work(void *t) REGPARM(0) NORETURN { reinterpret_cast<HostVga *>(t)->work(); }
static void do_work(void *t) VMM_REGPARM(0) NORETURN { reinterpret_cast<HostVga *>(t)->work(); }



Expand Down
44 changes: 12 additions & 32 deletions include/nul/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,29 @@
#error Your platform is not supported.
#endif

#define REGPARM(x) __attribute__((regparm(x)))
#define NORETURN __attribute__((noreturn))
#define PURE __attribute__((pure))
#define COLD __attribute__((cold))
#define ALIGNED(x) __attribute__((aligned(x)))
#define PACKED __attribute__((packed))
#define MEMORY_BARRIER __asm__ __volatile__ ("" ::: "memory")
#define RESTRICT __restrict__
#define UNUSED __attribute__((unused))
#define VMM_REGPARM(x) __attribute__((regparm(x)))

/* XXX Enable this and knock yourself out... */
//#define DEPRECATED __attribute__((deprecated))
#define DEPRECATED

#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
# define WARN_UNUSED __attribute__((warn_unused_result))
#else
# define WARN_UNUSED
#endif

#ifdef __cplusplus
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
# define nullptr 0
# endif
#endif
/* We can use [[ noreturn ]] here, when we all move to C++ 11. */
#define VMM_NORETURN __attribute__((noreturn))
#define VMM_UNUSED __attribute__((unused))

#ifdef __cplusplus
# define BEGIN_EXTERN_C extern "C" {
# define END_EXTERN_C }
# define EXTERN_C extern "C"
# define VMM_BEGIN_EXTERN_C extern "C" {
# define VMM_END_EXTERN_C }
# define VMM_EXTERN_C extern "C"
#else
# define BEGIN_EXTERN_C
# define END_EXTERN_C
# define EXTERN_C
# define VMM_BEGIN_EXTERN_C
# define VMM_END_EXTERN_C
# define VMM_EXTERN_C
#endif

/* Sadly GCC specific */

#define MAX(a, b) ({ typeof (a) _a = (a); \
#define VMM_MAX(a, b) ({ typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; })

#define MIN(a, b) ({ typeof (a) _a = (a); \
#define VMM_MIN(a, b) ({ typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _b : _a; })

Expand Down
2 changes: 1 addition & 1 deletion include/nul/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ struct MessageVesa
/****************************************************/

class VCpu;
typedef void (*ServiceThreadFn)(void *) REGPARM(0) NORETURN;
typedef void (*ServiceThreadFn)(void *) VMM_REGPARM(0) VMM_NORETURN;

/**
* Request to the host, such as notify irq or request IO region.
Expand Down
10 changes: 5 additions & 5 deletions include/nul/motherboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class Motherboard
assert(arglen > 0);

PARAM_ITER(param) {
size_t prefixlen = MIN(strcspn(current, word_separator()),
strcspn(current, wordparam_separator()));
size_t prefixlen = VMM_MIN(strcspn(current, word_separator()),
strcspn(current, wordparam_separator()));
if (strlen((*param)->name) == prefixlen && !memcmp(current, (*param)->name, prefixlen)) {
Logging::printf("\t=> %.*s <=\n", (int)arglen, current);

Expand All @@ -109,8 +109,8 @@ class Motherboard
const char *start = s;
unsigned long argv[16];
for (unsigned j=0; j < 16; j++) {
size_t alen = MIN(strcspn(s, param_separator()),
strcspn(s, word_separator()));
size_t alen = VMM_MIN(strcspn(s, param_separator()),
strcspn(s, word_separator()));
if (alen)
argv[j] = strtoul(s, 0, 0);
else
Expand All @@ -130,7 +130,7 @@ class Motherboard
*/
void dump_counters(bool full = false)
{
static timevalue orig_time UNUSED;
static timevalue orig_time VMM_UNUSED;
timevalue t = _clock->clock(1000);
COUNTER_SET("Time", t - orig_time);
orig_time = t;
Expand Down
2 changes: 1 addition & 1 deletion include/service/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Cpu
static unsigned minshift(unsigned long start, unsigned long size) {
unsigned basealign = Cpu::bsf(start | (1ul << (8*sizeof(unsigned long)-1)));
unsigned shiftalign = Cpu::bsr(size | 1);
return MIN(basealign, shiftalign);
return VMM_MIN(basealign, shiftalign);
}

/* Computes the maximum amount of natural alignment we can apply to fault. */
Expand Down
4 changes: 2 additions & 2 deletions unix/include/nul/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include <nul/compiler.h>

BEGIN_EXTERN_C
VMM_BEGIN_EXTERN_C
#ifdef __MMX__
#include <mmintrin.h>
#endif
Expand All @@ -37,7 +37,7 @@ BEGIN_EXTERN_C
#ifdef __SSSE3__
#include <tmmintrin.h>
#endif
END_EXTERN_C
VMM_END_EXTERN_C

/* Constant-width integer types. */
typedef uint64_t uint64;
Expand Down
2 changes: 1 addition & 1 deletion unix/include/service/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Logging
{
public:

static void panic(const char *format, ...) NORETURN __attribute__ ((format(printf, 1, 2)));
static void panic(const char *format, ...) VMM_NORETURN __attribute__ ((format(printf, 1, 2)));
static void printf(const char *format, ...) __attribute__ ((format(printf, 1, 2)));
static void vprintf(const char *format, va_list &ap);
};

0 comments on commit b37d519

Please sign in to comment.