debug.h: merge both instances into ihk/debug.h
We do not need two debug.h files. Take Fujitsu's STATIC_ASSERT over BUILD_BUG_ON because it is more used Change-Id: If04c17fbb7406ab15fe86267fed8d6da460cec62 Fujitsu: POSTK_DEBUG_ARCH_DEP_9
This commit is contained in:
committed by
Dominique Martinet
parent
06e96005a6
commit
9ec0aeeab5
@@ -11,7 +11,7 @@
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <bitmap.h>
|
||||
#include <debug.h>
|
||||
#include <ihk/debug.h>
|
||||
|
||||
#define EXPORT_SYMBOL(x)
|
||||
|
||||
|
||||
@@ -1,43 +1,65 @@
|
||||
/* debug.h COPYRIGHT FUJITSU LIMITED 2015-2016 */
|
||||
/**
|
||||
* \file debug.h
|
||||
* License details are found in the file LICENSE.
|
||||
* \brief
|
||||
* Declare types and functions to print debug message (kmsg).
|
||||
* \author Taku Shimosawa <shimosawa@is.s.u-tokyo.ac.jp> \par
|
||||
* Copyright (C) 2011 - 2012 Taku Shimosawa
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
|
||||
#ifndef IHK_DEBUG_H
|
||||
#define IHK_DEBUG_H
|
||||
|
||||
#include <arch-lock.h>
|
||||
#include <ihk/memconst.h>
|
||||
#include <ihk/ihk_debug.h>
|
||||
#include "lwk/compiler.h"
|
||||
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_9 /* want to add a static assertion */
|
||||
void panic(const char *);
|
||||
|
||||
/* when someone has a lot of time, add attribute __printf(1, 2) to kprintf */
|
||||
int kprintf(const char *format, ...);
|
||||
unsigned long kprintf_lock(void);
|
||||
void kprintf_unlock(unsigned long irqflags);
|
||||
int __kprintf(const char *format, ...);
|
||||
|
||||
struct ddebug {
|
||||
const char *file;
|
||||
const char *func;
|
||||
const char *fmt;
|
||||
unsigned int line:24;
|
||||
unsigned int flags:8;
|
||||
} __aligned(8);
|
||||
|
||||
#define DDEBUG_NONE 0x0
|
||||
#define DDEBUG_PRINT 0x1
|
||||
|
||||
#define DDEBUG_DEFAULT DDEBUG_NONE
|
||||
|
||||
#define DDEBUG_SYMBOL() \
|
||||
static struct ddebug __aligned(8) \
|
||||
__attribute__((section("__verbose"))) ddebug = { \
|
||||
.file = __FILE__, \
|
||||
.func = __func__, \
|
||||
.line = __LINE__, \
|
||||
.flags = DDEBUG_DEFAULT, \
|
||||
}
|
||||
|
||||
#define DDEBUG_TEST ddebug.flags
|
||||
|
||||
|
||||
|
||||
#define dkprintf(fmt, args...) \
|
||||
do { \
|
||||
DDEBUG_SYMBOL(); \
|
||||
if (DDEBUG_TEST) \
|
||||
kprintf(fmt, ##args); \
|
||||
} while (0)
|
||||
#define ekprintf(fmt, args...) kprintf(fmt, ##args)
|
||||
|
||||
#define BUG_ON(condition) do { \
|
||||
if (condition) { \
|
||||
kprintf("PANIC: %s: %s(line:%d)\n", \
|
||||
__FILE__, __func__, __LINE__); \
|
||||
panic(""); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Force a compilation error if condition is false */
|
||||
#define STATIC_ASSERT(cond) _STATIC_ASSERT(cond, __LINE__)
|
||||
#define _STATIC_ASSERT(cond, line) __STATIC_ASSERT(cond, line)
|
||||
#define __STATIC_ASSERT(cond, line) \
|
||||
static void __static_assert_ ## line (void) { \
|
||||
STATIC_ASSERT_LOCAL(cond); \
|
||||
}
|
||||
|
||||
/* Force a compilation error if condition is false */
|
||||
#define STATIC_ASSERT_LOCAL(cond) ((void)sizeof(struct { int:-!!!(cond); }))
|
||||
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_9 */
|
||||
|
||||
extern int kprintf(const char *format, ...);
|
||||
extern unsigned long kprintf_lock(void);
|
||||
extern void kprintf_unlock(unsigned long irqflags);
|
||||
extern int __kprintf(const char *format, ...);
|
||||
|
||||
extern void panic(const char *msg);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
//#define DEBUG_PRINT_PAGE_ALLOC
|
||||
|
||||
#ifdef DEBUG_PRINT_PAGE_ALLOC
|
||||
#define dkprintf kprintf
|
||||
#else
|
||||
#define dkprintf(...) do { if (0) kprintf(__VA_ARGS__); } while (0)
|
||||
#undef DDEBUG_DEFAULT
|
||||
#define DDEBUG_DEFAULT DDEBUG_PRINT
|
||||
#endif
|
||||
|
||||
void free_pages(void *, int npages);
|
||||
|
||||
Reference in New Issue
Block a user