Skip to content

Commit 62d2403

Browse files
authored
[kernel] beautify code (#5890)
1 parent 4a12bc2 commit 62d2403

File tree

3 files changed

+49
-51
lines changed

3 files changed

+49
-51
lines changed

include/rtdef.h

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ struct rt_object
387387

388388
#ifdef RT_USING_MODULE
389389
void *module_id; /**< id of application module */
390-
#endif
390+
#endif /* RT_USING_MODULE */
391391
rt_list_t list; /**< list node of kernel object */
392392
};
393393
typedef struct rt_object *rt_object_t; /**< Type for kernel objects. */
@@ -450,8 +450,8 @@ struct rt_object_information
450450
#define __ON_HOOK_ARGS(__hook, argv) do {if ((__hook) != RT_NULL) __hook argv; } while (0)
451451
#else
452452
#define __ON_HOOK_ARGS(__hook, argv)
453-
#endif
454-
#endif
453+
#endif /* RT_HOOK_USING_FUNC_PTR */
454+
#endif /* RT_USING_HOOK */
455455

456456
#ifndef __on_rt_interrupt_switch_hook
457457
#define __on_rt_interrupt_switch_hook() __ON_HOOK_ARGS(rt_interrupt_switch_hook, ())
@@ -528,7 +528,7 @@ typedef void (*rt_sighandler_t)(int signo);
528528
typedef siginfo_t rt_siginfo_t;
529529

530530
#define RT_SIG_MAX 32
531-
#endif
531+
#endif /* RT_USING_SIGNALS */
532532
/**@}*/
533533

534534
/**
@@ -576,11 +576,11 @@ typedef siginfo_t rt_siginfo_t;
576576

577577
#ifndef RT_SCHEDULE_IPI
578578
#define RT_SCHEDULE_IPI 0
579-
#endif
579+
#endif /* RT_SCHEDULE_IPI */
580580

581581
#ifndef RT_STOP_IPI
582582
#define RT_STOP_IPI 1
583-
#endif
583+
#endif /* RT_STOP_IPI */
584584

585585
/**
586586
* CPUs definitions
@@ -600,12 +600,12 @@ struct rt_cpu
600600
rt_uint8_t ready_table[32];
601601
#else
602602
rt_uint32_t priority_group;
603-
#endif
603+
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
604604

605605
rt_tick_t tick;
606606
};
607607

608-
#endif
608+
#endif /* RT_USING_SMP */
609609

610610
/**
611611
* Thread structure
@@ -619,7 +619,7 @@ struct rt_thread
619619

620620
#ifdef RT_USING_MODULE
621621
void *module_id; /**< id of application module */
622-
#endif
622+
#endif /* RT_USING_MODULE */
623623

624624
rt_list_t list; /**< the object list */
625625
rt_list_t tlist; /**< the thread list */
@@ -650,32 +650,32 @@ struct rt_thread
650650
#if RT_THREAD_PRIORITY_MAX > 32
651651
rt_uint8_t number;
652652
rt_uint8_t high_mask;
653-
#endif
653+
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
654654
rt_uint32_t number_mask;
655655

656-
#if defined(RT_USING_EVENT)
656+
#ifdef RT_USING_EVENT
657657
/* thread event */
658658
rt_uint32_t event_set;
659659
rt_uint8_t event_info;
660-
#endif
660+
#endif /* RT_USING_EVENT */
661661

662-
#if defined(RT_USING_SIGNALS)
662+
#ifdef RT_USING_SIGNALS
663663
rt_sigset_t sig_pending; /**< the pending signals */
664664
rt_sigset_t sig_mask; /**< the mask bits of signal */
665665

666666
#ifndef RT_USING_SMP
667667
void *sig_ret; /**< the return stack pointer from signal */
668-
#endif
668+
#endif /* RT_USING_SMP */
669669
rt_sighandler_t *sig_vectors; /**< vectors of signal handler */
670670
void *si_list; /**< the signal infor list */
671-
#endif
671+
#endif /* RT_USING_SIGNALS */
672672

673673
rt_ubase_t init_tick; /**< thread's initialized tick */
674674
rt_ubase_t remaining_tick; /**< remaining tick */
675675

676676
#ifdef RT_USING_CPU_USAGE
677677
rt_uint64_t duration_tick; /**< cpu usage tick */
678-
#endif
678+
#endif /* RT_USING_CPU_USAGE */
679679

680680
struct rt_timer thread_timer; /**< built-in thread timer */
681681

@@ -684,7 +684,7 @@ struct rt_thread
684684
/* light weight process if present */
685685
#ifdef RT_USING_LWP
686686
void *lwp;
687-
#endif
687+
#endif /* RT_USING_LWP */
688688

689689
rt_ubase_t user_data; /**< private user data beyond this thread */
690690
};
@@ -732,7 +732,7 @@ struct rt_semaphore
732732
rt_uint16_t reserved; /**< reserved field */
733733
};
734734
typedef struct rt_semaphore *rt_sem_t;
735-
#endif
735+
#endif /* RT_USING_SEMAPHORE */
736736

737737
#ifdef RT_USING_MUTEX
738738
/**
@@ -750,7 +750,7 @@ struct rt_mutex
750750
struct rt_thread *owner; /**< current owner of mutex */
751751
};
752752
typedef struct rt_mutex *rt_mutex_t;
753-
#endif
753+
#endif /* RT_USING_MUTEX */
754754

755755
#ifdef RT_USING_EVENT
756756
/**
@@ -770,7 +770,7 @@ struct rt_event
770770
rt_uint32_t set; /**< event set */
771771
};
772772
typedef struct rt_event *rt_event_t;
773-
#endif
773+
#endif /* RT_USING_EVENT */
774774

775775
#ifdef RT_USING_MAILBOX
776776
/**
@@ -791,7 +791,7 @@ struct rt_mailbox
791791
rt_list_t suspend_sender_thread; /**< sender thread suspended on this mailbox */
792792
};
793793
typedef struct rt_mailbox *rt_mailbox_t;
794-
#endif
794+
#endif /* RT_USING_MAILBOX */
795795

796796
#ifdef RT_USING_MESSAGEQUEUE
797797
/**
@@ -815,7 +815,7 @@ struct rt_messagequeue
815815
rt_list_t suspend_sender_thread; /**< sender thread suspended on this message queue */
816816
};
817817
typedef struct rt_messagequeue *rt_mq_t;
818-
#endif
818+
#endif /* RT_USING_MESSAGEQUEUE */
819819

820820
/**@}*/
821821

@@ -839,7 +839,7 @@ struct rt_memory
839839
rt_size_t max; /**< maximum usage */
840840
};
841841
typedef struct rt_memory *rt_mem_t;
842-
#endif
842+
#endif /* RT_USING_HEAP */
843843

844844
/*
845845
* memory management
@@ -848,11 +848,11 @@ typedef struct rt_memory *rt_mem_t;
848848

849849
#ifdef RT_USING_SMALL_MEM
850850
typedef rt_mem_t rt_smem_t;
851-
#endif
851+
#endif /* RT_USING_SMALL_MEM */
852852

853853
#ifdef RT_USING_SLAB
854854
typedef rt_mem_t rt_slab_t;
855-
#endif
855+
#endif /* RT_USING_SLAB */
856856

857857
#ifdef RT_USING_MEMHEAP
858858
/**
@@ -870,7 +870,7 @@ struct rt_memheap_item
870870
struct rt_memheap_item *prev_free; /**< prev free memheap item */
871871
#ifdef RT_USING_MEMTRACE
872872
rt_uint8_t owner_thread_name[4]; /**< owner thread name */
873-
#endif
873+
#endif /* RT_USING_MEMTRACE */
874874
};
875875

876876
/**
@@ -894,7 +894,7 @@ struct rt_memheap
894894
struct rt_semaphore lock; /**< semaphore lock */
895895
rt_bool_t locked; /**< External lock mark */
896896
};
897-
#endif
897+
#endif /* RT_USING_MEMHEAP */
898898

899899
#ifdef RT_USING_MEMPOOL
900900
/**
@@ -916,7 +916,7 @@ struct rt_mempool
916916
rt_list_t suspend_thread; /**< threads pended on this resource */
917917
};
918918
typedef struct rt_mempool *rt_mp_t;
919-
#endif
919+
#endif /* RT_USING_MEMPOOL */
920920

921921
/**@}*/
922922

@@ -1036,7 +1036,7 @@ struct rt_device_ops
10361036
rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
10371037
rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
10381038
};
1039-
#endif
1039+
#endif /* RT_USING_DEVICE_OPS */
10401040

10411041
/**
10421042
* WaitQueue structure
@@ -1076,12 +1076,12 @@ struct rt_device
10761076
rt_size_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size);
10771077
rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
10781078
rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
1079-
#endif
1079+
#endif /* RT_USING_DEVICE_OPS */
10801080

10811081
#ifdef RT_USING_POSIX_DEVIO
10821082
const struct dfs_file_ops *fops;
10831083
struct rt_wqueue wait_queue;
1084-
#endif
1084+
#endif /* RT_USING_POSIX_DEVIO */
10851085

10861086
void *user_data; /**< device private data */
10871087
};
@@ -1194,7 +1194,7 @@ struct rt_device_graphic_ops
11941194
#define rt_graphix_ops(device) ((struct rt_device_graphic_ops *)(device->user_data))
11951195

11961196
/**@}*/
1197-
#endif
1197+
#endif /* RT_USING_DEVICE */
11981198

11991199
#ifdef __cplusplus
12001200
}
@@ -1211,6 +1211,6 @@ enum TICK_WAIT {
12111211

12121212
}
12131213

1214-
#endif /* end of __cplusplus */
1214+
#endif /* __cplusplus */
12151215

1216-
#endif
1216+
#endif /* __RT_DEF_H__ */

src/thread.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread))
8585
{
8686
rt_thread_inited_hook = hook;
8787
}
88-
89-
#endif /* RT_USING_HOOK */
88+
#endif /* defined(RT_USING_HOOK) && defined(RT_HOOK_USING_FUNC_PTR) */
9089

9190
static void _thread_exit(void)
9291
{
@@ -195,7 +194,7 @@ static rt_err_t _thread_init(struct rt_thread *thread,
195194
#ifdef RT_USING_EVENT
196195
thread->event_set = 0;
197196
thread->event_info = 0;
198-
#endif
197+
#endif /* RT_USING_EVENT */
199198

200199
#if RT_THREAD_PRIORITY_MAX > 32
201200
thread->number = 0;
@@ -251,12 +250,11 @@ static rt_err_t _thread_init(struct rt_thread *thread,
251250

252251
#ifdef RT_USING_CPU_USAGE
253252
thread->duration_tick = 0;
254-
#endif
255-
253+
#endif /* RT_USING_CPU_USAGE */
256254

257255
#ifdef RT_USING_MODULE
258256
thread->module_id = 0;
259-
#endif
257+
#endif /* RT_USING_MODULE */
260258

261259
RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread));
262260

@@ -473,13 +471,13 @@ rt_thread_t rt_thread_create(const char *name,
473471
}
474472

475473
_thread_init(thread,
476-
name,
477-
entry,
478-
parameter,
479-
stack_start,
480-
stack_size,
481-
priority,
482-
tick);
474+
name,
475+
entry,
476+
parameter,
477+
stack_start,
478+
stack_size,
479+
priority,
480+
tick);
483481

484482
return thread;
485483
}

src/timer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer))
118118
* @param flag the flag of timer
119119
*/
120120
static void _timer_init(rt_timer_t timer,
121-
void (*timeout)(void *parameter),
122-
void *parameter,
123-
rt_tick_t time,
124-
rt_uint8_t flag)
121+
void (*timeout)(void *parameter),
122+
void *parameter,
123+
rt_tick_t time,
124+
rt_uint8_t flag)
125125
{
126126
int i;
127127

0 commit comments

Comments
 (0)