Flexible I/O Tester development
 help / color / mirror / Atom feed
* [PATCH 1/4] Replace CONFIG_CPU_COUNT with plain CPU_COUNT
@ 2014-05-01 12:07 Daniel Gollub
  2014-05-01 12:07 ` [PATCH 2/4] distinguish internal/ext. builds with FIO_INTERNAL Daniel Gollub
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Daniel Gollub @ 2014-05-01 12:07 UTC (permalink / raw)
  To: fio; +Cc: Daniel Gollub

Fixes double-declartion issue of CPU_COUNT when fio.h is included by
third-party projects.

Checking for a define of CPU_COUNT seems to be a common approach
to deal with different versions of sched.h

Signed-off-by: Daniel Gollub <daniel.gollub@gmail.com>
---
 configure |   19 -------------------
 os/os.h   |    2 +-
 2 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/configure b/configure
index 4757d67..2ba1daf 100755
--- a/configure
+++ b/configure
@@ -652,22 +652,6 @@ echo "sched_setaffinity(3 arg)      $linux_3arg_affinity"
 echo "sched_setaffinity(2 arg)      $linux_2arg_affinity"
 
 ##########################################
-# CPU_COUNT test
-cpu_count="no"
-cat > $TMPC << EOF
-#include <sched.h>
-int main(int argc, char **argv)
-{
-  cpu_set_t mask;
-  return CPU_COUNT(&mask);
-}
-EOF
-if compile_prog "" "" "cpu_count"; then
-  cpu_count="yes"
-fi
-echo "CPU_COUNT                     $cpu_count"
-
-##########################################
 # clock_gettime probe
 clock_gettime="no"
 cat > $TMPC << EOF
@@ -1335,9 +1319,6 @@ fi
 if test "$rbd" = "yes" ; then
   output_sym "CONFIG_RBD"
 fi
-if test "$cpu_count" = "yes" ; then
-  output_sym "CONFIG_CPU_COUNT"
-fi
 if test "$setvbuf" = "yes" ; then
   output_sym "CONFIG_SETVBUF"
 fi
diff --git a/os/os.h b/os/os.h
index 2f2d069..98b4532 100644
--- a/os/os.h
+++ b/os/os.h
@@ -321,7 +321,7 @@ static inline unsigned int cpus_online(void)
 }
 #endif
 
-#ifndef CONFIG_CPU_COUNT
+#ifndef CPU_COUNT
 #ifdef FIO_HAVE_CPU_AFFINITY
 static inline int CPU_COUNT(os_cpu_mask_t *mask)
 {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] distinguish internal/ext. builds with FIO_INTERNAL
  2014-05-01 12:07 [PATCH 1/4] Replace CONFIG_CPU_COUNT with plain CPU_COUNT Daniel Gollub
@ 2014-05-01 12:07 ` Daniel Gollub
  2014-05-01 12:07 ` [PATCH 3/4] Avoid double-declaration of ARRAY_SIZE Daniel Gollub
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Gollub @ 2014-05-01 12:07 UTC (permalink / raw)
  To: fio; +Cc: Daniel Gollub

To distinguish between internal and external includes of
fio.h and other headers FIO_INTERNAL get applied only for
the fio (and gfio) internal build itself.

This helps to prevent double-declaration issues by making
ambigous declaration with common names coditional based on
the FIO_INTERNAL define.

Signed-off-by: Daniel Gollub <daniel.gollub@gmail.com>
---
 Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index e7659c4..a0f0f71 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ include config-host.mak
 endif
 
 DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
-CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS)
+CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL $(DEBUGFLAGS)
 OPTFLAGS= -O3 -g -ffast-math
 CFLAGS	= -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS)
 LIBS	+= -lm $(EXTLIBS)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] Avoid double-declaration of ARRAY_SIZE
  2014-05-01 12:07 [PATCH 1/4] Replace CONFIG_CPU_COUNT with plain CPU_COUNT Daniel Gollub
  2014-05-01 12:07 ` [PATCH 2/4] distinguish internal/ext. builds with FIO_INTERNAL Daniel Gollub
@ 2014-05-01 12:07 ` Daniel Gollub
  2014-05-01 12:07 ` [PATCH 4/4] Avoid double declaration of leXX_to_cpu Daniel Gollub
  2014-05-01 17:22 ` [PATCH 1/4] Replace CONFIG_CPU_COUNT with plain CPU_COUNT Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Gollub @ 2014-05-01 12:07 UTC (permalink / raw)
  To: fio; +Cc: Daniel Gollub

for external ioengines. ARRAY_SIZE is a very common
declaration - e.g. Ceph is using this as well.

Signed-off-by: Daniel Gollub <daniel.gollub@gmail.com>
---
 fio.h |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/fio.h b/fio.h
index ed034cb..4d4af0a 100644
--- a/fio.h
+++ b/fio.h
@@ -618,7 +618,9 @@ static inline void td_io_u_free_notify(struct thread_data *td)
 extern const char *fio_get_arch_string(int);
 extern const char *fio_get_os_string(int);
 
+#ifdef FIO_INTERNAL
 #define ARRAY_SIZE(x) (sizeof((x)) / (sizeof((x)[0])))
+#endif
 
 enum {
 	FIO_OUTPUT_TERSE	= 0,
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] Avoid double declaration of leXX_to_cpu
  2014-05-01 12:07 [PATCH 1/4] Replace CONFIG_CPU_COUNT with plain CPU_COUNT Daniel Gollub
  2014-05-01 12:07 ` [PATCH 2/4] distinguish internal/ext. builds with FIO_INTERNAL Daniel Gollub
  2014-05-01 12:07 ` [PATCH 3/4] Avoid double-declaration of ARRAY_SIZE Daniel Gollub
@ 2014-05-01 12:07 ` Daniel Gollub
  2014-05-01 17:22 ` [PATCH 1/4] Replace CONFIG_CPU_COUNT with plain CPU_COUNT Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Gollub @ 2014-05-01 12:07 UTC (permalink / raw)
  To: fio; +Cc: Daniel Gollub

for external ioengines. leXX_to_cpu is a very common
declaration - e.g. Ceph is using this as well.

Signed-off-by: Daniel Gollub <daniel.gollub@gmail.com>
---
 os/os.h |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/os/os.h b/os/os.h
index 98b4532..b8eee66 100644
--- a/os/os.h
+++ b/os/os.h
@@ -200,6 +200,7 @@ static inline uint64_t fio_swap64(uint64_t val)
 #endif
 #endif /* FIO_HAVE_BYTEORDER_FUNCS */
 
+#ifdef FIO_INTERNAL
 #define le16_to_cpu(val) ({			\
 	__le16_to_cpu(val);			\
 })
@@ -209,6 +210,8 @@ static inline uint64_t fio_swap64(uint64_t val)
 #define le64_to_cpu(val) ({			\
 	__le64_to_cpu(val);				\
 })
+#endif
+
 #define cpu_to_le16(val) ({			\
 	__cpu_to_le16(val);			\
 })
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/4] Replace CONFIG_CPU_COUNT with plain CPU_COUNT
  2014-05-01 12:07 [PATCH 1/4] Replace CONFIG_CPU_COUNT with plain CPU_COUNT Daniel Gollub
                   ` (2 preceding siblings ...)
  2014-05-01 12:07 ` [PATCH 4/4] Avoid double declaration of leXX_to_cpu Daniel Gollub
@ 2014-05-01 17:22 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2014-05-01 17:22 UTC (permalink / raw)
  To: Daniel Gollub, fio

On 05/01/2014 06:07 AM, Daniel Gollub wrote:
> Fixes double-declartion issue of CPU_COUNT when fio.h is included by
> third-party projects.
> 
> Checking for a define of CPU_COUNT seems to be a common approach
> to deal with different versions of sched.h]

Thanks Daniel, applied all 5 of your patches.

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-01 17:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-01 12:07 [PATCH 1/4] Replace CONFIG_CPU_COUNT with plain CPU_COUNT Daniel Gollub
2014-05-01 12:07 ` [PATCH 2/4] distinguish internal/ext. builds with FIO_INTERNAL Daniel Gollub
2014-05-01 12:07 ` [PATCH 3/4] Avoid double-declaration of ARRAY_SIZE Daniel Gollub
2014-05-01 12:07 ` [PATCH 4/4] Avoid double declaration of leXX_to_cpu Daniel Gollub
2014-05-01 17:22 ` [PATCH 1/4] Replace CONFIG_CPU_COUNT with plain CPU_COUNT Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox