mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-18 10:48:51 +00:00
44d0677a90
A number of headers define functions as "extern inline" which is causing problems with gcc5. The reason is that starting with version 5.1, gcc defaults to the standard C99 semantics for the inline keyword. Under the traditional GNU inline semantics, an "extern inline" function would never create an external definition, the same as inline *without* extern in C99. In C99, and "extern inline" definition is simply an external definition with an inline hint. In short, the meanings of inline with and without extern are swapped between GNU and C99. The upshot is that all these definitions in header files create an external definition wherever those headers are included, resulting in multiple definition errors at link time. Changing all these functions to "static inline" fixes the problem since this works as desired in all gcc versions. Although the semantics are slightly different (a static inline definition may result in an actual function being emitted), it works as intended in practice. This patch also removes extern prototype declarations for the changed functions where they existed. Signed-off-by: Mans Rullgard <mans@mansr.com>
55 lines
1.3 KiB
C
55 lines
1.3 KiB
C
/*
|
|
* bitops.h: Bit string operations on the m68k
|
|
*/
|
|
|
|
#ifndef _M68K_BITOPS_H
|
|
#define _M68K_BITOPS_H
|
|
|
|
#include <asm/byteorder.h>
|
|
#include <asm-generic/bitops/fls.h>
|
|
#include <asm-generic/bitops/__fls.h>
|
|
#include <asm-generic/bitops/fls64.h>
|
|
#include <asm-generic/bitops/__ffs.h>
|
|
|
|
extern void set_bit(int nr, volatile void *addr);
|
|
extern void clear_bit(int nr, volatile void *addr);
|
|
extern void change_bit(int nr, volatile void *addr);
|
|
extern int test_and_clear_bit(int nr, volatile void *addr);
|
|
extern int test_and_change_bit(int nr, volatile void *addr);
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
static inline int test_bit(int nr, __const__ volatile void *addr)
|
|
{
|
|
__const__ unsigned int *p = (__const__ unsigned int *) addr;
|
|
|
|
return (p[nr >> 5] & (1UL << (nr & 31))) != 0;
|
|
}
|
|
|
|
static inline int test_and_set_bit(int nr, volatile void *vaddr)
|
|
{
|
|
char retval;
|
|
|
|
volatile char *p = &((volatile char *)vaddr)[(nr^31) >> 3];
|
|
__asm__ __volatile__ ("bset %2,(%4); sne %0"
|
|
: "=d" (retval), "=m" (*p)
|
|
: "di" (nr & 7), "m" (*p), "a" (p));
|
|
|
|
return retval;
|
|
}
|
|
|
|
#define __ffs(x) (ffs(x) - 1)
|
|
|
|
/*
|
|
* * hweightN: returns the hamming weight (i.e. the number
|
|
* * of bits set) of a N-bit word
|
|
* */
|
|
|
|
#define hweight32(x) generic_hweight32(x)
|
|
#define hweight16(x) generic_hweight16(x)
|
|
#define hweight8(x) generic_hweight8(x)
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif /* _M68K_BITOPS_H */
|