Esempio n. 1
0
void dill_freestack(void *stack) {
    struct dill_ctx_stack *ctx = &dill_getctx->stack;
    struct dill_qlist *item = ((struct dill_qlist*)stack) - 1;
    /* If there are free slots in the cache put the stack to the cache. */
    if(ctx->count < dill_max_cached_stacks) {
        dill_qlist_push(&ctx->cache, item);
        ++ctx->count;
        return;
    }
    /* If the stack cache is full deallocate the stack. */
#if (HAVE_POSIX_MEMALIGN && HAVE_MPROTECT) & !defined DILL_NOGUARD
    void *ptr = ((uint8_t*)(item + 1)) - dill_stack_size - dill_page_size();
    int rc = mprotect(ptr, dill_page_size(), PROT_READ|PROT_WRITE);
    dill_assert(rc == 0);
    free(ptr);
#else
    void *ptr = ((uint8_t*)(item + 1)) - dill_stack_size;
    free(ptr);
#endif
}
Esempio n. 2
0
File: cr.c Progetto: jimjag/libdill
static void dill_resume(struct dill_cr *cr, int id, int err) {
    struct dill_ctx_cr *ctx = &dill_getctx->cr;
    cr->id = id;
    cr->err = err;
    dill_qlist_push(&ctx->ready, &cr->ready);
}