summaryrefslogtreecommitdiffstats
path: root/config.tests/unix/largefile/ConfigureChecks.cmake
blob: 4e0cc4c5d62cd7bf09040b95e2002aeb608a9525 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
###########################################
#                                         #
#  Improvements and feedback are welcome  #
#                                         #
#  This file is released under GPL >= 3   #
#                                         #
###########################################


##### check for large file support

check_cxx_source_compiles("
#define _LARGEFILE_SOURCE
#define _LARGE_FILES
#define _FILE_OFFSET_BITS 64

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <stdio.h>

int main( int, char **argv )
{
// check that off_t can hold 2^63 - 1 and perform basic operations...
#define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
    if (OFF_T_64 % 2147483647 != 1)
	return 1;

    // stat breaks on SCO OpenServer
    struct stat buf;
    stat( argv[0], &buf );
    if (!S_ISREG(buf.st_mode))
	return 2;

    FILE *file = fopen( argv[0], \"r\" );
    off_t offset = ftello( file );
    fseek( file, offset, SEEK_CUR );
    fclose( file );
    return 0;
}"
QT_LARGEFILE_SUPPORT)