Skip to content

Commit 0de6475

Browse files
committed
tools/nolibc: add prototypes for non-static functions
With -Wmissing-prototypes the compiler will warn about non-static functions which don't have a prototype defined. This warning doesn't make much sense for nolibc itself but for user code it is still useful. To pacify the compiler add prototypes next to the function definitions, similar to how it is handled elsewhere in the kernel. Acked-by: Willy Tarreau <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Thomas Weißschuh <[email protected]>
1 parent 2014c95 commit 0de6475

File tree

6 files changed

+11
-0
lines changed

6 files changed

+11
-0
lines changed

tools/include/nolibc/arch-mips.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
})
180180

181181
/* startup code, note that it's called __start on MIPS */
182+
void __start(void);
182183
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector __start(void)
183184
{
184185
__asm__ volatile (

tools/include/nolibc/crt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
char **environ __attribute__((weak));
1111
const unsigned long *_auxv __attribute__((weak));
1212

13+
void _start(void);
1314
static void __stack_chk_init(void);
1415
static void exit(int);
1516

@@ -22,6 +23,7 @@ extern void (*const __init_array_end[])(int, char **, char**) __attribute__((wea
2223
extern void (*const __fini_array_start[])(void) __attribute__((weak));
2324
extern void (*const __fini_array_end[])(void) __attribute__((weak));
2425

26+
void _start_c(long *sp);
2527
__attribute__((weak,used))
2628
void _start_c(long *sp)
2729
{

tools/include/nolibc/signal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "sys.h"
1414

1515
/* This one is not marked static as it's needed by libgcc for divide by zero */
16+
int raise(int signal);
1617
__attribute__((weak,unused,section(".text.nolibc_raise")))
1718
int raise(int signal)
1819
{

tools/include/nolibc/stackprotector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* triggering stack protector errors themselves
1919
*/
2020

21+
void __stack_chk_fail(void);
2122
__attribute__((weak,used,noreturn,section(".text.nolibc_stack_chk")))
2223
void __stack_chk_fail(void)
2324
{
@@ -28,6 +29,7 @@ void __stack_chk_fail(void)
2829
for (;;);
2930
}
3031

32+
void __stack_chk_fail_local(void);
3133
__attribute__((weak,noreturn,section(".text.nolibc_stack_chk")))
3234
void __stack_chk_fail_local(void)
3335
{

tools/include/nolibc/stdlib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static __attribute__((unused)) char itoa_buffer[21];
3030
*/
3131

3232
/* must be exported, as it's used by libgcc for various divide functions */
33+
void abort(void);
3334
__attribute__((weak,unused,noreturn,section(".text.nolibc_abort")))
3435
void abort(void)
3536
{

tools/include/nolibc/string.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ int memcmp(const void *s1, const void *s2, size_t n)
3232
/* might be ignored by the compiler without -ffreestanding, then found as
3333
* missing.
3434
*/
35+
void *memmove(void *dst, const void *src, size_t len);
3536
__attribute__((weak,unused,section(".text.nolibc_memmove")))
3637
void *memmove(void *dst, const void *src, size_t len)
3738
{
@@ -56,6 +57,7 @@ void *memmove(void *dst, const void *src, size_t len)
5657

5758
#ifndef NOLIBC_ARCH_HAS_MEMCPY
5859
/* must be exported, as it's used by libgcc on ARM */
60+
void *memcpy(void *dst, const void *src, size_t len);
5961
__attribute__((weak,unused,section(".text.nolibc_memcpy")))
6062
void *memcpy(void *dst, const void *src, size_t len)
6163
{
@@ -73,6 +75,7 @@ void *memcpy(void *dst, const void *src, size_t len)
7375
/* might be ignored by the compiler without -ffreestanding, then found as
7476
* missing.
7577
*/
78+
void *memset(void *dst, int b, size_t len);
7679
__attribute__((weak,unused,section(".text.nolibc_memset")))
7780
void *memset(void *dst, int b, size_t len)
7881
{
@@ -124,6 +127,7 @@ char *strcpy(char *dst, const char *src)
124127
* thus itself, hence the asm() statement below that's meant to disable this
125128
* confusing practice.
126129
*/
130+
size_t strlen(const char *str);
127131
__attribute__((weak,unused,section(".text.nolibc_strlen")))
128132
size_t strlen(const char *str)
129133
{

0 commit comments

Comments
 (0)