[PATCH 2/3] powerpc/.../sbrk.c: Do not reference errno.

Gedare Bloom gedare at rtems.org
Fri May 28 02:28:02 UTC 2021


On Fri, May 21, 2021 at 3:36 PM Joel Sherrill <joel at rtems.org> wrote:
>
> Closes #4r37.
?

> ---
>  bsps/powerpc/shared/start/sbrk.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/bsps/powerpc/shared/start/sbrk.c b/bsps/powerpc/shared/start/sbrk.c
> index 95104ba9c8..d7507b3997 100644
> --- a/bsps/powerpc/shared/start/sbrk.c
> +++ b/bsps/powerpc/shared/start/sbrk.c
> @@ -150,9 +150,19 @@ void *sbrk(ptrdiff_t incr)
>      remaining_size-=incr;
>      rval = (void *) remaining_start;
>      remaining_start += incr;
> -  } else {
> -    errno = ENOMEM;

This may be a kind of API change that needs to be documented in
release notes for PPC users?

>    }
> +
> +  /*
> +   * sbrk() is a Legacy POSIX method which means it is no longer part of the
> +   * POSIX standard. Historically, it was required to set errno to ENOMEM if
> +   * the extension failed. This implementation does not do that for two
> +   * reasons. First, this method is only called from the RTEMS malloc()
> +   * implementation and does not expect errno to be set when -1 is returned.
> +   * Second, setting errno implicitly pulls in some of the newlib reentrancy
> +   * support. Not setting errno avoids this method forcing that support
> +   * into every application for every BSP that uses this method.
> +   */
> +
>    #ifdef DEBUG
>      printk("************* SBRK 0x%08x (ret 0x%08x) **********\n", incr, rval);
>    #endif
> --
> 2.24.4
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list