mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 09:10:11 +01:00
i965: Only insert error message if not already present
Some restrictions require something like strides to match between src and dest. For multi-source instructions, I'd rather encapsulate the logic for not inserting already present errors in ERROR_IF than open-coding it multiple places.
This commit is contained in:
parent
5e76cf153c
commit
122ef3799d
1 changed files with 13 additions and 5 deletions
|
|
@ -44,13 +44,21 @@ cat(struct string *dest, const struct string src)
|
||||||
}
|
}
|
||||||
#define CAT(dest, src) cat(&dest, (struct string){src, strlen(src)})
|
#define CAT(dest, src) cat(&dest, (struct string){src, strlen(src)})
|
||||||
|
|
||||||
|
static bool
|
||||||
|
contains(const struct string haystack, const struct string needle)
|
||||||
|
{
|
||||||
|
return memmem(haystack.str, haystack.len, needle.str, needle.len) != NULL;
|
||||||
|
}
|
||||||
|
#define CONTAINS(haystack, needle) \
|
||||||
|
contains(haystack, (struct string){needle, strlen(needle)})
|
||||||
|
|
||||||
#define error(str) "\tERROR: " str "\n"
|
#define error(str) "\tERROR: " str "\n"
|
||||||
#define ERROR_INDENT "\t "
|
#define ERROR_INDENT "\t "
|
||||||
|
|
||||||
#define ERROR(msg) ERROR_IF(true, msg)
|
#define ERROR(msg) ERROR_IF(true, msg)
|
||||||
#define ERROR_IF(cond, msg) \
|
#define ERROR_IF(cond, msg) \
|
||||||
do { \
|
do { \
|
||||||
if (cond) { \
|
if ((cond) && !CONTAINS(error_msg, error(msg))) { \
|
||||||
CAT(error_msg, error(msg)); \
|
CAT(error_msg, error(msg)); \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue