Changeset e0a4686 in mainline for uspace/lib/c/include/fibril.h


Ignore:
Timestamp:
2018-03-08T18:25:31Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
53ad43c, 615e83d
Parents:
fd57cf17
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-06 22:03:11)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-08 18:25:31)
Message:

Introduce context_swap() and use it to simplify fibril implementation.

This wraps the use of context_save()/context_restore(), to provide a more
natural (and easier to understand) control flow. The patch also hides the
details of the underlying context, requiring the use of context_get_pc()
to acquire program counter. This might allow context_swap() to only store
one pointer in the context, storing the remaining information in its stack
frame. However, that is not done in this patch.

File:
1 edited

Legend:

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

    rfd57cf17 re0a4686  
    3636#define LIBC_FIBRIL_H_
    3737
    38 #include <libarch/fibril.h>
     38#include <context.h>
    3939#include <types/common.h>
    4040#include <adt/list.h>
    4141#include <libarch/tls.h>
    42 
    43 #define context_set_generic(c, _pc, stack, size, ptls) \
    44         do { \
    45                 (c)->pc = (sysarg_t) (_pc); \
    46                 (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
    47                 (c)->tls = (sysarg_t) (ptls); \
    48         } while (0)
    4942
    5043#define FIBRIL_WRITER   1
     
    8679#define fibril_local __thread
    8780
    88 extern int context_save(context_t *ctx) __attribute__((returns_twice));
    89 extern void context_restore(context_t *ctx) __attribute__((noreturn));
    90 
    9181#define FIBRIL_DFLT_STK_SIZE    0
    9282
    93 #define fibril_create(func, arg) \
    94         fibril_create_generic((func), (arg), FIBRIL_DFLT_STK_SIZE)
    9583extern fid_t fibril_create_generic(errno_t (*func)(void *), void *arg, size_t);
    9684extern void fibril_destroy(fid_t fid);
     
    10391extern fid_t fibril_get_id(void);
    10492
     93static inline fid_t fibril_create(errno_t (*func)(void *), void *arg)
     94{
     95        return fibril_create_generic(func, arg, FIBRIL_DFLT_STK_SIZE);
     96}
     97
    10598static inline int fibril_yield(void)
    10699{
Note: See TracChangeset for help on using the changeset viewer.