bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH 4/4] cond, lock, thread: better 'inline'


From: Paul Eggert
Subject: [PATCH 4/4] cond, lock, thread: better 'inline'
Date: Sun, 04 Nov 2012 23:19:47 -0800
User-agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121028 Thunderbird/16.0.2

* lib/glthread/cond.c, lib/glthread/cond.h (_GLTHREAD_COND_INLINE):
* lib/glthread/thread.c, lib/glthread/thread.h (_GLTHREAD_THREAD_INLINE):
New macros.  Use them instead of static inline, for header functions.
* lib/glthread/cond.c (gl_waitqueue_init, gl_waitqueue_remove)
(gl_waitqueue_notify_first, gl_waitqueue_notify_all):
* lib/glthread/lock.c (gl_waitqueue_init)
(gl_waitqueue_notify_first, gl_waitqueue_notify_all):
* lib/glthread/thread.c (get_current_thread_handle):
Change 'static inline' to 'inline'.
* lib/glthread/cond.h, lib/glthread/thread.h:
Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
* m4/cond.m4 (gl_COND):
* m4/lock.m4 (gl_PREREQ_LOCK):
* m4/thread.m4 (gl_THREAD):
Do not require AC_C_INLINE.
* modules/cond, modules/thread (Depends-on): Add extern-inline.
---
 ChangeLog             | 18 ++++++++++++++++++
 lib/glthread/cond.c   |  9 +++++----
 lib/glthread/cond.h   |  9 ++++++++-
 lib/glthread/lock.c   |  6 +++---
 lib/glthread/thread.c |  3 ++-
 lib/glthread/thread.h |  9 ++++++++-
 m4/cond.m4            |  3 +--
 m4/lock.m4            |  8 +++-----
 m4/thread.m4          |  3 +--
 modules/cond          |  2 +-
 modules/thread        |  2 +-
 11 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 891ac34..a89dd0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2012-11-04  Paul Eggert  <address@hidden>
 
+       cond, lock, thread: better 'inline'
+       * lib/glthread/cond.c, lib/glthread/cond.h (_GLTHREAD_COND_INLINE):
+       * lib/glthread/thread.c, lib/glthread/thread.h 
(_GLTHREAD_THREAD_INLINE):
+       New macros.  Use them instead of static inline, for header functions.
+       * lib/glthread/cond.c (gl_waitqueue_init, gl_waitqueue_remove)
+       (gl_waitqueue_notify_first, gl_waitqueue_notify_all):
+       * lib/glthread/lock.c (gl_waitqueue_init)
+       (gl_waitqueue_notify_first, gl_waitqueue_notify_all):
+       * lib/glthread/thread.c (get_current_thread_handle):
+       Change 'static inline' to 'inline'.
+       * lib/glthread/cond.h, lib/glthread/thread.h:
+       Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
+       * m4/cond.m4 (gl_COND):
+       * m4/lock.m4 (gl_PREREQ_LOCK):
+       * m4/thread.m4 (gl_THREAD):
+       Do not require AC_C_INLINE.
+       * modules/cond, modules/thread (Depends-on): Add extern-inline.
+
        chdir-long, cycle-check, savewd: better 'inline'
        * lib/chdir-long.c (cdb_init, cdb_fchdir, cdb_free)
        (find_non_slash):
diff --git a/lib/glthread/cond.c b/lib/glthread/cond.c
index ef69d14..cdf4c5b 100644
--- a/lib/glthread/cond.c
+++ b/lib/glthread/cond.c
@@ -19,6 +19,7 @@
 
 #include <config.h>
 
+#define _GLTHREAD_COND_INLINE _GL_EXTERN_INLINE
 #include "glthread/cond.h"
 
 /* ========================================================================= */
@@ -90,7 +91,7 @@ struct gl_waitqueue_element
                    This field is immutable once initialized. */
 };
 
-static inline void
+static void
 gl_waitqueue_init (gl_waitqueue_t *wq)
 {
   wq->wq_list.wql_next = &wq->wq_list;
@@ -134,7 +135,7 @@ gl_waitqueue_add (gl_waitqueue_t *wq)
 /* Removes the current thread, represented by a 'struct gl_waitqueue_element 
*',
    from a wait queue.
    Returns true if is was found and removed, false if it was not present.  */
-static inline bool
+static bool
 gl_waitqueue_remove (gl_waitqueue_t *wq, struct gl_waitqueue_element *elt)
 {
   if (elt->link.wql_next != NULL && elt->link.wql_prev != NULL)
@@ -153,7 +154,7 @@ gl_waitqueue_remove (gl_waitqueue_t *wq, struct 
gl_waitqueue_element *elt)
 }
 
 /* Notifies the first thread from a wait queue and dequeues it.  */
-static inline void
+static void
 gl_waitqueue_notify_first (gl_waitqueue_t *wq)
 {
   if (wq->wq_list.wql_next != &wq->wq_list)
@@ -178,7 +179,7 @@ gl_waitqueue_notify_first (gl_waitqueue_t *wq)
 }
 
 /* Notifies all threads from a wait queue and dequeues them all.  */
-static inline void
+static void
 gl_waitqueue_notify_all (gl_waitqueue_t *wq)
 {
   struct gl_waitqueue_link *l;
diff --git a/lib/glthread/cond.h b/lib/glthread/cond.h
index db8f2d1..39a9ae7 100644
--- a/lib/glthread/cond.h
+++ b/lib/glthread/cond.h
@@ -55,6 +55,11 @@
 
 #include "glthread/lock.h"
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GLTHREAD_COND_INLINE
+# define _GLTHREAD_COND_INLINE _GL_INLINE
+#endif
+
 /* ========================================================================= */
 
 #if USE_POSIX_THREADS
@@ -369,7 +374,7 @@ extern "C" {
    while (0)
 #define gl_cond_timedwait(COND, LOCK, ABSTIME) \
   gl_cond_timedwait_func (&COND, &LOCK, ABSTIME)
-static inline bool
+_GLTHREAD_COND_INLINE bool
 gl_cond_timedwait_func (gl_cond_t *cond, gl_lock_t *lock, struct timespec 
*abstime)
 {
   int err = glthread_cond_timedwait (cond, lock, abstime);
@@ -405,4 +410,6 @@ gl_cond_timedwait_func (gl_cond_t *cond, gl_lock_t *lock, 
struct timespec *absti
 }
 #endif
 
+_GL_INLINE_HEADER_END
+
 #endif /* _GLTHREAD_COND_H */
diff --git a/lib/glthread/lock.c b/lib/glthread/lock.c
index a03dc3d..d5d060a 100644
--- a/lib/glthread/lock.c
+++ b/lib/glthread/lock.c
@@ -682,7 +682,7 @@ glthread_lock_destroy_func (gl_lock_t *lock)
 /* In this file, the waitqueues are implemented as circular arrays.  */
 #define gl_waitqueue_t gl_carray_waitqueue_t
 
-static inline void
+static void
 gl_waitqueue_init (gl_waitqueue_t *wq)
 {
   wq->array = NULL;
@@ -743,7 +743,7 @@ gl_waitqueue_add (gl_waitqueue_t *wq)
 }
 
 /* Notifies the first thread from a wait queue and dequeues it.  */
-static inline void
+static void
 gl_waitqueue_notify_first (gl_waitqueue_t *wq)
 {
   SetEvent (wq->array[wq->offset + 0]);
@@ -754,7 +754,7 @@ gl_waitqueue_notify_first (gl_waitqueue_t *wq)
 }
 
 /* Notifies all threads from a wait queue and dequeues them all.  */
-static inline void
+static void
 gl_waitqueue_notify_all (gl_waitqueue_t *wq)
 {
   unsigned int i;
diff --git a/lib/glthread/thread.c b/lib/glthread/thread.c
index 76e3764..25b758a 100644
--- a/lib/glthread/thread.c
+++ b/lib/glthread/thread.c
@@ -21,6 +21,7 @@
 #include <config.h>
 
 /* Specification.  */
+# define _GLTHREAD_THREAD_INLINE _GL_EXTERN_INLINE
 #include "glthread/thread.h"
 
 #include <stdlib.h>
@@ -85,7 +86,7 @@ struct gl_thread_struct
 };
 
 /* Return a real HANDLE object for the current thread.  */
-static inline HANDLE
+static HANDLE
 get_current_thread_handle (void)
 {
   HANDLE this_handle;
diff --git a/lib/glthread/thread.h b/lib/glthread/thread.h
index 87e8700..c5bc0ae 100644
--- a/lib/glthread/thread.h
+++ b/lib/glthread/thread.h
@@ -74,6 +74,11 @@
 #include <errno.h>
 #include <stdlib.h>
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GLTHREAD_THREAD_INLINE
+# define _GLTHREAD_THREAD_INLINE _GL_INLINE
+#endif
+
 /* ========================================================================= */
 
 #if USE_POSIX_THREADS
@@ -360,7 +365,7 @@ typedef int gl_thread_t;
 extern "C" {
 #endif
 
-static inline gl_thread_t
+_GLTHREAD_THREAD_INLINE gl_thread_t
 gl_thread_create (void *(*func) (void *arg), void *arg)
 {
   gl_thread_t thread;
@@ -397,4 +402,6 @@ gl_thread_create (void *(*func) (void *arg), void *arg)
 }
 #endif
 
+_GL_INLINE_HEADER_END
+
 #endif /* _GLTHREAD_THREAD_H */
diff --git a/m4/cond.m4 b/m4/cond.m4
index 8010d6c..b89d210 100644
--- a/m4/cond.m4
+++ b/m4/cond.m4
@@ -1,4 +1,4 @@
-# cond.m4 serial 1
+# cond.m4 serial 2
 dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,5 +7,4 @@ dnl with or without modifications, as long as this notice is 
preserved.
 AC_DEFUN([gl_COND],
 [
   AC_REQUIRE([gl_THREADLIB])
-  AC_REQUIRE([AC_C_INLINE])
 ])
diff --git a/m4/lock.m4 b/m4/lock.m4
index 19c6d45..83da6cc 100644
--- a/m4/lock.m4
+++ b/m4/lock.m4
@@ -1,4 +1,4 @@
-# lock.m4 serial 12 (gettext-0.18.2)
+# lock.m4 serial 13 (gettext-0.18.2)
 dnl Copyright (C) 2005-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -35,7 +35,5 @@ return !x;
   gl_PREREQ_LOCK
 ])
 
-# Prerequisites of lib/lock.c.
-AC_DEFUN([gl_PREREQ_LOCK], [
-  AC_REQUIRE([AC_C_INLINE])
-])
+# Prerequisites of lib/glthread/lock.c.
+AC_DEFUN([gl_PREREQ_LOCK], [:])
diff --git a/m4/thread.m4 b/m4/thread.m4
index cd66c3e..3c94d11 100644
--- a/m4/thread.m4
+++ b/m4/thread.m4
@@ -1,4 +1,4 @@
-# thread.m4 serial 2
+# thread.m4 serial 3
 dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,7 +7,6 @@ dnl with or without modifications, as long as this notice is 
preserved.
 AC_DEFUN([gl_THREAD],
 [
   AC_REQUIRE([gl_THREADLIB])
-  AC_REQUIRE([AC_C_INLINE])
 
   if test $gl_threads_api = posix; then
     gl_save_LIBS="$LIBS"
diff --git a/modules/cond b/modules/cond
index a28ed11..c3a2dab 100644
--- a/modules/cond
+++ b/modules/cond
@@ -10,6 +10,7 @@ Depends-on:
 threadlib
 lock
 errno
+extern-inline
 stdbool
 time
 gettimeofday
@@ -28,4 +29,3 @@ LGPLv2+
 
 Maintainer:
 Yoann Vandoorselaere
-
diff --git a/modules/thread b/modules/thread
index a7d338d..026e439 100644
--- a/modules/thread
+++ b/modules/thread
@@ -8,6 +8,7 @@ m4/thread.m4
 
 Depends-on:
 threadlib
+extern-inline
 lock
 
 configure.ac:
@@ -27,4 +28,3 @@ LGPLv2+
 
 Maintainer:
 Yoann Vandoorselaere
-
-- 
1.7.11.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]