-
Notifications
You must be signed in to change notification settings - Fork 256
eyalroz-printf: Add new wrap v6.2.0 #2258
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
Open
crvux
wants to merge
1
commit into
mesonbuild:master
Choose a base branch
from
crvux:eyalroz-printf
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.
Open
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 hidden or 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 hidden or 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,9 @@ | ||
[wrap-file] | ||
directory = printf-6.2.0 | ||
source_url = https://github.com/eyalroz/printf/archive/refs/tags/v6.2.0.zip | ||
source_filename = eyalroz-printf-6.2.0.zip | ||
source_hash = 42f40b07cf1012d7a69e2c34d44b118dc3a70530f3e2b591962cfe7a7c133fc7 | ||
patch_directory = eyalroz-printf | ||
|
||
[provide] | ||
dependency_names = eyalroz-printf |
This file contains hidden or 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,158 @@ | ||
project( | ||
'eyalroz-printf', | ||
'c', | ||
'cpp', | ||
license: 'MIT', | ||
meson_version: '>=0.63.0', | ||
Check notice on line 6 in subprojects/packagefiles/eyalroz-printf/meson.build
|
||
version: '6.2.0', | ||
default_options: [ | ||
'b_staticpic=false', | ||
'c_std=c99', | ||
'default_library=static', # For shared support we need to somehow provide putchar_ implementation | ||
'warning_level=3', | ||
], | ||
) | ||
|
||
|
||
cc = meson.get_compiler('c') | ||
## Checks related to the 'j', 'z' and 't' size modifiers | ||
sizeof_long = cc.sizeof('long') | ||
sizeof_long_long = cc.sizeof('long long') | ||
acceptable_jzt_type_sizes = [sizeof_long, sizeof_long_long] | ||
types = ['intmax_t', 'size_t', 'ptrdiff_t'] | ||
foreach type : types | ||
type_size = cc.sizeof( | ||
type, | ||
prefix: '#include <stdint.h>', | ||
) | ||
if type_size not in acceptable_jzt_type_sizes | ||
error( | ||
f'sizeof(@type@) is @type_size@, which is neither sizeof(long) (@sizeof_long@) nor sizeof(long long) (@sizeof_long_long@). Please contact the library maintainers with your platform details.', | ||
) | ||
endif | ||
endforeach | ||
|
||
lib_config = {} | ||
public_c_args = [] | ||
aliasing_defines = { | ||
'hard': { | ||
'PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_SOFT': 0, | ||
'PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_HARD': 1, | ||
}, | ||
'soft': { | ||
'PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_SOFT': 1, | ||
'PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_HARD': 0, | ||
}, | ||
'none': { | ||
'PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_SOFT': 0, | ||
'PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_HARD': 0, | ||
}, | ||
} | ||
alias_standard_function_names = get_option('alias_standard_function_names') | ||
if alias_standard_function_names != 'none' | ||
option_val_upper = alias_standard_function_names.to_upper() | ||
public_c_args += f'-DPRINTF_ALIAS_STANDARD_FUNCTION_NAMES_@option_val_upper@=1' | ||
public_c_args += cc.get_supported_arguments('-fno-builtin-printf') | ||
endif | ||
lib_config += aliasing_defines[alias_standard_function_names] | ||
|
||
bool_option_names = [ | ||
'support_decimal_specifiers', | ||
'support_exponential_specifiers', | ||
'support_msvc_style_integer_specifiers', | ||
'support_writeback_specifier', | ||
'support_long_long', | ||
'use_double_internally', | ||
'check_for_nul_in_format_specifier', | ||
] | ||
foreach option_name : bool_option_names | ||
lib_config += { | ||
'PRINTF_' + option_name.to_upper(): get_option(option_name).to_int(), | ||
} | ||
endforeach | ||
int_option_names = ['integer_buffer_size', 'decimal_buffer_size'] | ||
foreach option_name : int_option_names | ||
lib_config += { | ||
'PRINTF_' + option_name.to_upper(): get_option(option_name), | ||
} | ||
endforeach | ||
int_option_names_wo_prefix = [ | ||
'default_float_precision', | ||
'max_integral_digits_for_decimal', | ||
'log10_taylor_terms', | ||
] | ||
foreach option_name : int_option_names_wo_prefix | ||
lib_config += { | ||
option_name.to_upper(): get_option(option_name), | ||
} | ||
endforeach | ||
|
||
cfg_header_file = configure_file( | ||
input: 'printf_config.h.in', | ||
configuration: lib_config, | ||
format: 'cmake@', | ||
output: 'printf_config.h', | ||
) | ||
eyalroz_printf_lib = library( | ||
'eyalroz-printf', | ||
'src/printf/printf.c', | ||
cfg_header_file, | ||
include_directories: 'src', | ||
c_args: ['-DPRINTF_INCLUDE_CONFIG_H', public_c_args], | ||
) | ||
eyalroz_printf_dep = declare_dependency( | ||
include_directories: 'src', | ||
link_with: eyalroz_printf_lib, | ||
compile_args: [public_c_args], | ||
) | ||
meson.override_dependency('eyalroz-printf', eyalroz_printf_dep) | ||
|
||
subdir('test') | ||
|
||
# Prints the sizes of the different sections of the ELF file: text, dat, vss etc. | ||
size_prog = find_program( | ||
'size', | ||
required: false, | ||
) | ||
if size_prog.found() | ||
custom_target( | ||
'printf-sizes', | ||
command: [size_prog, '-A', '-t', eyalroz_printf_lib], | ||
capture: true, | ||
output: 'printf_sizes.txt', | ||
) | ||
endif | ||
|
||
# Produces lists of the symbols, and C++demangled symbols, inside the library | ||
nm_prog = find_program( | ||
'nm', | ||
required: false, | ||
) | ||
if nm_prog.found() | ||
custom_target( | ||
'printf-symbols', | ||
command: [nm_prog, '--numeric-sort', '--print-size', eyalroz_printf_lib], | ||
capture: true, | ||
output: 'printf_symbols.txt', | ||
) | ||
endif | ||
|
||
# Dissassembles the compiled library into an .list file | ||
objdump_prog = find_program( | ||
'objdump', | ||
required: false, | ||
) | ||
if objdump_prog.found() | ||
custom_target( | ||
'printf-lst', | ||
command: [ | ||
objdump_prog, | ||
'--disassemble', | ||
'--line-numbers', | ||
'-S', | ||
eyalroz_printf_lib, | ||
], | ||
capture: true, | ||
output: 'printf.list', | ||
) | ||
endif |
This file contains hidden or 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,85 @@ | ||
option( | ||
'test_with_non_standard_format_strings', | ||
description: 'Include tests using non-standard-compliant format strings', | ||
type: 'boolean', | ||
) | ||
|
||
option( | ||
'support_decimal_specifiers', | ||
description: 'Support decimal notation floating-point conversion specifiers (%f,%F)', | ||
type: 'boolean', | ||
) | ||
option( | ||
'support_exponential_specifiers', | ||
description: 'Support exponential floating point format conversion specifiers (%e,%E,%g,%G)', | ||
type: 'boolean', | ||
) | ||
option( | ||
'support_writeback_specifier', | ||
description: 'Support the length write-back specifier (%n)', | ||
type: 'boolean', | ||
) | ||
option( | ||
'support_msvc_style_integer_specifiers', | ||
description: 'Support the I + bit size integer specifiers (%I8, %I16, %I32, %I64) as in Microsoft Visual C++', | ||
type: 'boolean', | ||
) | ||
option( | ||
'support_long_long', | ||
description: 'Support long long integral types (allows for the ll length modifier and affects %p)', | ||
type: 'boolean', | ||
) | ||
option( | ||
'use_double_internally', | ||
description: 'Use the C `double` type - typically 64-bit in size - for internal floating-point arithmetic', | ||
type: 'boolean', | ||
) | ||
option( | ||
'check_for_nul_in_format_specifier', | ||
description: 'Be defensive in the undefined-behavior case of a format specifier not ending before the string ends', | ||
type: 'boolean', | ||
) | ||
|
||
option( | ||
'integer_buffer_size', | ||
description: 'Integer to string conversion buffer size', | ||
type: 'integer', | ||
min: 0, | ||
value: 32, | ||
) | ||
option( | ||
'decimal_buffer_size', | ||
description: 'Floating-point to decimal conversion buffer size', | ||
type: 'integer', | ||
min: 0, | ||
value: 32, | ||
) | ||
option( | ||
'default_float_precision', | ||
description: 'Default precision when printing floating-point values', | ||
type: 'integer', | ||
min: 0, | ||
value: 6, | ||
) | ||
option( | ||
'max_integral_digits_for_decimal', | ||
description: 'Maximum number of integral-part digits of a floating-point value for which printing with %f uses decimal (non-exponential) notation', | ||
type: 'integer', | ||
min: 0, | ||
value: 9, | ||
) | ||
option( | ||
'log10_taylor_terms', | ||
description: 'The number of terms in a Taylor series expansion of log_10(x) to use for approximation', | ||
type: 'integer', | ||
min: 0, | ||
value: 4, | ||
) | ||
|
||
option( | ||
'alias_standard_function_names', | ||
description: 'Alias the standard library function names (printf, sprintf etc.) to the library\'s functions - concretely, via a macro, or not at all', | ||
type: 'combo', | ||
choices: ['none', 'hard', 'soft'], | ||
value: 'none', | ||
) |
This file contains hidden or 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,64 @@ | ||
common_compiler_args = [ | ||
'-gdwarf-2', | ||
'-ffunction-sections', | ||
'-fdata-sections', | ||
'-fverbose-asm', | ||
'-Wundef', | ||
'-Wshadow', | ||
'-Wunreachable-code', | ||
'-Wswitch-default', | ||
'-Wcast-align', | ||
'-Wmissing-include-dirs', | ||
'-Winit-self', | ||
'-Wdouble-promotion', | ||
'-Wunused-parameter', | ||
'-Wstrict-prototypes', | ||
'-Wsign-conversion', | ||
] | ||
|
||
c_common_args = cc.get_supported_arguments(common_compiler_args) | ||
c_common_args += cc.get_supported_arguments('-fno-builtin-printf') | ||
aliasing_exe = executable( | ||
'aliasing', | ||
'aliasing.c', | ||
cfg_header_file, | ||
build_by_default: false, | ||
c_args: c_common_args, | ||
dependencies: [eyalroz_printf_dep], | ||
include_directories: '..', | ||
override_options: ['c_std=c11'], | ||
) | ||
test('printf.aliasing', aliasing_exe) | ||
|
||
cxx = meson.get_compiler('cpp') | ||
cxx_common_args = cxx.get_supported_arguments(common_compiler_args) | ||
if get_option('test_with_non_standard_format_strings') | ||
cxx_common_args += '-DTEST_WITH_NON_STANDARD_FORMAT_STRINGS' | ||
endif | ||
autotest_exe = executable( | ||
'autotest', | ||
'autotest.cpp', | ||
cfg_header_file, | ||
build_by_default: false, | ||
cpp_args: cxx_common_args, | ||
implicit_include_directories: false, | ||
include_directories: '..', | ||
dependencies: eyalroz_printf_dep, | ||
override_options: ['cpp_std=c++11', 'cpp_eh=none'], | ||
) | ||
# Not running autotest by default - it's randomized after all. | ||
|
||
# Ignore next test while 'test/test_suite_main_testcases.hpp:829' is not fixed in new version | ||
# | ||
# if get_option('alias_standard_function_names') != 'soft' | ||
# test_suite_exe = executable( | ||
# 'test_suite', | ||
# 'test_suite.cpp', | ||
# cfg_header_file, | ||
# build_by_default: false, | ||
# cpp_args: ['-DPRINTF_INCLUDE_CONFIG_H', cxx_common_args], | ||
# include_directories: ['..', '../src'], | ||
# override_options: ['cpp_std=c++11', 'cpp_eh=none'], | ||
# ) | ||
# test('printf.test_suite', test_suite_exe) | ||
# endif |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.