LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 722|回复: 3

程序代码中的cb是什么意思?

[复制链接]
发表于 2009-10-5 15:48:46 | 显示全部楼层 |阅读模式
以前看eog、epdfview的时候经常看到某个函数是以cb结尾的,今天找epoll例子的时候也发现其中有些函数是以cb结尾的,请问这个cb是什么意思呀!


  1. int file_notify_addcb(struct file *filep,
  2.                 void (*cbproc)(struct file *, void *, unsigned long *, long *), void *data)
  3. {
  4.         unsigned long flags;
  5.         struct fcb_struct *fcbp;

  6.         if (!(fcbp = (struct fcb_struct *) kmalloc(sizeof(struct fcb_struct), GFP_KERNEL)))
  7.                 return -ENOMEM;
  8.         memset(fcbp, 0, sizeof(struct fcb_struct));
  9.         fcbp->cbproc = cbproc;
  10.         fcbp->data = data;
  11.         fcblist_write_lock(filep, flags);
  12.         list_add_tail(&fcbp->lnk, &filep->f_cblist);
  13.         fcblist_write_unlock(filep, flags);
  14.         return 0;
  15. }

  16. int file_notify_delcb(struct file *filep,
  17.                 void (*cbproc)(struct file *, void *, unsigned long *, long *))
  18. {
  19.         unsigned long flags;
  20.         struct list_head *lnk;

  21.         fcblist_write_lock(filep, flags);
  22.         list_for_each(lnk, &filep->f_cblist) {
  23.                 struct fcb_struct *fcbp = list_entry(lnk, struct fcb_struct, lnk);

  24.                 if (fcbp->cbproc == cbproc) {
  25.                         list_del(lnk);
  26.                         fcblist_write_unlock(filep, flags);
  27.                         kfree(fcbp);
  28.                         return 0;
  29.                 }
  30.         }
  31.         fcblist_write_unlock(filep, flags);
  32.         return -ENOENT;
  33. }
复制代码
发表于 2009-10-5 20:06:22 | 显示全部楼层
cb == control block?
回复 支持 反对

使用道具 举报

发表于 2009-10-5 22:48:28 | 显示全部楼层
callback
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-10-5 23:25:02 | 显示全部楼层
嗯,callback有道理。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表