5 #include <exec/rawfmt.h>
8 #include <exec/rawfmt.h>
10 #include <exec/types.h>
13 static inline LONG
fls(ULONG mask
)
18 asm volatile("bsr %1, %0":"=r"(bit
):"rm"(mask
));
23 static inline LONG
fls(ULONG mask
)
30 for (bit
= 1; mask
!= 1; bit
++)
37 /* Finds first set bit in /data/ starting at /bitoffset/. This function
38 considers the MSB to be the first bit. */
39 static inline WORD
bfffo(ULONG data
, WORD bitoffset
)
41 ULONG mask
= 0xffffffff >> bitoffset
;
43 return data
== 0 ? 32 : 32-fls(data
);
46 /* Finds first zero bit in /data/ starting at /bitoffset/. This function
47 considers the MSB to be the first bit. */
48 static inline WORD
bfffz(ULONG data
, WORD bitoffset
)
50 return bfffo(~data
, bitoffset
);
53 ULONG
bfcnto(ULONG v
);
54 ULONG
bfcntz(ULONG v
);
55 LONG
bmflo(ULONG
*bitmap
, LONG bitoffset
);
56 LONG
bmflz(ULONG
*bitmap
, LONG bitoffset
);
57 LONG
bmffo(ULONG
*bitmap
, LONG longs
, LONG bitoffset
);
58 LONG
bmffz(ULONG
*bitmap
, LONG longs
, LONG bitoffset
);
59 LONG
bmclr(ULONG
*bitmap
, LONG longs
, LONG bitoffset
, LONG bits
);
60 LONG
bmset(ULONG
*bitmap
, LONG longs
, LONG bitoffset
, LONG bits
);
61 BOOL
bmtsto(ULONG
*bitmap
, LONG bitoffset
, LONG bits
);
62 BOOL
bmtstz(ULONG
*bitmap
, LONG bitoffset
, LONG bits
);
63 ULONG
bmcnto(ULONG
*bitmap
, LONG bitoffset
, LONG bits
);
64 ULONG
bmcntz(ULONG
*bitmap
, LONG bitoffset
, LONG bits
);
66 ULONG
CALCCHECKSUM(ULONG
, ULONG
*);
68 #ifdef RAWFMTFUNC_STRING
69 #define putChFunc RAWFMTFUNC_STRING
71 #define putChFunc (void (*)())"\x16\xC0\x4E\x75"
75 #define BE2L AROS_BE2LONG
76 #define L2BE AROS_LONG2BE
77 #define BE2W AROS_BE2WORD
78 #define W2BE AROS_WORD2BE
80 #define BE2L AROS_LE2LONG
81 #define L2BE AROS_LONG2LE
82 #define BE2W AROS_LE2WORD
83 #define W2BE AROS_WORD2LE
88 #define AROS_SWAP_BYTES_LONG_CPU(l) \
89 ({ ULONG v; __asm__ __volatile__("bswap %0":"=r"(v):"0"(l)); v;})
90 #define AROS_SWAP_BYTES_WORD_CPU(l) \
91 ({ UWORD w; __asm__ __volatile__("xchgb %b0,%h0":"=q"(w):"0"(l)); w;})
95 #endif /*ASMSUPPORT_H_*/