From: Michael Jeanson Date: Tue, 6 Apr 2021 20:45:50 +0000 (-0400) Subject: Move wait.h to 'src/common/' X-Git-Tag: v2.13.0-rc1~124 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6bd9392ed14dabcfadc64772e972c76e8752c199;p=lttng-ust.git Move wait.h to 'src/common/' It defines a generic macro that is only currently used in liblttng-ust-ctl. Change-Id: I9ed217176cf261f4fc410ba1655d0e9c0bf9ff07 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 6e155f7d..177ef070 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -16,7 +16,8 @@ noinst_HEADERS = \ macros.h \ patient.h \ procname.h \ - safe-snprintf.h + safe-snprintf.h \ + wait.h noinst_HEADERS += \ compat/dlfcn.h \ diff --git a/src/common/wait.h b/src/common/wait.h new file mode 100644 index 00000000..0af1f104 --- /dev/null +++ b/src/common/wait.h @@ -0,0 +1,38 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (C) 2011 Mathieu Desnoyers + */ + +#ifndef _UST_WAIT_H +#define _UST_WAIT_H + +#include + +/* + * Wait until "cond" gets true or timeout (in ms). + */ +#define wait_cond_interruptible_timeout(_cond, _timeout) \ + ({ \ + int __ret = 0, __pollret; \ + int __timeout = _timeout; \ + \ + for (;;) { \ + if (_cond) \ + break; \ + if (__timeout <= 0) { \ + __ret = -ETIMEDOUT; \ + break; \ + } \ + __pollret = poll(NULL, 0, 10); /* wait 10ms */ \ + if (__pollret < 0) { \ + __ret = -errno; \ + break; \ + } \ + __timeout -= 10; \ + } \ + __ret; \ + }) + + +#endif /* _UST_WAIT_H */ diff --git a/src/lib/lttng-ust-ctl/ustctl.c b/src/lib/lttng-ust-ctl/ustctl.c index 076c92f8..e4434bc0 100644 --- a/src/lib/lttng-ust-ctl/ustctl.c +++ b/src/lib/lttng-ust-ctl/ustctl.c @@ -25,7 +25,7 @@ #include "common/ringbuffer/backend.h" #include "common/ringbuffer/frontend.h" #include "lib/lttng-ust/ust-events-internal.h" -#include "lib/lttng-ust/wait.h" +#include "common/wait.h" #include "lib/lttng-ust/lttng-rb-clients.h" #include "lib/lttng-ust/clock.h" #include "lib/lttng-ust/getenv.h" diff --git a/src/lib/lttng-ust/Makefile.am b/src/lib/lttng-ust/Makefile.am index bca09ad8..df0ae8d0 100644 --- a/src/lib/lttng-ust/Makefile.am +++ b/src/lib/lttng-ust/Makefile.am @@ -80,7 +80,6 @@ liblttng_ust_runtime_la_SOURCES = \ tracepoint-internal.h \ ust-events-internal.h \ clock.h \ - wait.h \ jhash.h \ lttng-ust-uuid.h \ error.h \ diff --git a/src/lib/lttng-ust/wait.h b/src/lib/lttng-ust/wait.h deleted file mode 100644 index 0af1f104..00000000 --- a/src/lib/lttng-ust/wait.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (C) 2011 Mathieu Desnoyers - */ - -#ifndef _UST_WAIT_H -#define _UST_WAIT_H - -#include - -/* - * Wait until "cond" gets true or timeout (in ms). - */ -#define wait_cond_interruptible_timeout(_cond, _timeout) \ - ({ \ - int __ret = 0, __pollret; \ - int __timeout = _timeout; \ - \ - for (;;) { \ - if (_cond) \ - break; \ - if (__timeout <= 0) { \ - __ret = -ETIMEDOUT; \ - break; \ - } \ - __pollret = poll(NULL, 0, 10); /* wait 10ms */ \ - if (__pollret < 0) { \ - __ret = -errno; \ - break; \ - } \ - __timeout -= 10; \ - } \ - __ret; \ - }) - - -#endif /* _UST_WAIT_H */