X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Futil.c;h=1ebe22a5c7a09756eab2ad95b081289233f2a3ea;hb=4c21aa063fa1c7f95800c95fafebedcd577ce674;hp=0d1d9a52b1db9079b729c2a124d4391f890dffed;hpb=2fec66dbb5493ee5815507d47796f84c35181dd0;p=sliver-openvswitch.git diff --git a/lib/util.c b/lib/util.c index 0d1d9a52b..1ebe22a5c 100644 --- a/lib/util.c +++ b/lib/util.c @@ -30,6 +30,7 @@ #include "bitmap.h" #include "byte-order.h" #include "coverage.h" +#include "ovs-rcu.h" #include "ovs-thread.h" #include "vlog.h" #ifdef HAVE_PTHREAD_SET_NAME_NP @@ -612,6 +613,20 @@ str_to_llong(const char *s, int base, long long *x) } } +bool +str_to_uint(const char *s, int base, unsigned int *u) +{ + long long ll; + bool ok = str_to_llong(s, base, &ll); + if (!ok || ll < 0 || ll > UINT_MAX) { + *u = 0; + return false; + } else { + *u = ll; + return true; + } +} + /* Converts floating-point string 's' into a double. If successful, stores * the double in '*d' and returns true; on failure, stores 0 in '*d' and * returns false. @@ -1726,6 +1741,18 @@ exit: return ok; } +void +xsleep(unsigned int seconds) +{ + ovsrcu_quiesce_start(); +#ifdef _WIN32 + Sleep(seconds * 1000); +#else + sleep(seconds); +#endif + ovsrcu_quiesce_end(); +} + #ifdef _WIN32 char *