Print off_t size to easy large file detection

This commit is contained in:
Radim Kolar 2024-07-07 23:53:37 +02:00
parent 7a7b6feb60
commit d05ca1ac13

View File

@ -1,8 +1,8 @@
# #
# SCons Largefile enablement # SCons Largefile enablement
# #
# Version 1.3 # Version 1.4
# 06-Jun-2020 # 07-Jul-2024
# #
def enableLargeFiles(check,conf): def enableLargeFiles(check,conf):
@ -12,16 +12,19 @@ def enableLargeFiles(check,conf):
conf.env.Append(CPPFLAGS = '-DHAVE_FSEEKO') conf.env.Append(CPPFLAGS = '-DHAVE_FSEEKO')
offt=conf.CheckTypeSize('off_t','#include <stdio.h>\n#include <sys/types.h>') offt=conf.CheckTypeSize('off_t','#include <stdio.h>\n#include <sys/types.h>')
ulong=conf.CheckTypeSize('unsigned long') ulong=conf.CheckTypeSize('unsigned long')
if offt<8 and offt>0: if fseeko and offt<8 and offt>0:
flags=conf.env.Dictionary()['CPPFLAGS'] # we have off_t but its not 8 byte long
saved_flags=conf.env.Dictionary()['CPPFLAGS']
# we try to use some defs to make off_t longer
conf.env.Append(CPPFLAGS='-D_FILE_OFFSET_BITS=64') conf.env.Append(CPPFLAGS='-D_FILE_OFFSET_BITS=64')
offt=conf.CheckTypeSize('off_t','#include <stdio.h>\n#include <sys/types.h>') offt=conf.CheckTypeSize('off_t','#include <stdio.h>\n#include <sys/types.h>')
if offt < 8: if offt < 8:
env.Replace(CPPFLAGS=flags) env.Replace(CPPFLAGS=saved_flags)
else: if not fseeko:
if offt == 0: # no fseeko we do not need off_t for anything
#set default value to 4 offt = 0
offt=4 check.Message("Effective off_t size is ")
check.Result(str(offt)+" bytes")
conf.env.Append(CPPFLAGS = '-DSIZEOF_OFF_T='+str(offt)) conf.env.Append(CPPFLAGS = '-DSIZEOF_OFF_T='+str(offt))
check.Message("Checking if we have native large files ...") check.Message("Checking if we have native large files ...")
if fseeko and int(offt)>=8 and int(ulong)>=8: if fseeko and int(offt)>=8 and int(ulong)>=8: