Adjust styles and indents
This commit is contained in:
parent
a027c4b5b0
commit
a036a8a038
54
cont.c
54
cont.c
@ -313,7 +313,8 @@ fiber_pool_vacancy_reset(struct fiber_pool_vacancy * vacancy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline static struct fiber_pool_vacancy *
|
inline static struct fiber_pool_vacancy *
|
||||||
fiber_pool_vacancy_push(struct fiber_pool_vacancy * vacancy, struct fiber_pool_vacancy * head) {
|
fiber_pool_vacancy_push(struct fiber_pool_vacancy * vacancy, struct fiber_pool_vacancy * head)
|
||||||
|
{
|
||||||
vacancy->next = head;
|
vacancy->next = head;
|
||||||
|
|
||||||
#ifdef FIBER_POOL_ALLOCATION_FREE
|
#ifdef FIBER_POOL_ALLOCATION_FREE
|
||||||
@ -327,36 +328,40 @@ fiber_pool_vacancy_push(struct fiber_pool_vacancy * vacancy, struct fiber_pool_v
|
|||||||
|
|
||||||
#ifdef FIBER_POOL_ALLOCATION_FREE
|
#ifdef FIBER_POOL_ALLOCATION_FREE
|
||||||
static void
|
static void
|
||||||
fiber_pool_vacancy_remove(struct fiber_pool_vacancy * vacancy) {
|
fiber_pool_vacancy_remove(struct fiber_pool_vacancy * vacancy)
|
||||||
|
{
|
||||||
if (vacancy->next) {
|
if (vacancy->next) {
|
||||||
vacancy->next->previous = vacancy->previous;
|
vacancy->next->previous = vacancy->previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vacancy->previous) {
|
if (vacancy->previous) {
|
||||||
vacancy->previous->next = vacancy->next;
|
vacancy->previous->next = vacancy->next;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// It's the head of the list:
|
// It's the head of the list:
|
||||||
vacancy->stack.pool->vacancies = vacancy->next;
|
vacancy->stack.pool->vacancies = vacancy->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static struct fiber_pool_vacancy *
|
inline static struct fiber_pool_vacancy *
|
||||||
fiber_pool_vacancy_pop(struct fiber_pool * pool) {
|
fiber_pool_vacancy_pop(struct fiber_pool * pool)
|
||||||
|
{
|
||||||
struct fiber_pool_vacancy * vacancy = pool->vacancies;
|
struct fiber_pool_vacancy * vacancy = pool->vacancies;
|
||||||
|
|
||||||
if (vacancy) {
|
if (vacancy) {
|
||||||
fiber_pool_vacancy_remove(vacancy);
|
fiber_pool_vacancy_remove(vacancy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vacancy;
|
return vacancy;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
inline static struct fiber_pool_vacancy *
|
inline static struct fiber_pool_vacancy *
|
||||||
fiber_pool_vacancy_pop(struct fiber_pool * pool) {
|
fiber_pool_vacancy_pop(struct fiber_pool * pool)
|
||||||
|
{
|
||||||
struct fiber_pool_vacancy * vacancy = pool->vacancies;
|
struct fiber_pool_vacancy * vacancy = pool->vacancies;
|
||||||
|
|
||||||
if (vacancy) {
|
if (vacancy) {
|
||||||
pool->vacancies = vacancy->next;
|
pool->vacancies = vacancy->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return vacancy;
|
return vacancy;
|
||||||
@ -394,7 +399,8 @@ fiber_pool_allocate_memory(size_t * count, size_t stride)
|
|||||||
|
|
||||||
if (!base) {
|
if (!base) {
|
||||||
*count = (*count) >> 1;
|
*count = (*count) >> 1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -403,7 +409,8 @@ fiber_pool_allocate_memory(size_t * count, size_t stride)
|
|||||||
|
|
||||||
if (base == MAP_FAILED) {
|
if (base == MAP_FAILED) {
|
||||||
*count = (*count) >> 1;
|
*count = (*count) >> 1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -466,9 +473,9 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
vacancies = fiber_pool_vacancy_initialize(
|
vacancies = fiber_pool_vacancy_initialize(
|
||||||
fiber_pool, vacancies,
|
fiber_pool, vacancies,
|
||||||
(char*)base + STACK_DIR_UPPER(0, RB_PAGE_SIZE),
|
(char*)base + STACK_DIR_UPPER(0, RB_PAGE_SIZE),
|
||||||
size
|
size
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef FIBER_POOL_ALLOCATION_FREE
|
#ifdef FIBER_POOL_ALLOCATION_FREE
|
||||||
@ -536,14 +543,15 @@ fiber_pool_allocation_free(struct fiber_pool_allocation * allocation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
VirtualFree(allocation->base, 0, MEM_RELEASE);
|
VirtualFree(allocation->base, 0, MEM_RELEASE);
|
||||||
#else
|
#else
|
||||||
munmap(allocation->base, allocation->stride * allocation->count);
|
munmap(allocation->base, allocation->stride * allocation->count);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (allocation->previous) {
|
if (allocation->previous) {
|
||||||
allocation->previous->next = allocation->next;
|
allocation->previous->next = allocation->next;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// We are the head of the list, so update the pool:
|
// We are the head of the list, so update the pool:
|
||||||
allocation->pool->allocations = allocation->next;
|
allocation->pool->allocations = allocation->next;
|
||||||
}
|
}
|
||||||
@ -598,7 +606,8 @@ fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) {
|
|||||||
// We advise the operating system that the stack memory pages are no longer being used.
|
// We advise the operating system that the stack memory pages are no longer being used.
|
||||||
// This introduce some performance overhead but allows system to relaim memory when there is pressure.
|
// This introduce some performance overhead but allows system to relaim memory when there is pressure.
|
||||||
static inline void
|
static inline void
|
||||||
fiber_pool_stack_free(struct fiber_pool_stack * stack) {
|
fiber_pool_stack_free(struct fiber_pool_stack * stack)
|
||||||
|
{
|
||||||
void * base = fiber_pool_stack_base(stack);
|
void * base = fiber_pool_stack_base(stack);
|
||||||
size_t size = stack->available;
|
size_t size = stack->available;
|
||||||
|
|
||||||
@ -619,7 +628,8 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack) {
|
|||||||
|
|
||||||
// Release and return a stack to the vacancy list.
|
// Release and return a stack to the vacancy list.
|
||||||
static void
|
static void
|
||||||
fiber_pool_stack_release(struct fiber_pool_stack * stack) {
|
fiber_pool_stack_release(struct fiber_pool_stack * stack)
|
||||||
|
{
|
||||||
struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(stack->base, stack->size);
|
struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(stack->base, stack->size);
|
||||||
|
|
||||||
if (DEBUG) fprintf(stderr, "fiber_pool_stack_release: %p used=%zu\n", stack->base, stack->pool->used);
|
if (DEBUG) fprintf(stderr, "fiber_pool_stack_release: %p used=%zu\n", stack->base, stack->pool->used);
|
||||||
@ -640,7 +650,8 @@ fiber_pool_stack_release(struct fiber_pool_stack * stack) {
|
|||||||
// Release address space and/or dirty memory:
|
// Release address space and/or dirty memory:
|
||||||
if (stack->allocation->used == 0) {
|
if (stack->allocation->used == 0) {
|
||||||
fiber_pool_allocation_free(stack->allocation);
|
fiber_pool_allocation_free(stack->allocation);
|
||||||
} else if (stack->pool->free_stacks) {
|
}
|
||||||
|
else if (stack->pool->free_stacks) {
|
||||||
fiber_pool_stack_free(stack);
|
fiber_pool_stack_free(stack);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -808,7 +819,7 @@ fiber_ptr(VALUE obj)
|
|||||||
NOINLINE(static VALUE cont_capture(volatile int *volatile stat));
|
NOINLINE(static VALUE cont_capture(volatile int *volatile stat));
|
||||||
|
|
||||||
#define THREAD_MUST_BE_RUNNING(th) do { \
|
#define THREAD_MUST_BE_RUNNING(th) do { \
|
||||||
if (!(th)->ec->tag) rb_raise(rb_eThreadError, "not running thread"); \
|
if (!(th)->ec->tag) rb_raise(rb_eThreadError, "not running thread"); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -886,7 +897,8 @@ cont_free(void *ptr)
|
|||||||
ruby_xfree(cont->saved_ec.vm_stack);
|
ruby_xfree(cont->saved_ec.vm_stack);
|
||||||
ruby_xfree(cont->ensure_array);
|
ruby_xfree(cont->ensure_array);
|
||||||
RUBY_FREE_UNLESS_NULL(cont->machine.stack);
|
RUBY_FREE_UNLESS_NULL(cont->machine.stack);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
rb_fiber_t *fiber = (rb_fiber_t*)cont;
|
rb_fiber_t *fiber = (rb_fiber_t*)cont;
|
||||||
coroutine_destroy(&fiber->context);
|
coroutine_destroy(&fiber->context);
|
||||||
if (!fiber_is_root_p(fiber)) {
|
if (!fiber_is_root_p(fiber)) {
|
||||||
@ -1311,7 +1323,7 @@ cont_restore_1(rb_context_t *cont)
|
|||||||
if (cont->machine.stack_src) {
|
if (cont->machine.stack_src) {
|
||||||
FLUSH_REGISTER_WINDOWS;
|
FLUSH_REGISTER_WINDOWS;
|
||||||
MEMCPY(cont->machine.stack_src, cont->machine.stack,
|
MEMCPY(cont->machine.stack_src, cont->machine.stack,
|
||||||
VALUE, cont->machine.stack_size);
|
VALUE, cont->machine.stack_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ruby_longjmp(cont->jmpbuf, 1);
|
ruby_longjmp(cont->jmpbuf, 1);
|
||||||
|
3
hash.c
3
hash.c
@ -564,7 +564,8 @@ hash_ar_table_set(VALUE hash, ar_table *ar)
|
|||||||
#define RHASH_AR_TABLE_SIZE_INC(h) HASH_AR_TABLE_SIZE_ADD(h, 1)
|
#define RHASH_AR_TABLE_SIZE_INC(h) HASH_AR_TABLE_SIZE_ADD(h, 1)
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
RHASH_AR_TABLE_SIZE_DEC(VALUE h) {
|
RHASH_AR_TABLE_SIZE_DEC(VALUE h)
|
||||||
|
{
|
||||||
HASH_ASSERT(RHASH_AR_TABLE_P(h));
|
HASH_ASSERT(RHASH_AR_TABLE_P(h));
|
||||||
int new_size = RHASH_AR_TABLE_SIZE(h) - 1;
|
int new_size = RHASH_AR_TABLE_SIZE(h) - 1;
|
||||||
|
|
||||||
|
3
node.h
3
node.h
@ -138,7 +138,8 @@ typedef struct rb_code_location_struct {
|
|||||||
rb_code_position_t end_pos;
|
rb_code_position_t end_pos;
|
||||||
} rb_code_location_t;
|
} rb_code_location_t;
|
||||||
|
|
||||||
static inline rb_code_location_t code_loc_gen(rb_code_location_t *loc1, rb_code_location_t *loc2)
|
static inline rb_code_location_t
|
||||||
|
code_loc_gen(rb_code_location_t *loc1, rb_code_location_t *loc2)
|
||||||
{
|
{
|
||||||
rb_code_location_t loc;
|
rb_code_location_t loc;
|
||||||
loc.beg_pos = loc1->beg_pos;
|
loc.beg_pos = loc1->beg_pos;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user