akaros/scripts/spatch/linux/sync.cocci
<<
>>
Prefs
   1@@
   2typedef qlock_t;
   3@@
   4-struct mutex
   5+qlock_t
   6
   7@@
   8expression E;
   9@@
  10-mutex_init(
  11+qlock_init(
  12 E)
  13
  14@@
  15expression E;
  16@@
  17-mutex_lock(
  18+qlock(
  19 E)
  20
  21@@
  22expression E;
  23@@
  24-mutex_trylock(
  25+canqlock(
  26 E)
  27
  28@@
  29expression E;
  30@@
  31-mutex_unlock(
  32+qunlock(
  33 E)
  34
  35// the netif_addr_lock is a spinlock in linux, but it seems to protect the list
  36// of addresses.  That's the 'qlock' (great name) in plan 9
  37@@
  38expression DEV;
  39@@
  40-netif_addr_lock(DEV)
  41+qlock(&DEV->qlock)
  42
  43@@
  44expression DEV;
  45@@
  46-netif_addr_unlock(DEV)
  47+qunlock(&DEV->qlock)
  48
  49@@
  50expression DEV;
  51@@
  52-netif_addr_lock_bh(DEV)
  53+qlock(&DEV->qlock)
  54
  55@@
  56expression DEV;
  57@@
  58-netif_addr_unlock_bh(DEV)
  59+qunlock(&DEV->qlock)
  60
  61@@
  62expression AMT;
  63expression VARP;
  64@@
  65-atomic_add(AMT, VARP)
  66+atomic_add(VARP, AMT)
  67
  68@@
  69expression E;
  70@@
  71-atomic_dec_and_test(E)
  72+atomic_sub_and_test(E, 1)
  73