Changeset b1d3c36 in mainline


Ignore:
Timestamp:
2010-02-04T16:51:36Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4cac2d69
Parents:
d32358f
Message:

small arch/generic interface cleanup:
context_set() should be always defined explicitly (either as a custom macro
or as a reference to context_set_generic()), using #undef and implicit macro
values can be rather confusing

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/abs32le/include/context.h

    rd32358f rb1d3c36  
    3939#define SP_DELTA         0
    4040
     41#define context_set(ctx, pc, stack, size) \
     42    context_set_generic(ctx, pc, stack, size)
     43
    4144/*
    4245 * On real hardware this stores the registers which
  • kernel/arch/ia64/include/context.h

    rd32358f rb1d3c36  
    4848 */
    4949#define SP_DELTA        (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    50 
    51 #ifdef context_set
    52 #undef context_set
    53 #endif
    5450
    5551/* RSE stack starts at the bottom of memory stack. */
  • kernel/arch/mips32/include/context.h

    rd32358f rb1d3c36  
    2727 */
    2828
    29 /** @addtogroup mips32 
     29/** @addtogroup mips32
    3030 * @{
    3131 */
     
    4242 * Put one item onto the stack to support get_stack_base() and align it up.
    4343 */
    44 #define SP_DELTA        (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    45 
     44#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    4645
    4746#ifndef __ASM__
    4847
    4948#include <arch/types.h>
     49
     50#define context_set(ctx, pc, stack, size) \
     51    context_set_generic(ctx, pc, stack, size)
    5052
    5153/*
  • kernel/arch/ppc32/include/context.h

    rd32358f rb1d3c36  
    2727 */
    2828
    29 /** @addtogroup ppc32   
     29/** @addtogroup ppc32
    3030 * @{
    3131 */
     
    3838#include <arch/types.h>
    3939
    40 #define SP_DELTA        16
     40#define SP_DELTA  16
     41
     42#define context_set(ctx, pc, stack, size) \
     43    context_set_generic(ctx, pc, stack, size)
    4144
    4245typedef struct {
     
    6871       
    6972        ipl_t ipl;
    70 } __attribute__ ((packed)) context_t;
     73} __attribute__((packed)) context_t;
    7174
    7275#endif
  • kernel/arch/sparc64/include/context.h

    rd32358f rb1d3c36  
    4242#define SP_DELTA        (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE)
    4343
    44 #ifdef context_set
    45 #undef context_set
    46 #endif
    47 
    4844#define context_set(c, _pc, stack, size)                        \
    4945        (c)->pc = ((uintptr_t) _pc) - 8;                        \
  • kernel/generic/include/context.h

    rd32358f rb1d3c36  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3939#include <arch/context.h>
    4040
     41#define context_set_generic(ctx, _pc, stack, size) \
     42        (ctx)->pc = (uintptr_t) (_pc); \
     43        (ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA;
    4144
    42 #ifndef context_set
    43 #define context_set(c, _pc, stack, size)        \
    44         (c)->pc = (uintptr_t) (_pc);            \
    45         (c)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA;
    46 #endif /* context_set */
    47 
    48 extern int context_save_arch(context_t *c) __attribute__ ((returns_twice));
    49 extern void context_restore_arch(context_t *c) __attribute__ ((noreturn));
     45extern int context_save_arch(context_t *ctx) __attribute__((returns_twice));
     46extern void context_restore_arch(context_t *ctx) __attribute__((noreturn));
    5047
    5148/** Save register context.
     
    7370 * saved like that would therefore lead to a disaster.
    7471 *
    75  * @param c             Context structure.
     72 * @param ctx Context structure.
    7673 *
    77  * @return              context_save() returns 1, context_restore() returns 0.
     74 * @return context_save() returns 1, context_restore() returns 0.
     75 *
    7876 */
    79 #define context_save(c)   context_save_arch(c)
     77#define context_save(ctx)  context_save_arch(ctx)
    8078
    8179/** Restore register context.
     
    8886 * being return value.
    8987 *
    90  * @param c             Context structure.
     88 * @param ctx Context structure.
    9189 */
    92 static inline void context_restore(context_t *c)
     90static inline void context_restore(context_t *ctx)
    9391{
    94         context_restore_arch(c);
     92        context_restore_arch(ctx);
    9593}
    9694
  • uspace/lib/libc/arch/ia64/include/fibril.h

    rd32358f rb1d3c36  
    5252/* Stack is divided into two equal parts (for memory stack and register stack). */
    5353#define PSTHREAD_INITIAL_STACK_DIVISION 2 
    54 
    55 #ifdef context_set
    56 #undef context_set
    57 #endif
    5854
    5955#define context_set(c, _pc, stack, size, tls)                                                           \
  • uspace/lib/libc/arch/sparc64/include/fibril.h

    rd32358f rb1d3c36  
    4242#define SP_DELTA        (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE)
    4343
    44 #ifdef context_set
    45 #undef context_set
    46 #endif
    47 
    4844#define context_set(c, _pc, stack, size, ptls) \
    4945        do { \
  • uspace/lib/libc/include/fibril.h

    rd32358f rb1d3c36  
    4040#include <libarch/tls.h>
    4141
    42 #ifndef context_set
    43 #define context_set(c, _pc, stack, size, ptls) \
     42#define context_set_generic(c, _pc, stack, size, ptls) \
    4443        (c)->pc = (sysarg_t) (_pc); \
    4544        (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
    4645        (c)->tls = (sysarg_t) (ptls);
    47 #endif /* context_set */
    4846
    49 #define FIBRIL_SERIALIZED       1
    50 #define FIBRIL_WRITER           2
     47#define FIBRIL_SERIALIZED  1
     48#define FIBRIL_WRITER      2
    5149
    5250typedef enum {
     
    5957typedef sysarg_t fid_t;
    6058
    61 struct fibril {
     59typedef struct fibril {
    6260        link_t link;
    6361        context_t ctx;
     
    7068        int retval;
    7169        int flags;
    72 };
    73 typedef struct fibril fibril_t;
     70} fibril_t;
    7471
    7572/** Fibril-local variable specifier */
    7673#define fibril_local __thread
    7774
    78 extern int context_save(context_t *c) __attribute__ ((returns_twice));
    79 extern void context_restore(context_t *c) __attribute__ ((noreturn));
     75extern int context_save(context_t *ctx) __attribute__((returns_twice));
     76extern void context_restore(context_t *ctx) __attribute__((noreturn));
    8077
    8178extern fid_t fibril_create(int (*func)(void *), void *arg);
     
    9087extern void fibril_dec_sercount(void);
    9188
    92 static inline int fibril_yield(void) {
     89static inline int fibril_yield(void)
     90{
    9391        return fibril_switch(FIBRIL_PREEMPT);
    9492}
Note: See TracChangeset for help on using the changeset viewer.