RequireLargeFilesSupport.cxx 636 B

12345678910111213141516171819202122232425262728
  1. #define _LARGEFILE_SOURCE
  2. #define _LARGE_FILES
  3. #define _FILE_OFFSET_BITS 64
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <assert.h>
  7. #include <stdio.h>
  8. int main( int, char **argv )
  9. {
  10. // check that off_t can hold 2^63 - 1 and perform basic operations...
  11. #define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  12. if (OFF_T_64 % 2147483647 != 1)
  13. return 1;
  14. // stat breaks on SCO OpenServer
  15. struct stat buf;
  16. stat( argv[0], &buf );
  17. if (!S_ISREG(buf.st_mode))
  18. return 2;
  19. FILE *file = fopen( argv[0], "r" );
  20. off_t offset = ftello( file );
  21. fseek( file, offset, SEEK_CUR );
  22. fclose( file );
  23. return 0;
  24. }