* [PATCH] Redefine instances of sema_init() to use standard form.
@ 2006-10-12 7:44 Robert P. J. Day
2006-10-12 22:47 ` Roman Zippel
0 siblings, 1 reply; 3+ messages in thread
From: Robert P. J. Day @ 2006-10-12 7:44 UTC (permalink / raw)
To: Linux Kernel Mailing List
Since there seems to be no compelling reason *not* to do this, rewrite
all implementations of sema_init() in all instances of semaphore.h to
use the __SEMAPHORE_INITIALIZER macro. (And, while we're there,
rename a couple instances of __SEMAPHORE_INIT just to be consistent
with everyone else.)
Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
---
asm-alpha/semaphore.h | 9 +--------
asm-arm/semaphore.h | 8 +++-----
asm-arm26/semaphore.h | 8 +++-----
asm-avr32/semaphore.h | 4 +---
asm-i386/semaphore.h | 10 +---------
asm-ia64/semaphore.h | 2 +-
asm-m32r/semaphore.h | 10 +---------
asm-mips/semaphore.h | 3 +--
asm-powerpc/semaphore.h | 3 +--
asm-s390/semaphore.h | 3 +--
asm-sh/semaphore.h | 10 +---------
asm-sh64/semaphore.h | 10 +---------
asm-sparc/semaphore.h | 4 +---
asm-sparc64/semaphore.h | 3 +--
asm-x86_64/semaphore.h | 10 +---------
asm-xtensa/semaphore.h | 4 +---
16 files changed, 20 insertions(+), 81 deletions(-)
diff --git a/include/asm-alpha/semaphore.h b/include/asm-alpha/semaphore.h
index 1a6295f..8c3c6dd 100644
--- a/include/asm-alpha/semaphore.h
+++ b/include/asm-alpha/semaphore.h
@@ -34,14 +34,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init(struct semaphore *sem, int val)
{
- /*
- * Logically,
- * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- * except that gcc produces better initializing by parts yet.
- */
-
- atomic_set(&sem->count, val);
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-arm/semaphore.h b/include/asm-arm/semaphore.h
index d5dc624..ae1044b 100644
--- a/include/asm-arm/semaphore.h
+++ b/include/asm-arm/semaphore.h
@@ -18,23 +18,21 @@ struct semaphore {
wait_queue_head_t wait;
};
-#define __SEMAPHORE_INIT(name, cnt) \
+#define __SEMAPHORE_INITIALIZER(name, cnt) \
{ \
.count = ATOMIC_INIT(cnt), \
.wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait), \
}
#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
- struct semaphore name = __SEMAPHORE_INIT(name,count)
+ struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
static inline void sema_init(struct semaphore *sem, int val)
{
- atomic_set(&sem->count, val);
- sem->sleepers = 0;
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX(struct semaphore *sem)
diff --git a/include/asm-arm26/semaphore.h b/include/asm-arm26/semaphore.h
index 1fda543..ef51941 100644
--- a/include/asm-arm26/semaphore.h
+++ b/include/asm-arm26/semaphore.h
@@ -18,7 +18,7 @@ struct semaphore {
wait_queue_head_t wait;
};
-#define __SEMAPHORE_INIT(name, n) \
+#define __SEMAPHORE_INITIALIZER(name, n) \
{ \
.count = ATOMIC_INIT(n), \
.sleepers = 0, \
@@ -26,16 +26,14 @@ #define __SEMAPHORE_INIT(name, n) \
}
#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
- struct semaphore name = __SEMAPHORE_INIT(name,count)
+ struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
static inline void sema_init(struct semaphore *sem, int val)
{
- atomic_set(&sem->count, val);
- sem->sleepers = 0;
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX(struct semaphore *sem)
diff --git a/include/asm-avr32/semaphore.h b/include/asm-avr32/semaphore.h
index ef99ddc..7391408 100644
--- a/include/asm-avr32/semaphore.h
+++ b/include/asm-avr32/semaphore.h
@@ -40,9 +40,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
- atomic_set(&sem->count, val);
- sem->sleepers = 0;
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-i386/semaphore.h b/include/asm-i386/semaphore.h
index 4e34a46..0945d0f 100644
--- a/include/asm-i386/semaphore.h
+++ b/include/asm-i386/semaphore.h
@@ -63,15 +63,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
-/*
- * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- *
- * i'd rather use the more flexible initialization above, but sadly
- * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
- */
- atomic_set(&sem->count, val);
- sem->sleepers = 0;
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-ia64/semaphore.h b/include/asm-ia64/semaphore.h
index f483eeb..4e8eda1 100644
--- a/include/asm-ia64/semaphore.h
+++ b/include/asm-ia64/semaphore.h
@@ -24,7 +24,7 @@ #define __SEMAPHORE_INITIALIZER(name, n)
.wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
}
-#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
+#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
struct semaphore name = __SEMAPHORE_INITIALIZER(name, count)
#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
diff --git a/include/asm-m32r/semaphore.h b/include/asm-m32r/semaphore.h
index 41e45d7..d114364 100644
--- a/include/asm-m32r/semaphore.h
+++ b/include/asm-m32r/semaphore.h
@@ -39,15 +39,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
-/*
- * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- *
- * i'd rather use the more flexible initialization above, but sadly
- * GCC 2.7.2.3 emits a bogus warning. EGCS doesnt. Oh well.
- */
- atomic_set(&sem->count, val);
- sem->sleepers = 0;
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-mips/semaphore.h b/include/asm-mips/semaphore.h
index 3d6aa7c..cba043a 100644
--- a/include/asm-mips/semaphore.h
+++ b/include/asm-mips/semaphore.h
@@ -53,8 +53,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
- atomic_set(&sem->count, val);
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-powerpc/semaphore.h b/include/asm-powerpc/semaphore.h
index 57369d2..ca3ea7d 100644
--- a/include/asm-powerpc/semaphore.h
+++ b/include/asm-powerpc/semaphore.h
@@ -39,8 +39,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
- atomic_set(&sem->count, val);
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-s390/semaphore.h b/include/asm-s390/semaphore.h
index dbce058..ad8c949 100644
--- a/include/asm-s390/semaphore.h
+++ b/include/asm-s390/semaphore.h
@@ -37,8 +37,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
- atomic_set(&sem->count, val);
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-sh/semaphore.h b/include/asm-sh/semaphore.h
index 489f784..209103d 100644
--- a/include/asm-sh/semaphore.h
+++ b/include/asm-sh/semaphore.h
@@ -41,15 +41,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
-/*
- * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- *
- * i'd rather use the more flexible initialization above, but sadly
- * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
- */
- atomic_set(&sem->count, val);
- sem->sleepers = 0;
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-sh64/semaphore.h b/include/asm-sh64/semaphore.h
index 4695264..b2f3f57 100644
--- a/include/asm-sh64/semaphore.h
+++ b/include/asm-sh64/semaphore.h
@@ -48,15 +48,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
-/*
- * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- *
- * i'd rather use the more flexible initialization above, but sadly
- * GCC 2.7.2.3 emits a bogus warning. EGCS doesnt. Oh well.
- */
- atomic_set(&sem->count, val);
- sem->sleepers = 0;
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-sparc/semaphore.h b/include/asm-sparc/semaphore.h
index f74ba31..79d4121 100644
--- a/include/asm-sparc/semaphore.h
+++ b/include/asm-sparc/semaphore.h
@@ -30,9 +30,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
- atomic24_set(&sem->count, val);
- sem->sleepers = 0;
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-sparc64/semaphore.h b/include/asm-sparc64/semaphore.h
index 093dcc6..8a7c201 100644
--- a/include/asm-sparc64/semaphore.h
+++ b/include/asm-sparc64/semaphore.h
@@ -30,8 +30,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
- atomic_set(&sem->count, val);
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-x86_64/semaphore.h b/include/asm-x86_64/semaphore.h
index 1194888..504a3ac 100644
--- a/include/asm-x86_64/semaphore.h
+++ b/include/asm-x86_64/semaphore.h
@@ -64,15 +64,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
-/*
- * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- *
- * i'd rather use the more flexible initialization above, but sadly
- * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
- */
- atomic_set(&sem->count, val);
- sem->sleepers = 0;
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-xtensa/semaphore.h b/include/asm-xtensa/semaphore.h
index f10c348..017d892 100644
--- a/include/asm-xtensa/semaphore.h
+++ b/include/asm-xtensa/semaphore.h
@@ -37,9 +37,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC
static inline void sema_init (struct semaphore *sem, int val)
{
- atomic_set(&sem->count, val);
- sem->sleepers = 0;
- init_waitqueue_head(&sem->wait);
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
}
static inline void init_MUTEX (struct semaphore *sem)
--
while i digest all of steven's observations, i figure i'd get at
least this much into the pipeline. i'll take my victories where i can
get them.
rday
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Redefine instances of sema_init() to use standard form.
2006-10-12 7:44 [PATCH] Redefine instances of sema_init() to use standard form Robert P. J. Day
@ 2006-10-12 22:47 ` Roman Zippel
2006-10-13 6:10 ` Robert P. J. Day
0 siblings, 1 reply; 3+ messages in thread
From: Roman Zippel @ 2006-10-12 22:47 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: Linux Kernel Mailing List
Hi,
On Thursday 12 October 2006 09:44, Robert P. J. Day wrote:
> Since there seems to be no compelling reason *not* to do this,
[..]
> - /*
> - * Logically,
> - * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
> - * except that gcc produces better initializing by parts yet.
> - */
You've seen this?
bye, Roman
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Redefine instances of sema_init() to use standard form.
2006-10-12 22:47 ` Roman Zippel
@ 2006-10-13 6:10 ` Robert P. J. Day
0 siblings, 0 replies; 3+ messages in thread
From: Robert P. J. Day @ 2006-10-13 6:10 UTC (permalink / raw)
To: Roman Zippel; +Cc: Linux Kernel Mailing List
i can't believe a simple cleanup patch has turned into such an
issue.
On Fri, 13 Oct 2006, Roman Zippel wrote:
> Hi,
>
> On Thursday 12 October 2006 09:44, Robert P. J. Day wrote:
>
> > Since there seems to be no compelling reason *not* to do this,
> [..]
> > - /*
> > - * Logically,
> > - * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
> > - * except that gcc produces better initializing by parts yet.
> > - */
>
> You've seen this?
in fact, i did, and i admit that i have no idea what it means to say
that "gcc produces better initializing by parts yet."
there were a number of semaphore.h files whose comments made it clear
that GCC 2.7.2.3 was the *only* reason that the shorter, more direct
form wasn't being used, so it should be clear that those could be
changed.
there was only *one* of those header files (asm-alpha/semaphore.h)
that had the caution above, but i have no idea what "better
initializing" means?
"better" as in faster? "better" as in more compact? "better" as in
correct? i mean, either the shorter, more direct initialization
*works* and produces the same result in this case, or it *doesn't*.
which is it? or is that note perhaps a holdover from an old version
of gcc as well?
can you clarify what that comment means in the context of the alpha
architecture, and why simplifying the call would actually be a
mistake?
rday
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-13 6:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-12 7:44 [PATCH] Redefine instances of sema_init() to use standard form Robert P. J. Day
2006-10-12 22:47 ` Roman Zippel
2006-10-13 6:10 ` Robert P. J. Day
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®