[Mesa-dev] [PATCH 2/5] android: radeonsi: fix building error in si_shader.c
Michel Dänzer
michel at daenzer.net
Thu Feb 4 07:10:55 UTC 2016
On 03.02.2016 12:18, Mauro Rossi wrote:
> Hi Michel,
>
> Patch was updated according to the instructions and log/commit messages
> changed.
Thanks, but I'm afraid it doesn't match existing compatibility headers
very well.
> +#ifndef _ANDROID_COMPAT_H_
> +#define _ANDROID_COMPAT_H_
> +
> +/*
> + * Android Bionic has no strchrnul, which is used in
> si_shader_dump_disassembly(),
> + * so we must fill in an implementation.
> + */
Don't mention si_shader_dump_disassembly here.
> +char *
> +strchrnul(const char *s, int c)
> +{
> +char * result = strchr(s, c);
> +
> +if (result == NULL) {
> +result = s + strlen(s);
> +}
> +
> +return result;
> +}
> +
> +#endif /* _ANDROID_COMPAT_H_ */
Looking at e.g. include/c99_*.h or src/util/str*.h, there isn't one
header per platform but per standard header / feature. Since strchrnul
is defined in string.h, the compatibility header could be called e.g.
string_compat.h or just strchrnul.h, containing something like:
#include <string.h>
#if defined(__ANDROID__)
char *
strchrnul(const char *s, int c)
{
char * result = strchr(s, c);
if (result == NULL) {
result = s + strlen(s);
}
return result;
}
#endif /* __ANDROID__ */
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c
> b/src/gallium/drivers/radeonsi/si_shader.c
> index 2192b21..86a00fb 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -49,6 +49,10 @@
>
> #include <errno.h>
>
> +#if defined(__ANDROID__)
> +#include "android_compat.h"
> +#endif /* __ANDROID__ */
Also, adding the compatibility header and making use of it should be two
separate changes. Presumably si_shader.c picks up string.h from
src/gallium/include/pipe/p_compiler.h, so the second change could just
change the latter to
#include <string_compat.h>
or add
#include <strchrnul.h>
to si_shader.c.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
More information about the mesa-dev
mailing list