bug-hurd
[Top][All Lists]
Advanced

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

[PATCH 3/4] device/chario.c: qualify pointers that access their derefere


From: Marin Ramesa
Subject: [PATCH 3/4] device/chario.c: qualify pointers that access their dereferenced values under locks with __restrict__
Date: Tue, 17 Dec 2013 15:58:27 +0100

Qualifier __restrict__ means that only the pointer under __restrict__ will be 
used
to access dereferenced values. So if a code is under locks and no function is 
called
in the critical section with pointer as an argument, it's safe to use 
__restrict__.
This allows the compiler to make optimizations.

* device/chario.c (char_write) (tp): Qualify with __restrict__.
(char_read) (tp): Likewise.
(tty_get_status) (tp, tsp): Likewise.

---
 device/chario.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/device/chario.c b/device/chario.c
index 91bd8e8..ab848bd 100644
--- a/device/chario.c
+++ b/device/chario.c
@@ -245,8 +245,8 @@ boolean_t tty_close_open_reply(
  * device needs to run on master.
  */
 io_return_t char_write(
-       struct tty *    tp,
-       io_req_t        ior)
+       struct tty * __restrict__       tp,
+       io_req_t                        ior)
 {
        spl_t           s;
        int     count;
@@ -381,8 +381,8 @@ boolean_t tty_close_write_reply(
  * May run on any CPU - does not talk to device driver.
  */
 io_return_t char_read(
-       struct tty *tp,
-       io_req_t ior)
+       struct tty * __restrict__       tp,
+       io_req_t                        ior)
 {
        spl_t           s;
        kern_return_t   rc;
@@ -587,17 +587,17 @@ tty_portdeath(
  * May run on any CPU.
  */
 io_return_t tty_get_status(
-       struct tty *tp,
-       dev_flavor_t    flavor,
-       int *           data,           /* pointer to OUT array */
-       natural_t       *count)         /* out */
+       struct tty * __restrict__       tp,
+       dev_flavor_t                    flavor,
+       int *                           data,           /* pointer to OUT array 
*/
+       natural_t                       *count)         /* out */
 {
        spl_t           s;
 
        switch (flavor) {
            case TTY_STATUS:
            {
-               struct tty_status *tsp =
+               struct tty_status * __restrict__ tsp =
                        (struct tty_status *) data;
 
                if (*count < TTY_STATUS_COUNT)
@@ -633,7 +633,7 @@ io_return_t tty_get_status(
  * device needs to run on master.
  */
 io_return_t tty_set_status(
-       struct tty *tp,
+       struct tty      *tp,
        dev_flavor_t    flavor,
        int *           data,
        natural_t       count)
-- 
1.8.1.4




reply via email to

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