[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] util: move declarations out of qemu-common.h
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] util: move declarations out of qemu-common.h |
Date: |
Mon, 21 Mar 2016 18:50:47 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
There are only two issues with the patch, which I fixed before queuing
it for my next pull request.
On 20/03/2016 18:16, address@hidden wrote:
> -/* path.c */
> -void init_paths(const char *prefix);
> -const char *path(const char *pathname);
The first is that only the above two lines were really for path.c, so I
have removed everything else from path.h. Likewise, unicode.c only has
mod_utf8_codepoint.
> -/* unicode.c */
> -int mod_utf8_codepoint(const char *s, size_t n, char **end);
> -
> -/*
> - * Hexdump a buffer to a file. An optional string prefix is added to every
> line
> - */
> -
> -void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t
> size);
> -
> /* vector definitions */
> #ifdef __ALTIVEC__
> #include <altivec.h>
> diff --git a/include/qemu/bcd.h b/include/qemu/bcd.h
> new file mode 100644
> index 0000000..7e720c4
> --- /dev/null
> +++ b/include/qemu/bcd.h
> @@ -0,0 +1,10 @@
> +/* Convert a byte between binary and BCD. */
> +static inline uint8_t to_bcd(uint8_t val)
> +{
> + return ((val / 10) << 4) | (val % 10);
> +}
> +
> +static inline uint8_t from_bcd(uint8_t val)
> +{
> + return ((val >> 4) * 10) + (val & 0x0f);
> +}
The second is that you need multiple-inclusion guards here, like
#ifndef QEMU_BCD_H
#define QEMU_BCD_H 1
/* Convert a byte between binary and BCD. */
static inline uint8_t to_bcd(uint8_t val)
{
return ((val / 10) << 4) | (val % 10);
}
static inline uint8_t from_bcd(uint8_t val)
{
return ((val >> 4) * 10) + (val & 0x0f);
}
#endif
That said, great job, considering that even just creating qemu/bcd.h
would have been enough. Instead, you went ahead and touched 140 files.
Thanks!
Paolo