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

Fix warnings from kill and getpid not being implemented #183

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions platform/source/mbed_retarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,10 @@ extern "C" WEAK void __cxa_pure_virtual(void)
// SP. This make it compatible with RTX RTOS thread stacks.
#if defined(TOOLCHAIN_GCC_ARM)

// Turn off the errno macro and use actual global variable instead.
#undef errno
extern "C" int errno;

#if defined(MBED_SPLIT_HEAP)

// Default RAM memory used for heap
Expand Down Expand Up @@ -1506,10 +1510,6 @@ extern "C" WEAK caddr_t _sbrk(int incr)
extern "C" uint32_t __end__;
extern "C" uint32_t __HeapLimit;

// Turn off the errno macro and use actual global variable instead.
#undef errno
extern "C" int errno;

// Weak attribute allows user to override, e.g. to use external RAM for dynamic memory.
extern "C" WEAK caddr_t _sbrk(int incr)
{
Expand All @@ -1529,6 +1529,27 @@ extern "C" WEAK caddr_t _sbrk(int incr)
#endif
#endif

#if defined(TOOLCHAIN_GCC_ARM)

// Implementation of getpid for Newlib, following signature here:
// https://github.com/bminor/newlib/blob/55485616ba2afedca05da40f5cde59ee336b9f28/newlib/libc/sys/arm/syscalls.c#L32
extern "C" pid_t _getpid()
{
// Since PIDs aren't a thing on embedded, just return 0
return 0;
}

// Implementation of kill for Newlib, following signature here:
// https://github.com/bminor/newlib/blob/55485616ba2afedca05da40f5cde59ee336b9f28/newlib/libc/sys/arm/syscalls.c#L33
extern "C" int _kill(int pid, int signal)
{
// Always return error
errno = ENOSYS;
return -1;
}

#endif

#if defined(TOOLCHAIN_GCC_ARM)
extern "C" void _exit(int return_code)
{
Expand Down
Loading