version 1.5, 2002/07/24 08:00:10 |
version 1.6, 2003/06/24 05:11:33 |
|
|
} |
} |
} |
} |
|
|
# if defined(REDIRECT_MALLOC) || defined(REDIRECT_REALLOC) |
# if defined(REDIRECT_MALLOC) && !defined(REDIRECT_REALLOC) |
|
# define REDIRECT_REALLOC GC_realloc |
|
# endif |
|
|
|
# ifdef REDIRECT_REALLOC |
# ifdef __STDC__ |
# ifdef __STDC__ |
GC_PTR realloc(GC_PTR p, size_t lb) |
GC_PTR realloc(GC_PTR p, size_t lb) |
# else |
# else |
|
|
size_t lb; |
size_t lb; |
# endif |
# endif |
{ |
{ |
# ifdef REDIRECT_REALLOC |
return(REDIRECT_REALLOC(p, lb)); |
return(REDIRECT_REALLOC(p, lb)); |
|
# else |
|
return(GC_realloc(p, lb)); |
|
# endif |
|
} |
} |
# endif /* REDIRECT_MALLOC */ |
# endif /* REDIRECT_REALLOC */ |
|
|
|
|
/* The same thing, except caller does not hold allocation lock. */ |
/* The same thing, except caller does not hold allocation lock. */ |
|
|
lw = ROUNDED_UP_WORDS(lb); |
lw = ROUNDED_UP_WORDS(lb); |
n_blocks = OBJ_SZ_TO_BLOCKS(lw); |
n_blocks = OBJ_SZ_TO_BLOCKS(lw); |
init = GC_obj_kinds[k].ok_init; |
init = GC_obj_kinds[k].ok_init; |
if (GC_debugging_started) GC_print_all_smashed(); |
if (GC_have_errors) GC_print_all_errors(); |
GC_INVOKE_FINALIZERS(); |
GC_INVOKE_FINALIZERS(); |
DISABLE_SIGNALS(); |
DISABLE_SIGNALS(); |
LOCK(); |
LOCK(); |
Line 287 register struct obj_kind * kind = GC_obj_kinds + k; |
|
Line 287 register struct obj_kind * kind = GC_obj_kinds + k; |
|
register ptr_t op; |
register ptr_t op; |
DCL_LOCK_STATE; |
DCL_LOCK_STATE; |
|
|
if (GC_debugging_started) GC_print_all_smashed(); |
if (GC_have_errors) GC_print_all_errors(); |
GC_INVOKE_FINALIZERS(); |
GC_INVOKE_FINALIZERS(); |
DISABLE_SIGNALS(); |
DISABLE_SIGNALS(); |
LOCK(); |
LOCK(); |
|
|
return; |
return; |
} |
} |
lw = ALIGNED_WORDS(lb); |
lw = ALIGNED_WORDS(lb); |
if (GC_debugging_started) GC_print_all_smashed(); |
if (GC_have_errors) GC_print_all_errors(); |
GC_INVOKE_FINALIZERS(); |
GC_INVOKE_FINALIZERS(); |
DISABLE_SIGNALS(); |
DISABLE_SIGNALS(); |
LOCK(); |
LOCK(); |
|
|
return((GC_PTR) op); |
return((GC_PTR) op); |
} |
} |
} |
} |
|
|
|
#ifdef __STDC__ |
|
/* Not well tested nor integrated. */ |
|
/* Debug version is tricky and currently missing. */ |
|
#include <limits.h> |
|
|
|
GC_PTR GC_memalign(size_t align, size_t lb) |
|
{ |
|
size_t new_lb; |
|
size_t offset; |
|
ptr_t result; |
|
|
|
# ifdef ALIGN_DOUBLE |
|
if (align <= WORDS_TO_BYTES(2) && lb > align) return GC_malloc(lb); |
|
# endif |
|
if (align <= WORDS_TO_BYTES(1)) return GC_malloc(lb); |
|
if (align >= HBLKSIZE/2 || lb >= HBLKSIZE/2) { |
|
if (align > HBLKSIZE) return GC_oom_fn(LONG_MAX-1024) /* Fail */; |
|
return GC_malloc(lb <= HBLKSIZE? HBLKSIZE : lb); |
|
/* Will be HBLKSIZE aligned. */ |
|
} |
|
/* We could also try to make sure that the real rounded-up object size */ |
|
/* is a multiple of align. That would be correct up to HBLKSIZE. */ |
|
new_lb = lb + align - 1; |
|
result = GC_malloc(new_lb); |
|
offset = (word)result % align; |
|
if (offset != 0) { |
|
offset = align - offset; |
|
if (!GC_all_interior_pointers) { |
|
if (offset >= VALID_OFFSET_SZ) return GC_malloc(HBLKSIZE); |
|
GC_register_displacement(offset); |
|
} |
|
} |
|
result = (GC_PTR) ((ptr_t)result + offset); |
|
GC_ASSERT((word)result % align == 0); |
|
return result; |
|
} |
|
#endif |
|
|
# ifdef ATOMIC_UNCOLLECTABLE |
# ifdef ATOMIC_UNCOLLECTABLE |
/* Allocate lb bytes of pointerfree, untraced, uncollectable data */ |
/* Allocate lb bytes of pointerfree, untraced, uncollectable data */ |