added stub implementations of GC entry points.

This commit is contained in:
beard%netscape.com 2000-04-07 04:00:21 +00:00
Родитель d7fa1b7fe2
Коммит ca07212aa6
2 изменённых файлов: 44 добавлений и 24 удалений

Просмотреть файл

@ -28,17 +28,27 @@ using std::ptrdiff_t;
#endif #endif
namespace JavaScript { namespace JavaScript {
extern "C" { extern "C" {
void* GC_malloc(size_t bytes); void* GC_malloc(size_t bytes);
void* GC_malloc_atomic(size_t bytes); void* GC_malloc_atomic(size_t bytes);
void GC_free(void* ptr); void GC_free(void* ptr);
void GC_gcollect(void); void GC_gcollect(void);
typedef void (*GC_finalization_proc) (void* obj, void* client_data); typedef void (*GC_finalization_proc) (void* obj, void* client_data);
void GC_register_finalizer(void* obj, GC_finalization_proc proc, void* client_data, void GC_register_finalizer(void* obj, GC_finalization_proc proc, void* client_data,
GC_finalization_proc *old_proc, void* *old_client_data); GC_finalization_proc *old_proc, void* *old_client_data);
} }
#ifndef XP_MAC
// for platforms where GC doesn't exist yet.
inline void* GC_malloc(size_t bytes) { return ::operator new(bytes); }
inline void* GC_malloc_atomic(size_t bytes) { return ::operator new(bytes); }
inline void GC_free(void* ptr) { return ::operator delete(ptr); }
inline void GC_gcollect() {}
inline void GC_register_finalizer(void* obj, GC_finalization_proc proc, void* client_data,
GC_finalization_proc *old_proc, void* *old_client_data) {}
#endif
/** /**
* General case: memory for type must be allocated as a conservatively * General case: memory for type must be allocated as a conservatively
* scanned block of memory. * scanned block of memory.
@ -109,13 +119,13 @@ namespace JavaScript {
typedef T &reference; typedef T &reference;
typedef const T &const_reference; typedef const T &const_reference;
static pointer address(reference r) { return &r; }
static const_pointer address(const_reference r) { return &r; }
gc_allocator() {} gc_allocator() {}
template<class U> gc_allocator(const gc_allocator<U>&) {} template<class U> gc_allocator(const gc_allocator<U>&) {}
// ~gc_allocator() {} // ~gc_allocator() {}
static pointer address(reference r) { return &r; }
static const_pointer address(const_reference r) { return &r; }
static pointer allocate(size_type n, const void* /* hint */ = 0) { return traits::allocate(n); } static pointer allocate(size_type n, const void* /* hint */ = 0) { return traits::allocate(n); }
static void deallocate(pointer, size_type) {} static void deallocate(pointer, size_type) {}

Просмотреть файл

@ -28,17 +28,27 @@ using std::ptrdiff_t;
#endif #endif
namespace JavaScript { namespace JavaScript {
extern "C" { extern "C" {
void* GC_malloc(size_t bytes); void* GC_malloc(size_t bytes);
void* GC_malloc_atomic(size_t bytes); void* GC_malloc_atomic(size_t bytes);
void GC_free(void* ptr); void GC_free(void* ptr);
void GC_gcollect(void); void GC_gcollect(void);
typedef void (*GC_finalization_proc) (void* obj, void* client_data); typedef void (*GC_finalization_proc) (void* obj, void* client_data);
void GC_register_finalizer(void* obj, GC_finalization_proc proc, void* client_data, void GC_register_finalizer(void* obj, GC_finalization_proc proc, void* client_data,
GC_finalization_proc *old_proc, void* *old_client_data); GC_finalization_proc *old_proc, void* *old_client_data);
} }
#ifndef XP_MAC
// for platforms where GC doesn't exist yet.
inline void* GC_malloc(size_t bytes) { return ::operator new(bytes); }
inline void* GC_malloc_atomic(size_t bytes) { return ::operator new(bytes); }
inline void GC_free(void* ptr) { return ::operator delete(ptr); }
inline void GC_gcollect() {}
inline void GC_register_finalizer(void* obj, GC_finalization_proc proc, void* client_data,
GC_finalization_proc *old_proc, void* *old_client_data) {}
#endif
/** /**
* General case: memory for type must be allocated as a conservatively * General case: memory for type must be allocated as a conservatively
* scanned block of memory. * scanned block of memory.
@ -109,13 +119,13 @@ namespace JavaScript {
typedef T &reference; typedef T &reference;
typedef const T &const_reference; typedef const T &const_reference;
static pointer address(reference r) { return &r; }
static const_pointer address(const_reference r) { return &r; }
gc_allocator() {} gc_allocator() {}
template<class U> gc_allocator(const gc_allocator<U>&) {} template<class U> gc_allocator(const gc_allocator<U>&) {}
// ~gc_allocator() {} // ~gc_allocator() {}
static pointer address(reference r) { return &r; }
static const_pointer address(const_reference r) { return &r; }
static pointer allocate(size_type n, const void* /* hint */ = 0) { return traits::allocate(n); } static pointer allocate(size_type n, const void* /* hint */ = 0) { return traits::allocate(n); }
static void deallocate(pointer, size_type) {} static void deallocate(pointer, size_type) {}