Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fseek test #2055

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -792,10 +792,13 @@ endif()
#!TODO Leaving as is in WRF for now but investigate why we don't do this
# https://stackoverflow.com/a/1035713
# If fseeko64 succeeds, use that, else check if we can fall back to fseeko, and if not just use fseek
if ( ${FSEEKO64} )
list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEKO64_OK )
elseif( "${FSEEKO}" )
list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEKO_OK )
if ( "${FSEEKO64}" OR "${FSEEKO}" )
list( APPEND PROJECT_COMPILE_DEFINITIONS _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE=1 )
if ( "${FSEEKO64}" )
list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEKO64_OK )
elseif( "${FSEEKO}" )
list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEKO_OK )
endif()
else()
list( APPEND PROJECT_COMPILE_DEFINITIONS FSEEK_OK )
endif()
Expand Down
4 changes: 2 additions & 2 deletions confcheck/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ wrf_conf_check(
RESULT_VAR FSEEKO64
SOURCE ${PROJECT_SOURCE_DIR}/tools/fseek_test.c
EXTENSION .c
ADDITIONAL_DEFINITIONS -DTEST_FSEEKO64 -DFILE_TO_TEST="${PROJECT_SOURCE_DIR}/CMakeLists.txt"
ADDITIONAL_DEFINITIONS -DTEST_FSEEKO64 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -DFILE_TO_TEST="${PROJECT_SOURCE_DIR}/CMakeLists.txt"
MESSAGE "fseeko64 not supported, checking alternate fseeko"
)

Expand All @@ -60,7 +60,7 @@ if ( NOT "${FSEEKO64}" )
RESULT_VAR FSEEKO
SOURCE ${PROJECT_SOURCE_DIR}/tools/fseek_test.c
EXTENSION .c
ADDITIONAL_DEFINITIONS -DTEST_FSEEKO -DFILE_TO_TEST="${PROJECT_SOURCE_DIR}/CMakeLists.txt"
ADDITIONAL_DEFINITIONS -DTEST_FSEEKO -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -DFILE_TO_TEST="${PROJECT_SOURCE_DIR}/CMakeLists.txt"
MESSAGE "fseeko not supported, compiling with fseek (caution with large files)"
)
endif()
Expand Down
3 changes: 2 additions & 1 deletion tools/fseek_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
int
main()
{
FILE *fp ;
Expand Down Expand Up @@ -43,6 +44,6 @@ main()
retval = 1 ;
}
fclose(fp) ;
exit(retval) ;
return retval ;
}