[libvirt] [PATCH 14/46] util: thread: use #pragma once in headers

Jonathon Jongsma jjongsma at redhat.com
Tue Jun 18 16:12:44 UTC 2019


Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
---
 src/util/virthread.h     | 19 ++++++++-----------
 src/util/virthreadjob.h  |  6 +-----
 src/util/virthreadpool.h |  9 +++------
 3 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/src/util/virthread.h b/src/util/virthread.h
index 218d1fcd3f..7870340c47 100644
--- a/src/util/virthread.h
+++ b/src/util/virthread.h
@@ -19,13 +19,12 @@
  *
  */
 
-#ifndef LIBVIRT_VIRTHREAD_H
-# define LIBVIRT_VIRTHREAD_H
+#pragma once
 
-# include "internal.h"
-# include "virerror.h"
+#include "internal.h"
+#include "virerror.h"
 
-# include <pthread.h>
+#include <pthread.h>
 
 typedef struct virMutex virMutex;
 typedef virMutex *virMutexPtr;
@@ -71,12 +70,12 @@ struct virOnceControl {
 };
 
 
-# define VIR_MUTEX_INITIALIZER \
+#define VIR_MUTEX_INITIALIZER \
     { \
         .lock = PTHREAD_MUTEX_INITIALIZER \
     }
 
-# define VIR_ONCE_CONTROL_INITIALIZER \
+#define VIR_ONCE_CONTROL_INITIALIZER \
     { \
         .once = PTHREAD_ONCE_INIT \
     }
@@ -88,7 +87,7 @@ void virThreadOnExit(void);
 
 typedef void (*virThreadFunc)(void *opaque);
 
-# define virThreadCreate(thread, joinable, func, opaque) \
+#define virThreadCreate(thread, joinable, func, opaque) \
     virThreadCreateFull(thread, joinable, func, #func, false, opaque)
 
 int virThreadCreateFull(virThreadPtr thread,
@@ -190,7 +189,7 @@ int virThreadLocalSet(virThreadLocalPtr l, void*) ATTRIBUTE_RETURN_CHECK;
  * Which will ensure that 'virMyObjectOnceInit' is
  * guaranteed to be invoked exactly once.
  */
-# define VIR_ONCE_GLOBAL_INIT(classname) \
+#define VIR_ONCE_GLOBAL_INIT(classname) \
     static virOnceControl classname ## OnceControl = VIR_ONCE_CONTROL_INITIALIZER; \
     static virErrorPtr classname ## OnceError; \
  \
@@ -213,5 +212,3 @@ int virThreadLocalSet(virThreadLocalPtr l, void*) ATTRIBUTE_RETURN_CHECK;
         return 0; \
     } \
     struct classname ## EatSemicolon
-
-#endif /* LIBVIRT_VIRTHREAD_H */
diff --git a/src/util/virthreadjob.h b/src/util/virthreadjob.h
index 697a932625..aac23c7780 100644
--- a/src/util/virthreadjob.h
+++ b/src/util/virthreadjob.h
@@ -18,14 +18,10 @@
  * <http://www.gnu.org/licenses/>.
  */
 
-#ifndef LIBVIRT_VIRTHREADJOB_H
-# define LIBVIRT_VIRTHREADJOB_H
-
+#pragma once
 
 const char *virThreadJobGet(void);
 
 void virThreadJobSetWorker(const char *caller);
 void virThreadJobSet(const char *caller);
 void virThreadJobClear(int rv);
-
-#endif /* LIBVIRT_VIRTHREADJOB_H */
diff --git a/src/util/virthreadpool.h b/src/util/virthreadpool.h
index 461682b01a..7dfb511c0a 100644
--- a/src/util/virthreadpool.h
+++ b/src/util/virthreadpool.h
@@ -19,17 +19,16 @@
  * <http://www.gnu.org/licenses/>.
  */
 
-#ifndef LIBVIRT_VIRTHREADPOOL_H
-# define LIBVIRT_VIRTHREADPOOL_H
+#pragma once
 
-# include "internal.h"
+#include "internal.h"
 
 typedef struct _virThreadPool virThreadPool;
 typedef virThreadPool *virThreadPoolPtr;
 
 typedef void (*virThreadPoolJobFunc)(void *jobdata, void *opaque);
 
-# define virThreadPoolNew(min, max, prio, func, opaque) \
+#define virThreadPoolNew(min, max, prio, func, opaque) \
     virThreadPoolNewFull(min, max, prio, func, #func, opaque)
 
 virThreadPoolPtr virThreadPoolNewFull(size_t minWorkers,
@@ -57,5 +56,3 @@ int virThreadPoolSetParameters(virThreadPoolPtr pool,
                                long long int minWorkers,
                                long long int maxWorkers,
                                long long int prioWorkers);
-
-#endif /* LIBVIRT_VIRTHREADPOOL_H */
-- 
2.20.1




More information about the libvir-list mailing list