-
Notifications
You must be signed in to change notification settings - Fork 856
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
Enable Large File Support #1068
Draft
thesamesam
wants to merge
1
commit into
the-tcpdump-group:master
Choose a base branch
from
thesamesam:largefilesupport
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
# CMake support for large files | ||
# | ||
# Copyright (C) 2016 Julian Andres Klode <[email protected]>. | ||
# | ||
# Permission is hereby granted, free of charge, to any person | ||
# obtaining a copy of this software and associated documentation files | ||
# (the "Software"), to deal in the Software without restriction, | ||
# including without limitation the rights to use, copy, modify, merge, | ||
# publish, distribute, sublicense, and/or sell copies of the Software, | ||
# and to permit persons to whom the Software is furnished to do so, | ||
# subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be | ||
# included in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# | ||
# This defines the following variables | ||
# | ||
# LFS_DEFINITIONS - List of definitions to pass to add_definitions() | ||
# LFS_COMPILE_OPTIONS - List of definitions to pass to add_compile_options() | ||
# LFS_LIBRARIES - List of libraries and linker flags | ||
# LFS_FOUND - If there is Large files support | ||
# | ||
|
||
include(CheckCSourceCompiles) | ||
include(FindPackageHandleStandardArgs) | ||
include(CMakePushCheckState) | ||
|
||
# Test program to check for LFS. Requires that off_t has at least 8 byte large | ||
set(_lfs_test_source | ||
" | ||
#include <sys/types.h> | ||
typedef char my_static_assert[sizeof(off_t) >= 8 ? 1 : -1]; | ||
int main(void) { return 0; } | ||
" | ||
) | ||
|
||
# Check if the given options are needed | ||
# | ||
# This appends to the variables _lfs_cppflags, _lfs_cflags, and _lfs_ldflags, | ||
# it also sets LFS_FOUND to 1 if it works. | ||
function(_lfs_check_compiler_option var options definitions libraries) | ||
cmake_push_check_state() | ||
set(CMAKE_REQUIRED_QUIET 1) | ||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} ${options}) | ||
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${definitions}) | ||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_DEFINITIONS} ${libraries}) | ||
|
||
message(STATUS "Looking for LFS support using ${options} ${definitions} ${libraries}") | ||
check_c_source_compiles("${_lfs_test_source}" ${var}) | ||
cmake_pop_check_state() | ||
|
||
if(${var}) | ||
message(STATUS "Looking for LFS support using ${options} ${definitions} ${libraries} - found") | ||
set(_lfs_cppflags ${_lfs_cppflags} ${definitions} PARENT_SCOPE) | ||
set(_lfs_cflags ${_lfs_cflags} ${options} PARENT_SCOPE) | ||
set(_lfs_ldflags ${_lfs_ldflags} ${libraries} PARENT_SCOPE) | ||
set(LFS_FOUND TRUE PARENT_SCOPE) | ||
else() | ||
message(STATUS "Looking for LFS support using ${options} ${definitions} ${libraries} - not found") | ||
endif() | ||
endfunction() | ||
|
||
# Check for the availability of LFS. | ||
# The cases handled are: | ||
# | ||
# * Native LFS | ||
# * Output of getconf LFS_CFLAGS; getconf LFS_LIBS; getconf LFS_LDFLAGS | ||
# * Preprocessor flag -D_FILE_OFFSET_BITS=64 | ||
# * Preprocessor flag -D_LARGE_FILES | ||
# | ||
function(_lfs_check) | ||
set(_lfs_cflags) | ||
set(_lfs_cppflags) | ||
set(_lfs_ldflags) | ||
set(_lfs_libs) | ||
cmake_push_check_state() | ||
set(CMAKE_REQUIRED_QUIET 1) | ||
message(STATUS "Looking for native LFS support") | ||
check_c_source_compiles("${_lfs_test_source}" lfs_native) | ||
cmake_pop_check_state() | ||
if (lfs_native) | ||
message(STATUS "Looking for native LFS support - found") | ||
set(LFS_FOUND TRUE) | ||
else() | ||
message(STATUS "Looking for native LFS support - not found") | ||
endif() | ||
|
||
if (NOT LFS_FOUND) | ||
# Check using getconf. If getconf fails, don't worry, the check in | ||
# _lfs_check_compiler_option will fail as well. | ||
execute_process(COMMAND getconf LFS_CFLAGS | ||
OUTPUT_VARIABLE _lfs_cflags_raw | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_QUIET) | ||
execute_process(COMMAND getconf LFS_LIBS | ||
OUTPUT_VARIABLE _lfs_libs_tmp | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_QUIET) | ||
execute_process(COMMAND getconf LFS_LDFLAGS | ||
OUTPUT_VARIABLE _lfs_ldflags_tmp | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_QUIET) | ||
|
||
separate_arguments(_lfs_cflags_raw) | ||
separate_arguments(_lfs_ldflags_tmp) | ||
separate_arguments(_lfs_libs_tmp) | ||
|
||
# Move -D flags to the place they are supposed to be | ||
foreach(flag ${_lfs_cflags_raw}) | ||
if (flag MATCHES "-D.*") | ||
list(APPEND _lfs_cppflags_tmp ${flag}) | ||
else() | ||
list(APPEND _lfs_cflags_tmp ${flag}) | ||
endif() | ||
endforeach() | ||
|
||
# Check if the flags we received (if any) produce working LFS support | ||
_lfs_check_compiler_option(lfs_getconf_works | ||
"${_lfs_cflags_tmp}" | ||
"${_lfs_cppflags_tmp}" | ||
"${_lfs_libs_tmp};${_lfs_ldflags_tmp}") | ||
endif() | ||
|
||
if(NOT LFS_FOUND) # IRIX stuff | ||
_lfs_check_compiler_option(lfs_need_n32 "-n32" "" "") | ||
endif() | ||
if(NOT LFS_FOUND) # Linux and friends | ||
_lfs_check_compiler_option(lfs_need_file_offset_bits "" "-D_FILE_OFFSET_BITS=64" "") | ||
endif() | ||
if(NOT LFS_FOUND) # AIX | ||
_lfs_check_compiler_option(lfs_need_large_files "" "-D_LARGE_FILES=1" "") | ||
endif() | ||
|
||
set(LFS_DEFINITIONS ${_lfs_cppflags} CACHE STRING "Extra definitions for large file support") | ||
set(LFS_COMPILE_OPTIONS ${_lfs_cflags} CACHE STRING "Extra definitions for large file support") | ||
set(LFS_LIBRARIES ${_lfs_libs} ${_lfs_ldflags} CACHE STRING "Extra definitions for large file support") | ||
set(LFS_FOUND ${LFS_FOUND} CACHE INTERNAL "Found LFS") | ||
endfunction() | ||
|
||
if (NOT LFS_FOUND) | ||
_lfs_check() | ||
endif() | ||
|
||
find_package_handle_standard_args(LFS "Could not find LFS. Set LFS_DEFINITIONS, LFS_COMPILE_OPTIONS, LFS_LIBRARIES." LFS_FOUND) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we want a note here that it's from libpcap and hence changes should be made there first, etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but then the equivalent code in libpcap should be marked as "this was picked up by tcpdump and changes should be made there, too".
Or:
(And then we should look at tcpslice; that does a bunch of seeking, so it may involve even more work there.)