Changeset 0b05082 in mainline for uspace/lib/c/include/tls.h


Ignore:
Timestamp:
2018-07-18T18:56:16Z (7 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
40abf56
Parents:
9b1baac
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-18 14:25:11)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-18 18:56:16)
Message:

Adds

  • tcb_raw_get(), which returns the value of the TP register without any offsets applied to it,
  • tcb_raw_set(), which does the opposite,
  • tcb_is_set(), which returns true iff the register is not NULL,
  • tcb_reset(), which sets the register to NULL.

Used for debug assertions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/tls.h

    r9b1baac r0b05082  
    3737
    3838#include <libarch/tls.h>
     39#include <stdbool.h>
    3940#include <stddef.h>
    4041#include <stdint.h>
     42
     43static inline void __tcb_reset(void)
     44{
     45        __tcb_raw_set(NULL);
     46}
     47
     48static inline void __tcb_set(tcb_t *tcb)
     49{
     50        __tcb_raw_set((uint8_t *)tcb + ARCH_TP_OFFSET);
     51}
     52
     53
     54static inline tcb_t *__tcb_get(void)
     55{
     56        return (tcb_t *)((uint8_t *)__tcb_raw_get() - ARCH_TP_OFFSET);
     57}
     58
     59/*
     60 * The TP register is supposed to be zero when the thread is first created
     61 * by the kernel. We use this for some debugging assertions.
     62 */
     63static inline bool __tcb_is_set(void)
     64{
     65        return __tcb_raw_get() != NULL;
     66}
    4167
    4268/** DTV Generation number - equals vector length */
Note: See TracChangeset for help on using the changeset viewer.