Browse Source

[kernel] 补充endif后缀注释(3)

Meco Man 4 years ago
parent
commit
8b53609f57
8 changed files with 107 additions and 108 deletions
  1. 15 15
      src/memheap.c
  2. 3 4
      src/mempool.c
  3. 7 7
      src/object.c
  4. 38 38
      src/scheduler.c
  5. 6 6
      src/signal.c
  6. 11 11
      src/slab.c
  7. 17 17
      src/thread.c
  8. 10 10
      src/timer.c

+ 15 - 15
src/memheap.c

@@ -74,7 +74,7 @@ void rt_mem_set_tag(void *ptr, const char *name)
         rt_memheap_setname(item, name);
     }
 }
-#endif
+#endif /* RT_USING_MEMTRACE */
 
 /*
  * The initialized memory pool will be:
@@ -127,7 +127,7 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap,
 
 #ifdef RT_USING_MEMTRACE
     rt_memset(item->owner_thread_name, ' ', sizeof(item->owner_thread_name));
-#endif
+#endif /* RT_USING_MEMTRACE */
 
     item->next = (struct rt_memheap_item *)
                  ((rt_uint8_t *)item + memheap->available_size + RT_MEMHEAP_SIZE);
@@ -252,7 +252,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
 
 #ifdef RT_USING_MEMTRACE
                 rt_memset(new_ptr->owner_thread_name, ' ', sizeof(new_ptr->owner_thread_name));
-#endif
+#endif /* RT_USING_MEMTRACE */
 
                 /* break down the block list */
                 new_ptr->prev          = header_ptr;
@@ -310,7 +310,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
                 rt_memcpy(header_ptr->owner_thread_name, rt_thread_self()->name, sizeof(header_ptr->owner_thread_name));
             else
                 rt_memcpy(header_ptr->owner_thread_name, "NONE", sizeof(header_ptr->owner_thread_name));
-#endif
+#endif /* RT_USING_MEMTRACE */
 
             /* release lock */
             rt_sem_release(&(heap->lock));
@@ -439,7 +439,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
 
 #ifdef RT_USING_MEMTRACE
                 rt_memset(next_ptr->owner_thread_name, ' ', sizeof(next_ptr->owner_thread_name));
-#endif
+#endif /* RT_USING_MEMTRACE */
 
                 next_ptr->prev          = header_ptr;
                 next_ptr->next          = header_ptr->next;
@@ -507,7 +507,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
 
 #ifdef RT_USING_MEMTRACE
     rt_memset(new_ptr->owner_thread_name, ' ', sizeof(new_ptr->owner_thread_name));
-#endif
+#endif /* RT_USING_MEMTRACE */
 
     /* break down the block list */
     new_ptr->prev          = header_ptr;
@@ -660,7 +660,7 @@ void rt_memheap_free(void *ptr)
 
 #ifdef RT_USING_MEMTRACE
     rt_memset(header_ptr->owner_thread_name, ' ', sizeof(header_ptr->owner_thread_name));
-#endif
+#endif /* RT_USING_MEMTRACE */
 
     /* release lock */
     rt_sem_release(&(heap->lock));
@@ -750,7 +750,7 @@ int memheaptrace(void)
     return 0;
 }
 MSH_CMD_EXPORT(memheaptrace, dump memory trace information);
-#endif
+#endif /* RT_USING_FINSH */
 
 #ifdef RT_USING_MEMHEAP_AS_HEAP
 static struct rt_memheap _heap;
@@ -816,7 +816,7 @@ void *rt_malloc(rt_size_t size)
 
         RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("malloc => 0x%08x : %d", ptr, size));
     }
-#endif
+#endif /* RT_USING_MEMTRACE */
 
     return ptr;
 }
@@ -882,7 +882,7 @@ void *rt_realloc(void *rmem, rt_size_t newsize)
         RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("realloc => 0x%08x : %d",
                                         new_ptr, newsize));
     }
-#endif
+#endif /* RT_USING_MEMTRACE */
 
     return new_ptr;
 }
@@ -912,7 +912,7 @@ void *rt_calloc(rt_size_t count, rt_size_t size)
         RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("calloc => 0x%08x : %d",
                                         ptr, count * size));
     }
-#endif
+#endif /* RT_USING_MEMTRACE */
 
     return ptr;
 }
@@ -932,7 +932,7 @@ void rt_memory_info(rt_uint32_t *total,
         *max_used = _heap.max_used_size;
 }
 
-#endif
+#endif /* RT_USING_MEMHEAP_AS_HEAP */
 
 #ifdef RT_USING_MEMTRACE
 
@@ -1004,8 +1004,8 @@ void memtrace_heap()
 #ifdef RT_USING_FINSH
 #include <finsh.h>
 MSH_CMD_EXPORT(memtrace_heap, dump memory trace for heap);
-#endif /* end of RT_USING_FINSH */
+#endif /* RT_USING_FINSH */
 
-#endif /* end of RT_USING_MEMTRACE */
+#endif /* RT_USING_MEMTRACE */
 
-#endif /* end of RT_USING_MEMHEAP */
+#endif /* RT_USING_MEMHEAP */

+ 3 - 4
src/mempool.c

@@ -54,7 +54,7 @@ void rt_mp_free_sethook(void (*hook)(struct rt_mempool *mp, void *block))
 }
 
 /**@}*/
-#endif
+#endif /* RT_USING_HOOK */
 
 /**
  * @addtogroup MM
@@ -290,7 +290,7 @@ rt_err_t rt_mp_delete(rt_mp_t mp)
     return RT_EOK;
 }
 RTM_EXPORT(rt_mp_delete);
-#endif
+#endif /* RT_USING_HEAP */
 
 /**
  * This function will allocate a block from memory pool
@@ -451,5 +451,4 @@ RTM_EXPORT(rt_mp_free);
 
 /**@}*/
 
-#endif
-
+#endif /* RT_USING_MEMPOOL */

+ 7 - 7
src/object.c

@@ -20,7 +20,7 @@
 
 #ifdef RT_USING_MODULE
 #include <dlmodule.h>
-#endif
+#endif /* RT_USING_MODULE */
 
 /*
  * define object_info for the number of rt_object_container items.
@@ -189,7 +189,7 @@ void rt_object_put_sethook(void (*hook)(struct rt_object *object))
 }
 
 /**@}*/
-#endif
+#endif /* RT_USING_HOOK */
 
 /**
  * @addtogroup KernelObject
@@ -305,7 +305,7 @@ void rt_object_init(struct rt_object         *object,
     struct rt_object_information *information;
 #ifdef RT_USING_MODULE
     struct rt_dlmodule *module = dlmodule_self();
-#endif
+#endif /* RT_USING_MODULE */
 
     /* get object information */
     information = rt_object_get_information(type);
@@ -349,7 +349,7 @@ void rt_object_init(struct rt_object         *object,
         object->module_id = (void *)module;
     }
     else
-#endif
+#endif /* RT_USING_MODULE */
     {
         /* insert object into information object list */
         rt_list_insert_after(&(information->object_list), &(object->list));
@@ -403,7 +403,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name)
     struct rt_object_information *information;
 #ifdef RT_USING_MODULE
     struct rt_dlmodule *module = dlmodule_self();
-#endif
+#endif /* RT_USING_MODULE */
 
     RT_DEBUG_NOT_IN_INTERRUPT;
 
@@ -444,7 +444,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name)
         object->module_id = (void *)module;
     }
     else
-#endif
+#endif /* RT_USING_MODULE */
     {
         /* insert object into information object list */
         rt_list_insert_after(&(information->object_list), &(object->list));
@@ -487,7 +487,7 @@ void rt_object_delete(rt_object_t object)
     /* free the memory of object */
     RT_KERNEL_FREE(object);
 }
-#endif
+#endif /* RT_USING_HEAP */
 
 /**
  * This function will judge the object is system object or not.

+ 38 - 38
src/scheduler.c

@@ -38,14 +38,14 @@ rt_uint32_t rt_thread_ready_priority_group;
 #if RT_THREAD_PRIORITY_MAX > 32
 /* Maximum priority level, 256 */
 rt_uint8_t rt_thread_ready_table[32];
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
 
 #ifndef RT_USING_SMP
 extern volatile rt_uint8_t rt_interrupt_nest;
 static rt_int16_t rt_scheduler_lock_nest;
 struct rt_thread *rt_current_thread = RT_NULL;
 rt_uint8_t rt_current_priority;
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 
 rt_list_t rt_thread_defunct;
 
@@ -71,18 +71,18 @@ rt_scheduler_sethook(void (*hook)(struct rt_thread *from, struct rt_thread *to))
 }
 
 /**@}*/
-#endif
+#endif /* RT_USING_HOOK */
 
 #ifdef RT_USING_OVERFLOW_CHECK
 static void _rt_scheduler_stack_check(struct rt_thread *thread)
 {
     RT_ASSERT(thread != RT_NULL);
 
-#if defined(ARCH_CPU_STACK_GROWS_UPWARD)
+#ifdef ARCH_CPU_STACK_GROWS_UPWARD
     if (*((rt_uint8_t *)((rt_ubase_t)thread->stack_addr + thread->stack_size - 1)) != '#' ||
 #else
     if (*((rt_uint8_t *)thread->stack_addr) != '#' ||
-#endif
+#endif /* ARCH_CPU_STACK_GROWS_UPWARD */
         (rt_ubase_t)thread->sp <= (rt_ubase_t)thread->stack_addr ||
         (rt_ubase_t)thread->sp >
         (rt_ubase_t)thread->stack_addr + (rt_ubase_t)thread->stack_size)
@@ -94,7 +94,7 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread)
         level = rt_hw_interrupt_disable();
         while (level);
     }
-#if defined(ARCH_CPU_STACK_GROWS_UPWARD)
+#ifdef ARCH_CPU_STACK_GROWS_UPWARD
     else if ((rt_ubase_t)thread->sp > ((rt_ubase_t)thread->stack_addr + thread->stack_size))
     {
         rt_kprintf("warning: %s stack is close to the top of stack address.\n",
@@ -106,9 +106,9 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread)
         rt_kprintf("warning: %s stack is close to end of stack address.\n",
                    thread->name);
     }
-#endif
+#endif /* ARCH_CPU_STACK_GROWS_UPWARD */
 }
-#endif
+#endif /* RT_USING_OVERFLOW_CHECK */
 
 /*
  * get the highest priority thread in ready queue
@@ -129,7 +129,7 @@ static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio)
 #else
     highest_ready_priority = __rt_ffs(rt_thread_ready_priority_group) - 1;
     local_highest_ready_priority = __rt_ffs(pcpu->priority_group) - 1;
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
 
     /* get highest ready priority thread */
     if (highest_ready_priority < local_highest_ready_priority)
@@ -162,7 +162,7 @@ static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio)
     highest_ready_priority = (number << 3) + __rt_ffs(rt_thread_ready_table[number]) - 1;
 #else
     highest_ready_priority = __rt_ffs(rt_thread_ready_priority_group) - 1;
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
 
     /* get highest ready priority thread */
     highest_priority_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next,
@@ -173,7 +173,7 @@ static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio)
 
     return highest_priority_thread;
 }
-#endif
+#endif /* RT_USING_SMP */
 
 /**
  * @ingroup SystemInit
@@ -183,12 +183,12 @@ void rt_system_scheduler_init(void)
 {
 #ifdef RT_USING_SMP
     int cpu;
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
     register rt_base_t offset;
 
 #ifndef RT_USING_SMP
     rt_scheduler_lock_nest = 0;
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 
     RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("start scheduler: max priority 0x%02x\n",
                                       RT_THREAD_PRIORITY_MAX));
@@ -213,9 +213,9 @@ void rt_system_scheduler_init(void)
 
 #if RT_THREAD_PRIORITY_MAX > 32
         rt_memset(pcpu->ready_table, 0, sizeof(pcpu->ready_table));
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
     }
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 
     /* initialize ready priority group */
     rt_thread_ready_priority_group = 0;
@@ -223,7 +223,7 @@ void rt_system_scheduler_init(void)
 #if RT_THREAD_PRIORITY_MAX > 32
     /* initialize ready table */
     rt_memset(rt_thread_ready_table, 0, sizeof(rt_thread_ready_table));
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
 
     /* initialize thread defunct */
     rt_list_init(&rt_thread_defunct);
@@ -245,7 +245,7 @@ void rt_system_scheduler_start(void)
     to_thread->oncpu = rt_hw_cpu_id();
 #else
     rt_current_thread = to_thread;
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 
     rt_schedule_remove_thread(to_thread);
     to_thread->stat = RT_THREAD_RUNNING;
@@ -255,7 +255,7 @@ void rt_system_scheduler_start(void)
     rt_hw_context_switch_to((rt_ubase_t)&to_thread->sp, to_thread);
 #else
     rt_hw_context_switch_to((rt_ubase_t)&to_thread->sp);
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 
     /* never come back */
 }
@@ -319,7 +319,7 @@ void rt_schedule(void)
             rt_thread_resume(current_thread);
         }
     }
-#endif
+#endif /* RT_USING_SIGNALS */
 
     if (current_thread->scheduler_lock_nest == 1) /* whether lock scheduler */
     {
@@ -367,7 +367,7 @@ void rt_schedule(void)
 
 #ifdef RT_USING_OVERFLOW_CHECK
                 _rt_scheduler_stack_check(to_thread);
-#endif
+#endif /* RT_USING_OVERFLOW_CHECK */
 
                 rt_hw_context_switch((rt_ubase_t)&current_thread->sp,
                         (rt_ubase_t)&to_thread->sp, to_thread);
@@ -396,7 +396,7 @@ void rt_schedule(void)
     {
         rt_hw_interrupt_enable(level);
     }
-#endif
+#endif /* RT_USING_SIGNALS */
 
 __exit:
     return ;
@@ -472,7 +472,7 @@ void rt_schedule(void)
 
 #ifdef RT_USING_OVERFLOW_CHECK
                 _rt_scheduler_stack_check(to_thread);
-#endif
+#endif /* RT_USING_OVERFLOW_CHECK */
 
                 if (rt_interrupt_nest == 0)
                 {
@@ -502,7 +502,7 @@ void rt_schedule(void)
                     {
                         rt_hw_interrupt_enable(level);
                     }
-#endif
+#endif /* RT_USING_SIGNALS */
                     goto __exit;
                 }
                 else
@@ -527,7 +527,7 @@ void rt_schedule(void)
 __exit:
     return;
 }
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 
 /**
  * This function checks if a scheduling is needed after IRQ context. If yes,
@@ -559,7 +559,7 @@ void rt_scheduler_do_irq_switch(void *context)
             rt_thread_resume(current_thread);
         }
     }
-#endif
+#endif /* RT_USING_SIGNALS */
 
     if (pcpu->irq_switch_flag == 0)
     {
@@ -608,7 +608,7 @@ void rt_scheduler_do_irq_switch(void *context)
 
 #ifdef RT_USING_OVERFLOW_CHECK
                 _rt_scheduler_stack_check(to_thread);
-#endif
+#endif /* RT_USING_OVERFLOW_CHECK */
                 RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("switch in interrupt\n"));
 
                 current_thread->cpus_lock_nest--;
@@ -621,7 +621,7 @@ void rt_scheduler_do_irq_switch(void *context)
     }
     rt_hw_interrupt_enable(level);
 }
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 
 /*
  * This function will insert a thread to system ready queue. The state of
@@ -661,7 +661,7 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
     {
 #if RT_THREAD_PRIORITY_MAX > 32
         rt_thread_ready_table[thread->number] |= thread->high_mask;
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
         rt_thread_ready_priority_group |= thread->number_mask;
 
         rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]),
@@ -675,7 +675,7 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
 
 #if RT_THREAD_PRIORITY_MAX > 32
         pcpu->ready_table[thread->number] |= thread->high_mask;
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
         pcpu->priority_group |= thread->number_mask;
 
         rt_list_insert_before(&(rt_cpu_index(bind_cpu)->priority_table[thread->current_priority]),
@@ -724,14 +724,14 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
     /* set priority mask */
 #if RT_THREAD_PRIORITY_MAX > 32
     rt_thread_ready_table[thread->number] |= thread->high_mask;
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
     rt_thread_ready_priority_group |= thread->number_mask;
 
 __exit:
     /* enable interrupt */
     rt_hw_interrupt_enable(temp);
 }
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 
 /*
  * This function will remove a thread from system ready queue.
@@ -768,7 +768,7 @@ void rt_schedule_remove_thread(struct rt_thread *thread)
             }
 #else
             rt_thread_ready_priority_group &= ~thread->number_mask;
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
         }
     }
     else
@@ -785,7 +785,7 @@ void rt_schedule_remove_thread(struct rt_thread *thread)
             }
 #else
             pcpu->priority_group &= ~thread->number_mask;
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
         }
     }
 
@@ -818,13 +818,13 @@ void rt_schedule_remove_thread(struct rt_thread *thread)
         }
 #else
         rt_thread_ready_priority_group &= ~thread->number_mask;
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
     }
 
     /* enable interrupt */
     rt_hw_interrupt_enable(level);
 }
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 
 /**
  * This function will lock the thread scheduler.
@@ -885,7 +885,7 @@ void rt_enter_critical(void)
     /* enable interrupt */
     rt_hw_interrupt_enable(level);
 }
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 RTM_EXPORT(rt_enter_critical);
 
 /**
@@ -959,7 +959,7 @@ void rt_exit_critical(void)
         rt_hw_interrupt_enable(level);
     }
 }
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 RTM_EXPORT(rt_exit_critical);
 
 /**
@@ -975,7 +975,7 @@ rt_uint16_t rt_critical_level(void)
     return current_thread->critical_lock_nest;
 #else
     return rt_scheduler_lock_nest;
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 }
 RTM_EXPORT(rt_critical_level);
 

+ 6 - 6
src/signal.c

@@ -20,7 +20,7 @@
 
 #ifndef RT_SIG_INFO_MAX
 #define RT_SIG_INFO_MAX 32
-#endif
+#endif /* RT_SIG_INFO_MAX */
 
 #define DBG_TAG     "SIGN"
 #define DBG_LVL     DBG_WARNING
@@ -67,7 +67,7 @@ static void _signal_entry(void *parameter)
     /* return to thread */
     tid->sp = tid->sig_ret;
     tid->sig_ret = RT_NULL;
-#endif
+#endif /* RT_USING_SMP */
 
     LOG_D("switch back to: 0x%08x\n", tid->sp);
     tid->stat &= ~RT_THREAD_STAT_SIGNAL;
@@ -76,7 +76,7 @@ static void _signal_entry(void *parameter)
     rt_hw_context_switch_to((rt_base_t)&parameter, tid);
 #else
     rt_hw_context_switch_to((rt_ubase_t)&(tid->sp));
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 }
 
 /*
@@ -153,7 +153,7 @@ static void _signal_deliver(rt_thread_t tid)
             tid->sig_ret = tid->sp;
             tid->sp = rt_hw_stack_init((void *)_signal_entry, RT_NULL,
                                        (void *)((char *)tid->sig_ret - 32), RT_NULL);
-#endif
+#endif /* RT_USING_SMP */
 
             rt_hw_interrupt_enable(level);
             LOG_D("signal stack pointer @ 0x%08x", tid->sp);
@@ -204,7 +204,7 @@ void *rt_signal_check(void* context)
     rt_hw_interrupt_enable(level);
     return context;
 }
-#endif
+#endif /* RT_USING_SMP */
 
 rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler)
 {
@@ -586,4 +586,4 @@ int rt_system_signal_init(void)
     return 0;
 }
 
-#endif
+#endif /* RT_USING_SIGNALS */

+ 11 - 11
src/slab.c

@@ -61,7 +61,7 @@
 /* some statistical variable */
 #ifdef RT_MEM_STATS
 static rt_size_t used_mem, max_mem;
-#endif
+#endif /* RT_MEM_STATS */
 
 #ifdef RT_USING_HOOK
 static void (*rt_malloc_hook)(void *ptr, rt_size_t size);
@@ -99,7 +99,7 @@ RTM_EXPORT(rt_free_sethook);
 
 /**@}*/
 
-#endif
+#endif /* RT_USING_HOOK */
 
 /*
  * slab allocator implementation
@@ -516,7 +516,7 @@ void *rt_malloc(rt_size_t size)
         used_mem += size;
         if (used_mem > max_mem)
             max_mem = used_mem;
-#endif
+#endif /* RT_MEM_STATS */
         goto done;
     }
 
@@ -571,7 +571,7 @@ void *rt_malloc(rt_size_t size)
         used_mem += z->z_chunksize;
         if (used_mem > max_mem)
             max_mem = used_mem;
-#endif
+#endif /* RT_MEM_STATS */
 
         goto done;
     }
@@ -655,7 +655,7 @@ void *rt_malloc(rt_size_t size)
         used_mem += z->z_chunksize;
         if (used_mem > max_mem)
             max_mem = used_mem;
-#endif
+#endif /* RT_MEM_STATS */
     }
 
 done:
@@ -790,7 +790,7 @@ void rt_free(void *ptr)
                       (rt_ubase_t)addr,
                       ((rt_ubase_t)(addr) - heap_start) >> RT_MM_PAGE_BITS));
     }
-#endif
+#endif /* RT_DEBUG_SLAB */
 
     kup = btokup((rt_ubase_t)ptr & ~RT_MM_PAGE_MASK);
     /* release large allocation */
@@ -806,7 +806,7 @@ void rt_free(void *ptr)
 
 #ifdef RT_MEM_STATS
         used_mem -= size * RT_MM_PAGE_SIZE;
-#endif
+#endif /* RT_MEM_STATS */
         rt_sem_release(&heap_sem);
 
         RT_DEBUG_LOG(RT_DEBUG_SLAB,
@@ -833,7 +833,7 @@ void rt_free(void *ptr)
 
 #ifdef RT_MEM_STATS
     used_mem -= z->z_chunksize;
-#endif
+#endif /* RT_MEM_STATS */
 
     /*
      * Bump the number of free chunks.  If it becomes non-zero the zone
@@ -929,9 +929,9 @@ void list_mem(void)
     rt_kprintf("maximum allocated memory: %d\n", max_mem);
 }
 FINSH_FUNCTION_EXPORT(list_mem, list memory usage information)
-#endif
-#endif
+#endif /* RT_USING_FINSH */
+#endif /* RT_MEM_STATS */
 
 /**@}*/
 
-#endif
+#endif /* defined (RT_USING_HEAP) && defined (RT_USING_SLAB) */

+ 17 - 17
src/thread.c

@@ -76,7 +76,7 @@ void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread))
     rt_thread_inited_hook = hook;
 }
 
-#endif
+#endif /* RT_USING_HOOK */
 
 /* must be invoke witch rt_hw_interrupt_disable */
 static void _rt_thread_cleanup_execute(rt_thread_t thread)
@@ -84,7 +84,7 @@ static void _rt_thread_cleanup_execute(rt_thread_t thread)
     register rt_base_t level;
 #ifdef RT_USING_MODULE
     struct rt_dlmodule *module = RT_NULL;
-#endif
+#endif /* RT_USING_MODULE */
     level = rt_hw_interrupt_disable();
 #ifdef RT_USING_MODULE
     module = (struct rt_dlmodule*)thread->module_id;
@@ -92,14 +92,14 @@ static void _rt_thread_cleanup_execute(rt_thread_t thread)
     {
         dlmodule_destroy(module);
     }
-#endif
+#endif /* RT_USING_MODULE */
     /* invoke thread cleanup */
     if (thread->cleanup != RT_NULL)
         thread->cleanup(thread);
 
 #ifdef RT_USING_SIGNALS
     rt_thread_free_sig(thread);
-#endif
+#endif /* RT_USING_SIGNALS */
     rt_hw_interrupt_enable(level);
 }
 
@@ -170,7 +170,7 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread,
     thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter,
                                           (rt_uint8_t *)((char *)thread->stack_addr + thread->stack_size - sizeof(rt_ubase_t)),
                                           (void *)_rt_thread_exit);
-#endif
+#endif /* ARCH_CPU_STACK_GROWS_UPWARD */
 
     /* priority init */
     RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX);
@@ -181,7 +181,7 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread,
 #if RT_THREAD_PRIORITY_MAX > 32
     thread->number = 0;
     thread->high_mask = 0;
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
 
     /* tick init */
     thread->init_tick      = tick;
@@ -200,7 +200,7 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread,
     thread->scheduler_lock_nest = 0;
     thread->cpus_lock_nest = 0;
     thread->critical_lock_nest = 0;
-#endif /*RT_USING_SMP*/
+#endif /* RT_USING_SMP */
 
     /* initialize cleanup function and user data */
     thread->cleanup   = 0;
@@ -221,14 +221,14 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread,
 
 #ifndef RT_USING_SMP
     thread->sig_ret     = RT_NULL;
-#endif
+#endif /* RT_USING_SMP */
     thread->sig_vectors = RT_NULL;
     thread->si_list     = RT_NULL;
-#endif
+#endif /* RT_USING_SIGNALS */
 
 #ifdef RT_USING_LWP
     thread->lwp = RT_NULL;
-#endif
+#endif /* RT_USING_LWP */
 
     RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread));
 
@@ -302,7 +302,7 @@ rt_thread_t rt_thread_self(void)
     extern rt_thread_t rt_current_thread;
 
     return rt_current_thread;
-#endif
+#endif /* RT_USING_SMP */
 }
 RTM_EXPORT(rt_thread_self);
 
@@ -330,7 +330,7 @@ rt_err_t rt_thread_startup(rt_thread_t thread)
     thread->high_mask   = 1L << (thread->current_priority & 0x07);  /* 3bit */
 #else
     thread->number_mask = 1L << thread->current_priority;
-#endif
+#endif /* RT_THREAD_PRIORITY_MAX > 32 */
 
     RT_DEBUG_LOG(RT_DEBUG_THREAD, ("startup a thread:%s with priority:%d\n",
                                    thread->name, thread->init_priority));
@@ -492,7 +492,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread)
     return RT_EOK;
 }
 RTM_EXPORT(rt_thread_delete);
-#endif
+#endif /* RT_USING_HEAP */
 
 /**
  * This function will let current thread yield processor, and scheduler will
@@ -690,7 +690,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg)
                 thread->high_mask   = 1 << (thread->current_priority & 0x07);   /* 3bit */
     #else
                 thread->number_mask = 1 << thread->current_priority;
-    #endif
+    #endif /* RT_THREAD_PRIORITY_MAX > 32 */
 
                 /* insert thread to schedule queue again */
                 rt_schedule_insert_thread(thread);
@@ -706,7 +706,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg)
                 thread->high_mask   = 1 << (thread->current_priority & 0x07);   /* 3bit */
     #else
                 thread->number_mask = 1 << thread->current_priority;
-    #endif
+    #endif /* RT_THREAD_PRIORITY_MAX > 32 */
             }
 
             /* enable interrupt */
@@ -732,7 +732,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg)
             {
                 rt_err = rt_thread_delete(thread);
             }
-    #endif
+    #endif /* RT_USING_HEAP */
             rt_schedule();
             return rt_err;
         }
@@ -752,7 +752,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg)
             thread->bind_cpu = cpu > RT_CPUS_NR? RT_CPUS_NR : cpu;
             break;
         }
-    #endif /*RT_USING_SMP*/
+    #endif /* RT_USING_SMP */
 
         default:
             break;

+ 10 - 10
src/timer.c

@@ -31,11 +31,11 @@ static rt_list_t rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL];
 
 #ifndef RT_TIMER_THREAD_STACK_SIZE
 #define RT_TIMER_THREAD_STACK_SIZE     512
-#endif
+#endif /* RT_TIMER_THREAD_STACK_SIZE */
 
 #ifndef RT_TIMER_THREAD_PRIO
 #define RT_TIMER_THREAD_PRIO           0
-#endif
+#endif /* RT_TIMER_THREAD_PRIO */
 
 /* soft timer status */
 static rt_uint8_t soft_timer_status = RT_SOFT_TIMER_IDLE;
@@ -44,7 +44,7 @@ static rt_list_t rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL];
 static struct rt_thread timer_thread;
 ALIGN(RT_ALIGN_SIZE)
 static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE];
-#endif
+#endif /* RT_USING_TIMER_SOFT */
 
 #ifdef RT_USING_HOOK
 extern void (*rt_object_take_hook)(struct rt_object *object);
@@ -81,7 +81,7 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer))
 }
 
 /**@}*/
-#endif
+#endif /* RT_USING_HOOK */
 
 static void _rt_timer_init(rt_timer_t timer,
                            void (*timeout)(void *parameter),
@@ -171,7 +171,7 @@ void rt_timer_dump(rt_list_t timer_heads[])
     }
     rt_kprintf("\n");
 }
-#endif
+#endif /* RT_DEBUG_TIMER */
 
 /**
  * @addtogroup Clock
@@ -303,7 +303,7 @@ rt_err_t rt_timer_delete(rt_timer_t timer)
     return RT_EOK;
 }
 RTM_EXPORT(rt_timer_delete);
-#endif
+#endif /* RT_USING_HEAP */
 
 /**
  * This function will start the timer
@@ -348,7 +348,7 @@ rt_err_t rt_timer_start(rt_timer_t timer)
         timer_list = rt_soft_timer_list;
     }
     else
-#endif
+#endif /* RT_USING_TIMER_SOFT */
     {
         /* insert timer to system timer list */
         timer_list = rt_timer_list;
@@ -422,7 +422,7 @@ rt_err_t rt_timer_start(rt_timer_t timer)
             rt_schedule();
         }
     }
-#endif
+#endif /* RT_USING_TIMER_SOFT */
 
     return RT_EOK;
 }
@@ -718,7 +718,7 @@ static void rt_thread_timer_entry(void *parameter)
         rt_soft_timer_check();
     }
 }
-#endif
+#endif /* RT_USING_TIMER_SOFT */
 
 /**
  * @ingroup SystemInit
@@ -764,7 +764,7 @@ void rt_system_timer_thread_init(void)
 
     /* startup */
     rt_thread_startup(&timer_thread);
-#endif
+#endif /* RT_USING_TIMER_SOFT */
 }
 
 /**@}*/