# define os_file_read(file, buf, offset, offset_high, n)        \
    os_file_read_func(file, buf, offset, offset_high, n)
/*******************************************************************//**
NOTE! Use the corresponding macro os_file_read(), not directly this
function!
Requests a synchronous positioned read operation.
@return    TRUE if request was successful, FALSE if fail */
UNIV_INTERN
ibool
os_file_read_func(
/*==============*/
    os_file_t    file,    /*!< in: handle to a file */
    void*        buf,    /*!< in: buffer where to read */
    ulint        offset,    /*!< in: least significant 32 bits of file
                offset where to read */
    ulint        offset_high, /*!< in: most significant 32 bits of
                offset */
    ulint        n)    /*!< in: number of bytes to read */
{
#ifdef __WIN__
    BOOL        ret;
    DWORD        len;
    DWORD        ret2;
    DWORD        low;
    DWORD        high;
    ibool        retry;
#ifndef UNIV_HOTBACKUP
    ulint        i;
#endif /* !UNIV_HOTBACKUP */

    /* On 64-bit Windows, ulint is 64 bits. But offset and n should be
    no more than 32 bits. */
    ut_a((offset & 0xFFFFFFFFUL) == offset);
    ut_a((n & 0xFFFFFFFFUL) == n);

    os_n_file_reads++;
    os_bytes_read_since_printout += n;

try_again:
    ut_ad(file);
    ut_ad(buf);
    ut_ad(n > );

    low = (DWORD) offset;
    high = (DWORD) offset_high;

    os_mutex_enter(os_file_count_mutex);
    os_n_pending_reads++;
    os_mutex_exit(os_file_count_mutex);

#ifndef UNIV_HOTBACKUP
    /* Protect the seek / read operation with a mutex */
    i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES;

    os_mutex_enter(os_file_seek_mutexes[i]);
#endif /* !UNIV_HOTBACKUP */

    ret2 = SetFilePointer(file, low, &high, FILE_BEGIN);

    if (ret2 == 0xFFFFFFFF && GetLastError() != NO_ERROR) {

#ifndef UNIV_HOTBACKUP
        os_mutex_exit(os_file_seek_mutexes[i]);
#endif /* !UNIV_HOTBACKUP */

        os_mutex_enter(os_file_count_mutex);
        os_n_pending_reads--;
        os_mutex_exit(os_file_count_mutex);

        goto error_handling;
    }

    ret = ReadFile(file, buf, (DWORD) n, &len, NULL);

#ifndef UNIV_HOTBACKUP
    os_mutex_exit(os_file_seek_mutexes[i]);
#endif /* !UNIV_HOTBACKUP */

    os_mutex_enter(os_file_count_mutex);
    os_n_pending_reads--;
    os_mutex_exit(os_file_count_mutex);

    if (ret && len == n) {
        return(TRUE);
    }
#else /* __WIN__ */
    ibool    retry;
    ssize_t    ret;

    os_bytes_read_since_printout += n;

try_again:
    ret = os_file_pread(file, buf, n, offset, offset_high); //读取数据 详见    if ((ulint)ret == n) {

        return(TRUE);
    }

    fprintf(stderr,
        "InnoDB: Error: tried to read %lu bytes at offset %lu %lu.\n"
        "InnoDB: Was only able to read %ld.\n",
        (ulong)n, (ulong)offset_high,
        (ulong)offset, (long)ret);
#endif /* __WIN__ */
#ifdef __WIN__
error_handling:
#endif
    retry = os_file_handle_error(NULL, "read");

    if (retry) {
        goto try_again;
    }

    fprintf(stderr,
        "InnoDB: Fatal error: cannot read from file."
        " OS error number %lu.\n",
#ifdef __WIN__
        (ulong) GetLastError()
#else
        (ulong) errno
#endif
        );
    fflush(stderr);

    ut_error;

    return(FALSE);
}

宏os_file_read_func的更多相关文章

  1. Visual Studio 宏的高级用法

    因为自 Visual Studio 2012 开始,微软已经取消了对宏的支持,所以本篇文章所述内容只适用于 Visual Studio 2010 或更早期版本的 VS. 在上一篇中,我已经介绍了如何编 ...

  2. VC 中与字符串相关的宏 _T、TEXT,_TEXT、L 的作用

    CSDN原博文:http://blog.csdn.net/houkai363/article/details/8134787 遇到了:不能将参数 1 从“const char [5]”转换为“LPCT ...

  3. 【转】linux内核中writesb(), writesw(), writesl() 宏函数

    writesb(), writesw(), writesl() 宏函数 功能 : writesb()    I/O 上写入 8 位数据流数据 (1字节) writesw()   I/O  上写入 16 ...

  4. c++宏定义命令

    在程序开始以#开头的命令,他们是预编译命令.有三类预编译命令:宏定义命令.文件包含命令.条件编译命令:今天聊聊宏定义: 宏定义命令将一个标识符定义为一个字符串,源程序中的该标识符均以指定的字符串来代替 ...

  5. dll导入导出宏定义,出现“不允许 dllimport 函数 的定义”的问题分析

    建立dll项目后,在头文件中,定义API宏 #ifndef API_S_H #define API_S_H ...... #ifndef DLL_S_20160424 #define API _dec ...

  6. VC++/MFC 最常用宏和指令

    1.#include指令  包含指定的文件,最基本的最熟悉的指令,编程中不得不用,包含库文件用双尖括号,包含自定义头文件用双引号. 2.#define指令   预定义,通常用它来定义常量(包括无参量与 ...

  7. [Sass]混合宏的参数

    [Sass]混合宏的参数--传一个不带值的参数 Sass 的混合宏有一个强大的功能,可以传参,那么在 Sass 中传参主要有以下几种情形: A) 传一个不带值的参数 在混合宏中,可以传一个不带任何值的 ...

  8. [Sass]混合宏

    [Sass]混合宏-声明混合宏 如果整个网站中有几处小样式类似,比如颜色,字体等,在 Sass 可以使用变量来统一处理,那么这种选择还是不错的.但当你的样式变得越来越复杂,需要重复使用大段的样式时,使 ...

  9. BOOST_AUTO宏

    在boost中,有个非常不错的宏BOOST_AUTO(),它的作用是自动给var定义类型,适合function()函数返回的值的类型. int function() { ; } main() { BO ...

随机推荐

  1. Daily Scrum 11.6

    摘要:在本次meeting时,所有代码的修改工作已经接近尾声,接下来是进行的就是单元测试以及进行alpha版本的改进.本次的Task列表如下: Task列表 出席人员 Today's Task Tom ...

  2. c语言基础:各种数据类型的输出占位符

    c语言中的输出操作相对java来说是比较麻烦的,每种数据类型的输出都有各自的占位符: 下面是各种数据类型的输出占位符: short/int : %d ; printf("这个整数是:%d&q ...

  3. tomcat绑定域名

    现在很多的公司的网站都是用tomcat作为应用服务区的,可是对于初学者,8080端口号是如何去掉的,这些网站是如何和域名绑定到一起的呢?一个tomcat是如何绑定多域名?并且这些域名是如何对应不同的项 ...

  4. android 自定义ratingbar 图片显示不全的解决方案

    在res/style中自定义评分条: <!-- 自定义评分条 --> <style name="roomRatingBar" parent="@andr ...

  5. PHP对XML文件操作之属性与方法讲解

    DOMDocument相关的内容. 属性: Attributes 存储节点的属性列表(只读) childNodes 存储节点的子节点列表(只读) dataType 返回此节点的数据类型 Definit ...

  6. MySql修改默认端口号,修改my.ini的端口号

    MySql默认端口号为3306,如果安装多个或者冲突需要修改端口号,修改my.ini的端口号就可以了,文件一般情况下在安装目录下.下面是具体说明: 方法/步骤 先在服务里停止mysql的服务器,再找到 ...

  7. EasyTouch 3.1中文翻译

    Unity3D的Easy Touch 的手册最近寻找中文版本,google无果,自己动手.目前暂时只有c# ,javascript原理是一样的. 一.Quick Start 1-Import Easy ...

  8. Properties --- C++读配置信息的类(一)

    http://blog.csdn.net/billow_zhang/article/details/4304980 在开发实践中,积累了一些通用的C++ 类库,在此写出来给大家分享.也希望能给出更好的 ...

  9. python的dict()函数

    dict(one=1,two=2) dict({'one':1,'two':2}) dict((('one',1),('two',2))) dict((['one',1],['two',2])) di ...

  10. DiskGenius的 “终止位置参数溢出”错误解决方法。

    (转帖)同事电脑系统启动突然明显变慢,重装系统后问题仍未解决(windowsxp sp3).帮忙分析感觉是磁盘分区表出现了错误,用通用PE工具箱进入PE系统,DiskGenius工具检查:“终止位置参 ...