文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>IS_ERR ERR_PTR PTR_ERR

IS_ERR ERR_PTR PTR_ERR

时间:2007-04-27  来源:g_hk

查看2.6 include/linux/err.h

/*
 * Kernel pointers have redundant information, so we can use a
 * scheme where we can return either an error code or a dentry
 * pointer with the same return value.
 *
 * This should be a per-architecture thing, to allow different
 * error and pointer decisions.
 */
static inline void *ERR_PTR(long error)
{
        return (void *) error;
}

static inline long PTR_ERR(const void *ptr)
{
        return (long) ptr;
}

static inline long IS_ERR(const void *ptr)
{
        return unlikely((unsigned long)ptr > (unsigned long)-1000L);
}



使用eg:

int err;
void *perr;

err = -ENOMEM;
perr = ERR_PTR(err);

printk("err.%d perr.%p \n", err, perr);

if (IS_ERR(perr))
{
  printk("PTR_ERR changed ==> err.%d", (int)PTR_ERR(perr));
}


主要用在错误指针同错误int类型间转换.
相关阅读 更多 +
排行榜 更多 +
僵尸猎手小明

僵尸猎手小明

动作格斗 下载
狩猎波比

狩猎波比

动作格斗 下载
花海相机

花海相机

图像拍照 下载