summaryrefslogtreecommitdiff
path: root/libcr
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-21 23:51:38 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-23 13:56:38 -0700
commit0615af6f4748e4f7dc6a4f034a9db636742cc3bd (patch)
treea0c09720ca4c8670869b56d03e57431b46073f75 /libcr
parent3064cb13577edd31d3a3ceb79b2bc72314ec208b (diff)
Use C23 (C++11) attribute syntax instead of __attribute__
Diffstat (limited to 'libcr')
-rw-r--r--libcr/coroutine.c22
-rw-r--r--libcr/include/libcr/coroutine.h6
2 files changed, 14 insertions, 14 deletions
diff --git a/libcr/coroutine.c b/libcr/coroutine.c
index cb872b0..c935c22 100644
--- a/libcr/coroutine.c
+++ b/libcr/coroutine.c
@@ -48,8 +48,8 @@
/*
* Portability notes:
*
- * - It uses GCC `__attribute__`s, and the GNUC ({ ... }) statement
- * exprs extension.
+ * - It uses GCC `gnu::` attributes, and the GNUC `({ ... })`
+ * statement exprs extension.
*
* - It has a small bit of platform-specific code in the "platform
* support" section. Other than this, it should be portable to
@@ -122,7 +122,7 @@
* no longer exists.
*/
-#define ALWAYS_INLINE inline __attribute__((always_inline))
+#define ALWAYS_INLINE [[gnu::always_inline]] inline
/* platform support ***********************************************************/
@@ -130,7 +130,7 @@
* able to run it on my x86-64 GNU/Linux laptop is useful for debugging. */
#define CR_PLAT_STACK_ALIGNMENT \
- ({ __attribute__((aligned)) void fn(void) {}; __alignof__(fn); })
+ ({ [[gnu::aligned]] void fn(void) {}; __alignof__(fn); })
#if 0
{ /* bracket to get Emacs indentation to work how I want */
@@ -197,7 +197,7 @@
);
return isr_number != 0;
}
- static ALWAYS_INLINE bool _cr_plat_are_interrupts_enabled(void) {
+ ALWAYS_INLINE static bool _cr_plat_are_interrupts_enabled(void) {
assert(!cr_is_in_intrhandler());
uint32_t primask;
asm volatile ("mrs %0, PRIMASK"
@@ -206,7 +206,7 @@
return primask == 0;
}
- static ALWAYS_INLINE void cr_plat_wait_for_interrupt(void) {
+ ALWAYS_INLINE static void cr_plat_wait_for_interrupt(void) {
assert(!cr_is_in_intrhandler());
assert(!_cr_plat_are_interrupts_enabled());
asm volatile ("wfi\n"
@@ -236,7 +236,7 @@
#define CR_PLAT_STACK_GROWS_DOWNWARD 1
#if CONFIG_COROUTINE_MEASURE_STACK
- static ALWAYS_INLINE uintptr_t cr_plat_get_sp(void) {
+ ALWAYS_INLINE static uintptr_t cr_plat_get_sp(void) {
uintptr_t sp;
asm volatile ("mov %0, sp":"=r"(sp));
return sp;
@@ -268,7 +268,7 @@
#define CR_PLAT_STACK_GROWS_DOWNWARD 1
#if CONFIG_COROUTINE_MEASURE_STACK
- static ALWAYS_INLINE uintptr_t cr_plat_get_sp(void) {
+ ALWAYS_INLINE static uintptr_t cr_plat_get_sp(void) {
uintptr_t sp;
asm volatile ("movq %%rsp, %0":"=r"(sp));
return sp;
@@ -459,7 +459,7 @@ static inline void assert_cid(cid_t cid) {
/* coroutine_add() ************************************************************/
cid_t coroutine_add_with_stack_size(size_t stack_size,
- const char __attribute__((unused)) *name,
+ const char [[gnu::unused]] *name,
cr_fn_t fn, void *args) {
static cid_t last_created = 0;
cid_t parent = coroutine_running;
@@ -537,7 +537,7 @@ cid_t coroutine_add(const char *name, cr_fn_t fn, void *args) {
/* coroutine_main() ***********************************************************/
-__attribute__ ((noreturn)) void coroutine_main(void) {
+[[noreturn]] void coroutine_main(void) {
debugf("coroutine_main()");
bool saved = cr_save_and_disable_interrupts();
assert(saved);
@@ -626,7 +626,7 @@ void cr_pause_and_yield(void) {
cr_restore_interrupts(saved);
}
-__attribute__ ((noreturn)) void cr_exit(void) {
+[[noreturn]] void cr_exit(void) {
debugf("cid=%zu: cr_exit()", coroutine_running);
assert(!cr_is_in_intrhandler());
assert_cid_state(coroutine_running, state == CR_RUNNING);
diff --git a/libcr/include/libcr/coroutine.h b/libcr/include/libcr/coroutine.h
index dc51a0f..86b8452 100644
--- a/libcr/include/libcr/coroutine.h
+++ b/libcr/include/libcr/coroutine.h
@@ -68,7 +68,7 @@ typedef size_t cid_t;
* cr_rpc_*() and cr_chan_*() macros call these functions).
*/
typedef void (*cr_fn_t)(void *args);
-#define COROUTINE __attribute__ ((noreturn)) void
+#define COROUTINE __attribute__((noreturn)) void
/* managing coroutines ********************************************************/
@@ -95,14 +95,14 @@ cid_t coroutine_add(const char *name, cr_fn_t fn, void *args);
/**
* The main scheduler loop.
*/
-__attribute__ ((noreturn)) void coroutine_main(void);
+[[noreturn]] void coroutine_main(void);
/* inside of coroutines *******************************************************/
/** cr_begin() goes at the beginning of a coroutine, after it has initialized its stack. */
void cr_begin( void);
/** cr_exit() terminates the currently-running coroutine. */
-__attribute__ ((noreturn)) void cr_exit(void);
+[[noreturn]] void cr_exit(void);
/** cr_yield() switches to another coroutine (if there is another runnable coroutine to switch to). */
void cr_yield(void);
/** cr_pause_and_yield() marks the current coroutine as not-runnable and switches to another coroutine. */