All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: xenomai@xenomai.org
Cc: Jan Kiszka <jan.kiszka@domain.hid>
Subject: [Xenomai-core] Allow "break" statement in RTDM_EXECUTE_ATOMICALLY()
Date: Sun, 17 May 2009 16:54:57 +0200	[thread overview]
Message-ID: <1242572097.17138.57.camel@domain.hid> (raw)


Jan,

Would you consider allowing "break" for leaving an atomic code block as
illustrated below?

I understand this would create a potential issue with newer RTDM drivers
relying on this feature when backported to former RTDM implementations,
but only having if/else constructs to control the execution flow within
an atomic block may be painful sometimes and lead to uselessly hairy
code, especially for error handling.
Maybe adding another helper macro with the desired behavior, and
documenting it separately from RTDM_EXECUTE_ATOMICALLY() would mitigate
the portability issue?

Additionally, I would definitely shadow/hide the spl value from the code
block in a way or another, since using "s" as a socket identifier for
RTDM-based protocol drivers is not that unusual.

e.g.

diff --git a/include/rtdm/rtdm_driver.h b/include/rtdm/rtdm_driver.h
index 058a9f8..18b6001 100644
--- a/include/rtdm/rtdm_driver.h
+++ b/include/rtdm/rtdm_driver.h
@@ -595,14 +595,16 @@ int rtdm_select_bind(int fd, rtdm_selector_t *selector,
 	<LEAVE_ATOMIC_SECTION>			\
 }
 #else /* This is how it really works */
-#define RTDM_EXECUTE_ATOMICALLY(code_block)	\
-{						\
+#define RTDM_ATOMIC_BLOCK(code_block)		\
+do {						\
 	spl_t s;				\
-						\
 	xnlock_get_irqsave(&nklock, s);		\
-	code_block;				\
+	do {					\
+	  code_block;				\
+	} while(0);				\
 	xnlock_put_irqrestore(&nklock, s);	\
-}
+} while(0)
+#define RTDM_EXECUTE_ATOMICALLY(code_block)	RTDM_ATOMIC_BLOCK(code_block)
 #endif
 /** @} Global Lock across Scheduler Invocation */
 
-- 
Philippe.




             reply	other threads:[~2009-05-17 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-17 14:54 Philippe Gerum [this message]
2009-05-18  8:31 ` [Xenomai-core] Allow "break" statement in RTDM_EXECUTE_ATOMICALLY() Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1242572097.17138.57.camel@domain.hid \
    --to=rpm@xenomai.org \
    --cc=jan.kiszka@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.