Message ID | 20180215042900.16078-2-f4bug@amsat.org |
---|---|
State | New |
Headers | show |
Series | hw: use the BYTE-based definitions when useful | expand |
On Thu, Feb 15, 2018 at 5:28 AM, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote: > (added in 076b35b5a56) > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Or osdep.h? Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > include/qemu/cunits.h | 11 +++++++++++ > include/qemu/cutils.h | 8 +------- > 2 files changed, 12 insertions(+), 7 deletions(-) > create mode 100644 include/qemu/cunits.h > > diff --git a/include/qemu/cunits.h b/include/qemu/cunits.h > new file mode 100644 > index 0000000000..c0207b7611 > --- /dev/null > +++ b/include/qemu/cunits.h > @@ -0,0 +1,11 @@ > +#ifndef QEMU_CUNITS_H > +#define QEMU_CUNITS_H > + > +#define K_BYTE (1ULL << 10) > +#define M_BYTE (1ULL << 20) > +#define G_BYTE (1ULL << 30) > +#define T_BYTE (1ULL << 40) > +#define P_BYTE (1ULL << 50) > +#define E_BYTE (1ULL << 60) > + > +#endif > diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h > index f0878eaafa..01184a70b3 100644 > --- a/include/qemu/cutils.h > +++ b/include/qemu/cutils.h > @@ -2,6 +2,7 @@ > #define QEMU_CUTILS_H > > #include "qemu/fprintf-fn.h" > +#include "qemu/cunits.h" > > /** > * pstrcpy: > @@ -143,13 +144,6 @@ int qemu_strtosz(const char *nptr, char **end, uint64_t *result); > int qemu_strtosz_MiB(const char *nptr, char **end, uint64_t *result); > int qemu_strtosz_metric(const char *nptr, char **end, uint64_t *result); > > -#define K_BYTE (1ULL << 10) > -#define M_BYTE (1ULL << 20) > -#define G_BYTE (1ULL << 30) > -#define T_BYTE (1ULL << 40) > -#define P_BYTE (1ULL << 50) > -#define E_BYTE (1ULL << 60) > - > /* used to print char* safely */ > #define STR_OR_NULL(str) ((str) ? (str) : "null") > > -- > 2.16.1 > >
On 15.02.2018 10:55, Marc-André Lureau wrote: > On Thu, Feb 15, 2018 at 5:28 AM, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote: >> (added in 076b35b5a56) >> >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > > Or osdep.h? No, osdep.h is for "OS includes and handling of OS dependencies", not for declaring constants like this. Thomas
diff --git a/include/qemu/cunits.h b/include/qemu/cunits.h new file mode 100644 index 0000000000..c0207b7611 --- /dev/null +++ b/include/qemu/cunits.h @@ -0,0 +1,11 @@ +#ifndef QEMU_CUNITS_H +#define QEMU_CUNITS_H + +#define K_BYTE (1ULL << 10) +#define M_BYTE (1ULL << 20) +#define G_BYTE (1ULL << 30) +#define T_BYTE (1ULL << 40) +#define P_BYTE (1ULL << 50) +#define E_BYTE (1ULL << 60) + +#endif diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index f0878eaafa..01184a70b3 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -2,6 +2,7 @@ #define QEMU_CUTILS_H #include "qemu/fprintf-fn.h" +#include "qemu/cunits.h" /** * pstrcpy: @@ -143,13 +144,6 @@ int qemu_strtosz(const char *nptr, char **end, uint64_t *result); int qemu_strtosz_MiB(const char *nptr, char **end, uint64_t *result); int qemu_strtosz_metric(const char *nptr, char **end, uint64_t *result); -#define K_BYTE (1ULL << 10) -#define M_BYTE (1ULL << 20) -#define G_BYTE (1ULL << 30) -#define T_BYTE (1ULL << 40) -#define P_BYTE (1ULL << 50) -#define E_BYTE (1ULL << 60) - /* used to print char* safely */ #define STR_OR_NULL(str) ((str) ? (str) : "null")
(added in 076b35b5a56) Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- include/qemu/cunits.h | 11 +++++++++++ include/qemu/cutils.h | 8 +------- 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 include/qemu/cunits.h