mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
Added xstrtol_ll and xstrtol_ull convenience functions
This commit is contained in:
parent
e05a879022
commit
d56aff5255
@ -1,3 +1,8 @@
|
|||||||
|
Sun Jan 20 11:01:22 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
* src/internal.h: Add xstrtol_ull, xstrtol_ll convenience
|
||||||
|
functions
|
||||||
|
|
||||||
Sun Jan 20 10:54:22 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
Sun Jan 20 10:54:22 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
* src/xend_internal.c: Fix nodeinfo compat with Xen 3.2.0 and
|
* src/xend_internal.c: Fix nodeinfo compat with Xen 3.2.0 and
|
||||||
|
@ -308,6 +308,42 @@ xstrtol_ui(char const *s, char **end_ptr, int base, unsigned int *result)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
xstrtol_ll(char const *s, char **end_ptr, int base, long long *result)
|
||||||
|
{
|
||||||
|
long long val;
|
||||||
|
char *p;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
val = strtoll(s, &p, base);
|
||||||
|
err = (errno || (!end_ptr && *p) || p == s || (long long) val != val);
|
||||||
|
if (end_ptr)
|
||||||
|
*end_ptr = p;
|
||||||
|
if (err)
|
||||||
|
return -1;
|
||||||
|
*result = val;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Just like xstrtol_i, above, but produce an "unsigned long long" value. */
|
||||||
|
static inline int
|
||||||
|
xstrtol_ull(char const *s, char **end_ptr, int base, unsigned long long *result)
|
||||||
|
{
|
||||||
|
unsigned long long val;
|
||||||
|
char *p;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
val = strtoull(s, &p, base);
|
||||||
|
err = (errno || (!end_ptr && *p) || p == s || (unsigned long long) val != val);
|
||||||
|
if (end_ptr)
|
||||||
|
*end_ptr = p;
|
||||||
|
if (err)
|
||||||
|
return -1;
|
||||||
|
*result = val;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
Loading…
Reference in New Issue
Block a user