[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/11] pthread: better 'inline'
From: |
Paul Eggert |
Subject: |
[PATCH 05/11] pthread: better 'inline' |
Date: |
Mon, 29 Oct 2012 00:16:03 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 |
* lib/pthread.c: New file.
* lib/pthread.in.h (_GL_PTHREAD_INLINE):
New macro. Replace all uses of 'static inline' with it.
Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
* m4/pthread.m4 (gl_PTHREAD_CHECK):
Add AC_LIBOBJ([pthread]). Do not require AC_C_INLINE.
* modules/pthread (Files): Add lib/pthread.c.
(Depends-on): Add extern-inline.
---
ChangeLog | 10 ++++++++++
lib/pthread.c | 3 +++
lib/pthread.in.h | 47 +++++++++++++++++++++++++++--------------------
m4/pthread.m4 | 4 ++--
modules/pthread | 2 ++
5 files changed, 44 insertions(+), 22 deletions(-)
create mode 100644 lib/pthread.c
diff --git a/ChangeLog b/ChangeLog
index 5ffa31d..86893db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2012-10-28 Paul Eggert <address@hidden>
+ pthread: better 'inline'
+ * lib/pthread.c: New file.
+ * lib/pthread.in.h (_GL_PTHREAD_INLINE):
+ New macro. Replace all uses of 'static inline' with it.
+ Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
+ * m4/pthread.m4 (gl_PTHREAD_CHECK):
+ Add AC_LIBOBJ([pthread]). Do not require AC_C_INLINE.
+ * modules/pthread (Files): Add lib/pthread.c.
+ (Depends-on): Add extern-inline.
+
math: better 'inline'
* lib/math.c: New file.
* lib/math.in.h (_GL_MATH_INLINE):
diff --git a/lib/pthread.c b/lib/pthread.c
new file mode 100644
index 0000000..a7de637
--- /dev/null
+++ b/lib/pthread.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define _GL_PTHREAD_INLINE _GL_EXTERN_INLINE
+#include "pthread.h"
diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index 6f93e29..91829b6 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -38,6 +38,11 @@
#include <sys/types.h>
#include <time.h>
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_PTHREAD_INLINE
+# define _GL_PTHREAD_INLINE _GL_INLINE
+#endif
+
#if ! @HAVE_PTHREAD_T@
# if !GNULIB_defined_pthread_types
typedef int pthread_t;
@@ -110,14 +115,14 @@
know what to do, so that they elicit a compile-time error for
now. */
-static inline int
+_GL_PTHREAD_INLINE int
pthread_cond_destroy (pthread_cond_t *cond)
{
/* COND is never seriously used. */
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_cond_init (pthread_cond_t *restrict cond,
pthread_condattr_t const *restrict attr)
{
@@ -125,14 +130,14 @@ pthread_cond_init (pthread_cond_t *restrict cond,
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_cond_signal (pthread_cond_t *cond)
{
/* No threads can currently be blocked on COND. */
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_cond_wait (pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex)
{
@@ -141,7 +146,7 @@ pthread_cond_wait (pthread_cond_t *restrict cond,
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_create (pthread_t *restrict thread,
pthread_attr_t const *restrict attr,
void * (*start_routine) (void*), void *restrict arg)
@@ -150,14 +155,14 @@ pthread_create (pthread_t *restrict thread,
return EAGAIN;
}
-static inline void
+_GL_PTHREAD_INLINE void
pthread_exit (void *value)
{
/* There is just one thread, so the process exits. */
exit (0);
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_join (pthread_t thread, void **pvalue)
{
/* Properly-written applications never come here. */
@@ -165,32 +170,32 @@ pthread_join (pthread_t thread, void **pvalue)
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_mutexattr_destroy (pthread_mutexattr_t *attr)
{
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_mutexattr_init (pthread_mutexattr_t *attr)
{
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_mutexattr_settype (pthread_mutexattr_t *attr, int attr_type)
{
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_mutex_destroy (pthread_mutex_t *mutex)
{
/* MUTEX is never seriously used. */
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_mutex_init (pthread_mutex_t *restrict mutex,
pthread_mutexattr_t const *restrict attr)
{
@@ -198,7 +203,7 @@ pthread_mutex_init (pthread_mutex_t *restrict mutex,
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_mutex_lock (pthread_mutex_t *mutex)
{
/* There is only one thread, so it always gets the lock. This
@@ -206,13 +211,13 @@ pthread_mutex_lock (pthread_mutex_t *mutex)
return 0;
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_mutex_trylock (pthread_mutex_t *mutex)
{
return pthread_mutex_lock (mutex);
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_mutex_unlock (pthread_mutex_t *mutex)
{
/* There is only one thread, so it always unlocks successfully.
@@ -234,31 +239,31 @@ pthread_mutex_unlock (pthread_mutex_t *mutex)
typedef pthread_mutex_t pthread_spinlock_t;
-static inline int
+_GL_PTHREAD_INLINE int
pthread_spin_init (pthread_spinlock_t *lock, int pshared)
{
return pthread_mutex_init (lock, NULL);
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_spin_destroy (pthread_spinlock_t *lock)
{
return pthread_mutex_destroy (lock);
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_spin_lock (pthread_spinlock_t *lock)
{
return pthread_mutex_lock (lock);
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_spin_trylock (pthread_spinlock_t *lock)
{
return pthread_mutex_trylock (lock);
}
-static inline int
+_GL_PTHREAD_INLINE int
pthread_spin_unlock (pthread_spinlock_t *lock)
{
return pthread_mutex_unlock (lock);
@@ -269,5 +274,7 @@ pthread_spin_unlock (pthread_spinlock_t *lock)
#endif
+_GL_INLINE_HEADER_END
+
#endif /* address@hidden@_PTHREAD_H_ */
#endif /* address@hidden@_PTHREAD_H_ */
diff --git a/m4/pthread.m4 b/m4/pthread.m4
index 70c185c..38b2c78 100644
--- a/m4/pthread.m4
+++ b/m4/pthread.m4
@@ -1,4 +1,4 @@
-# pthread.m4 serial 5
+# pthread.m4 serial 7
dnl Copyright (C) 2009-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,
@@ -30,6 +30,7 @@ AC_DEFUN([gl_PTHREAD_CHECK],
test $ac_cv_type_pthread_t != yes ||
test $ac_cv_type_pthread_spinlock_t != yes; then
PTHREAD_H='pthread.h'
+ AC_LIBOBJ([pthread])
else
PTHREAD_H=
fi
@@ -72,7 +73,6 @@ AC_DEFUN([gl_PTHREAD_CHECK],
fi
AC_SUBST([LIB_PTHREAD])
- AC_REQUIRE([AC_C_INLINE])
AC_REQUIRE([AC_C_RESTRICT])
])
diff --git a/modules/pthread b/modules/pthread
index eef4b07..cd49852 100644
--- a/modules/pthread
+++ b/modules/pthread
@@ -2,10 +2,12 @@ Description:
Implement a trivial subset of the pthreads library.
Files:
+lib/pthread.c
lib/pthread.in.h
m4/pthread.m4
Depends-on:
+extern-inline
sched
time
--
1.7.11.7
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH 05/11] pthread: better 'inline',
Paul Eggert <=