[spice-server,1/3] utils: Remove get/set/clear_bit

Submitted by Christophe Fergeau on Oct. 4, 2018, 4:01 p.m.

Details

Message ID 20181004160144.19606-1-cfergeau@redhat.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Christophe Fergeau Oct. 4, 2018, 4:01 p.m.
These function are used once each by red-qxl.c, they don't need to be
exported in utils.h
---
 server/red-qxl.c | 17 +++++++++++++++++
 server/utils.h   | 16 ----------------
 2 files changed, 17 insertions(+), 16 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/red-qxl.c b/server/red-qxl.c
index 97940611b..4f05abb4e 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -455,6 +455,17 @@  static void qxl_worker_reset_memslots(QXLWorker *qxl_worker)
     red_qxl_reset_memslots(qxl_state);
 }
 
+static void set_bit(int index, uint32_t *addr)
+{
+    uint32_t mask = 1 << index;
+    __sync_or_and_fetch(addr, mask);
+}
+
+static int test_bit(int index, uint32_t val)
+{
+    return val & (1u << index);
+}
+
 static bool red_qxl_set_pending(QXLState *qxl_state, int pending)
 {
     // this is not atomic but is not an issue
@@ -922,6 +933,12 @@  Dispatcher *red_qxl_get_dispatcher(QXLInstance *qxl)
     return qxl->st->dispatcher;
 }
 
+static void clear_bit(int index, uint32_t *addr)
+{
+    uint32_t mask = ~(1 << index);
+    __sync_and_and_fetch(addr, mask);
+}
+
 void red_qxl_clear_pending(QXLState *qxl_state, int pending)
 {
     spice_return_if_fail(qxl_state != NULL);
diff --git a/server/utils.h b/server/utils.h
index 58d43cafe..36ad1d83f 100644
--- a/server/utils.h
+++ b/server/utils.h
@@ -24,22 +24,6 @@ 
 
 #define SPICE_GNUC_VISIBLE __attribute__ ((visibility ("default")))
 
-static inline void set_bit(int index, uint32_t *addr)
-{
-    uint32_t mask = 1 << index;
-    __sync_or_and_fetch(addr, mask);
-}
-
-static inline void clear_bit(int index, uint32_t *addr)
-{
-    uint32_t mask = ~(1 << index);
-    __sync_and_and_fetch(addr, mask);
-}
-
-static inline int test_bit(int index, uint32_t val)
-{
-    return val & (1u << index);
-}
 /* a generic safe for loop macro  */
 #define SAFE_FOREACH(link, next, cond, ring, data, get_data)            \
     for ((((link) = ((cond) ? ring_get_head(ring) : NULL)),             \

Comments

> 
> These function are used once each by red-qxl.c, they don't need to be
> exported in utils.h
> ---
>  server/red-qxl.c | 17 +++++++++++++++++
>  server/utils.h   | 16 ----------------
>  2 files changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/server/red-qxl.c b/server/red-qxl.c
> index 97940611b..4f05abb4e 100644
> --- a/server/red-qxl.c
> +++ b/server/red-qxl.c
> @@ -455,6 +455,17 @@ static void qxl_worker_reset_memslots(QXLWorker
> *qxl_worker)
>      red_qxl_reset_memslots(qxl_state);
>  }
>  
> +static void set_bit(int index, uint32_t *addr)
> +{
> +    uint32_t mask = 1 << index;
> +    __sync_or_and_fetch(addr, mask);
> +}
> +
> +static int test_bit(int index, uint32_t val)
> +{
> +    return val & (1u << index);
> +}
> +
>  static bool red_qxl_set_pending(QXLState *qxl_state, int pending)
>  {
>      // this is not atomic but is not an issue
> @@ -922,6 +933,12 @@ Dispatcher *red_qxl_get_dispatcher(QXLInstance *qxl)
>      return qxl->st->dispatcher;
>  }
>  
> +static void clear_bit(int index, uint32_t *addr)
> +{
> +    uint32_t mask = ~(1 << index);
> +    __sync_and_and_fetch(addr, mask);
> +}
> +
>  void red_qxl_clear_pending(QXLState *qxl_state, int pending)
>  {
>      spice_return_if_fail(qxl_state != NULL);
> diff --git a/server/utils.h b/server/utils.h
> index 58d43cafe..36ad1d83f 100644
> --- a/server/utils.h
> +++ b/server/utils.h
> @@ -24,22 +24,6 @@
>  
>  #define SPICE_GNUC_VISIBLE __attribute__ ((visibility ("default")))
>  
> -static inline void set_bit(int index, uint32_t *addr)
> -{
> -    uint32_t mask = 1 << index;
> -    __sync_or_and_fetch(addr, mask);
> -}
> -
> -static inline void clear_bit(int index, uint32_t *addr)
> -{
> -    uint32_t mask = ~(1 << index);
> -    __sync_and_and_fetch(addr, mask);
> -}
> -
> -static inline int test_bit(int index, uint32_t val)
> -{
> -    return val & (1u << index);
> -}
>  /* a generic safe for loop macro  */
>  #define SAFE_FOREACH(link, next, cond, ring, data, get_data)            \
>      for ((((link) = ((cond) ? ring_get_head(ring) : NULL)),             \

I prefer them in utils.h, they don't have something to do specifically
with qxl interface.

Frediano
On Thu, Oct 04, 2018 at 01:42:23PM -0400, Frediano Ziglio wrote:
> > -static inline void set_bit(int index, uint32_t *addr)
> > -{
> > -    uint32_t mask = 1 << index;
> > -    __sync_or_and_fetch(addr, mask);
> > -}
> > -
> > -static inline void clear_bit(int index, uint32_t *addr)
> > -{
> > -    uint32_t mask = ~(1 << index);
> > -    __sync_and_and_fetch(addr, mask);
> > -}
> > -
> > -static inline int test_bit(int index, uint32_t val)
> > -{
> > -    return val & (1u << index);
> > -}
> >  /* a generic safe for loop macro  */
> >  #define SAFE_FOREACH(link, next, cond, ring, data, get_data)            \
> >      for ((((link) = ((cond) ? ring_get_head(ring) : NULL)),             \
> 
> I prefer them in utils.h, they don't have something to do specifically
> with qxl interface.

That's true, on the other hand, these are not methods we want to use
outside of the QXL interface.

Christophe
> On Thu, Oct 04, 2018 at 01:42:23PM -0400, Frediano Ziglio wrote:
> > > -static inline void set_bit(int index, uint32_t *addr)
> > > -{
> > > -    uint32_t mask = 1 << index;
> > > -    __sync_or_and_fetch(addr, mask);
> > > -}
> > > -
> > > -static inline void clear_bit(int index, uint32_t *addr)
> > > -{
> > > -    uint32_t mask = ~(1 << index);
> > > -    __sync_and_and_fetch(addr, mask);
> > > -}
> > > -
> > > -static inline int test_bit(int index, uint32_t val)
> > > -{
> > > -    return val & (1u << index);
> > > -}
> > >  /* a generic safe for loop macro  */
> > >  #define SAFE_FOREACH(link, next, cond, ring, data, get_data)
> > >  \
> > >      for ((((link) = ((cond) ? ring_get_head(ring) : NULL)),
> > >      \
> > 
> > I prefer them in utils.h, they don't have something to do specifically
> > with qxl interface.
> 
> That's true, on the other hand, these are not methods we want to use
> outside of the QXL interface.
> 
> Christophe
> 

I prefer them in utils.h.

Frediano