grepを読む(その10)

前回のoff_tの検索結果をもう一度みてみます。

takk@deb9:/usr/include$ grep -r 'typedef.*\<off_t\>' *
fcntl.h:typedef __off_t off_t;
fcntl.h:typedef __off64_t off_t;
mysql/my_global.h:typedef off_t os_off_t;
stdio.h:typedef __off_t off_t;
stdio.h:typedef __off64_t off_t;
unistd.h:typedef __off_t off_t;
unistd.h:typedef __off64_t off_t;
x86_64-linux-gnu/sys/mman.h:typedef __off_t off_t;
x86_64-linux-gnu/sys/mman.h:typedef __off64_t off_t;
x86_64-linux-gnu/sys/types.h:typedef __off_t off_t;
x86_64-linux-gnu/sys/types.h:typedef __off64_t off_t;
x86_64-linux-gnu/sys/stat.h:typedef __off_t off_t;
x86_64-linux-gnu/sys/stat.h:typedef __off64_t off_t;
takk@deb9:/usr/include$

似たような定義をいろんな所でしてるんですね。

off_tを探すのは骨が折れる気がしますので、GNUのサイトでも見てみます。

File Position Primitive (The GNU C Library)
File Position Primitive (The GNU C Library)
13.3 Setting the File Position of a Descriptor

の章に、

Function: off_t lseek (int filedes, off_t offset, int whence)

を見つけることができますが、この関数に使われている引数の型や、戻り値の型について詳細の説明があります。

例えば、filedesに指定する値に関しては、

SEEK_SET

    Specifies that offset is a count of characters from the beginning of the file.
    SEEK_CUR

    Specifies that offset is a count of characters from the current file position. This count may be positive or negative.
SEEK_END

    Specifies that offset is a count of characters from the end of the file. ..

~省略~

まあ、ここらへんはman lseekにもありますね。

で、off_tの説明を見てみると、

Data Type: off_t

    This is a signed integer type used to represent file sizes. In the GNU C Library, this type is no narrower than int.

    If the source is compiled with _FILE_OFFSET_BITS == 64 this type is transparently replaced by off64_t. 

Data Type: off64_t

    This type is used similar to off_t. The difference is that even on 32 bit machines, where the off_t type would have 32 bits, off64_t has 64 bits and so is able to address files up to 2^63 bytes in length.

    When compiling with _FILE_OFFSET_BITS == 64 this type is available under the name off_t. 

ただの整数型でした。
できれば、Webを探さずに、ソースからぱっと見つけたいですね。

つづく

コメント

タイトルとURLをコピーしました