<commit_before>/*
 * File      : rtdebug.h
 * This file is part of RT-Thread RTOS
 * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rt-thread.org/license/LICENSE
 */
 
#ifndef __RTDEBUG_H__
#define __RTDEBUG_H__

#include <rtconfig.h>

/* Using this macro to control all kernel debug features. */
#ifdef RT_DEBUG

/* Turn on some of these (set to non-zero) to debug kernel */
#ifndef RT_DEBUG_MEM
#define RT_DEBUG_MEM        0
#endif

#ifndef RT_DEBUG_MEMHEAP
#define RT_DEBUG_MEMHEAP	0
#endif

#ifndef RT_DEBUG_MODULE
#define RT_DEBUG_MODULE     0
#endif

#ifndef RT_DEBUG_SCHEDULER
#define RT_DEBUG_SCHEDULER  0
#endif

#ifndef RT_DEBUG_SLAB
#define RT_DEBUG_SLAB       0
#endif

#ifndef RT_DEBUG_THREAD
#define RT_DEBUG_THREAD     0
#endif

#ifndef RT_DEBUG_TIMER
#define RT_DEBUG_TIMER      0
#endif

#ifndef RT_DEBUG_IRQ
#define RT_DEBUG_IRQ        0
#endif

#ifndef RT_DEBUG_IPC
#define RT_DEBUG_IPC        0
#endif

/* Turn on this to enable context check */
#ifndef RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_CONTEXT_CHECK 1
#endif

#define RT_DEBUG_LOG(type,message)  do { if (type) rt_kprintf message;} while (0)

#define RT_ASSERT(EX)   if (!(EX)) {volatile char dummy = 0;\
                            rt_kprintf("(%s) assert failed at %s:%d \n", \
                            #EX, __FUNCTION__, __LINE__); while (dummy == 0);}

/* Macro to check current context */
#if RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_NOT_IN_INTERRUPT do {\
        rt_base_t level;\
        level = rt_hw_interrupt_disable();\
        if (rt_interrupt_get_nest() != 0){\
            rt_kprintf("Function[%s] shall not used in ISR\n", __FUNCTION__);\
            RT_ASSERT(0)}\
        rt_hw_interrupt_enable(level);} while (0)
#else
#define RT_DEBUG_NOT_IN_INTERRUPT
#endif

#else /* RT_DEBUG */

#define RT_ASSERT(EX)
#define RT_DEBUG_LOG(type,message)
#define RT_DEBUG_NOT_IN_INTERRUPT

#endif /* RT_DEBUG */

#endif /* __RTDEBUG_H__ */<commit_msg>re-format the coding style, convert the tab to 4 spaces and make sure the line length is not longer than 80 in rtdebug.h<commit_after>/*
 * File      : rtdebug.h
 * This file is part of RT-Thread RTOS
 * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rt-thread.org/license/LICENSE
 */
 
#ifndef __RTDEBUG_H__
#define __RTDEBUG_H__

#include <rtconfig.h>

/* Using this macro to control all kernel debug features. */
#ifdef RT_DEBUG

/* Turn on some of these (set to non-zero) to debug kernel */
#ifndef RT_DEBUG_MEM
#define RT_DEBUG_MEM                   0
#endif

#ifndef RT_DEBUG_MEMHEAP
#define RT_DEBUG_MEMHEAP               0
#endif

#ifndef RT_DEBUG_MODULE
#define RT_DEBUG_MODULE                0
#endif

#ifndef RT_DEBUG_SCHEDULER
#define RT_DEBUG_SCHEDULER             0
#endif

#ifndef RT_DEBUG_SLAB
#define RT_DEBUG_SLAB                  0
#endif

#ifndef RT_DEBUG_THREAD
#define RT_DEBUG_THREAD                0
#endif

#ifndef RT_DEBUG_TIMER
#define RT_DEBUG_TIMER                 0
#endif

#ifndef RT_DEBUG_IRQ
#define RT_DEBUG_IRQ                   0
#endif

#ifndef RT_DEBUG_IPC
#define RT_DEBUG_IPC                   0
#endif

/* Turn on this to enable context check */
#ifndef RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_CONTEXT_CHECK         1
#endif

#define RT_DEBUG_LOG(type, message)                                           \
do                                                                            \
{                                                                             \
    if (type)                                                                 \
        rt_kprintf message;                                                   \
}                                                                             \
while (0)

#define RT_ASSERT(EX)                                                         \
if (!(EX))                                                                    \
{                                                                             \
    volatile char dummy = 0;                                                  \
    rt_kprintf("(%s) assert failed at %s:%d \n", #EX, __FUNCTION__, __LINE__);\
    while (dummy == 0);                                                       \
}

/* Macro to check current context */
#if RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_NOT_IN_INTERRUPT                                             \
do                                                                            \
{                                                                             \
    rt_base_t level;                                                          \
    level = rt_hw_interrupt_disable();                                        \
    if (rt_interrupt_get_nest() != 0)                                         \
    {                                                                         \
        rt_kprintf("Function[%s] shall not used in ISR\n", __FUNCTION__);     \
        RT_ASSERT(0)                                                          \
    }                                                                         \
    rt_hw_interrupt_enable(level);                                            \
}                                                                             \
while (0)
#else
#define RT_DEBUG_NOT_IN_INTERRUPT
#endif

#else /* RT_DEBUG */

#define RT_ASSERT(EX)
#define RT_DEBUG_LOG(type, message)
#define RT_DEBUG_NOT_IN_INTERRUPT

#endif /* RT_DEBUG */

#endif /* __RTDEBUG_H__ */
{'fraction_non_alphanumeric': 0.0731578947368421, 'fraction_numerical': 0.008947368421052631, 'mean_word_length': 1.3734388009991674, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 53, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7440698', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1489, 'n_words': 436}