Changeset 26a9388 in mainline for kernel/generic/include


Ignore:
Timestamp:
2026-01-29T15:20:01Z (4 days ago)
Author:
Martin Decky <martin@…>
Branches:
master
Children:
d1a551f, d98f43e
Parents:
c35cc8b
Message:

Use the stack pointer to derive CURRENT (if possible)

If provided by the compiler, use the builtin_stack_address()
intrinsic instead of
builtin_frame_address(0) to derive CURRENT.

This generally generates faster and shorter code. In cases where the
compiler does not maintain the frame pointer rountinely, it also does
not force the compiler to establish the stack frame for the current
function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/arch.h

    rc35cc8b r26a9388  
    4949 *
    5050 */
     51#if __has_builtin(__builtin_stack_address)
     52
     53#define CURRENT \
     54        ((current_t *) (((uintptr_t) __builtin_stack_address()) & \
     55            (~((uintptr_t) STACK_SIZE - 1))))
     56
     57#else
     58
    5159#define CURRENT \
    5260        ((current_t *) (((uintptr_t) __builtin_frame_address(0)) & \
    5361            (~((uintptr_t) STACK_SIZE - 1))))
     62
     63#endif
    5464
    5565#define MAGIC  UINT32_C(0xfacefeed)
Note: See TracChangeset for help on using the changeset viewer.