Giter Site home page Giter Site logo

embeddedartistry / libc Goto Github PK

View Code? Open in Web Editor NEW
494.0 24.0 66.0 1.67 MB

libc targeted for embedded systems usage. Reduced set of functionality (due to embedded nature). Chosen for portability and quick bringup.

License: MIT License

C 78.73% Makefile 1.00% Meson 4.68% Groovy 0.73% Assembly 3.86% CMake 4.32% C++ 6.68%
libc bringup embedded-systems portability c test-coverage meson hacktoberfest

libc's Introduction

Embedded Artistry libc

Embedded Artistry's libc is a stripped-down C standard library implementation targeted for microcontroller-based embedded systems.

In order to conserve precious memory resources, this library does not supply the complete C standard library implementation. Instead, a subset of functions which are useful on bare-metal embedded systems has been selected. If you have a bare metal or RTOS-based embedded system, this library is for you!

Unlike many other C libraries that I've come across, this library implements unit tests and has addressed long-standing flaws in open-source implementations of the C standard library functions. We're continually adding tests and making additional improvements over the baseline implementations.

malloc and free are not included in this library. If you need dynamic memory allocation support, you will need to couple this library with something like Embedded Artistry's libmemory, which contains implementations of malloc and free.

If you are interested in contributing to this project, please read the CONTRIBUTING guide.

Table of Contents

  1. About the Project
  2. Project Status
  3. Getting Started
    1. Requirements
      1. git-lfs
      2. Meson Build System
    2. Getting the Source
    3. Building 2. Disabling Position Independent Code 2. Enabling Link-time Optimization
    4. Installation
    5. Usage
  4. Configuration Options
  5. Stack Overflow Protection
  6. Documentation
  7. Need Help?
  8. Contributing
  9. Further Reading
  10. Authors
  11. License
  12. Acknowledgments

About the Project

Embedded Artistry's libc is intended to provide a portable set of useful C standard library functions that allows quick bring-up of new bare-metal and RTOS-based embedded systems.

Additionally, we want to provide a high-quality libc implementation by ensuring that each function has unit test coverage and addresses flaws exposed by the static analyzer. Many C library function implementations remain untested and contain errors. We are fighting back against poor implementations.

In order to conserve memory, this library does not supply the complete C standard library functionality. Instead, a subset of functions which are useful on bare-metal embedded systems has been selected. This selection has primarily been driven by my own experience in microcontroller-focused development. If you need additional features, please file an issue and make a feature request.

The functional implementations in this library have been selected for portability and quick bring-up of new systems. There may be more efficient implementations for these functions, but often they are architecture specific implementations. If you have suggestions for improving performance, we are always happy to hear them.

malloc and free are not included in this library. Because memory allocation schemes vary greatly with embedded systems (some not even allowing dynamic memory), you will need to supply your own implementations based on your system's needs. You can couple this library with the Embedded Artistry libmemory, which contains implementations of malloc and free.

Project Status

This library provides a complete-enough implementation to compile and link clang's libc++ and libc++abi (see Embedded Artistry's libcpp project). In order to achieve this, some functions are only defined in the headers but do not have an implementation. Unsupported-but-defined functions can be removed using a build option (hide-unimplemented-libc-apis).

The following portions of the C library have been implemented:

  • assert
  • Basic C runtime support (crt.c, exit, atexit, etc.)
  • ctype
  • math (via openlibm)
  • string functions
  • stdlib
    • atoX
    • abs, labs, llabs
    • bsearch
    • calloc
    • div, ldiv, lldiv
    • heapsort, heapsort_r
    • imaxabs, imaxdiv
    • qsort, qsort_r
    • rand family
    • realloc
    • strtoX functions (many via gdtoa)
  • Basic stdio
  • time types and asctime()
  • wchar type definitions and wctype functions

In addition, this library provides implementations for __stack_chk_guard and __stack_chk_fail.

The following architectures are currently supported:

  • x86
  • x86_64
  • ARM
  • ARM64

The following unit tests need to be added:

  • realloc
  • rand family

These are not implemented by may be added in the future:

  • wchar functions
  • errno support (enabled as a compile-time switch)
  • getopt support
  • time support
  • FILE and additional stdio functions

We are currently not planning full support for:

  • locale

Getting Started

Requirements

This project uses Embedded Artistry's standard Meson build system, and dependencies are described in detail on our website.

At a minimum you will need:

  • git-lfs, which is used to store binary files in this repository
  • Meson is the build system
  • Some kind of compiler for your target system.
    • This repository has been tested with:
      • gcc-7, gcc-8, gcc-9
      • arm-none-eabi-gcc
      • Apple clang
      • Mainline clang

git-lfs

This project stores some files using git-lfs.

To install git-lfs on Linux:

sudo apt install git-lfs

To install git-lfs on MacOS:

brew install git-lfs

Additional installation instructions can be found on the git-lfs website.

Meson Build System

The Meson build system depends on python3 and ninja-build.

To install on Linux:

sudo apt-get install python3 python3-pip ninja-build

To install on OSX:

brew install python3 ninja

Meson can be installed through pip3:

pip3 install meson

If you want to install Meson globally on Linux, use:

sudo -H pip3 install meson

Getting the Source

This project uses git-lfs, so please install it before cloning. If you cloned prior to installing git-lfs, simply run git lfs pull after installation.

This project is hosted on GitHub. You can clone the project directly using this command:

git clone --recursive [email protected]:embeddedartistry/libc.git

If you don't clone recursively, be sure to run the following command in the repository or your build will fail:

git submodule update --init

Building

If Make is installed, the library can be built by issuing the following command:

make

This will build all targets for your current architecture.

You can clean builds using:

make clean

You can eliminate the generated buildresults folder using:

make distclean

You can also use meson directly for compiling.

Create a build output folder:

meson buildresults

And build all targets by running

ninja -C buildresults

Cross-compilation is handled using meson cross files. Example files are included in the build/cross folder. You can write your own cross files for your specific processor by defining the toolchain, compilation flags, and linker flags. These settings will be used to compile libc. (or open an issue and we can help you).

Cross-compilation must be configured using the meson command when creating the build output folder. For example:

meson buildresults --cross-file build/cross/gcc_arm_cortex-m4.txt

Following that, you can run make (at the project root) or ninja to build the project.

Tests will not be cross-compiled. They will only be built for the native platform.

Full instructions for building the project, using alternate toolchains, and running supporting tooling are documented in Embedded Artistry's Standardized Meson Build System on our website.

Disabling Position Independent Code

Position Independent Code (PIC) is enabled by default, but can be disabled during the Meson configuration stage by setting the built-in option b_staticpic to false:

meson buildresults -Db_staticpic=false

Enabling Link-time Optimization

Link-time Optimization (LTO) can be enabled during the meson configuration stage by setting the built-in option b_lto to true:

meson buildresults -Db_lto=true

This can be combined with other build options.

Installation

If you don't use meson for your project, the best method to use this project is to build it separately and copy the headers and library contents into your source tree.

  • Copy the include/ directory contents into your source tree.
  • Library artifacts are stored in the buildresults/src folder
  • Copy the desired library to your project and add the library to your link step.

Example linker flags:

-Lpath/to/libc.a -lc

If you're using meson, you can use libc as a subproject. Place it into your subproject directory of choice and add a subproject statement:

libc = subproject('libc')

You will need to promote the desired subproject dependency variable to your project:

libc_dep = libc.get_variable('libc_dep')

You can use the dependency for your target library configuration in your executable declarations(s) or other dependencies. For example:

fwdemo_sim_platform_dep = declare_dependency(
	include_directories: fwdemo_sim_platform_inc,
	dependencies: [
		fwdemo_simulator_hw_platform_dep,
		posix_os_dep,
		libmemory_native_dep,
		libc_dep, # <----- libc added here
		libcxxabi_native_dep,
		libcxx_full_native_dep,
		logging_subsystem_dep
	],
	sources: files('platform.cpp'),
)

Testing

The tests for this library are written with CMocka, which is included as a subproject and does not need to be installed on your system. You can run the tests by issuing the following command:

make test

By default, test results are generated for use by the CI server and are formatted in JUnit XML. The test results XML files can be found in buildresults/test/.

Configuration Options

The following meson project options can be set for this library when creating the build results directory with meson, or by using meson configure:

  • enable-pedantic: Turn on pedantic warnings
  • enable-pedantic-error: Turn on pedantic warnings and errors
  • hide-unimplemented-libc-apis: Hides the header definitions for functions which are not actually implemented
  • enable-gnu-extensions will enable GNU libc extensions that are implemented in this library
  • disable-builtins will tell the compiler not to generate built-in functions, forcing it to use the library functions
  • disable-stack-protection will tell the compiler not to insert stack protection calls
  • stack-canary-value enables you to customize the canary value for your application. Supply a hexadecimal string (e.g., '0xdeadbeef') with the same length as your processor's word size.
  • disable-stk-guard-runtime-config disables the code that is used to configure __stk_chk_guard during program initialization. When this option is true, the program will revert to using a hard-coded definition for the guard value.

Options can be specified using -D and the option name:

meson buildresults -Ddisable-builtins=false

The same style works with meson configure:

cd buildresults
meson configure -Ddisable-builtins=false

Stack Overflow Protection

This library provides an implementation of __stack_chk_guard and __stack_chk_fail, which enables it to be used with GCC and Clang's stack protection code.

The default value for __stack_chk_guard can be overridden with the stack-canary-value build option.

Documentation

[Documentation for the latest release can always be found here]https://embeddedartistry.github.io/libc/index.html.

Documentation can be built locally by running the following command:

make docs

Documentation can be found in buildresults/docs, and the root page is index.html.

Need help?

If you need further assistance or have any questions, please file a GitHub Issue or send us an email using the Embedded Artistry Contact Form.

You can also reach out on Twitter: mbeddedartistry.

Contributing

If you are interested in contributing to this project, please read our contributing guidelines.

Authors

License

Copyright © 2022 Embedded Artistry LLC

This project is licensed under the MIT License - see LICENSE file for details.

For other open-source licenses, please see the Software Inventory.

Acknowledgments

I'd like to thank the following individuals for their direct contributions on this project:

  • @seekaddo (Documentation)
  • @mpaland (Original author of the printf library)
  • @eyalroz (Picked up mpaland's printf library and continued development)

Many of the open-source function implementations used in this library have been pulled from two primary sources:

  • Apple Open Source libc
    • abs, atof, bsearch, div family, heapsort/qsort family, abs family, imax family, strtol/ll/ull
    • fls, flsl, flsll
    • strstr, strtok. strnstr, strnlen, strndup, strncpy, strncat, strlen, strdup, strcpy, strcat
    • memmem, memcpy
  • musl libc
    • All ctype member functions (locale support removed)
    • strrchr, strchrnul, strchr
    • memset, memrchr

I have also used and improved the open-source gdtoa library.

The initial groundwork of testing was implemented by referencing the libc-test project.

Back to top

libc's People

Contributors

adhamea avatar celskeggs avatar eriols avatar jkent avatar patstew avatar phillipjohnston avatar seanbarber avatar seekaddo avatar vestrel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libc's Issues

wchar support

Add support for the wide APIs

Would be nice to have compile time hooks to disable

ea-nightly/libc/master: #24 Failed

Build ea-nightly/libc/master #24 Failed

View full output

Change log:

  • 26086ed: Address linter feedback for README.md [Phillip Johnston]
  • 0e2c78c: Improve readme with further linting [Phillip Johnston]
  • bcadef9: unit test for strnstr Fixes #5 [Phillip Johnston]
  • 67b19b3: Enable ADR for this repository [Phillip Johnston]
  • 203f71b: Add dependency note regarding ADR tools [Phillip Johnston]
  • d2cb180: Remove premake build module + file [Phillip Johnston]
  • 8446684: Non-atomic commit: Add build submodule, fix warnings [Phillip Johnston]
  • bdb6394: Create a meson build file [Phillip Johnston]
  • 11a7021: Makefile shim now supports meson [Phillip Johnston]
  • 206e384: Update README to refer to meson [Phillip Johnston]
  • be2ca36: Fix header guard prefix warnings in x64_64 arch definitions [Phillip Johnston]
  • 3e4df42: Fix additional header guard warnings discovered by new build settings [Phillip Johnston]
  • 996bac6: Update memcmp due to test failure - NULL vs NULL should pass [Phillip Johnston]
  • d79935e: Fix string tests warnings [Phillip Johnston]
  • 29c6570: Fix stdlib test warnings [Phillip Johnston]
  • 73860ed: Fix warnings in lldiv_t by adding {} around struct declaration list [Phillip Johnston]
  • cda6788: Formatting [Phillip Johnston]
  • f41165b: Update memmem tests to check the correct behavior for empty strings [Phillip Johnston]
  • 4fbf1cc: Add brackets to memmem.c implementation [Phillip Johnston]
  • 200f6f8: Meson build cleanup - split into separate test and libc meson files [Phillip Johnston]
  • 8ede957: Constrain tests to host machine [Phillip Johnston]
  • 1bb7ecf: Fix language definition [Phillip Johnston]
  • 768881c: Eliminate the need for the arch library folder with cmocka, since we are [Phillip Johnston]
  • 3edc1f8: Rename project to libc [Phillip Johnston]
  • 3509791: Re-track cmocka library [Phillip Johnston]
  • 2027292: Convert add_global_arguments call to add_project_arguments call, since [Phillip Johnston]
  • ae55ec6: Fix warnings in div.c tets [Phillip Johnston]
  • a1cf837: Apply arguments for C and C++, create a libc dependency [Phillip Johnston]
  • 3e9eb86: Use latest build submodule [Phillip Johnston]
  • e981c49: Enable c++ for this project as well as C [Phillip Johnston]
  • 5b412e4: Add a native library when we are doing cross builds for testing purposes [Phillip Johnston]
  • acb8da6: Advance build subpointer [Phillip Johnston]
  • 85ccacf: Advance build submodule [Phillip Johnston]
  • c91adba: Remove -lm [Phillip Johnston]
  • 116a882: First-pass STDIO implementation. Just uses printf.h definitions. [Phillip Johnston]
  • e51efeb: Always build a libc native and link with the tests [Phillip Johnston]
  • 224c713: Add note for native library on missing stdio files [Phillip Johnston]
  • 1fd6c38: Add xlsx files to git-lfs [Phillip Johnston]
  • d35e9f6: Start software inventory for libc [Phillip Johnston]
  • 8c82b11: Update to the latest build submodule [Phillip Johnston]
  • 43dd9a9: Track printf license [Phillip Johnston]
  • 0f13fd2: Fix warnings in rand test code [Phillip Johnston]
  • 4670878: Add first-pass float.h support [Phillip Johnston]
  • 41458b6: Add first-pass math.h support for fabs, fabsf (used to fix warnings in [Phillip Johnston]
  • 93e3b33: Start aarch64 arch folder [Phillip Johnston]
  • f385ce5: Add float to arm arch [Phillip Johnston]
  • 1f05cd5: Fix warnings in libc tests [Phillip Johnston]
  • 0835c2b: Formatting updates for include [Phillip Johnston]
  • 32810cf: Formatting update for arch folder [Phillip Johnston]
  • 16338b3: math formatting update [Phillip Johnston]
  • be63fd1: Fix header include build error [Phillip Johnston]
  • 71fb226: Add a meson dependency for the native library [Phillip Johnston]
  • e222e75: Fix warnings in qsort [Phillip Johnston]
  • fb410fa: Fix warnings in fls* [Phillip Johnston]
  • 8bcb3a4: Fix strtok warning [Phillip Johnston]
  • de4b22d: Fix srnstr warning [Phillip Johnston]
  • 8486bbc: Fix warning (and stupid implementation) in strncmp [Phillip Johnston]
  • dc2d2c7: Split strtol, stroul and fix warnings [Phillip Johnston]
  • c25175a: Fix warnings in string functions [Phillip Johnston]
  • a170f6a: Fix warnings in stdlib functions [Phillip Johnston]
  • 076f758: libc build update [Phillip Johnston]
  • 7817767: use latest gdtoa - no warnings [Phillip Johnston]
  • d19658e: Add wchar type to arch folder [Phillip Johnston]
  • bb60ef6: First-pass wide character support (libcpp requires) [Phillip Johnston]
  • 93bd6e9: Add wchar to build [Phillip Johnston]
  • 4aef656: Fix warnings in wchar code [Phillip Johnston]
  • 61f041e: Add basic assert implementation [Phillip Johnston]
  • 4cff61c: Add basic errno implementation (gets libcpp code compiling, but errno [Phillip Johnston]
  • 1d7be66: stdlib WIP: get libcpp compiling, not all symbols link [Phillip Johnston]
  • 4eba91f: Define additional string functions required by libcpp [Phillip Johnston]
  • 72dbb1c: Define bare-metal putchar and puts implementations. Add additional stdio [Phillip Johnston]
  • 8261b14: wchar cleanup - get libcpp compiling [Phillip Johnston]
  • 1af9257: printf formatting update [Phillip Johnston]
  • eb636c3: libc build cleanup - get libcpp compiling [Phillip Johnston]
  • be5c0e3: Fix warnings in printf.c [Phillip Johnston]
  • 32fe0f1: Add placeholder functions for eabi_atexit [Phillip Johnston]
  • 802f49e: First-pass at some exit functions [Phillip Johnston]
  • eb00919: Fix new string warnings [Phillip Johnston]
  • 0ecdf17: Format exit code [Phillip Johnston]
  • 3bfd41a: Fix warning in strerror.c [Phillip Johnston]
  • f00c884: Format arch/ code [Phillip Johnston]
  • 7a9f2c9: Documentation note [Phillip Johnston]
  • 34f6813: wchar header cleanup [Phillip Johnston]
  • 5b666be: printf formatting [Phillip Johnston]
  • 1fdc1b5: Build file update - add exit files [Phillip Johnston]
  • fc04b5e: Add ccc support (via lizard) to libc [Phillip Johnston]

Last 75 of output:

[...truncated 14.70 KB...]
- `acb8da6`: Advance build subpointer [Phillip Johnston]
- `85ccacf`: Advance build submodule [Phillip Johnston]
- `c91adba`: Remove -lm [Phillip Johnston]
- `116a882`: First-pass STDIO implementation. Just uses printf.h definitions. [Phillip Johnston]
- `e51efeb`: Always build a libc native and link with the tests [Phillip Johnston]
- `224c713`: Add note for native library on missing stdio files [Phillip Johnston]
- `1fd6c38`: Add xlsx files to git-lfs [Phillip Johnston]
- `d35e9f6`: Start software inventory for libc [Phillip Johnston]
- `8c82b11`: Update to the latest build submodule [Phillip Johnston]
- `43dd9a9`: Track printf license [Phillip Johnston]
- `0f13fd2`: Fix warnings in rand test code [Phillip Johnston]
- `4670878`: Add first-pass float.h support [Phillip Johnston]
- `41458b6`: Add first-pass math.h support for fabs, fabsf (used to fix warnings in [Phillip Johnston]
- `93e3b33`: Start aarch64 arch folder [Phillip Johnston]
- `f385ce5`: Add float to arm arch [Phillip Johnston]
- `1f05cd5`: Fix warnings in libc tests [Phillip Johnston]
- `0835c2b`: Formatting updates for include [Phillip Johnston]
- `32810cf`: Formatting update for arch folder [Phillip Johnston]
- `16338b3`: math formatting update [Phillip Johnston]
- `be63fd1`: Fix header include build error [Phillip Johnston]
- `71fb226`: Add a meson dependency for the native library [Phillip Johnston]
- `e222e75`: Fix warnings in qsort [Phillip Johnston]
- `fb410fa`: Fix warnings in fls* [Phillip Johnston]
- `8bcb3a4`: Fix strtok warning [Phillip Johnston]
- `de4b22d`: Fix srnstr warning [Phillip Johnston]
- `8486bbc`: Fix warning (and stupid implementation) in strncmp [Phillip Johnston]
- `dc2d2c7`: Split strtol, stroul and fix warnings [Phillip Johnston]
- `c25175a`: Fix warnings in string functions [Phillip Johnston]
- `a170f6a`: Fix warnings in stdlib functions [Phillip Johnston]
- `076f758`: libc build update [Phillip Johnston]
- `7817767`: use latest gdtoa - no warnings [Phillip Johnston]
- `d19658e`: Add wchar type to arch folder [Phillip Johnston]
- `bb60ef6`: First-pass wide character support (libcpp requires) [Phillip Johnston]
- `93bd6e9`: Add wchar to build [Phillip Johnston]
- `4aef656`: Fix warnings in wchar code [Phillip Johnston]
- `61f041e`: Add basic assert implementation [Phillip Johnston]
- `4cff61c`: Add basic errno implementation (gets libcpp code compiling, but errno [Phillip Johnston]
- `1d7be66`: stdlib WIP: get libcpp compiling, not all symbols link [Phillip Johnston]
- `4eba91f`: Define additional string functions required by libcpp [Phillip Johnston]
- `72dbb1c`: Define bare-metal putchar and puts implementations. Add additional stdio [Phillip Johnston]
- `8261b14`: wchar cleanup - get libcpp compiling [Phillip Johnston]
- `1af9257`: printf formatting update [Phillip Johnston]
- `eb636c3`: libc build cleanup - get libcpp compiling [Phillip Johnston]
- `be5c0e3`: Fix warnings in printf.c [Phillip Johnston]
- `32fe0f1`: Add placeholder functions for eabi_atexit [Phillip Johnston]
- `802f49e`: First-pass at some exit functions [Phillip Johnston]
- `eb00919`: Fix new string warnings [Phillip Johnston]
- `0ecdf17`: Format exit code [Phillip Johnston]
- `3bfd41a`: Fix warning in strerror.c [Phillip Johnston]
- `f00c884`: Format arch/ code [Phillip Johnston]
- `7a9f2c9`: Documentation note [Phillip Johnston]
- `34f6813`: wchar header cleanup [Phillip Johnston]
- `5b666be`: printf formatting [Phillip Johnston]
- `1fdc1b5`: Build file update - add exit files [Phillip Johnston]
- `fc04b5e`: Add ccc support (via lizard) to libc [Phillip Johnston]

[Pipeline] slackSend
run slackstepsend, step null:false, desc :true
Slack Send Pipeline step configured values from global config - baseUrl: true, teamDomain: true, token: true, channel: true, color: false
[Pipeline] echo
Deleting temporary tag
[Pipeline] sh
[ea-nightly_libc_master-MTVIUQJOZBC7SDBFGUQSYP25Z67VD5GU7NRZ6ZAJCNBHKOTTDYFQ] Running shell script
+ git tag -d 0.1.24
error: tag '0.1.24' not found.
[Pipeline] sh
[ea-nightly_libc_master-MTVIUQJOZBC7SDBFGUQSYP25Z67VD5GU7NRZ6ZAJCNBHKOTTDYFQ] Running shell script
+ git config --get remote.origin.url
[Pipeline] readFile
[Pipeline] echo
Creating a GitHubPluginConfig for credential 4c01f168-ca25-483e-bc6d-8d105fc5fb70
[Pipeline] echo
Registering GithubProjectProperty for repo URL https://github.com/embeddedartistry/libc
[Pipeline] properties

Add definitions for stdint

Defined in header 

Signed integers : minimum value
INT8_MININT16_MININT32_MININT64_MIN | minimum value of an object of type int8_t, int16_t, int32_t, int64_t  (macro constant)
INT_FAST8_MININT_FAST16_MININT_FAST32_MININT_FAST64_MIN | minimum value of an object of type int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t  (macro constant)
INT_LEAST8_MININT_LEAST16_MININT_LEAST32_MININT_LEAST64_MIN | minimum value of an object of type int_least8_t, int_least16_t, int_least32_t, int_least64_t  (macro constant)
INTPTR_MIN | minimum value of an object of type intptr_t  (macro constant)
INTMAX_MIN | minimum value of an object of type intmax_t  (macro constant)
Signed integers : maximum value
INT8_MAXINT16_MAXINT32_MAXINT64_MAX | maximum value of an object of type int8_t, int16_t, int32_t, int64_t  (macro constant)
INT_FAST8_MAXINT_FAST16_MAXINT_FAST32_MAXINT_FAST64_MAX | maximum value of an object of type int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t  (macro constant)
INT_LEAST8_MAXINT_LEAST16_MAXINT_LEAST32_MAXINT_LEAST64_MAX | maximum value of an object of type int_least8_t, int_least16_t, int_least32_t, int_least64_t  (macro constant)
INTPTR_MAX | maximum value of an object of type intptr_t  (macro constant)
INTMAX_MAX | maximum value of an object of type intmax_t  (macro constant)
Unsigned integers : maximum value
UINT8_MAXUINT16_MAXUINT32_MAXUINT64_MAX | maximum value of an object of type uint8_t, uint16_t, uint32_t, uint64_t  (macro constant)
UINT_FAST8_MAXUINT_FAST16_MAXUINT_FAST32_MAXUINT_FAST64_MAX | maximum value of an object of type uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t  (macro constant)
UINT_LEAST8_MAXUINT_LEAST16_MAXUINT_LEAST32_MAXUINT_LEAST64_MAX | maximum value of an object of type uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t  (macro constant)
UINTPTR_MAX | maximum value of an object of type uintptr_t  (macro constant)
UINTMAX_MAX | maximum value of an object of type uintmax_t  (macro constant)

Resolve complexity failures, then add complexity step to Jenkins build

stage('Complexity')
    {
      steps
      {
        sh 'make ccc'
      }
      post
      {
        success
        {
          setGithubStatus('continuous-integration/jenkins/complexity', 'Code meets complexity standards', 'SUCCESS')
        }
        failure
        {
          setGithubStatus('continuous-integration/jenkins/complexity', 'Code fails to meet complexity standards', 'FAILURE')
        }
      }
    }

ea-nightly/libc/master: #29 Failed

Build ea-nightly/libc/master #29 Failed

View full output

Change log:

  • 9a9df64: Relocate Jenkinsfiles from docs -> tools [Phillip Johnston]
  • 28f0fc0: Make docs in libc CI build [Phillip Johnston]
  • 2fc3f35: Register libc tests with meson [Phillip Johnston]
  • 688ad53: Complete conversion to meson for running the test sequence [Phillip Johnston]
  • de99c55: Update jenkinsfiles with new test location [Phillip Johnston]
  • 0575232: Update tests [Phillip Johnston]

Last 75 of output:

[...truncated 6.88 KB...]
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Setup)
[Pipeline] echo
Creating temporary tag
[Pipeline] sh
[ea-nightly_libc_master-MTVIUQJOZBC7SDBFGUQSYP25Z67VD5GU7NRZ6ZAJCNBHKOTTDYFQ] Running shell script
+ git tag -a 0.1.29 -m 'Creating tag to build 0.1.29'
[Pipeline] echo
Removing existing build results
[Pipeline] sh
[ea-nightly_libc_master-MTVIUQJOZBC7SDBFGUQSYP25Z67VD5GU7NRZ6ZAJCNBHKOTTDYFQ] Running shell script
+ make purify
Removing Build Output
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] sh
[ea-nightly_libc_master-MTVIUQJOZBC7SDBFGUQSYP25Z67VD5GU7NRZ6ZAJCNBHKOTTDYFQ] Running shell script
+ make
make: meson: No such file or directory
make: *** [groundwork] Error 1
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test)
Stage "Test" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Documentation)
Stage "Documentation" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Archive)
Stage "Archive" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] warnings
[WARNINGS] Skipping publisher since build result is FAILURE
[Pipeline] openTasks
[TASKS] Skipping publisher since build result is FAILURE
[Pipeline] echo
Sending slack message: <http://136.24.14.137:12345/job/ea-nightly/job/libc/job/master/29/display/redirect|ea-nightly/libc/master #29>: *FAILED*
Changes:
- `9a9df64`: Relocate Jenkinsfiles from docs -> tools [Phillip Johnston]
- `28f0fc0`: Make docs in libc CI build [Phillip Johnston]
- `2fc3f35`: Register libc tests with meson [Phillip Johnston]
- `688ad53`: Complete conversion to meson for running the test sequence [Phillip Johnston]
- `de99c55`: Update jenkinsfiles with new test location [Phillip Johnston]
- `0575232`: Update tests [Phillip Johnston]

[Pipeline] slackSend
run slackstepsend, step null:false, desc :true
Slack Send Pipeline step configured values from global config - baseUrl: true, teamDomain: true, token: true, channel: true, color: false
[Pipeline] echo
Deleting temporary tag
[Pipeline] sh
[ea-nightly_libc_master-MTVIUQJOZBC7SDBFGUQSYP25Z67VD5GU7NRZ6ZAJCNBHKOTTDYFQ] Running shell script
+ git tag -d 0.1.29
Deleted tag '0.1.29' (was ba8817a)
[Pipeline] sh
[ea-nightly_libc_master-MTVIUQJOZBC7SDBFGUQSYP25Z67VD5GU7NRZ6ZAJCNBHKOTTDYFQ] Running shell script
+ git config --get remote.origin.url
[Pipeline] readFile
[Pipeline] echo
Creating a GitHubPluginConfig for credential 4c01f168-ca25-483e-bc6d-8d105fc5fb70
[Pipeline] echo
Registering GithubProjectProperty for repo URL https://github.com/embeddedartistry/libc
[Pipeline] properties

ea-nightly/libc/master: #34 Failed

Build ea-nightly/libc/master #34 Failed

View full output

Change log:

  • 4f4f0b0: Add /usr/local/include to test build to address scan-build warnings [Phillip Johnston]
  • aade2c1: Add clang analysis build step, warnings parsing, todo parsing, and [Phillip Johnston]

Last 75 of output:

[...truncated 71.48 KB...]
[327/350] Compiling C object 'src/src@@@c_native@sta/string_strstr.c.o'.
[328/350] Compiling C object 'src/src@@@c_native@sta/string_strncat.c.o'.
[329/350] Compiling C object 'src/src@@@c_native@sta/string_strncmp.c.o'.
[330/350] Compiling C object 'src/src@@@c_native@sta/string_strlen.c.o'.
[331/350] Compiling C object 'src/src@@@c_native@sta/stdlib_strtoll.c.o'.
[332/350] Compiling C object 'src/src@@@c_native@sta/string_strncpy.c.o'.
[333/350] Compiling C object 'src/src@@@c_native@sta/string_strndup.c.o'.
[334/350] Compiling C object 'src/src@@@c_native@sta/string_strnlen.c.o'.
[335/350] Compiling C object 'src/src@@@c_native@sta/string_strnstr.c.o'.
[336/350] Compiling C object 'src/src@@@c_native@sta/string_strpbrk.c.o'.
[337/350] Compiling C object 'src/src@@@c_native@sta/string_strrchr.c.o'.
[338/350] Compiling C object 'src/src@@@c_native@sta/string_strspn.c.o'.
[339/350] Compiling C object 'src/src@@@c_native@sta/string_strtok.c.o'.
[340/350] Compiling C object 'src/src@@@c_native@sta/support_flsl.c.o'.
[341/350] Compiling C object 'src/src@@@c_native@sta/string_strxfrm.c.o'.
[342/350] Compiling C object 'src/src@@@c_native@sta/support_fls.c.o'.
[343/350] Compiling C object 'src/src@@@c_native@sta/wchar_iswalnum.c.o'.
[344/350] Compiling C object 'src/src@@@c_native@sta/support_flsll.c.o'.
[345/350] Compiling C object 'src/src@@@c_native@sta/wchar_iswblank.c.o'.
[346/350] Compiling C object 'src/src@@@c_native@sta/wchar_iswalpha.c.o'.
[347/350] Compiling C object 'src/src@@@c_native@sta/stdlib_strtoul.c.o'.
[348/350] Compiling C object 'src/src@@@c_native@sta/stdlib_strtoull.c.o'.
[349/350] Linking static target src/libc_native.a.
[350/350] Linking target test/libc_test.
ld: warning: option -prebind is obsolete and being ignored
scan-build: 13 bugs found.
scan-build: Run 'scan-view /Users/pjohnston/.jenkins/workspace/ea-nightly_libc_master-MTVIUQJOZBC7SDBFGUQSYP25Z67VD5GU7NRZ6ZAJCNBHKOTTDYFQ/buildresults/meson-logs/scanbuild/2018-09-20-095720-13212-1' to examine bug reports.
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (ScanWorkspace)
[Pipeline] step
[WARNINGS] Parsing warnings in console log with parser Clang (LLVM based)
Skipping warnings blame since pipelines do not have an SCM link.%n
[WARNINGS] Computing warning deltas based on reference build #30
[WARNINGS] Plug-in Result: Failed - <a href="warningsResult/new">13 new warnings</a> exceed the threshold of 5 by 8
[Pipeline] openTasks
[TASKS] Skipping publisher since build result is FAILURE
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Archive)
[Pipeline] echo
Archiving artifacts
[Pipeline] archiveArtifacts
Archiving artifacts
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] echo
Sending slack message: <http://136.24.14.137:12345/job/ea-nightly/job/libc/job/master/34/display/redirect|ea-nightly/libc/master #34>: *FAILED*
Changes:
- `4f4f0b0`: Add /usr/local/include to test build to address scan-build warnings [Phillip Johnston]
- `aade2c1`: Add clang analysis build step, warnings parsing, todo parsing, and [Phillip Johnston]

[Pipeline] slackSend
run slackstepsend, step null:false, desc :true
Slack Send Pipeline step configured values from global config - baseUrl: true, teamDomain: true, token: true, channel: true, color: false
[Pipeline] echo
Deleting temporary tag
[Pipeline] sh
[ea-nightly_libc_master-MTVIUQJOZBC7SDBFGUQSYP25Z67VD5GU7NRZ6ZAJCNBHKOTTDYFQ] Running shell script
+ git tag -d 0.1.34
Deleted tag '0.1.34' (was ee87e00)
[Pipeline] sh
[ea-nightly_libc_master-MTVIUQJOZBC7SDBFGUQSYP25Z67VD5GU7NRZ6ZAJCNBHKOTTDYFQ] Running shell script
+ git config --get remote.origin.url
[Pipeline] readFile
[Pipeline] echo
Creating a GitHubPluginConfig for credential 4c01f168-ca25-483e-bc6d-8d105fc5fb70
[Pipeline] echo
Registering GithubProjectProperty for repo URL https://github.com/embeddedartistry/libc
[Pipeline] properties

Add unit test for bsearch

The bsearch function has a test file (test/stdlib/bsearch.c), but no test have been written for it.

I would like to see similar tests performed as are performed in qsort. You can reuse the existing data sets and comparison functions for this tests. The sorted versions of the data are not needed. This is because bsearch does not sort, just tries to find the match.

The test functions would check different types (string, integer, char, etc.) similar to how the qsort tests work. But the difference is that you are trying to find a value in the input data set.

Tests should confirm:

  • you can specify a value in the dataset, have bsearch succeed and return a pointer to the proper element. Then, you would check that the returned pointer points to the proper element in the array.
  • you can specify a value NOT in the dataset, have bsearch return NULL

Reference for bsearch: https://en.cppreference.com/w/c/algorithm/bsearch

comparison function which returns ​a negative integer value if the first argument is less than the second, a positive integer value if the first argument is greater than the second and zero if the arguments are equivalent. key is passed as the first argument, an element from the array as the second.
The signature of the comparison function should be equivalent to the following:
int cmp(const void *a, const void *b);
The function must not modify the objects passed to it and must return consistent results when called for the same objects, regardless of their positions in the array.

Add a compile-time option to remove unsupported APIs

We need to include some API definitions which we don't support in order for libcpp to compile and link with our libc.

We should have a compile-time option (and meson option) to disable the unsupported APIs.

Arch refactor/extension

Revisit the organization - what can be commonized? e.g. 32-bit ARM, 64-bit ARM

Add general headers to the arch options for PIC: PIC8, PIC16, PIC32, PIC24, etc.

size types and limits should be the same for each.

stdlib: exit/abort

#pragma mark - exits -

_Noreturn void abort (void);
int atexit (void () (void));
_Noreturn void exit (int);
_Noreturn void _Exit (int);
int at_quick_exit (void () (void));
_Noreturn void quick_exit (int);

Add nullability specifiers to functions

_Nonnull
_Nullable

../include/stdlib.h:354:51: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
long long strtoll(const char* __restrict str, char** __restrict str_end, int base);
                                                  ^
../include/stdlib.h:354:51: note: insert '_Nullable' if the pointer may be null
long long strtoll(const char* __restrict str, char** __restrict str_end, int base);
                                                  ^
                                                   _Nullable
../include/stdlib.h:354:51: note: insert '_Nonnull' if the pointer should never be null
long long strtoll(const char* __restrict str, char** __restrict str_end, int base);
                                                  ^
                                                   _Nonnull

Test thunk param in qsort_r/heapsort_r

Currently, qsort_r, and heapsort_r test code sets thunk to NULL. A new test function should be added to both of these test suites (test/stdlib/qsort_r.c, test/stdlib/heapsort_r.c) that tests thunk with a non-null value, ensuring the value supplied to the comparison function is the same as what was passed in.

The strategy I can think of for testing this:

  1. Create a file-global static variable, like input_thunk
  2. Set the input_thunk to a non-zero value (e.g., 0xDEADBEEF)
  3. Create a copy of one of the comparison/sorting functions (e.g., icmp). In this new comparison, you will add a check that thunk (the input parameter) matches the value of input_thunk
  4. Create a new test function (e.g., based on heapsort_r_int_test), supply input_thunk as the thunk parameter, and use your new comparison function in place of the previous one (e.g., icmp_thunk_check instead of icmp)
  5. Register the new test with the existing test code

The same basic test strategy

Here is documentation regarding thunk:

The qsort_r() function behaves identically to qsort(), except that it
takes an additional argument, thunk, which is passed unchanged as the
first argument to function pointed to compar. This allows the comparison
function to access additional data without using global variables, and
thus qsort_r() is suitable for use in functions which must be reentrant.
The qsort_b() function behaves identically to qsort(), except that it
takes a block, rather than a function pointer.

Add proper tests for div, ldiv, imaxdiv

There are four division functions:

  • div
  • ldiv
  • lldiv
  • imaxdiv

Currently, we only have tests that cover lldiv (test/stdlib/lldiv.c). The tests for div are simply a copy of lldiv, and not really testing div(). ldiv and imax div are untested altogether.

To test the other functions, we essentially need to copy the method used to test lldiv.c, but adjust the types and table definitions.

  • div needs to have int type in the table
  • ldiv needs to have long type in the table
  • imaxdiv needs to have intmax_t type in the table

The values in lldiv can be repurposed to test out imaxdiv, but the suffix of "ull" will need to be changed to "ll" in that file. But new tables of values will need to be generated for div and ldiv.

For div and ldiv, you will need to create a new table that has numbers x, y, and the corresponding div and mod values. Make sure to pick a range of big and small values. The table does not have to be as comprehensive as what exists for lldiv.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.