Skip to content

st use function instead of macro #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better way to fix rare GC condition
  • Loading branch information
funny-falcon committed Dec 31, 2011
commit 3371756c4ef2b12e852ca89a6a5d431f0ad4cc82
21 changes: 21 additions & 0 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,15 @@ vm_xmalloc(rb_objspace_t *objspace, size_t size)
return vm_malloc_fixup(objspace, mem, size);
}

static void *
vm_xmalloc_only(rb_objspace_t *objspace, size_t size)
{
void *mem;

TRY_WITH_GC(mem = malloc(size));
return vm_malloc_fixup(objspace, mem, size);
}

static void *
vm_xrealloc(rb_objspace_t *objspace, void *ptr, size_t size)
{
Expand Down Expand Up @@ -850,6 +859,18 @@ ruby_xmalloc(size_t size)
return vm_xmalloc(&rb_objspace, size);
}

size_t
ruby_gcprepare(size_t size)
{
return vm_malloc_prepare(&rb_objspace, size);
}

void *
ruby_xmalloc_prepared(size_t size)
{
return vm_xmalloc_only(&rb_objspace, size);
}

static inline size_t
xmalloc2_size(size_t n, size_t size)
{
Expand Down
4 changes: 4 additions & 0 deletions internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ void Init_File(void);

/* gc.c */
void Init_heap(void);
#define xgc_prepare ruby_gcprepare
#define xmalloc_prepared ruby_xmalloc_prepared
size_t xgc_prepare(size_t);
void *xmalloc_prepared(size_t);

/* inits.c */
void rb_call_inits(void);
Expand Down
18 changes: 13 additions & 5 deletions pool_alloc.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct entry_typename {
holder_typename *holder;
};

#define HOLDER_SIZE (256 / sizeof(entry_typename) - 1)
#define HOLDER_SIZE ((4096 - sizeof(void*) * 3 - sizeof(int)) / sizeof(entry_typename) )
struct holder_typename {
unsigned int free;
entry_typename items[HOLDER_SIZE];
Expand Down Expand Up @@ -65,11 +65,19 @@ entry_chain(entry_typename *entry)
static void
holder_alloc()
{
holder_typename *holder = alloc(holder_typename);
unsigned int i = HOLDER_SIZE - 1;
register entry_typename *ptr = holder->items;
holder_typename *holder;
unsigned int i;
register entry_typename *ptr;
#ifdef xgc_prepare
size_t sz = xgc_prepare(sizeof(holder_typename));
if (free_entry_p) return;
holder = (holder_typename*)xmalloc_prepared(sz);
#else
holder = alloc(holder_typename);
#endif
ptr = holder->items;
holder->free = HOLDER_SIZE;
for(; i; ptr++, i-- ) {
for(i = HOLDER_SIZE - 1; i; ptr++, i-- ) {
ptr->holder = holder;
ptr->fore = ptr + 1;
(ptr + 1)->back = ptr;
Expand Down
1 change: 1 addition & 0 deletions st.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "st.h"
#else
#include "ruby/ruby.h"
#include "internal.h"
#endif

#include <stdio.h>
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy