From 8398b2e2e4e3c72d8354b64db28fe02012fd59b3 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 15 Oct 2022 09:52:37 +0200 Subject: [PATCH] libc: Change bits/macros.h to use a __lc_ prefix for internal macros That way, we don't pollute user programs with our own 'noreturn' and 'deprecated' macros --- libs/libc/include/bits/macros.h | 6 +++--- libs/libc/include/luna.h | 2 +- libs/libc/include/stdlib.h | 4 ++-- libs/libc/include/string.h | 8 ++++---- libs/libc/include/unistd.h | 2 +- libs/libc/src/atexit.cpp | 2 +- libs/libc/src/luna.cpp | 2 +- libs/libc/src/stdlib.cpp | 2 +- libs/libc/src/unistd.cpp | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libs/libc/include/bits/macros.h b/libs/libc/include/bits/macros.h index 16ede7b4..886b7019 100644 --- a/libs/libc/include/bits/macros.h +++ b/libs/libc/include/bits/macros.h @@ -1,8 +1,8 @@ #ifndef _BITS_MACROS_H #define _BITS_MACROS_H -#define noreturn __attribute__((noreturn)) -#define align(n) __attribute__((aligned(n))) -#define deprecated(msg) __attribute__((deprecated(msg))) +#define __lc_noreturn __attribute__((noreturn)) +#define __lc_align(n) __attribute__((aligned(n))) +#define __lc_deprecated(msg) __attribute__((deprecated(msg))) #endif \ No newline at end of file diff --git a/libs/libc/include/luna.h b/libs/libc/include/luna.h index 648398f7..66df537a 100644 --- a/libs/libc/include/luna.h +++ b/libs/libc/include/luna.h @@ -16,7 +16,7 @@ extern "C" unsigned int msleep(unsigned int ms); /* Prints a message to standard error and aborts the program. */ - noreturn void __luna_abort(const char* message); + __lc_noreturn void __luna_abort(const char* message); #ifdef __cplusplus } diff --git a/libs/libc/include/stdlib.h b/libs/libc/include/stdlib.h index cde4fa34..a87fddb3 100644 --- a/libs/libc/include/stdlib.h +++ b/libs/libc/include/stdlib.h @@ -10,10 +10,10 @@ extern "C" #endif /* Aborts the program. */ - noreturn void abort(); + __lc_noreturn void abort(); /* Normally exits the program with the specified status code. */ - noreturn void exit(int status); + __lc_noreturn void exit(int status); /* Registers a handler function to be run at normal program termination. */ int atexit(void (*handler)(void)); diff --git a/libs/libc/include/string.h b/libs/libc/include/string.h index f7fef890..f8e94c17 100644 --- a/libs/libc/include/string.h +++ b/libs/libc/include/string.h @@ -22,8 +22,8 @@ extern "C" size_t strlen(const char* str); /* Copies the string src into dest. This function is unsafe, use strncpy instead. */ - deprecated("strcpy is unsafe and should not be used; use strncpy instead") char* strcpy(char* dest, - const char* src); + __lc_deprecated("strcpy is unsafe and should not be used; use strncpy instead") char* strcpy(char* dest, + const char* src); /* Copies at most max bytes from the string src into dest. */ char* strncpy(char* dest, const char* src, size_t max); @@ -32,8 +32,8 @@ extern "C" char* strchr(const char* str, int c); /* Concatenates the string src into dest. This function is unsafe, use strncat instead. */ - deprecated("strcat is unsafe and should not be used; use strncat instead") char* strcat(char* dest, - const char* src); + __lc_deprecated("strcat is unsafe and should not be used; use strncat instead") char* strcat(char* dest, + const char* src); /* Concatenates at most max bytes of the string src into dest. */ char* strncat(char* dest, const char* src, size_t max); diff --git a/libs/libc/include/unistd.h b/libs/libc/include/unistd.h index 27f8bcf0..cde368b0 100644 --- a/libs/libc/include/unistd.h +++ b/libs/libc/include/unistd.h @@ -25,7 +25,7 @@ extern "C" pid_t fork(void); /* Terminates the program with the status code status. */ - noreturn void _exit(int status); + __lc_noreturn void _exit(int status); /* Calls the kernel for a specific service, determined by number. */ long syscall(long number, ...); diff --git a/libs/libc/src/atexit.cpp b/libs/libc/src/atexit.cpp index 8df2a117..a27b81f2 100644 --- a/libs/libc/src/atexit.cpp +++ b/libs/libc/src/atexit.cpp @@ -17,7 +17,7 @@ extern "C" return 0; } - noreturn void exit(int status) + __lc_noreturn void exit(int status) { for (int i = 0; i < atexit_function_count; i++) { atexit_functions[i](); } _exit(status); diff --git a/libs/libc/src/luna.cpp b/libs/libc/src/luna.cpp index 6f760571..7c7af050 100644 --- a/libs/libc/src/luna.cpp +++ b/libs/libc/src/luna.cpp @@ -17,7 +17,7 @@ extern "C" return (unsigned int)syscall(SYS_sleep, ms); } - noreturn void __luna_abort(const char* message) + __lc_noreturn void __luna_abort(const char* message) { fputs(message, stderr); abort(); diff --git a/libs/libc/src/stdlib.cpp b/libs/libc/src/stdlib.cpp index f05cf891..eb5261f7 100644 --- a/libs/libc/src/stdlib.cpp +++ b/libs/libc/src/stdlib.cpp @@ -5,7 +5,7 @@ extern "C" { - noreturn void abort() + __lc_noreturn void abort() { _exit(-1); } diff --git a/libs/libc/src/unistd.cpp b/libs/libc/src/unistd.cpp index 21efc6ea..8c05f72a 100644 --- a/libs/libc/src/unistd.cpp +++ b/libs/libc/src/unistd.cpp @@ -96,7 +96,7 @@ extern "C" return syscall(SYS_seek, fd, offset, whence); } - noreturn void _exit(int status) + __lc_noreturn void _exit(int status) { syscall(SYS_exit, status); __builtin_unreachable();