Skip to content

Commit 36506c9

Browse files
author
Jamie Smith
authored
Fix warnings from kill and getpid not being implemented (#183)
* Fix warnings from kill and getpid not being implemented * Fix comments
1 parent 264dbe2 commit 36506c9

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

platform/source/mbed_retarget.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,10 @@ extern "C" WEAK void __cxa_pure_virtual(void)
14641464
// SP. This make it compatible with RTX RTOS thread stacks.
14651465
#if defined(TOOLCHAIN_GCC_ARM)
14661466

1467+
// Turn off the errno macro and use actual global variable instead.
1468+
#undef errno
1469+
extern "C" int errno;
1470+
14671471
#if defined(MBED_SPLIT_HEAP)
14681472

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

1509-
// Turn off the errno macro and use actual global variable instead.
1510-
#undef errno
1511-
extern "C" int errno;
1512-
15131513
// Weak attribute allows user to override, e.g. to use external RAM for dynamic memory.
15141514
extern "C" WEAK caddr_t _sbrk(int incr)
15151515
{
@@ -1529,6 +1529,27 @@ extern "C" WEAK caddr_t _sbrk(int incr)
15291529
#endif
15301530
#endif
15311531

1532+
#if defined(TOOLCHAIN_GCC_ARM)
1533+
1534+
// Implementation of getpid for Newlib, following signature here:
1535+
// https://github.com/bminor/newlib/blob/55485616ba2afedca05da40f5cde59ee336b9f28/newlib/libc/sys/arm/syscalls.c#L32
1536+
extern "C" pid_t _getpid()
1537+
{
1538+
// Since PIDs aren't a thing on embedded, just return 0
1539+
return 0;
1540+
}
1541+
1542+
// Implementation of kill for Newlib, following signature here:
1543+
// https://github.com/bminor/newlib/blob/55485616ba2afedca05da40f5cde59ee336b9f28/newlib/libc/sys/arm/syscalls.c#L33
1544+
extern "C" int _kill(int pid, int signal)
1545+
{
1546+
// Always return error
1547+
errno = ENOSYS;
1548+
return -1;
1549+
}
1550+
1551+
#endif
1552+
15321553
#if defined(TOOLCHAIN_GCC_ARM)
15331554
extern "C" void _exit(int return_code)
15341555
{

0 commit comments

Comments
 (0)