[ovs-dev] [PATCH] util: xleep for Windows.

Pravin Shelar pshelar at nicira.com
Fri Mar 28 22:33:09 UTC 2014


On Fri, Mar 28, 2014 at 3:19 PM, Gurucharan Shetty <shettyg at nicira.com> wrote:
> Windows does not have a sleep(seconds). But it does have
> a Sleep(milliseconds). Sleep() in windows does not have a
> return value. Since we are not using the return value for xsleep()
> anywhere as of now, don't return any.
>
> Introduced by commit 275eebb9 (utils: Introduce xsleep for RCU quiescent state)
>
> CC: Pravin B Shelar <pshelar at nicira.com>
> Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>

Looks good.

Acked-by: Pravin B Shelar <pshelar at nicira.com>

> ---
>  lib/util.c |   11 ++++++-----
>  lib/util.h |    2 +-
>  2 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/lib/util.c b/lib/util.c
> index 805f33a..3f08c4a 100644
> --- a/lib/util.c
> +++ b/lib/util.c
> @@ -1727,15 +1727,16 @@ exit:
>      return ok;
>  }
>
> -unsigned int
> +void
>  xsleep(unsigned int seconds)
>  {
> -    unsigned int t;
> -
>      ovsrcu_quiesce_start();
> -    t = sleep(seconds);
> +#ifdef _WIN32
> +    Sleep(seconds * 1000);
> +#else
> +    sleep(seconds);
> +#endif
>      ovsrcu_quiesce_end();
> -    return t;
>  }
>
>  #ifdef _WIN32
> diff --git a/lib/util.h b/lib/util.h
> index 13ff58e..11305ba 100644
> --- a/lib/util.h
> +++ b/lib/util.h
> @@ -501,13 +501,13 @@ void bitwise_put(uint64_t value,
>  uint64_t bitwise_get(const void *src, unsigned int src_len,
>                       unsigned int src_ofs, unsigned int n_bits);
>
> +void xsleep(unsigned int seconds);
>  #ifdef _WIN32
>
>  char *ovs_format_message(int error);
>  char *ovs_lasterror_to_string(void);
>  int ftruncate(int fd, off_t length);
>  #endif
> -unsigned int xsleep(unsigned int seconds);
>
>  #ifdef  __cplusplus
>  }
> --
> 1.7.9.5
>



More information about the dev mailing list