mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
Conditionalize __builtin_prefetch() on it existing!!
You have to check that something that isn't standard C actually exists before trying to use it... Cc: Colin Ian King <colin.i.king@intel.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
d6dc97dfc0
commit
b4697f09e7
4 changed files with 11 additions and 4 deletions
|
|
@ -278,6 +278,7 @@ dnl Some rather useful gcc extensions...
|
|||
dnl
|
||||
PA_HAVE_FUNC(__builtin_constant_p, (0))
|
||||
PA_HAVE_FUNC(__builtin_choose_expr, (0,1,2))
|
||||
PA_HAVE_FUNC(__builtin_prefetch, (NULL))
|
||||
|
||||
dnl
|
||||
dnl Check for supported gcc attributes; some compilers (e.g. Sun CC)
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ static inline void *mempset(void *dst, int c, size_t n)
|
|||
* Hints to the compiler that a particular branch of code is more or
|
||||
* less likely to be taken.
|
||||
*/
|
||||
#if HAVE___BUILTIN_EXPECT
|
||||
#ifdef HAVE___BUILTIN_EXPECT
|
||||
# define likely(x) __builtin_expect(bool(x), true)
|
||||
# define unlikely(x) __builtin_expect(bool(x), false)
|
||||
#else
|
||||
|
|
@ -328,6 +328,12 @@ static inline void *mempset(void *dst, int c, size_t n)
|
|||
# define unlikely(x) bool(x)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE___BUILTIN_PREFETCH
|
||||
# define prefetch(x) __builtin_prefetch(x)
|
||||
#else
|
||||
# define prefetch(x) ((void)(x))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Attributes
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ void **hash_findb(struct hash_table *head, const void *key,
|
|||
void **hash_find(struct hash_table *head, const char *key,
|
||||
struct hash_insert *insert)
|
||||
{
|
||||
__builtin_prefetch(key);
|
||||
prefetch(key);
|
||||
|
||||
return hash_findb(head, key, strlen(key)+1, insert);
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ void **hash_findib(struct hash_table *head, const void *key, size_t keylen,
|
|||
void **hash_findi(struct hash_table *head, const char *key,
|
||||
struct hash_insert *insert)
|
||||
{
|
||||
__builtin_prefetch(key);
|
||||
prefetch(key);
|
||||
|
||||
return hash_findib(head, key, strlen(key)+1, insert);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ strlist_add(struct strlist *list, const char *str)
|
|||
struct hash_insert hi;
|
||||
size_t size;
|
||||
|
||||
__builtin_prefetch(str);
|
||||
prefetch(str);
|
||||
|
||||
if (!list)
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue