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

Replace nano printf implementation #3013

Closed
wants to merge 5 commits into from

Conversation

josesimoes
Copy link
Member

@josesimoes josesimoes commented Aug 29, 2024

Description

  • Dropping Skirrid Systems es-printf in favour of nanoprintf.
  • Update CMake and code accordingly.

Motivation and Context

  • Need to use more format specifiers than the ones available. nanoprintf is an active and maintained project.

How Has This Been Tested?

  • Sample test apps.
  • Running mscorlib unit tests on pipeline.

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dev Containers (changes related with Dev Containers, has no impact on code or features)
  • Dependencies/declarations (update dependencies or assembly declarations and changes associated, has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced the nanoprintf library with new format specifiers and improved error handling for formatted output.
    • Introduced new flexible functions for formatted output, allowing for better customization and usability.
  • Bug Fixes

    • Removed the nanoprintf.c file from the build process, which may resolve potential issues related to unused functionality.
  • Documentation

    • Updated licensing information for the nanoprintf library, now dual-licensed for broader accessibility.

- Dropping Skirrid Systems es-printf in favour of nanoprintf.
- Update CMake and code accordingly.
@nfbot nfbot added Area: Config-and-Build Area: Dev-Containers Type: dependencies Pull requests that update a dependency file(s) or version labels Aug 29, 2024
Copy link

coderabbitai bot commented Aug 29, 2024

Walkthrough

The changes involve the removal of the nanoprintf.c file from the build configuration across multiple project files, indicating its exclusion from the compilation process. Additionally, the nanoprintf.h header file has been significantly updated to enhance its functionality and configurability, introducing new function declarations and refining format specification parsing. These modifications collectively impact how formatted output is handled in the project.

Changes

File Path Change Summary
CMake/Modules/FindNF_CoreCLR.cmake, src/CLR/Core/Core.vcxproj, src/CLR/Core/Core.vcxproj.filters Removed nanoprintf.c from build configurations and filters.
src/CLR/Diagnostics/Info_Safeprintf.cpp Added #define NANOPRINTF_IMPLEMENTATION 1 to prevent multiple definitions of NanoPrintf.
src/CLR/Helpers/nanoprintf/nanoprintf.h Updated header with new function declarations, enhanced format specifier handling, and changed licensing.

Possibly related PRs

  • Add private implementation of vsnprintf #3011: This PR adds a private implementation of vsnprintf, which is directly related to the changes in the main PR that involve the removal of nanoprintf.c, as both deal with string formatting functionality.

Suggested labels

Type: enhancement, Area: Common libs, Platform: Virtual Device & WIN32


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c0f82e3 and 5cfaf13.

Files selected for processing (1)
  • src/CLR/Helpers/nanoprintf/nanoprintf.h (1 hunks)
Additional comments not posted (11)
src/CLR/Helpers/nanoprintf/nanoprintf.h (11)

1-6: LGTM!

The changes to the copyright notice and license information look good.


7-15: LGTM!

The preprocessor directives to enable additional format specifiers and set the conversion buffer size look good. These changes are necessary to support the requirements of nanoFramework.


19-23: LGTM!

The updates to the library information comment block, including the version number, author email, and licensing details, look good.


24-35: LGTM!

The include guard, standard C header inclusions, and the NPF_VISIBILITY macro definition look good. The code follows standard practices and provides flexibility in controlling the visibility of the library's functions.


37-42: LGTM!

The NPF_PRINTF_ATTR macro definition looks good. It properly handles the printf-like function attribute for GCC/Clang compilers and defines it as empty for other compilers.


44-48: LGTM!

The comment indicating the start of the public API section and the extern "C" block for C++ compatibility look good. These additions provide useful information and ensure proper integration with C++ code.


50-66: LGTM!

The function declarations for npf_snprintf, npf_vsnprintf, npf_pprintf, and npf_vpprintf look good. The comments provide useful information about the return values, and the functions are marked with the appropriate visibility and printf-like function attributes.


72-107: LGTM!

The preprocessor directives that set default values for the format specifier options when none are explicitly defined look good. This ensures that the library has a default configuration and behaves consistently even if the options are not specified.


109-133: LGTM!

The preprocessor directives that check for the proper definition of all format specifier options look good. Raising errors if any option is missing or if there is an incompatible configuration helps catch potential issues at compile-time and ensures that the library is used correctly.


135-148: LGTM!

The preprocessor directives that check for the required C++ version or C standard when large format specifiers are enabled look good. Ensuring that the library is used with compatible language versions helps maintain compatibility and avoids potential issues.


150-189: LGTM!

The preprocessor directives that detect the compiler and its version to determine if warning pragmas are supported look good. Selectively ign


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai generate interesting stats about this repository and render them as a table.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0223857 and c38b0b1.

Files selected for processing (5)
  • CMake/Modules/FindNF_CoreCLR.cmake (1 hunks)
  • src/CLR/Core/Core.vcxproj (1 hunks)
  • src/CLR/Core/Core.vcxproj.filters (2 hunks)
  • src/CLR/Diagnostics/Info_Safeprintf.cpp (1 hunks)
  • src/CLR/Helpers/nanoprintf/nanoprintf.h (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/CLR/Diagnostics/Info_Safeprintf.cpp
Additional comments not posted (35)
src/CLR/Core/Core.vcxproj.filters (1)

218-218: LGTM!

The removal of nanoprintf.c from the project file is consistent with the PR objective of replacing the existing printf implementation.

src/CLR/Core/Core.vcxproj (1)

Line range hint 91-91: LGTM!

The removal of nanoprintf.c from the project file is consistent with the PR objective of replacing the existing printf implementation.

CMake/Modules/FindNF_CoreCLR.cmake (1)

Line range hint 97-97: LGTM!

The removal of nanoprintf.c from the list of source files is consistent with the PR objective of replacing the existing printf implementation.

src/CLR/Helpers/nanoprintf/nanoprintf.h (32)

2-3: LGTM!

The copyright and license information changes are correct and necessary for compliance.


8-13: LGTM!

The preprocessor directives for format specifiers are correctly defined and improve the configurability of the library.


54-65: LGTM!

The public API function declarations are correctly defined and enhance the functionality of the library.


60-60: LGTM!

The typedef for npf_putc is correctly defined and necessary for the new function declarations.


768-1049: LGTM!

The implementation of npf_vpprintf is correctly defined and enhances the functionality of the library.


1056-1062: LGTM!

The implementation of npf_pprintf is correctly defined and enhances the functionality of the library.


1064-1070: LGTM!

The implementation of npf_snprintf is correctly defined and enhances the functionality of the library.


1072-1091: LGTM!

The implementation of npf_vsnprintf is correctly defined and enhances the functionality of the library.


30-41: LGTM!

The preprocessor directives for visibility and attributes are correctly defined and necessary for the new function declarations.


306-486: LGTM!

The format specification parsing logic is correctly defined and enhances the functionality of the library.


549-698: LGTM!

The floating-point conversion logic is correctly defined and enhances the functionality of the library.


703-738: LGTM!

The binary format specifier logic is correctly defined and enhances the functionality of the library.


741-744: LGTM!

The buffer put character function is correctly defined and necessary for the new function implementations.


754-757: LGTM!

The count put character function is correctly defined and necessary for the new function implementations.


86-91: LGTM!

The preprocessor directives for conversion buffer size are correctly defined and necessary for the new function implementations.


135-147: LGTM!

The preprocessor directives for large format specifiers are correctly defined and necessary for the new function implementations.


149-206: LGTM!

The preprocessor directives for disabling warnings are correctly defined and necessary for the new function implementations.


208-214: LGTM!

The preprocessor directives for noinline attribute are correctly defined and necessary for the new function implementations.


216-222: LGTM!

The preprocessor directives for format specifier options are correctly defined and necessary for the new function implementations.


226-237: LGTM!

The preprocessor directives for length modifiers are correctly defined and necessary for the new function implementations.


239-261: LGTM!

The preprocessor directives for conversion specifiers are correctly defined and necessary for the new function implementations.


263-279: LGTM!

The typedef for npf_format_spec is correctly defined and necessary for the new function implementations.


281-287: LGTM!

The typedefs for integer types are correctly defined and necessary for the new function implementations.


289-293: LGTM!

The typedef for npf_bufputc_ctx is correctly defined and necessary for the new function implementations.


748-752: LGTM!

The typedef for npf_cnt_putc_ctx is correctly defined and necessary for the new function implementations.


505-516: LGTM!

The preprocessor directives for float conversion types are correctly defined and necessary for the new function implementations.


519-528: LGTM!

The preprocessor directives for float conversion buffer size are correctly defined and necessary for the new function implementations.


531-538: LGTM!

The preprocessor directives for double type are correctly defined and necessary for the new function implementations.


540-547: LGTM!

The preprocessor directives for floating-point conversion algorithms are correctly defined and necessary for the new function implementations.


703-738: LGTM!

The preprocessor directives for floating-point conversion types are correctly defined and necessary for the new function implementations.


703-738: LGTM!

The preprocessor directives for floating-point conversion types are correctly defined and necessary for the new function implementations.


703-738: LGTM!

The preprocessor directives for floating-point conversion types are correctly defined and necessary for the new function implementations.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c38b0b1 and c0f82e3.

Files selected for processing (1)
  • src/CLR/Helpers/nanoprintf/nanoprintf.h (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/CLR/Helpers/nanoprintf/nanoprintf.h

@josesimoes
Copy link
Member Author

Dropping this as nanoprintf implementation fails to pass all our unit tests.

@josesimoes josesimoes closed this Sep 25, 2024
@josesimoes josesimoes deleted the replace-nanoprintf branch September 25, 2024 12:00
@nfbot nfbot added invalid and removed Area: Config-and-Build Type: dependencies Pull requests that update a dependency file(s) or version Area: Dev-Containers labels Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants