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

Add Support for Annex K functions according to C11 #13

Merged
merged 42 commits into from
Aug 18, 2024

Commits on Jul 30, 2024

  1. semihosting: reduce code duplication for calls with indirect arguments

    These functions make it easier to call the semihosting functions without
    having to declare a local struct in each caller.
    Since there is only one call with 4 indirect parameters, I did not add
    a sys_semihost4 wrapper.
    arichardson committed Jul 30, 2024
    Configuration menu
    Copy the full SHA
    1098984 View commit details
    Browse the repository at this point in the history
  2. strcmp optimization for riscv

    Optimize strcmp by calling orc.b (OR-Combine) instruction when Zbb extension
    is supported instead of 4 instructions to detect if zero byte is exist in word
    
    Signed-off-by: Mohamed Moawad <moawad@synopsys.com>
    M-Moawad authored and keith-packard committed Jul 30, 2024
    Configuration menu
    Copy the full SHA
    e71c602 View commit details
    Browse the repository at this point in the history
  3. Enable zbb extension in CI configuration

    Enable zbb extension in CI for RISC-V to test optimizations using bit manipulation instructions like `orc.b`. 
    This ensures that the strcmp optimization and other features using zbb are tested and validated
    
    Signed-off-by: Mohamed Moawad <moawad@synopsys.com>
    M-Moawad authored and keith-packard committed Jul 30, 2024
    Configuration menu
    Copy the full SHA
    61560a1 View commit details
    Browse the repository at this point in the history

Commits on Jul 31, 2024

  1. picocrt: Add an option to enable MMU (and caches)

    This is currently only implemented for Arm32 v7a where the CPU starts
    off with MMU disabled. This requires 8KB of page table memory, so there
    is an option to disable it if necessary.
    arichardson authored and keith-packard committed Jul 31, 2024
    Configuration menu
    Copy the full SHA
    5252f4d View commit details
    Browse the repository at this point in the history
  2. arm: Initialize all of the shadow SPs for non-M targets

    Non-M processors have a wealth of stack pointers, one for each
    interrupt entry point. As the only thing we're using the other entry
    points for in the sample code is to catch errors, we'll just smash
    the same stack for every one.
    
    This allows us to stop setting the SP in the vectors themselves which
    trashed one of the saved register values.
    
    This is mixed in with code which uses ARM mode exception vectors on
    'A' profile targets; attempting to set the TE bit on those doesn't
    seem to work on QEMU.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Jul 31, 2024
    Configuration menu
    Copy the full SHA
    b2d921a View commit details
    Browse the repository at this point in the history
  3. scripts: Split out non-'A' V7 arm targets in run-arm

    We need to distinguish between v7, v7-a and v7-r targets as the v7-r
    don't support the 32-bit ARM ISA and hence can't use ARM mode for
    exception handling, while the v7-a only seem to support ARM mode for
    exception handling.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Jul 31, 2024
    Configuration menu
    Copy the full SHA
    2740e4f View commit details
    Browse the repository at this point in the history

Commits on Aug 1, 2024

  1. arm: Use aeabi_memcpy-armv7a.S on aligned targets, memcpy-armv7a on u…

    …naligned
    
    This seems like it got scrambled when merging newlib updates from arm.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    06abb65 View commit details
    Browse the repository at this point in the history
  2. picocrt: Set correct reason value in non-M arm exception handlers

    copy-paste programming error left them all using REASON_UNDEF. Also
    switch instruction to 'movs', which makes clang happy.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    64d0ff4 View commit details
    Browse the repository at this point in the history
  3. picocrt: Call thumb-1 stack setting function from non-naked function

    Clang doesn't let us do any regular C code from a naked function, so move
    all of the Thumb-1 stack pointer setup into a single function and call that
    from _cstart instead of _start.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    dd71126 View commit details
    Browse the repository at this point in the history
  4. scripts: Use arm926 for v5T targets too

    clang sticks 'v5T' into the CPU_arch tag instead of 'v5TE', so check
    for that value.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    e67e8b8 View commit details
    Browse the repository at this point in the history
  5. scripts: Add clang arm v7a thumb v5 sample scripts

    Allow these architectures to be tested
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    5a41939 View commit details
    Browse the repository at this point in the history
  6. .github: Disable testing on aarch64 targets for now

    These fail on current qemu which now checks memory access alignment
    when the MMU is disabled.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    8a9d58a View commit details
    Browse the repository at this point in the history
  7. .github: Test clang on arm v7a and arm 5 in thumb mode

    Make sure these two architectures work when using clang.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    c8a2a97 View commit details
    Browse the repository at this point in the history

Commits on Aug 2, 2024

  1. math/aarch64: Fix lrint/lround in ilp32 mode

    In this mode, longs are only 32 bits, so we need to use the 32-bit
    form of the fcvtzs instruction instead of the 64-bit form.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 2, 2024
    Configuration menu
    Copy the full SHA
    2ef817b View commit details
    Browse the repository at this point in the history

Commits on Aug 3, 2024

  1. aarch64: Fix up strcmp for ilp32

    The asm version was missing a check for LP64 causing it to also define
    the function.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    8686449 View commit details
    Browse the repository at this point in the history
  2. picocrt/aarch64: Enable MMU

    We need to enable the MMU so that unaligned access to normal memory
    doesn't trap. On aarch64, that's not too bad as we can create level-1
    block maps that cover 1GB apiece and then set up an 8GB virtual
    space. That means we only need 8 PTEs.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    343aead View commit details
    Browse the repository at this point in the history
  3. picocrt/aarch64: Add sample interrupt vector

    This provides for override-able interrupt handling at the cost of
    wasting all of the room provided for these functions in the interrupt
    table.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    594d11d View commit details
    Browse the repository at this point in the history
  4. picocrt/aarch64: Trap exceptions in semihost mode

    Handle exceptions in semihost mode so that we'll get useful data.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    a662ca1 View commit details
    Browse the repository at this point in the history
  5. test: Add invalid instruction for aarch64 to test-except

    Now that exceptions are trapped, make sure they work.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    b7bdbb8 View commit details
    Browse the repository at this point in the history
  6. scripts: Add aarch64-zephyr configuration script

    This uses the existing aarch64-zephyr cross compile file.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    2dc7540 View commit details
    Browse the repository at this point in the history
  7. .github: Re-enable aarch64 testing with linux toolchain

    Now that the MMU is enabled, testing can be turned back on.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    6b39d34 View commit details
    Browse the repository at this point in the history
  8. .github: Test aarch64 using zephyr toolchain

    Update the Zephyr SDK and add aarch64 bits
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    ee52287 View commit details
    Browse the repository at this point in the history

Commits on Aug 7, 2024

  1. tinystdio: handling "nan(n-sequence char)" by scanf() family & `s…

    …trtod()`
    
    Quoting from C standard part 7.19.6.2
    
    > `a,e,f,g` Matches an optionally signed floating-point number, infinity, or NaN, whose
    format is the same as expected for the subject sequence of the `strtod`
    function. The corresponding argument shall be a pointer to floating.
    
    Regarding `strtod`, quoting from C standard part 7.20.1.3
    
    > A character sequence `NAN` or `NAN(n-char-sequence)`, is interpreted as a quiet
    NaN, if supported in the return type, else like a subject sequence part that does not have
    the expected form; the meaning of the `n-char sequences` is implementation-defined.
    
    Signed-off-by: Abdallah Abdelhafeez (Abdallahs70)
    Abdallahs70 authored and keith-packard committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    eadb39b View commit details
    Browse the repository at this point in the history
  2. tinystdio: Reformat conv_flt change

    Make the new code match the old format
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    e434fa1 View commit details
    Browse the repository at this point in the history

Commits on Aug 8, 2024

  1. test: Place libc in link_args consistently

    To avoid depending on a .specs file, we can't let meson insert the
    libraries relative to the link_args by itself as the link_args end up
    after the libs, which breaks the printf/scanf symbol definitions.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    bf0b693 View commit details
    Browse the repository at this point in the history
  2. Don't use specs files when building tests

    The generated specs files reference installed versions of the library
    files.  If those are already present in the system, we may end up
    using them for things like #include_next. The existing compile and
    link args already provide all of the values which the .specs files
    want to add.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    a88bcb7 View commit details
    Browse the repository at this point in the history
  3. posix: Disable analyzer bounds checks for computematchjumps

    I couldn't figure out why it got confused about the bounds checking
    for pmatches.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    766eae1 View commit details
    Browse the repository at this point in the history
  4. tinystdio: Remove public header includes from stdio.h

    Keep stdio.h from making other standard symbols visible
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    c4b55b0 View commit details
    Browse the repository at this point in the history
  5. signal: Remove sys/signal.h, clean up signal.h

    Follow POSIX requirements for visible symbols by placing them all in
    signal.h and then cleaning that up to stop making other symbols
    visible.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    37f520a View commit details
    Browse the repository at this point in the history
  6. string: Remove sys/features from string.h

    sys/cdefs already includes this
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    4759097 View commit details
    Browse the repository at this point in the history
  7. include: Clean up errno.h (and sys/errno.h)

    move 'error_t' to argz.h and envz.h where it belongs.
    Get rid of __LINUX_ERRNO_EXTENSIONS__ -- C allows the library
    to define as many errno values as it likes.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    2f56cbd View commit details
    Browse the repository at this point in the history
  8. include: Clean up complex.h

    Move sys/cdefs include to the top of the file.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    e9aeef5 View commit details
    Browse the repository at this point in the history
  9. include: Remove unnecessary sys/config.h includes

    sys/config.h is included by sys/cdefs.h, which is included by
    every public header.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    3eac897 View commit details
    Browse the repository at this point in the history
  10. Remove internal source references to sys/cdefs.h

    This will be included by any public header, so the internal
    source files don't need to also include it.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    ea86a27 View commit details
    Browse the repository at this point in the history
  11. posix: Remove the entirely unused LC_COLLATE file support

    Not even newlib still supports any of this mechanism. Remove the
    collate.c file and eliminate all internal usage of __collate_load_error.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    a785772 View commit details
    Browse the repository at this point in the history
  12. test: semihost test needs POSIX limits for PATH_MAX

    PATH_MAX is a posix value, not a C value.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    025c2cf View commit details
    Browse the repository at this point in the history
  13. include: _POSIX_2_RE_DUP_MAX -> unistd.h. Mask POSIX limits.

    Make sure limits.h doesn't expose any non-C limits unless the
    application requests them.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    2f5f843 View commit details
    Browse the repository at this point in the history
  14. Move sys/fenv.h to machine/fenv.h

    This is a machine-specific file, not an OS specific file.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    38b527a View commit details
    Browse the repository at this point in the history
  15. sys/time.h: remove time_t declaration

    This is declared in sys/_timespec.h already, no need to duplicate it
    here.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    e2d144a View commit details
    Browse the repository at this point in the history
  16. include/math.h: Define FP_FMA*

    These are required by C.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    5a04e1c View commit details
    Browse the repository at this point in the history
  17. regex: Use RE_DUP_MAX instead of _POSIX2_RE_DUP_MAX

    _POSIX2_RE_DUP_MAX is the minimum acceptable value for any POSIX
    system while RE_DUP_MAX is the value supported by the library.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    keith-packard committed Aug 8, 2024
    Configuration menu
    Copy the full SHA
    29f1da4 View commit details
    Browse the repository at this point in the history

Commits on Aug 12, 2024

  1. Add Support for Annex K functions according to C11

    Adding an implementation of the bounds-checking C functions (as specified in Annex K of the C11 standard) to the PicoLibc.
    These functions lower the risk of introducing security vulnerabilities such as buffer overflows and format string vulnerabilities into your code by providing clear and easy-to-use interfaces.
    For each C function a secure alternate function ending in a "_s" postfix is provided (e.g., strcpy_s).
    Use of these functions is recommended by security experts and secure coding standards.
    
    also, Implemented unit tests for the Annex-K functions to ensure their corrctness.
    Covered various scenarios including normal operation, boundary conditions, and error handling.
    
    Signed-off-by: Mostafa Salman <mostafas@synopsys.com>
    mostafa-salmaan authored and keith-packard committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    1e23bb1 View commit details
    Browse the repository at this point in the history