From 1b04bfae200f63b04ba5a3c391eff929e3aa625c Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 16 Aug 2022 12:20:39 +0800 Subject: [PATCH] sched: Remove the unnecessary weak_function because not all compiler support the weak attribute, and many features are either always used or guarded by config. Signed-off-by: Xiang Xiao --- sched/clock/clock.h | 6 +++-- sched/group/group.h | 4 ++- sched/init/nx_start.c | 44 +++++--------------------------- sched/irq/irq.h | 2 +- sched/mqueue/mq_rcvinternal.c | 2 +- sched/mqueue/mqueue.h | 4 +-- sched/sched/sched_processtimer.c | 7 +---- sched/sched/sched_releasetcb.c | 7 +---- sched/signal/signal.h | 2 +- sched/timer/timer.h | 4 +-- sched/timer/timer_initialize.c | 4 +-- 11 files changed, 24 insertions(+), 62 deletions(-) diff --git a/sched/clock/clock.h b/sched/clock/clock.h index 3f67f0fcc2..632e672798 100644 --- a/sched/clock/clock.h +++ b/sched/clock/clock.h @@ -76,9 +76,11 @@ extern struct timespec g_basetime; int clock_basetime(FAR struct timespec *tp); -void weak_function clock_initialize(void); +void clock_initialize(void); #ifndef CONFIG_SCHED_TICKLESS -void weak_function clock_timer(void); +void clock_timer(void); +#else +# define clock_timer() #endif int clock_abstime2ticks(clockid_t clockid, diff --git a/sched/group/group.h b/sched/group/group.h index 7d9403f143..bb22403e8b 100644 --- a/sched/group/group.h +++ b/sched/group/group.h @@ -67,7 +67,9 @@ extern FAR struct task_group_s *g_group_current[CONFIG_SMP_NCPUS]; ****************************************************************************/ #ifdef CONFIG_SCHED_CHILD_STATUS -void weak_function task_initialize(void); +void task_initialize(void); +#else +# define task_initialize() #endif /* Task group data structure management */ diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index 0ee8077e74..f6bcff4e42 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -564,16 +564,9 @@ void nx_start(void) g_nx_initstate = OSINIT_MEMORY; -#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS) /* Initialize tasking data structures */ -#ifdef CONFIG_HAVE_WEAKFUNCTIONS - if (task_initialize != NULL) -#endif - { - task_initialize(); - } -#endif + task_initialize(); /* Disables context switching because we need take the memory manager * semaphore on this CPU so that it will not be available on the other @@ -588,49 +581,24 @@ void nx_start(void) /* Initialize the interrupt handling subsystem (if included) */ -#ifdef CONFIG_HAVE_WEAKFUNCTIONS - if (irq_initialize != NULL) -#endif - { - irq_initialize(); - } + irq_initialize(); /* Initialize the POSIX timer facility (if included in the link) */ -#ifdef CONFIG_HAVE_WEAKFUNCTIONS - if (clock_initialize != NULL) -#endif - { - clock_initialize(); - } + clock_initialize(); #ifndef CONFIG_DISABLE_POSIX_TIMERS -#ifdef CONFIG_HAVE_WEAKFUNCTIONS - if (timer_initialize != NULL) -#endif - { - timer_initialize(); - } + timer_initialize(); #endif /* Initialize the signal facility (if in link) */ -#ifdef CONFIG_HAVE_WEAKFUNCTIONS - if (nxsig_initialize != NULL) -#endif - { - nxsig_initialize(); - } + nxsig_initialize(); #ifndef CONFIG_DISABLE_MQUEUE /* Initialize the named message queue facility (if in link) */ -#ifdef CONFIG_HAVE_WEAKFUNCTIONS - if (nxmq_initialize != NULL) -#endif - { - nxmq_initialize(); - } + nxmq_initialize(); #endif #ifdef CONFIG_NET diff --git a/sched/irq/irq.h b/sched/irq/irq.h index cc70893b42..43d495b2be 100644 --- a/sched/irq/irq.h +++ b/sched/irq/irq.h @@ -142,7 +142,7 @@ extern "C" * ****************************************************************************/ -void weak_function irq_initialize(void); +void irq_initialize(void); /**************************************************************************** * Name: irq_unexpected_isr diff --git a/sched/mqueue/mq_rcvinternal.c b/sched/mqueue/mq_rcvinternal.c index 0187255d1e..fab06d232a 100644 --- a/sched/mqueue/mq_rcvinternal.c +++ b/sched/mqueue/mq_rcvinternal.c @@ -251,7 +251,7 @@ int nxmq_wait_receive(FAR struct mqueue_inode_s *msgq, ssize_t nxmq_do_receive(FAR struct mqueue_inode_s *msgq, FAR struct mqueue_msg_s *mqmsg, - FAR char *ubuffer, unsigned int *prio) + FAR char *ubuffer, FAR unsigned int *prio) { FAR struct tcb_s *btcb; ssize_t rcvmsglen; diff --git a/sched/mqueue/mqueue.h b/sched/mqueue/mqueue.h index 1eed43d0ba..7e1834f9a9 100644 --- a/sched/mqueue/mqueue.h +++ b/sched/mqueue/mqueue.h @@ -106,7 +106,7 @@ struct task_group_s; /* Forward reference */ /* Functions defined in mq_initialize.c *****************************************/ -void weak_function nxmq_initialize(void); +void nxmq_initialize(void); void nxmq_free_msg(FAR struct mqueue_msg_s *mqmsg); /* mq_waitirq.c *****************************************************************/ @@ -124,7 +124,7 @@ int nxmq_wait_receive(FAR struct mqueue_inode_s *msgq, int oflags, FAR struct mqueue_msg_s **rcvmsg); ssize_t nxmq_do_receive(FAR struct mqueue_inode_s *msgq, FAR struct mqueue_msg_s *mqmsg, - FAR char *ubuffer, unsigned int *prio); + FAR char *ubuffer, FAR unsigned int *prio); /* mq_sndinternal.c *************************************************************/ diff --git a/sched/sched/sched_processtimer.c b/sched/sched/sched_processtimer.c index d141727dd1..3979b1f62c 100644 --- a/sched/sched/sched_processtimer.c +++ b/sched/sched/sched_processtimer.c @@ -218,12 +218,7 @@ void nxsched_process_timer(void) /* Increment the system time (if in the link) */ -#ifdef CONFIG_HAVE_WEAKFUNCTIONS - if (clock_timer != NULL) -#endif - { - clock_timer(); - } + clock_timer(); #ifndef CONFIG_SCHED_CPULOAD_EXTCLK /* Perform CPU load measurements (before any timer-initiated context diff --git a/sched/sched/sched_releasetcb.c b/sched/sched/sched_releasetcb.c index 12fdde5fba..ab644ce783 100644 --- a/sched/sched/sched_releasetcb.c +++ b/sched/sched/sched_releasetcb.c @@ -108,12 +108,7 @@ int nxsched_release_tcb(FAR struct tcb_s *tcb, uint8_t ttype) * disabled here). */ -#ifdef CONFIG_HAVE_WEAKFUNCTIONS - if (timer_deleteall != NULL) -#endif - { - timer_deleteall(tcb->pid); - } + timer_deleteall(tcb->pid); #endif /* Release the task's process ID if one was assigned. PID diff --git a/sched/signal/signal.h b/sched/signal/signal.h index b8a3f5e1f6..f9409e9b67 100644 --- a/sched/signal/signal.h +++ b/sched/signal/signal.h @@ -147,7 +147,7 @@ struct task_group_s; /* sig_initializee.c */ -void weak_function nxsig_initialize(void); +void nxsig_initialize(void); /* sig_action.c */ diff --git a/sched/timer/timer.h b/sched/timer/timer.h index 5f37000c01..e8b1508172 100644 --- a/sched/timer/timer.h +++ b/sched/timer/timer.h @@ -81,8 +81,8 @@ extern volatile sq_queue_t g_alloctimers; * Public Function Prototypes ****************************************************************************/ -void weak_function timer_initialize(void); -void weak_function timer_deleteall(pid_t pid); +void timer_initialize(void); +void timer_deleteall(pid_t pid); int timer_release(FAR struct posix_timer_s *timer); #endif /* __SCHED_TIMER_TIMER_H */ diff --git a/sched/timer/timer_initialize.c b/sched/timer/timer_initialize.c index 0e22317875..dedf2b0d37 100644 --- a/sched/timer/timer_initialize.c +++ b/sched/timer/timer_initialize.c @@ -81,7 +81,7 @@ volatile sq_queue_t g_alloctimers; * ****************************************************************************/ -void weak_function timer_initialize(void) +void timer_initialize(void) { #if CONFIG_PREALLOC_TIMERS > 0 int i; @@ -122,7 +122,7 @@ void weak_function timer_initialize(void) * ****************************************************************************/ -void weak_function timer_deleteall(pid_t pid) +void timer_deleteall(pid_t pid) { FAR struct posix_timer_s *timer; FAR struct posix_timer_s *next;