util: thread: use #pragma once in headers

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jonathon Jongsma 2019-06-18 11:12:44 -05:00 committed by Ján Tomko
parent 6bbc6269c1
commit 064c15fbf1
3 changed files with 12 additions and 22 deletions

View File

@ -19,13 +19,12 @@
* *
*/ */
#ifndef LIBVIRT_VIRTHREAD_H #pragma once
# define LIBVIRT_VIRTHREAD_H
# include "internal.h" #include "internal.h"
# include "virerror.h" #include "virerror.h"
# include <pthread.h> #include <pthread.h>
typedef struct virMutex virMutex; typedef struct virMutex virMutex;
typedef virMutex *virMutexPtr; typedef virMutex *virMutexPtr;
@ -71,12 +70,12 @@ struct virOnceControl {
}; };
# define VIR_MUTEX_INITIALIZER \ #define VIR_MUTEX_INITIALIZER \
{ \ { \
.lock = PTHREAD_MUTEX_INITIALIZER \ .lock = PTHREAD_MUTEX_INITIALIZER \
} }
# define VIR_ONCE_CONTROL_INITIALIZER \ #define VIR_ONCE_CONTROL_INITIALIZER \
{ \ { \
.once = PTHREAD_ONCE_INIT \ .once = PTHREAD_ONCE_INIT \
} }
@ -88,7 +87,7 @@ void virThreadOnExit(void);
typedef void (*virThreadFunc)(void *opaque); typedef void (*virThreadFunc)(void *opaque);
# define virThreadCreate(thread, joinable, func, opaque) \ #define virThreadCreate(thread, joinable, func, opaque) \
virThreadCreateFull(thread, joinable, func, #func, false, opaque) virThreadCreateFull(thread, joinable, func, #func, false, opaque)
int virThreadCreateFull(virThreadPtr thread, int virThreadCreateFull(virThreadPtr thread,
@ -190,7 +189,7 @@ int virThreadLocalSet(virThreadLocalPtr l, void*) ATTRIBUTE_RETURN_CHECK;
* Which will ensure that 'virMyObjectOnceInit' is * Which will ensure that 'virMyObjectOnceInit' is
* guaranteed to be invoked exactly once. * 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 virOnceControl classname ## OnceControl = VIR_ONCE_CONTROL_INITIALIZER; \
static virErrorPtr classname ## OnceError; \ static virErrorPtr classname ## OnceError; \
\ \
@ -213,5 +212,3 @@ int virThreadLocalSet(virThreadLocalPtr l, void*) ATTRIBUTE_RETURN_CHECK;
return 0; \ return 0; \
} \ } \
struct classname ## EatSemicolon struct classname ## EatSemicolon
#endif /* LIBVIRT_VIRTHREAD_H */

View File

@ -18,14 +18,10 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
#ifndef LIBVIRT_VIRTHREADJOB_H #pragma once
# define LIBVIRT_VIRTHREADJOB_H
const char *virThreadJobGet(void); const char *virThreadJobGet(void);
void virThreadJobSetWorker(const char *caller); void virThreadJobSetWorker(const char *caller);
void virThreadJobSet(const char *caller); void virThreadJobSet(const char *caller);
void virThreadJobClear(int rv); void virThreadJobClear(int rv);
#endif /* LIBVIRT_VIRTHREADJOB_H */

View File

@ -19,17 +19,16 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
#ifndef LIBVIRT_VIRTHREADPOOL_H #pragma once
# define LIBVIRT_VIRTHREADPOOL_H
# include "internal.h" #include "internal.h"
typedef struct _virThreadPool virThreadPool; typedef struct _virThreadPool virThreadPool;
typedef virThreadPool *virThreadPoolPtr; typedef virThreadPool *virThreadPoolPtr;
typedef void (*virThreadPoolJobFunc)(void *jobdata, void *opaque); 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) virThreadPoolNewFull(min, max, prio, func, #func, opaque)
virThreadPoolPtr virThreadPoolNewFull(size_t minWorkers, virThreadPoolPtr virThreadPoolNewFull(size_t minWorkers,
@ -57,5 +56,3 @@ int virThreadPoolSetParameters(virThreadPoolPtr pool,
long long int minWorkers, long long int minWorkers,
long long int maxWorkers, long long int maxWorkers,
long long int prioWorkers); long long int prioWorkers);
#endif /* LIBVIRT_VIRTHREADPOOL_H */