2 * Copyright 2007, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
17 #define device_printf(dev, a...) dprintf("firewire:" a)
18 #define printf(a...) dprintf(a)
19 #define KASSERT(cond,msg) do { \
25 #define howmany(x, y) (((x)+((y)-1))/(y)) // x/y的上界
27 #define rounddown(x, y) (((x)/(y))*(y)) // 比x小,y的最大的倍数
28 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ // 比x大,y的最小倍数
29 #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
30 #define powerof2(x) ((((x)-1)&(x))==0) // 是否是2的次方
32 typedef uint32_t bus_addr_t
;
33 typedef uint32_t bus_size_t
;
35 #define atomic_readandclear_int(ptr) atomic_get_and_set((int32*)(ptr), 0)
36 #define atomic_set_int(ptr, value) atomic_or((int32 *)(ptr), value)
38 #define mtx_lock mutex_lock
39 #define mtx_unlock mutex_unlock
40 #define mtx_destroy mutex_destroy
41 #define mtx_init(lockaddr, name, type, opts) mutex_init(lockaddr, name)
43 #define wakeup(i) release_sem_etc(i->Sem, 0, B_RELEASE_IF_WAITING_ONLY | B_RELEASE_ALL)
46 #define splx(s) (void)s
50 #define DELAY(n) snooze(n)
52 #define OWRITE(sc, offset, value) (*(volatile uint32 *)((char *)(sc->regAddr) + (offset)) = value)
53 #define OREAD(sc, offset) (*(volatile uint32 *)((char *)(sc->regAddr) + (offset)))
56 extern dpc_module_info
*gDpc
;
58 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))