[PATCH -perfbook 4/6] CodeSamples/count: Add static to __inline__ function declarations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At lower optimization levels of GCC, __inline__ functions without "static"
cause build errors like below:

    make[1]: Entering directory 'perfbook/CodeSamples/count'
    cc -g -O0 -Wall  -o count_end count_end.c -lpthread
    /usr/bin/ld: /tmp/ccxpkcHA.o: in function `perftestrun':
    perfbook/CodeSamples/count/counttorture.h:159: undefined reference to `count_cleanup'
    /usr/bin/ld: /tmp/ccxpkcHA.o: in function `main':
    perfbook/CodeSamples/count/counttorture.h:248: undefined reference to `count_init'
    collect2: error: ld returned 1 exit status
    make[1]: *** [Makefile:55: count_end] Error 1
    make[1]: Leaving directory 'git/perfbook/CodeSamples/count'

Always put "static" to those function declarations.

While here, add __inline__ to read_count() of count_stack.c.

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 CodeSamples/count/count_end.c         | 4 ++--
 CodeSamples/count/count_end_rcu.c     | 4 ++--
 CodeSamples/count/count_stack.c       | 6 +++---
 CodeSamples/count/count_stat_atomic.c | 6 +++---
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/CodeSamples/count/count_end.c b/CodeSamples/count/count_end.c
index b6ed851c..cf6056e6 100644
--- a/CodeSamples/count/count_end.c
+++ b/CodeSamples/count/count_end.c
@@ -48,7 +48,7 @@ static inline unsigned long read_count(void)
 }
 
 #ifndef FCV_SNIPPET
-inline void count_init(void)
+static __inline__ void count_init(void)
 {
 }
 #endif /* FCV_SNIPPET */
@@ -73,7 +73,7 @@ void count_unregister_thread(int nthreadsexpected)	//\lnlbl{unreg:b}
 }							//\lnlbl{unreg:e}
 //\end{snippet}
 
-inline void count_cleanup(void)
+static __inline__ void count_cleanup(void)
 {
 }
 
diff --git a/CodeSamples/count/count_end_rcu.c b/CodeSamples/count/count_end_rcu.c
index 71bd5269..104a016b 100644
--- a/CodeSamples/count/count_end_rcu.c
+++ b/CodeSamples/count/count_end_rcu.c
@@ -34,7 +34,7 @@ unsigned long __thread counter = 0;		//\lnlbl{perthread:b}
 struct countarray *countarrayp = NULL;
 DEFINE_SPINLOCK(final_mutex);			//\lnlbl{perthread:e}
 
-__inline__ void inc_count(void)			//\lnlbl{inc:b}
+static __inline__ void inc_count(void)		//\lnlbl{inc:b}
 {
 	WRITE_ONCE(counter, counter + 1);
 }						//\lnlbl{inc:e}
@@ -99,7 +99,7 @@ void count_unregister_thread(int nthreadsexpected)	//\lnlbl{unreg:b}
 }							//\lnlbl{unreg:e}
 //\end{snippet}
 
-__inline__ void count_cleanup(void)
+static __inline__ void count_cleanup(void)
 {
 }
 
diff --git a/CodeSamples/count/count_stack.c b/CodeSamples/count/count_stack.c
index e10bcbbd..384310b7 100644
--- a/CodeSamples/count/count_stack.c
+++ b/CodeSamples/count/count_stack.c
@@ -27,7 +27,7 @@ unsigned long *counterp[NR_THREADS] = { NULL };
 unsigned long finalcount = 0;
 DEFINE_SPINLOCK(final_mutex);
 
-__inline__ void inc_count(void)
+static __inline__ void inc_count(void)
 {
 	WRITE_ONCE(*counter,
 		   READ_ONCE(*counter) + 1);
@@ -47,7 +47,7 @@ unsigned long read_count(void)
 	return sum;
 }
 
-__inline__ void count_init(void)
+static __inline__ void count_init(void)
 {
 }
 
@@ -71,7 +71,7 @@ void count_unregister_thread(int nthreadsexpected)
 	spin_unlock(&final_mutex);
 }
 
-__inline__ void count_cleanup(void)
+static __inline__ void count_cleanup(void)
 {
 }
 
diff --git a/CodeSamples/count/count_stat_atomic.c b/CodeSamples/count/count_stat_atomic.c
index 9d9457a4..ec57c4b0 100644
--- a/CodeSamples/count/count_stat_atomic.c
+++ b/CodeSamples/count/count_stat_atomic.c
@@ -28,7 +28,7 @@ void inc_count(void)
 	atomic_inc(&__get_thread_var(counter));
 }
 
-__inline__ unsigned long read_count(void)
+static __inline__ unsigned long read_count(void)
 {
 	int t;
 	unsigned long sum = 0;
@@ -38,11 +38,11 @@ __inline__ unsigned long read_count(void)
 	return sum;
 }
 
-__inline__ void count_init(void)
+static __inline__ void count_init(void)
 {
 }
 
-__inline__ void count_cleanup(void)
+static __inline__ void count_cleanup(void)
 {
 }
 
-- 
2.34.1






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux