Skip to content

Instantly share code, notes, and snippets.

@slaskis
Created May 18, 2009 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slaskis/113449 to your computer and use it in GitHub Desktop.
Save slaskis/113449 to your computer and use it in GitHub Desktop.
# 1 "vm/threads.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "vm/threads.c"
# 17 "vm/threads.c"
# 1 "vm/vm.h" 1
# 19 "vm/vm.h"
# 1 "/usr/include/setjmp.h" 1 3 4
# 26 "/usr/include/setjmp.h" 3 4
# 1 "/usr/include/machine/setjmp.h" 1 3 4
# 37 "/usr/include/machine/setjmp.h" 3 4
# 1 "/usr/include/i386/setjmp.h" 1 3 4
# 37 "/usr/include/i386/setjmp.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 38 "/usr/include/i386/setjmp.h" 2 3 4
# 60 "/usr/include/i386/setjmp.h" 3 4
typedef int jmp_buf[(18)];
typedef int sigjmp_buf[(18) + 1];
int setjmp(jmp_buf);
void longjmp(jmp_buf, int);
int _setjmp(jmp_buf);
void _longjmp(jmp_buf, int);
int sigsetjmp(sigjmp_buf, int);
void siglongjmp(sigjmp_buf, int);
void longjmperror(void);
# 38 "/usr/include/machine/setjmp.h" 2 3 4
# 27 "/usr/include/setjmp.h" 2 3 4
# 20 "vm/vm.h" 2
# 1 "vm/neko_vm.h" 1
# 19 "vm/neko_vm.h"
# 1 "vm/neko.h" 1
# 79 "vm/neko.h"
# 1 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h" 1 3 4
# 152 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h" 3 4
typedef int ptrdiff_t;
# 214 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h" 3 4
typedef long unsigned int size_t;
# 326 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h" 3 4
typedef int wchar_t;
# 80 "vm/neko.h" 2
# 1 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h" 1 3 4
# 20 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h" 3 4
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long long int intmax_t;
# 106 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h" 3 4
typedef long long unsigned int uintmax_t;
# 82 "vm/neko.h" 2
typedef intptr_t int_val;
typedef enum {
VAL_INT = 0xFF,
VAL_NULL = 0,
VAL_FLOAT = 1,
VAL_BOOL = 2,
VAL_STRING = 3,
VAL_OBJECT = 4,
VAL_ARRAY = 5,
VAL_FUNCTION = 6,
VAL_ABSTRACT = 7,
VAL_PRIMITIVE = 6 | 8,
VAL_JITFUN = 6 | 16,
VAL_32_BITS = 0xFFFFFFFF
} val_type;
struct _value {
val_type t;
};
struct _buffer;
typedef int field;
typedef struct { int __zero; } *vkind;
typedef struct _value *value;
typedef struct {
field id;
value v;
} objcell;
typedef struct _objtable
{
int count;
objcell *cells;
} objtable;
typedef struct _buffer *buffer;
typedef double tfloat;
typedef void (*finalizer)(value v);
#pragma pack(4)
typedef struct {
val_type t;
tfloat f;
} vfloat;
#pragma pack()
typedef struct _vobject {
val_type t;
objtable table;
struct _vobject *proto;
} vobject;
typedef struct {
val_type t;
int nargs;
void *addr;
value env;
void *module;
} vfunction;
typedef struct {
val_type t;
char c;
} vstring;
typedef struct {
val_type t;
value ptr;
} varray;
typedef struct {
val_type t;
vkind kind;
void *data;
} vabstract;
typedef struct hcell {
int hkey;
value key;
value val;
struct hcell *next;
} hcell;
typedef struct {
hcell **cells;
int ncells;
int nitems;
} vhash;
struct _mt_local;
struct _mt_lock;
typedef struct _mt_local mt_local;
typedef struct _mt_lock mt_lock;
# 252 "vm/neko.h"
typedef int bool;
# 272 "vm/neko.h"
# 1 "/usr/include/errno.h" 1 3 4
# 23 "/usr/include/errno.h" 3 4
# 1 "/usr/include/sys/errno.h" 1 3 4
# 73 "/usr/include/sys/errno.h" 3 4
extern int * __error(void);
# 24 "/usr/include/errno.h" 2 3 4
# 273 "vm/neko.h" 2
# 356 "vm/neko.h"
extern vkind neko_k_int32;
extern vkind neko_k_hash;
extern value val_null;
extern value val_true;
extern value val_false;
value neko_alloc_float( tfloat t );
value neko_alloc_string( const char *str );
value neko_alloc_empty_string( unsigned int size );
value neko_copy_string( const char *str, int_val size );
value neko_val_this();
field neko_val_id( const char *str );
value neko_val_field( value o, field f );
value neko_alloc_object( value o );
void neko_alloc_field( value obj, field f, value v );
void neko_val_iter_fields( value obj, void f( value v, field f, void * ), void *p );
value neko_val_field_name( field f );
value neko_alloc_array( unsigned int n );
value neko_alloc_abstract( vkind k, void *data );
value neko_val_call0( value f );
value neko_val_call1( value f, value arg );
value neko_val_call2( value f, value arg1, value arg2 );
value neko_val_call3( value f, value arg1, value arg2, value arg3 );
value neko_val_callN( value f, value *args, int nargs );
value neko_val_ocall0( value o, field f );
value neko_val_ocall1( value o, field f, value arg );
value neko_val_ocall2( value o, field f, value arg1, value arg2 );
value neko_val_ocallN( value o, field f, value *args, int nargs );
value neko_val_callEx( value vthis, value f, value *args, int nargs, value *exc );
value *neko_alloc_root( unsigned int nvals );
void neko_free_root( value *r );
char *neko_alloc( unsigned int nbytes );
char *neko_alloc_private( unsigned int nbytes );
value neko_alloc_function( void *c_prim, unsigned int nargs, const char *name );
buffer neko_alloc_buffer( const char *init );
void neko_buffer_append( buffer b, const char *s );
void neko_buffer_append_sub( buffer b, const char *s, int_val len );
void neko_buffer_append_char( buffer b, char c );
value neko_buffer_to_string( buffer b );
void neko_val_buffer( buffer b, value v );
int neko_val_compare( value a, value b );
void neko_val_print( value s );
void neko_val_gc( value v, finalizer f );
void neko_val_throw( value v );
void neko_val_rethrow( value v );
int neko_val_hash( value v );
void neko_kind_share( vkind *k, const char *name );
void _neko_failure( value msg, const char *file, int line );
mt_local *neko_alloc_local();
void *neko_local_get( mt_local *l );
void neko_local_set( mt_local *l, void *v );
void neko_free_local( mt_local *l );
mt_lock *neko_alloc_lock();
void neko_lock_acquire( mt_lock *l );
int neko_lock_try( mt_lock *l );
void neko_lock_release( mt_lock *l );
void neko_free_lock( mt_lock *l );
# 20 "vm/neko_vm.h" 2
typedef void (*neko_printer)( const char *data, int size, void *param );
typedef void (*thread_main_func)( void *param );
typedef struct _neko_vm neko_vm;
typedef void (*neko_stat_func)( neko_vm *vm, const char *kind, int start );
void neko_global_init();
void neko_global_free();
void neko_gc_major();
void neko_gc_loop();
void neko_gc_stats( int *heap, int *free );
int neko_thread_create( thread_main_func init, thread_main_func main, void *param, void **handle );
void neko_thread_blocking( thread_main_func f, void *p );
bool neko_thread_register( bool t );
neko_vm *neko_vm_alloc( void *unused );
neko_vm *neko_vm_current();
value neko_exc_stack( neko_vm *vm );
value neko_call_stack( neko_vm *vm );
void *neko_vm_custom( neko_vm *vm, vkind k );
void neko_vm_set_custom( neko_vm *vm, vkind k, void *v );
value neko_vm_execute( neko_vm *vm, void *module );
void neko_vm_select( neko_vm *vm );
int neko_vm_jit( neko_vm *vm, int enable_jit );
int neko_vm_trusted( neko_vm *vm, int trusted );
value neko_default_loader( char **argv, int argc );
void neko_vm_redirect( neko_vm *vm, neko_printer print, void *param );
void neko_vm_set_stats( neko_vm *vm, neko_stat_func fstats, neko_stat_func pstats );
void neko_vm_dump_stack( neko_vm *vm );
int neko_is_big_endian();
# 21 "vm/vm.h" 2
# 29 "vm/vm.h"
typedef struct _custom_list {
vkind tag;
void *custom;
struct _custom_list *next;
} custom_list;
struct _neko_vm {
int_val *sp;
int_val *csp;
value env;
value vthis;
int_val *spmin;
int_val *spmax;
int_val trap;
void *jit_val;
jmp_buf start;
void *c_stack_max;
int run_jit;
value exc_stack;
neko_printer print;
void *print_param;
custom_list *clist;
value resolver;
char tmp[100];
int trusted_code;
neko_stat_func fstats;
neko_stat_func pstats;
};
extern int_val *callback_return;
extern mt_local *neko_vm_context;
extern value neko_alloc_apply( int nargs, value env );
extern value neko_interp( neko_vm *vm, void *m, int_val acc, int_val *pc );
extern int_val *neko_get_ttable();
# 18 "vm/threads.c" 2
# 1 "/usr/include/string.h" 1 3 4
# 60 "/usr/include/string.h" 3 4
# 1 "/usr/include/_types.h" 1 3 4
# 27 "/usr/include/_types.h" 3 4
# 1 "/usr/include/sys/_types.h" 1 3 4
# 33 "/usr/include/sys/_types.h" 3 4
# 1 "/usr/include/machine/_types.h" 1 3 4
# 34 "/usr/include/machine/_types.h" 3 4
# 1 "/usr/include/i386/_types.h" 1 3 4
# 37 "/usr/include/i386/_types.h" 3 4
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
typedef long __darwin_intptr_t;
typedef unsigned int __darwin_natural_t;
# 70 "/usr/include/i386/_types.h" 3 4
typedef int __darwin_ct_rune_t;
typedef union {
char __mbstate8[128];
long long _mbstateL;
} __mbstate_t;
typedef __mbstate_t __darwin_mbstate_t;
typedef int __darwin_ptrdiff_t;
typedef long unsigned int __darwin_size_t;
typedef __builtin_va_list __darwin_va_list;
typedef int __darwin_wchar_t;
typedef __darwin_wchar_t __darwin_rune_t;
typedef int __darwin_wint_t;
typedef unsigned long __darwin_clock_t;
typedef __uint32_t __darwin_socklen_t;
typedef long __darwin_ssize_t;
typedef long __darwin_time_t;
# 35 "/usr/include/machine/_types.h" 2 3 4
# 34 "/usr/include/sys/_types.h" 2 3 4
# 58 "/usr/include/sys/_types.h" 3 4
struct __darwin_pthread_handler_rec
{
void (*__routine)(void *);
void *__arg;
struct __darwin_pthread_handler_rec *__next;
};
struct _opaque_pthread_attr_t { long __sig; char __opaque[36]; };
struct _opaque_pthread_cond_t { long __sig; char __opaque[24]; };
struct _opaque_pthread_condattr_t { long __sig; char __opaque[4]; };
struct _opaque_pthread_mutex_t { long __sig; char __opaque[40]; };
struct _opaque_pthread_mutexattr_t { long __sig; char __opaque[8]; };
struct _opaque_pthread_once_t { long __sig; char __opaque[4]; };
struct _opaque_pthread_rwlock_t { long __sig; char __opaque[124]; };
struct _opaque_pthread_rwlockattr_t { long __sig; char __opaque[12]; };
struct _opaque_pthread_t { long __sig; struct __darwin_pthread_handler_rec *__cleanup_stack; char __opaque[596]; };
# 94 "/usr/include/sys/_types.h" 3 4
typedef __int64_t __darwin_blkcnt_t;
typedef __int32_t __darwin_blksize_t;
typedef __int32_t __darwin_dev_t;
typedef unsigned int __darwin_fsblkcnt_t;
typedef unsigned int __darwin_fsfilcnt_t;
typedef __uint32_t __darwin_gid_t;
typedef __uint32_t __darwin_id_t;
typedef __uint64_t __darwin_ino64_t;
typedef __uint32_t __darwin_ino_t;
typedef __darwin_natural_t __darwin_mach_port_name_t;
typedef __darwin_mach_port_name_t __darwin_mach_port_t;
typedef __uint16_t __darwin_mode_t;
typedef __int64_t __darwin_off_t;
typedef __int32_t __darwin_pid_t;
typedef struct _opaque_pthread_attr_t
__darwin_pthread_attr_t;
typedef struct _opaque_pthread_cond_t
__darwin_pthread_cond_t;
typedef struct _opaque_pthread_condattr_t
__darwin_pthread_condattr_t;
typedef unsigned long __darwin_pthread_key_t;
typedef struct _opaque_pthread_mutex_t
__darwin_pthread_mutex_t;
typedef struct _opaque_pthread_mutexattr_t
__darwin_pthread_mutexattr_t;
typedef struct _opaque_pthread_once_t
__darwin_pthread_once_t;
typedef struct _opaque_pthread_rwlock_t
__darwin_pthread_rwlock_t;
typedef struct _opaque_pthread_rwlockattr_t
__darwin_pthread_rwlockattr_t;
typedef struct _opaque_pthread_t
*__darwin_pthread_t;
typedef __uint32_t __darwin_sigset_t;
typedef __int32_t __darwin_suseconds_t;
typedef __uint32_t __darwin_uid_t;
typedef __uint32_t __darwin_useconds_t;
typedef unsigned char __darwin_uuid_t[16];
# 28 "/usr/include/_types.h" 2 3 4
typedef int __darwin_nl_item;
typedef int __darwin_wctrans_t;
typedef unsigned long __darwin_wctype_t;
# 61 "/usr/include/string.h" 2 3 4
# 70 "/usr/include/string.h" 3 4
typedef __darwin_ssize_t ssize_t;
# 80 "/usr/include/string.h" 3 4
void *memchr(const void *, int, size_t);
int memcmp(const void *, const void *, size_t);
void *memcpy(void *, const void *, size_t);
void *memmove(void *, const void *, size_t);
void *memset(void *, int, size_t);
char *stpcpy(char *, const char *);
char *strcasestr(const char *, const char *);
char *strcat(char *, const char *);
char *strchr(const char *, int);
int strcmp(const char *, const char *);
int strcoll(const char *, const char *);
char *strcpy(char *, const char *);
size_t strcspn(const char *, const char *);
char *strerror(int) __asm("_" "strerror" "$UNIX2003");
int strerror_r(int, char *, size_t);
size_t strlen(const char *);
char *strncat(char *, const char *, size_t);
int strncmp(const char *, const char *, size_t);
char *strncpy(char *, const char *, size_t);
char *strnstr(const char *, const char *, size_t);
char *strpbrk(const char *, const char *);
char *strrchr(const char *, int);
size_t strspn(const char *, const char *);
char *strstr(const char *, const char *);
char *strtok(char *, const char *);
size_t strxfrm(char *, const char *, size_t);
void *memccpy(void *, const void *, int, size_t);
char *strtok_r(char *, const char *, char **);
char *strdup(const char *);
int bcmp(const void *, const void *, size_t);
void bcopy(const void *, void *, size_t);
void bzero(void *, size_t);
int ffs(int);
int ffsl(long);
int fls(int);
int flsl(long);
char *index(const char *, int);
void memset_pattern4(void *, const void *, size_t);
void memset_pattern8(void *, const void *, size_t);
void memset_pattern16(void *, const void *, size_t);
char *rindex(const char *, int);
int strcasecmp(const char *, const char *);
size_t strlcat(char *, const char *, size_t);
size_t strlcpy(char *, const char *, size_t);
void strmode(int, char *);
int strncasecmp(const char *, const char *, size_t);
char *strsep(char **, const char *);
char *strsignal(int sig);
void swab(const void * , void * , ssize_t);
# 19 "vm/threads.c" 2
# 38 "vm/threads.c"
# 1 "/opt/local/include/gc/gc.h" 1
# 34 "/opt/local/include/gc/gc.h"
# 1 "/opt/local/include/gc/gc_version.h" 1
# 35 "/opt/local/include/gc/gc.h" 2
# 1 "/opt/local/include/gc/gc_config_macros.h" 1
# 135 "/opt/local/include/gc/gc_config_macros.h"
# 1 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h" 1 3 4
# 136 "/opt/local/include/gc/gc_config_macros.h" 2
# 42 "/opt/local/include/gc/gc.h" 2
# 56 "/opt/local/include/gc/gc.h"
typedef unsigned long GC_word;
typedef long GC_signed_word;
# 68 "/opt/local/include/gc/gc.h"
extern GC_word GC_gc_no;
extern int GC_parallel;
# 84 "/opt/local/include/gc/gc.h"
extern void * (*GC_oom_fn) (size_t bytes_requested);
# 93 "/opt/local/include/gc/gc.h"
extern int GC_find_leak;
extern int GC_all_interior_pointers;
# 111 "/opt/local/include/gc/gc.h"
extern int GC_finalize_on_demand;
extern int GC_java_finalization;
# 127 "/opt/local/include/gc/gc.h"
extern void (* GC_finalizer_notifier)(void);
# 136 "/opt/local/include/gc/gc.h"
extern int GC_dont_gc;
# 145 "/opt/local/include/gc/gc.h"
extern int GC_dont_expand;
extern int GC_use_entire_heap;
# 160 "/opt/local/include/gc/gc.h"
extern int GC_full_freq;
# 170 "/opt/local/include/gc/gc.h"
extern GC_word GC_non_gc_bytes;
extern int GC_no_dls;
extern GC_word GC_free_space_divisor;
# 198 "/opt/local/include/gc/gc.h"
extern GC_word GC_max_retries;
extern char *GC_stackbottom;
# 216 "/opt/local/include/gc/gc.h"
extern int GC_dont_precollect;
extern unsigned long GC_time_limit;
# 243 "/opt/local/include/gc/gc.h"
extern void GC_init(void);
# 261 "/opt/local/include/gc/gc.h"
extern void * GC_malloc(size_t size_in_bytes);
extern void * GC_malloc_atomic(size_t size_in_bytes);
extern char * GC_strdup (const char *str);
extern void * GC_malloc_uncollectable(size_t size_in_bytes);
extern void * GC_malloc_stubborn(size_t size_in_bytes);
extern void * GC_malloc_atomic_uncollectable(size_t size_in_bytes);
extern void GC_free(void * object_addr);
# 294 "/opt/local/include/gc/gc.h"
extern void GC_change_stubborn(void *);
extern void GC_end_stubborn_change(void *);
# 308 "/opt/local/include/gc/gc.h"
extern void * GC_base(void * displaced_pointer);
extern size_t GC_size(void * object_addr);
# 323 "/opt/local/include/gc/gc.h"
extern void * GC_realloc(void * old_object, size_t new_size_in_bytes);
extern int GC_expand_hp(size_t number_of_bytes);
extern void GC_set_max_heap_size(GC_word n);
extern void GC_exclude_static_roots(void * low_address,
void * high_address_plus_1);
extern void GC_clear_roots(void);
extern void GC_add_roots(void * low_address, void * high_address_plus_1);
extern void GC_remove_roots(void * low_address, void * high_address_plus_1);
# 363 "/opt/local/include/gc/gc.h"
extern void GC_register_displacement(size_t n);
extern void GC_debug_register_displacement(size_t n);
extern void GC_gcollect(void);
# 381 "/opt/local/include/gc/gc.h"
typedef int (* GC_stop_func)(void);
extern int GC_try_to_collect(GC_stop_func stop_func);
extern size_t GC_get_heap_size(void);
extern size_t GC_get_free_bytes(void);
extern size_t GC_get_bytes_since_gc(void);
extern size_t GC_get_total_bytes(void);
extern void GC_disable(void);
extern void GC_enable(void);
# 423 "/opt/local/include/gc/gc.h"
extern void GC_enable_incremental(void);
# 433 "/opt/local/include/gc/gc.h"
extern int GC_incremental_protection_needs(void);
# 442 "/opt/local/include/gc/gc.h"
extern int GC_collect_a_little(void);
# 458 "/opt/local/include/gc/gc.h"
extern void * GC_malloc_ignore_off_page(size_t lb);
extern void * GC_malloc_atomic_ignore_off_page(size_t lb);
# 524 "/opt/local/include/gc/gc.h"
extern void * GC_debug_malloc(size_t size_in_bytes, const char * s, int i);
extern void * GC_debug_malloc_atomic(size_t size_in_bytes, const char * s, int i);
extern char * GC_debug_strdup(const char *str, const char * s, int i);
extern void * GC_debug_malloc_uncollectable
(size_t size_in_bytes, const char * s, int i);
extern void * GC_debug_malloc_stubborn
(size_t size_in_bytes, const char * s, int i);
extern void * GC_debug_malloc_ignore_off_page
(size_t size_in_bytes, const char * s, int i);
extern void * GC_debug_malloc_atomic_ignore_off_page
(size_t size_in_bytes, const char * s, int i);
extern void GC_debug_free (void * object_addr);
extern void * GC_debug_realloc
(void * old_object, size_t new_size_in_bytes, const char * s, int i);
extern void GC_debug_change_stubborn(void *);
extern void GC_debug_end_stubborn_change(void *);
# 553 "/opt/local/include/gc/gc.h"
extern void * GC_debug_malloc_replacement (size_t size_in_bytes);
extern void * GC_debug_realloc_replacement
(void * object_addr, size_t size_in_bytes);
# 625 "/opt/local/include/gc/gc.h"
typedef void (*GC_finalization_proc) (void * obj, void * client_data);
extern void GC_register_finalizer(void * obj, GC_finalization_proc fn,
void * cd, GC_finalization_proc *ofn,
void * *ocd);
extern void GC_debug_register_finalizer
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
# 675 "/opt/local/include/gc/gc.h"
extern void GC_register_finalizer_ignore_self
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
extern void GC_debug_register_finalizer_ignore_self
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
extern void GC_register_finalizer_no_order
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
extern void GC_debug_register_finalizer_no_order
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
# 709 "/opt/local/include/gc/gc.h"
extern void GC_register_finalizer_unreachable
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
extern void GC_debug_register_finalizer_unreachable
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
# 723 "/opt/local/include/gc/gc.h"
extern int GC_register_disappearing_link(void * * link );
# 744 "/opt/local/include/gc/gc.h"
extern int GC_general_register_disappearing_link (void * * link, void * obj);
# 771 "/opt/local/include/gc/gc.h"
extern int GC_unregister_disappearing_link (void * * link);
extern int GC_should_invoke_finalizers(void);
extern int GC_invoke_finalizers(void);
# 806 "/opt/local/include/gc/gc.h"
typedef void (*GC_warn_proc) (char *msg, GC_word arg);
extern GC_warn_proc GC_set_warn_proc(GC_warn_proc p);
extern GC_word GC_set_free_space_divisor(GC_word value);
# 831 "/opt/local/include/gc/gc.h"
typedef void * (*GC_fn_type) (void * client_data);
extern void * GC_call_with_alloc_lock (GC_fn_type fn, void * client_data);
# 846 "/opt/local/include/gc/gc.h"
struct GC_stack_base {
void * mem_base;
};
typedef void * (*GC_stack_base_func)(struct GC_stack_base *sb, void *arg);
void * GC_call_with_stack_base(GC_stack_base_func fn, void *arg);
# 872 "/opt/local/include/gc/gc.h"
int GC_register_my_thread(struct GC_stack_base *);
# 881 "/opt/local/include/gc/gc.h"
int GC_unregister_my_thread(void);
int GC_get_stack_base(struct GC_stack_base *);
# 900 "/opt/local/include/gc/gc.h"
extern void * GC_same_obj (void * p, void * q);
extern void * GC_pre_incr (void * *p, size_t how_much);
extern void * GC_post_incr (void * *p, size_t how_much);
# 917 "/opt/local/include/gc/gc.h"
extern void * GC_is_visible (void * p);
extern void * GC_is_valid_displacement (void * p);
void GC_dump(void);
# 972 "/opt/local/include/gc/gc.h"
extern void (*GC_same_obj_print_proc) (void * p, void * q);
extern void (*GC_is_valid_displacement_print_proc) (void * p);
extern void (*GC_is_visible_print_proc) (void * p);
# 1 "/opt/local/include/gc/gc_pthread_redirects.h" 1
# 18 "/opt/local/include/gc/gc_pthread_redirects.h"
# 1 "/usr/include/pthread.h" 1 3 4
# 57 "/usr/include/pthread.h" 3 4
# 1 "/usr/include/pthread_impl.h" 1 3 4
# 58 "/usr/include/pthread.h" 2 3 4
# 1 "/usr/include/sched.h" 1 3 4
# 30 "/usr/include/sched.h" 3 4
struct sched_param { int sched_priority; char __opaque[4]; };
extern int sched_yield(void);
extern int sched_get_priority_min(int);
extern int sched_get_priority_max(int);
# 60 "/usr/include/pthread.h" 2 3 4
# 1 "/usr/include/time.h" 1 3 4
# 69 "/usr/include/time.h" 3 4
# 1 "/usr/include/_structs.h" 1 3 4
# 24 "/usr/include/_structs.h" 3 4
# 1 "/usr/include/sys/_structs.h" 1 3 4
# 88 "/usr/include/sys/_structs.h" 3 4
struct timespec
{
__darwin_time_t tv_sec;
long tv_nsec;
};
# 25 "/usr/include/_structs.h" 2 3 4
# 70 "/usr/include/time.h" 2 3 4
typedef __darwin_clock_t clock_t;
# 87 "/usr/include/time.h" 3 4
typedef __darwin_time_t time_t;
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
long tm_gmtoff;
char *tm_zone;
};
# 113 "/usr/include/time.h" 3 4
extern char *tzname[];
extern int getdate_err;
extern long timezone __asm("_" "timezone" "$UNIX2003");
extern int daylight;
char *asctime(const struct tm *);
clock_t clock(void) __asm("_" "clock" "$UNIX2003");
char *ctime(const time_t *);
double difftime(time_t, time_t);
struct tm *getdate(const char *);
struct tm *gmtime(const time_t *);
struct tm *localtime(const time_t *);
time_t mktime(struct tm *) __asm("_" "mktime" "$UNIX2003");
size_t strftime(char * , size_t, const char * , const struct tm * ) __asm("_" "strftime" "$UNIX2003");
char *strptime(const char * , const char * , struct tm * ) __asm("_" "strptime" "$UNIX2003");
time_t time(time_t *);
void tzset(void);
char *asctime_r(const struct tm * , char * );
char *ctime_r(const time_t *, char *);
struct tm *gmtime_r(const time_t * , struct tm * );
struct tm *localtime_r(const time_t * , struct tm * );
time_t posix2time(time_t);
void tzsetwall(void);
time_t time2posix(time_t);
time_t timelocal(struct tm * const);
time_t timegm(struct tm * const);
int nanosleep(const struct timespec *, struct timespec *) __asm("_" "nanosleep" "$UNIX2003");
# 61 "/usr/include/pthread.h" 2 3 4
typedef __darwin_pthread_attr_t pthread_attr_t;
typedef __darwin_pthread_cond_t pthread_cond_t;
typedef __darwin_pthread_condattr_t pthread_condattr_t;
typedef __darwin_pthread_key_t pthread_key_t;
typedef __darwin_pthread_mutex_t pthread_mutex_t;
typedef __darwin_pthread_mutexattr_t pthread_mutexattr_t;
typedef __darwin_pthread_once_t pthread_once_t;
typedef __darwin_pthread_rwlock_t pthread_rwlock_t;
typedef __darwin_pthread_rwlockattr_t pthread_rwlockattr_t;
typedef __darwin_pthread_t pthread_t;
typedef __darwin_mach_port_t mach_port_t;
typedef __darwin_sigset_t sigset_t;
# 148 "/usr/include/pthread.h" 3 4
# 244 "/usr/include/pthread.h" 3 4
int pthread_atfork(void (*)(void), void (*)(void),
void (*)(void));
int pthread_attr_destroy(pthread_attr_t *);
int pthread_attr_getdetachstate(const pthread_attr_t *,
int *);
int pthread_attr_getguardsize(const pthread_attr_t * ,
size_t * );
int pthread_attr_getinheritsched(const pthread_attr_t * ,
int * );
int pthread_attr_getschedparam(const pthread_attr_t * ,
struct sched_param * );
int pthread_attr_getschedpolicy(const pthread_attr_t * ,
int * );
int pthread_attr_getscope(const pthread_attr_t * , int * );
int pthread_attr_getstack(const pthread_attr_t * ,
void ** , size_t * );
int pthread_attr_getstackaddr(const pthread_attr_t * ,
void ** );
int pthread_attr_getstacksize(const pthread_attr_t * ,
size_t * );
int pthread_attr_init(pthread_attr_t *);
int pthread_attr_setdetachstate(pthread_attr_t *,
int );
int pthread_attr_setguardsize(pthread_attr_t *, size_t );
int pthread_attr_setinheritsched(pthread_attr_t *,
int );
int pthread_attr_setschedparam(pthread_attr_t * ,
const struct sched_param * );
int pthread_attr_setschedpolicy(pthread_attr_t *,
int );
int pthread_attr_setscope(pthread_attr_t *, int);
int pthread_attr_setstack(pthread_attr_t *,
void *, size_t );
int pthread_attr_setstackaddr(pthread_attr_t *,
void *);
int pthread_attr_setstacksize(pthread_attr_t *, size_t );
int pthread_cancel(pthread_t ) __asm("_" "pthread_cancel" "$UNIX2003");
int pthread_cond_broadcast(pthread_cond_t *);
int pthread_cond_destroy(pthread_cond_t *);
int pthread_cond_init(pthread_cond_t * ,
const pthread_condattr_t * ) __asm("_" "pthread_cond_init" "$UNIX2003");
int pthread_cond_signal(pthread_cond_t *);
int pthread_cond_timedwait(pthread_cond_t * ,
pthread_mutex_t * ,
const struct timespec * ) __asm("_" "pthread_cond_timedwait" "$UNIX2003");
int pthread_cond_wait(pthread_cond_t * ,
pthread_mutex_t * ) __asm("_" "pthread_cond_wait" "$UNIX2003");
int pthread_condattr_destroy(pthread_condattr_t *);
int pthread_condattr_init(pthread_condattr_t *);
int pthread_condattr_getpshared(const pthread_condattr_t * ,
int * );
int pthread_condattr_setpshared(pthread_condattr_t *,
int );
int pthread_create(pthread_t * ,
const pthread_attr_t * ,
void *(*)(void *),
void * );
int pthread_detach(pthread_t );
int pthread_equal(pthread_t ,
pthread_t );
void pthread_exit(void *) __attribute__((__noreturn__));
int pthread_getconcurrency(void);
int pthread_getschedparam(pthread_t , int * , struct sched_param * );
void *pthread_getspecific(pthread_key_t );
int pthread_join(pthread_t , void **) __asm("_" "pthread_join" "$UNIX2003");
int pthread_key_create(pthread_key_t *, void (*)(void *));
int pthread_key_delete(pthread_key_t );
int pthread_mutex_destroy(pthread_mutex_t *);
int pthread_mutex_getprioceiling(const pthread_mutex_t * , int * );
int pthread_mutex_init(pthread_mutex_t * , const pthread_mutexattr_t * );
int pthread_mutex_lock(pthread_mutex_t *);
int pthread_mutex_setprioceiling(pthread_mutex_t * , int, int * );
int pthread_mutex_trylock(pthread_mutex_t *);
int pthread_mutex_unlock(pthread_mutex_t *);
int pthread_mutexattr_destroy(pthread_mutexattr_t *) __asm("_" "pthread_mutexattr_destroy" "$UNIX2003");
int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * , int * );
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * , int * );
int pthread_mutexattr_getpshared(const pthread_mutexattr_t * , int * );
int pthread_mutexattr_gettype(const pthread_mutexattr_t * , int * );
int pthread_mutexattr_init(pthread_mutexattr_t *);
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int );
int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
int pthread_once(pthread_once_t *, void (*)(void));
int pthread_rwlock_destroy(pthread_rwlock_t * ) __asm("_" "pthread_rwlock_destroy" "$UNIX2003");
int pthread_rwlock_init(pthread_rwlock_t * , const pthread_rwlockattr_t * ) __asm("_" "pthread_rwlock_init" "$UNIX2003");
int pthread_rwlock_rdlock(pthread_rwlock_t *) __asm("_" "pthread_rwlock_rdlock" "$UNIX2003");
int pthread_rwlock_tryrdlock(pthread_rwlock_t *) __asm("_" "pthread_rwlock_tryrdlock" "$UNIX2003");
int pthread_rwlock_trywrlock(pthread_rwlock_t *) __asm("_" "pthread_rwlock_trywrlock" "$UNIX2003");
int pthread_rwlock_wrlock(pthread_rwlock_t *) __asm("_" "pthread_rwlock_wrlock" "$UNIX2003");
int pthread_rwlock_unlock(pthread_rwlock_t *) __asm("_" "pthread_rwlock_unlock" "$UNIX2003");
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * ,
int * );
int pthread_rwlockattr_init(pthread_rwlockattr_t *);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *,
int );
pthread_t pthread_self(void);
int pthread_setcancelstate(int , int *) __asm("_" "pthread_setcancelstate" "$UNIX2003");
int pthread_setcanceltype(int , int *) __asm("_" "pthread_setcanceltype" "$UNIX2003");
int pthread_setconcurrency(int);
int pthread_setschedparam(pthread_t ,
int ,
const struct sched_param *);
int pthread_setspecific(pthread_key_t ,
const void *);
void pthread_testcancel(void) __asm("_" "pthread_testcancel" "$UNIX2003");
int pthread_is_threaded_np(void);
int pthread_main_np(void);
mach_port_t pthread_mach_thread_np(pthread_t);
size_t pthread_get_stacksize_np(pthread_t);
void * pthread_get_stackaddr_np(pthread_t);
int pthread_cond_signal_thread_np(pthread_cond_t *, pthread_t);
int pthread_cond_timedwait_relative_np(pthread_cond_t *,
pthread_mutex_t *,
const struct timespec *);
int pthread_create_suspended_np(pthread_t *,
const pthread_attr_t *,
void *(*)(void *),
void *);
int pthread_kill(pthread_t, int);
pthread_t pthread_from_mach_thread_np(mach_port_t);
int pthread_sigmask(int, const sigset_t *, sigset_t *) __asm("_" "pthread_sigmask" "$UNIX2003");
void pthread_yield_np(void);
# 19 "/opt/local/include/gc/gc_pthread_redirects.h" 2
# 1 "/usr/include/signal.h" 1 3 4
# 63 "/usr/include/signal.h" 3 4
# 1 "/usr/include/sys/signal.h" 1 3 4
# 73 "/usr/include/sys/signal.h" 3 4
# 1 "/usr/include/sys/appleapiopts.h" 1 3 4
# 74 "/usr/include/sys/signal.h" 2 3 4
# 1 "/usr/include/machine/signal.h" 1 3 4
# 34 "/usr/include/machine/signal.h" 3 4
# 1 "/usr/include/i386/signal.h" 1 3 4
# 39 "/usr/include/i386/signal.h" 3 4
typedef int sig_atomic_t;
# 55 "/usr/include/i386/signal.h" 3 4
# 1 "/usr/include/i386/_structs.h" 1 3 4
# 56 "/usr/include/i386/signal.h" 2 3 4
# 35 "/usr/include/machine/signal.h" 2 3 4
# 82 "/usr/include/sys/signal.h" 2 3 4
# 154 "/usr/include/sys/signal.h" 3 4
# 1 "/usr/include/sys/_structs.h" 1 3 4
# 57 "/usr/include/sys/_structs.h" 3 4
# 1 "/usr/include/machine/_structs.h" 1 3 4
# 31 "/usr/include/machine/_structs.h" 3 4
# 1 "/usr/include/i386/_structs.h" 1 3 4
# 38 "/usr/include/i386/_structs.h" 3 4
# 1 "/usr/include/mach/i386/_structs.h" 1 3 4
# 43 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_i386_thread_state
{
unsigned int __eax;
unsigned int __ebx;
unsigned int __ecx;
unsigned int __edx;
unsigned int __edi;
unsigned int __esi;
unsigned int __ebp;
unsigned int __esp;
unsigned int __ss;
unsigned int __eflags;
unsigned int __eip;
unsigned int __cs;
unsigned int __ds;
unsigned int __es;
unsigned int __fs;
unsigned int __gs;
};
# 89 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_fp_control
{
unsigned short __invalid :1,
__denorm :1,
__zdiv :1,
__ovrfl :1,
__undfl :1,
__precis :1,
:2,
__pc :2,
__rc :2,
:1,
:3;
};
typedef struct __darwin_fp_control __darwin_fp_control_t;
# 147 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_fp_status
{
unsigned short __invalid :1,
__denorm :1,
__zdiv :1,
__ovrfl :1,
__undfl :1,
__precis :1,
__stkflt :1,
__errsumm :1,
__c0 :1,
__c1 :1,
__c2 :1,
__tos :3,
__c3 :1,
__busy :1;
};
typedef struct __darwin_fp_status __darwin_fp_status_t;
# 191 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_mmst_reg
{
char __mmst_reg[10];
char __mmst_rsrv[6];
};
# 210 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_xmm_reg
{
char __xmm_reg[16];
};
# 232 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_i386_float_state
{
int __fpu_reserved[2];
struct __darwin_fp_control __fpu_fcw;
struct __darwin_fp_status __fpu_fsw;
__uint8_t __fpu_ftw;
__uint8_t __fpu_rsrv1;
__uint16_t __fpu_fop;
__uint32_t __fpu_ip;
__uint16_t __fpu_cs;
__uint16_t __fpu_rsrv2;
__uint32_t __fpu_dp;
__uint16_t __fpu_ds;
__uint16_t __fpu_rsrv3;
__uint32_t __fpu_mxcsr;
__uint32_t __fpu_mxcsrmask;
struct __darwin_mmst_reg __fpu_stmm0;
struct __darwin_mmst_reg __fpu_stmm1;
struct __darwin_mmst_reg __fpu_stmm2;
struct __darwin_mmst_reg __fpu_stmm3;
struct __darwin_mmst_reg __fpu_stmm4;
struct __darwin_mmst_reg __fpu_stmm5;
struct __darwin_mmst_reg __fpu_stmm6;
struct __darwin_mmst_reg __fpu_stmm7;
struct __darwin_xmm_reg __fpu_xmm0;
struct __darwin_xmm_reg __fpu_xmm1;
struct __darwin_xmm_reg __fpu_xmm2;
struct __darwin_xmm_reg __fpu_xmm3;
struct __darwin_xmm_reg __fpu_xmm4;
struct __darwin_xmm_reg __fpu_xmm5;
struct __darwin_xmm_reg __fpu_xmm6;
struct __darwin_xmm_reg __fpu_xmm7;
char __fpu_rsrv4[14*16];
int __fpu_reserved1;
};
# 308 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_i386_exception_state
{
unsigned int __trapno;
unsigned int __err;
unsigned int __faultvaddr;
};
# 326 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_x86_debug_state32
{
unsigned int __dr0;
unsigned int __dr1;
unsigned int __dr2;
unsigned int __dr3;
unsigned int __dr4;
unsigned int __dr5;
unsigned int __dr6;
unsigned int __dr7;
};
# 358 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_x86_thread_state64
{
__uint64_t __rax;
__uint64_t __rbx;
__uint64_t __rcx;
__uint64_t __rdx;
__uint64_t __rdi;
__uint64_t __rsi;
__uint64_t __rbp;
__uint64_t __rsp;
__uint64_t __r8;
__uint64_t __r9;
__uint64_t __r10;
__uint64_t __r11;
__uint64_t __r12;
__uint64_t __r13;
__uint64_t __r14;
__uint64_t __r15;
__uint64_t __rip;
__uint64_t __rflags;
__uint64_t __cs;
__uint64_t __fs;
__uint64_t __gs;
};
# 413 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_x86_float_state64
{
int __fpu_reserved[2];
struct __darwin_fp_control __fpu_fcw;
struct __darwin_fp_status __fpu_fsw;
__uint8_t __fpu_ftw;
__uint8_t __fpu_rsrv1;
__uint16_t __fpu_fop;
__uint32_t __fpu_ip;
__uint16_t __fpu_cs;
__uint16_t __fpu_rsrv2;
__uint32_t __fpu_dp;
__uint16_t __fpu_ds;
__uint16_t __fpu_rsrv3;
__uint32_t __fpu_mxcsr;
__uint32_t __fpu_mxcsrmask;
struct __darwin_mmst_reg __fpu_stmm0;
struct __darwin_mmst_reg __fpu_stmm1;
struct __darwin_mmst_reg __fpu_stmm2;
struct __darwin_mmst_reg __fpu_stmm3;
struct __darwin_mmst_reg __fpu_stmm4;
struct __darwin_mmst_reg __fpu_stmm5;
struct __darwin_mmst_reg __fpu_stmm6;
struct __darwin_mmst_reg __fpu_stmm7;
struct __darwin_xmm_reg __fpu_xmm0;
struct __darwin_xmm_reg __fpu_xmm1;
struct __darwin_xmm_reg __fpu_xmm2;
struct __darwin_xmm_reg __fpu_xmm3;
struct __darwin_xmm_reg __fpu_xmm4;
struct __darwin_xmm_reg __fpu_xmm5;
struct __darwin_xmm_reg __fpu_xmm6;
struct __darwin_xmm_reg __fpu_xmm7;
struct __darwin_xmm_reg __fpu_xmm8;
struct __darwin_xmm_reg __fpu_xmm9;
struct __darwin_xmm_reg __fpu_xmm10;
struct __darwin_xmm_reg __fpu_xmm11;
struct __darwin_xmm_reg __fpu_xmm12;
struct __darwin_xmm_reg __fpu_xmm13;
struct __darwin_xmm_reg __fpu_xmm14;
struct __darwin_xmm_reg __fpu_xmm15;
char __fpu_rsrv4[6*16];
int __fpu_reserved1;
};
# 517 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_x86_exception_state64
{
unsigned int __trapno;
unsigned int __err;
__uint64_t __faultvaddr;
};
# 535 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_x86_debug_state64
{
__uint64_t __dr0;
__uint64_t __dr1;
__uint64_t __dr2;
__uint64_t __dr3;
__uint64_t __dr4;
__uint64_t __dr5;
__uint64_t __dr6;
__uint64_t __dr7;
};
# 39 "/usr/include/i386/_structs.h" 2 3 4
# 48 "/usr/include/i386/_structs.h" 3 4
struct __darwin_mcontext32
{
struct __darwin_i386_exception_state __es;
struct __darwin_i386_thread_state __ss;
struct __darwin_i386_float_state __fs;
};
# 68 "/usr/include/i386/_structs.h" 3 4
struct __darwin_mcontext64
{
struct __darwin_x86_exception_state64 __es;
struct __darwin_x86_thread_state64 __ss;
struct __darwin_x86_float_state64 __fs;
};
# 94 "/usr/include/i386/_structs.h" 3 4
typedef struct __darwin_mcontext32 *mcontext_t;
# 32 "/usr/include/machine/_structs.h" 2 3 4
# 58 "/usr/include/sys/_structs.h" 2 3 4
# 75 "/usr/include/sys/_structs.h" 3 4
struct __darwin_sigaltstack
{
void *ss_sp;
__darwin_size_t ss_size;
int ss_flags;
};
# 128 "/usr/include/sys/_structs.h" 3 4
struct __darwin_ucontext
{
int uc_onstack;
__darwin_sigset_t uc_sigmask;
struct __darwin_sigaltstack uc_stack;
struct __darwin_ucontext *uc_link;
__darwin_size_t uc_mcsize;
struct __darwin_mcontext32 *uc_mcontext;
};
# 218 "/usr/include/sys/_structs.h" 3 4
typedef struct __darwin_sigaltstack stack_t;
# 227 "/usr/include/sys/_structs.h" 3 4
typedef struct __darwin_ucontext ucontext_t;
# 155 "/usr/include/sys/signal.h" 2 3 4
typedef __darwin_pid_t pid_t;
# 178 "/usr/include/sys/signal.h" 3 4
typedef __darwin_uid_t uid_t;
union sigval {
int sival_int;
void *sival_ptr;
};
struct sigevent {
int sigev_notify;
int sigev_signo;
union sigval sigev_value;
void (*sigev_notify_function)(union sigval);
pthread_attr_t *sigev_notify_attributes;
};
typedef struct __siginfo {
int si_signo;
int si_errno;
int si_code;
pid_t si_pid;
uid_t si_uid;
int si_status;
void *si_addr;
union sigval si_value;
long si_band;
unsigned long __pad[7];
} siginfo_t;
# 292 "/usr/include/sys/signal.h" 3 4
union __sigaction_u {
void (*__sa_handler)(int);
void (*__sa_sigaction)(int, struct __siginfo *,
void *);
};
struct __sigaction {
union __sigaction_u __sigaction_u;
void (*sa_tramp)(void *, int, int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
};
struct sigaction {
union __sigaction_u __sigaction_u;
sigset_t sa_mask;
int sa_flags;
};
# 354 "/usr/include/sys/signal.h" 3 4
typedef void (*sig_t)(int);
# 371 "/usr/include/sys/signal.h" 3 4
struct sigvec {
void (*sv_handler)(int);
int sv_mask;
int sv_flags;
};
# 390 "/usr/include/sys/signal.h" 3 4
struct sigstack {
char *ss_sp;
int ss_onstack;
};
# 412 "/usr/include/sys/signal.h" 3 4
void (*signal(int, void (*)(int)))(int);
# 64 "/usr/include/signal.h" 2 3 4
extern const char *const sys_signame[32];
extern const char *const sys_siglist[32];
int raise(int);
void (*bsd_signal(int, void (*)(int)))(int);
int kill(pid_t, int) __asm("_" "kill" "$UNIX2003");
int killpg(pid_t, int) __asm("_" "killpg" "$UNIX2003");
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, const sigset_t *, sigset_t *) __asm("_" "pthread_sigmask" "$UNIX2003");
int sigaction(int, const struct sigaction * ,
struct sigaction * );
int sigaddset(sigset_t *, int);
int sigaltstack(const stack_t * , stack_t * ) __asm("_" "sigaltstack" "$UNIX2003");
int sigdelset(sigset_t *, int);
int sigemptyset(sigset_t *);
int sigfillset(sigset_t *);
int sighold(int);
int sigignore(int);
int siginterrupt(int, int);
int sigismember(const sigset_t *, int);
int sigpause(int) __asm("_" "sigpause" "$UNIX2003");
int sigpending(sigset_t *);
int sigprocmask(int, const sigset_t * , sigset_t * );
int sigrelse(int);
void (*sigset(int, void (*)(int)))(int);
int sigsuspend(const sigset_t *) __asm("_" "sigsuspend" "$UNIX2003");
int sigwait(const sigset_t * , int * ) __asm("_" "sigwait" "$UNIX2003");
void psignal(unsigned int, const char *);
int sigblock(int);
int sigsetmask(int);
int sigvec(int, struct sigvec *, struct sigvec *);
static __inline int
__sigbits(int __signo)
{
return __signo > 32 ? 0 : (1 << (__signo - 1));
}
# 20 "/opt/local/include/gc/gc_pthread_redirects.h" 2
int GC_pthread_create(pthread_t *new_thread,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
int GC_pthread_join(pthread_t thread, void **retval);
int GC_pthread_detach(pthread_t thread);
# 985 "/opt/local/include/gc/gc.h" 2
# 995 "/opt/local/include/gc/gc.h"
void * GC_malloc_many(size_t lb);
# 1006 "/opt/local/include/gc/gc.h"
extern void
GC_register_has_static_roots_callback
(int (*callback)(const char *, void *, size_t));
# 39 "vm/threads.c" 2
# 53 "vm/threads.c"
# 1 "/usr/include/stdlib.h" 1 3 4
# 61 "/usr/include/stdlib.h" 3 4
# 1 "/usr/include/available.h" 1 3 4
# 62 "/usr/include/stdlib.h" 2 3 4
# 1 "/usr/include/sys/wait.h" 1 3 4
# 79 "/usr/include/sys/wait.h" 3 4
typedef enum {
P_ALL,
P_PID,
P_PGID
} idtype_t;
# 95 "/usr/include/sys/wait.h" 3 4
typedef __darwin_id_t id_t;
# 117 "/usr/include/sys/wait.h" 3 4
# 1 "/usr/include/sys/resource.h" 1 3 4
# 76 "/usr/include/sys/resource.h" 3 4
# 1 "/usr/include/sys/_structs.h" 1 3 4
# 100 "/usr/include/sys/_structs.h" 3 4
struct timeval
{
__darwin_time_t tv_sec;
__darwin_suseconds_t tv_usec;
};
# 77 "/usr/include/sys/resource.h" 2 3 4
# 88 "/usr/include/sys/resource.h" 3 4
typedef __uint64_t rlim_t;
# 142 "/usr/include/sys/resource.h" 3 4
struct rusage {
struct timeval ru_utime;
struct timeval ru_stime;
# 153 "/usr/include/sys/resource.h" 3 4
long ru_maxrss;
long ru_ixrss;
long ru_idrss;
long ru_isrss;
long ru_minflt;
long ru_majflt;
long ru_nswap;
long ru_inblock;
long ru_oublock;
long ru_msgsnd;
long ru_msgrcv;
long ru_nsignals;
long ru_nvcsw;
long ru_nivcsw;
};
# 213 "/usr/include/sys/resource.h" 3 4
struct rlimit {
rlim_t rlim_cur;
rlim_t rlim_max;
};
# 235 "/usr/include/sys/resource.h" 3 4
int getpriority(int, id_t);
int getiopolicy_np(int, int);
int getrlimit(int, struct rlimit *) __asm("_" "getrlimit" "$UNIX2003");
int getrusage(int, struct rusage *);
int setpriority(int, id_t, int);
int setiopolicy_np(int, int, int);
int setrlimit(int, const struct rlimit *) __asm("_" "setrlimit" "$UNIX2003");
# 118 "/usr/include/sys/wait.h" 2 3 4
# 193 "/usr/include/sys/wait.h" 3 4
# 1 "/usr/include/machine/endian.h" 1 3 4
# 37 "/usr/include/machine/endian.h" 3 4
# 1 "/usr/include/i386/endian.h" 1 3 4
# 99 "/usr/include/i386/endian.h" 3 4
# 1 "/usr/include/sys/_endian.h" 1 3 4
# 124 "/usr/include/sys/_endian.h" 3 4
# 1 "/usr/include/libkern/_OSByteOrder.h" 1 3 4
# 66 "/usr/include/libkern/_OSByteOrder.h" 3 4
# 1 "/usr/include/libkern/i386/_OSByteOrder.h" 1 3 4
# 44 "/usr/include/libkern/i386/_OSByteOrder.h" 3 4
static __inline__
__uint16_t
_OSSwapInt16(
__uint16_t _data
)
{
return ((_data << 8) | (_data >> 8));
}
static __inline__
__uint32_t
_OSSwapInt32(
__uint32_t _data
)
{
__asm__ ("bswap %0" : "+r" (_data));
return _data;
}
static __inline__
__uint64_t
_OSSwapInt64(
__uint64_t _data
)
{
__asm__ ("bswap %%eax\n\t"
"bswap %%edx\n\t"
"xchgl %%eax, %%edx"
: "+A" (_data));
return _data;
}
# 67 "/usr/include/libkern/_OSByteOrder.h" 2 3 4
# 125 "/usr/include/sys/_endian.h" 2 3 4
# 100 "/usr/include/i386/endian.h" 2 3 4
# 38 "/usr/include/machine/endian.h" 2 3 4
# 194 "/usr/include/sys/wait.h" 2 3 4
union wait {
int w_status;
struct {
unsigned int w_Termsig:7,
w_Coredump:1,
w_Retcode:8,
w_Filler:16;
} w_T;
struct {
unsigned int w_Stopval:8,
w_Stopsig:8,
w_Filler:16;
} w_S;
};
# 254 "/usr/include/sys/wait.h" 3 4
pid_t wait(int *) __asm("_" "wait" "$UNIX2003");
pid_t waitpid(pid_t, int *, int) __asm("_" "waitpid" "$UNIX2003");
int waitid(idtype_t, id_t, siginfo_t *, int) __asm("_" "waitid" "$UNIX2003");
pid_t wait3(int *, int, struct rusage *);
pid_t wait4(pid_t, int *, int, struct rusage *);
# 66 "/usr/include/stdlib.h" 2 3 4
# 1 "/usr/include/alloca.h" 1 3 4
# 35 "/usr/include/alloca.h" 3 4
void *alloca(size_t);
# 68 "/usr/include/stdlib.h" 2 3 4
# 81 "/usr/include/stdlib.h" 3 4
typedef __darwin_ct_rune_t ct_rune_t;
typedef __darwin_rune_t rune_t;
# 97 "/usr/include/stdlib.h" 3 4
typedef struct {
int quot;
int rem;
} div_t;
typedef struct {
long quot;
long rem;
} ldiv_t;
typedef struct {
long long quot;
long long rem;
} lldiv_t;
# 134 "/usr/include/stdlib.h" 3 4
extern int __mb_cur_max;
# 144 "/usr/include/stdlib.h" 3 4
void abort(void) __attribute__((__noreturn__));
int abs(int) __attribute__((__const__));
int atexit(void (*)(void));
double atof(const char *);
int atoi(const char *);
long atol(const char *);
long long
atoll(const char *);
void *bsearch(const void *, const void *, size_t,
size_t, int (*)(const void *, const void *));
void *calloc(size_t, size_t);
div_t div(int, int) __attribute__((__const__));
void exit(int) __attribute__((__noreturn__));
void free(void *);
char *getenv(const char *);
long labs(long) __attribute__((__const__));
ldiv_t ldiv(long, long) __attribute__((__const__));
long long
llabs(long long);
lldiv_t lldiv(long long, long long);
void *malloc(size_t);
int mblen(const char *, size_t);
size_t mbstowcs(wchar_t * , const char * , size_t);
int mbtowc(wchar_t * , const char * , size_t);
void qsort(void *, size_t, size_t,
int (*)(const void *, const void *));
int rand(void);
void *realloc(void *, size_t);
void srand(unsigned);
double strtod(const char *, char **) __asm("_" "strtod" "$UNIX2003");
float strtof(const char *, char **) __asm("_" "strtof" "$UNIX2003");
long strtol(const char *, char **, int);
long double
strtold(const char *, char **) ;
long long
strtoll(const char *, char **, int);
unsigned long
strtoul(const char *, char **, int);
unsigned long long
strtoull(const char *, char **, int);
int system(const char *) __asm("_" "system" "$UNIX2003");
size_t wcstombs(char * , const wchar_t * , size_t);
int wctomb(char *, wchar_t);
void _Exit(int) __attribute__((__noreturn__));
long a64l(const char *);
double drand48(void);
char *ecvt(double, int, int *, int *);
double erand48(unsigned short[3]);
char *fcvt(double, int, int *, int *);
char *gcvt(double, int, char *);
int getsubopt(char **, char * const *, char **);
int grantpt(int);
char *initstate(unsigned, char *, size_t);
long jrand48(unsigned short[3]);
char *l64a(long);
void lcong48(unsigned short[7]);
long lrand48(void);
char *mktemp(char *);
int mkstemp(char *);
long mrand48(void);
long nrand48(unsigned short[3]);
int posix_openpt(int);
char *ptsname(int);
int putenv(char *) __asm("_" "putenv" "$UNIX2003");
long random(void);
int rand_r(unsigned *);
char *realpath(const char * , char * ) __asm("_" "realpath" "$DARWIN_EXTSN");
unsigned short
*seed48(unsigned short[3]);
int setenv(const char *, const char *, int) __asm("_" "setenv" "$UNIX2003");
void setkey(const char *) __asm("_" "setkey" "$UNIX2003");
char *setstate(const char *);
void srand48(long);
void srandom(unsigned);
int unlockpt(int);
int unsetenv(const char *) __asm("_" "unsetenv" "$UNIX2003");
# 1 "/usr/include/machine/types.h" 1 3 4
# 37 "/usr/include/machine/types.h" 3 4
# 1 "/usr/include/i386/types.h" 1 3 4
# 80 "/usr/include/i386/types.h" 3 4
typedef unsigned char u_int8_t;
typedef unsigned short u_int16_t;
typedef unsigned int u_int32_t;
typedef unsigned long long u_int64_t;
typedef int32_t register_t;
# 114 "/usr/include/i386/types.h" 3 4
typedef u_int64_t user_addr_t;
typedef u_int64_t user_size_t;
typedef int64_t user_ssize_t;
typedef int64_t user_long_t;
typedef u_int64_t user_ulong_t;
typedef int64_t user_time_t;
typedef u_int64_t syscall_arg_t;
# 38 "/usr/include/machine/types.h" 2 3 4
# 255 "/usr/include/stdlib.h" 2 3 4
typedef __darwin_dev_t dev_t;
typedef __darwin_mode_t mode_t;
u_int32_t
arc4random(void);
void arc4random_addrandom(unsigned char *dat, int datlen);
void arc4random_stir(void);
char *cgetcap(char *, const char *, int);
int cgetclose(void);
int cgetent(char **, char **, const char *);
int cgetfirst(char **, char **);
int cgetmatch(const char *, const char *);
int cgetnext(char **, char **);
int cgetnum(char *, const char *, long *);
int cgetset(const char *);
int cgetstr(char *, const char *, char **);
int cgetustr(char *, const char *, char **);
int daemon(int, int) __asm("_" "daemon" "$1050") __attribute__((deprecated));
char *devname(dev_t, mode_t);
char *devname_r(dev_t, mode_t, char *buf, int len);
char *getbsize(int *, long *);
int getloadavg(double [], int);
const char
*getprogname(void);
int heapsort(void *, size_t, size_t,
int (*)(const void *, const void *));
int mergesort(void *, size_t, size_t,
int (*)(const void *, const void *));
void qsort_r(void *, size_t, size_t, void *,
int (*)(void *, const void *, const void *));
int radixsort(const unsigned char **, int, const unsigned char *,
unsigned);
void setprogname(const char *);
int sradixsort(const unsigned char **, int, const unsigned char *,
unsigned);
void sranddev(void);
void srandomdev(void);
void *reallocf(void *, size_t);
long long
strtoq(const char *, char **, int);
unsigned long long
strtouq(const char *, char **, int);
extern char *suboptarg;
void *valloc(size_t);
# 54 "vm/threads.c" 2
struct _mt_local {
pthread_key_t key;
};
struct _mt_lock {
pthread_mutex_t lock;
};
typedef char __stack_base[64];
typedef struct {
thread_main_func init;
thread_main_func main;
void *param;
pthread_mutex_t lock;
} tparams;
# 92 "vm/threads.c"
typedef int (*rec)( int, void * );
static int clean_c_stack( int n, void *f ) {
char buf[256];
memset(buf,n,sizeof(buf));
if( n == 0 ) return *buf;
return ((rec)f)(n-1,f) ? 1 : 0;
}
static void * ThreadMain( void *_p ) {
tparams *lp = (tparams*)_p;
tparams p = *lp;
p.init(p.param);
pthread_mutex_unlock(&lp->lock);
clean_c_stack(40,clean_c_stack);
p.main(p.param);
return 0;
}
int neko_thread_create( thread_main_func init, thread_main_func main, void *param, void **handle ) {
tparams p;
p.init = init;
p.main = main;
p.param = param;
# 141 "vm/threads.c"
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr,2);
pthread_mutex_init(&p.lock,((void *)0));
pthread_mutex_lock(&p.lock);
if( GC_pthread_create((pthread_t*)handle,&attr,&ThreadMain,&p) != 0 ) {
pthread_attr_destroy(&attr);
pthread_mutex_destroy(&p.lock);
return 0;
}
pthread_mutex_lock(&p.lock);
pthread_attr_destroy(&attr);
pthread_mutex_destroy(&p.lock);
return 1;
}
# 1 "/usr/include/dlfcn.h" 1 3 4
# 40 "/usr/include/dlfcn.h" 3 4
# 1 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdbool.h" 1 3 4
# 41 "/usr/include/dlfcn.h" 2 3 4
# 1 "/usr/include/AvailabilityMacros.h" 1 3 4
# 42 "/usr/include/dlfcn.h" 2 3 4
typedef struct dl_info {
const char *dli_fname;
void *dli_fbase;
const char *dli_sname;
void *dli_saddr;
} Dl_info;
extern int dladdr(const void *, Dl_info *);
extern int dlclose(void * __handle);
extern char * dlerror(void);
extern void * dlopen(const char * __path, int __mode);
extern void * dlsym(void * __handle, const char * __symbol);
extern _Bool dlopen_preflight(const char* __path) ;
# 162 "vm/threads.c" 2
typedef void (*callb_func)( thread_main_func, void * );
typedef int (*std_func)();
typedef int (*gc_stack_ptr)( __stack_base * );
static int do_nothing( __stack_base *sb ) {
return -1;
}
void neko_thread_blocking( thread_main_func f, void *p ) {
static callb_func do_blocking = ((void *)0);
static std_func start = ((void *)0), end = ((void *)0);
if( do_blocking )
do_blocking(f,p);
else if( start ) {
start();
f(p);
end();
} else {
void *self = dlopen(((void *)0),0);
do_blocking = (callb_func)dlsym(self,"GC_do_blocking");
if( !do_blocking ) {
start = (std_func)dlsym(self,"GC_start_blocking");
end = (std_func)dlsym(self,"GC_end_blocking");
if( !start || !end )
neko_val_throw(neko_alloc_string("Could not init GC blocking API"));
}
neko_thread_blocking(f,p);
}
}
_Bool neko_thread_register( _Bool t ) {
# 217 "vm/threads.c"
static gc_stack_ptr get_sb = ((void *)0), my_thread = ((void *)0);
static std_func unreg_my_thread = ((void *)0);
if( !t && unreg_my_thread != ((void *)0) ) {
return unreg_my_thread() == 0;
} else if( my_thread != ((void *)0) ) {
__stack_base sb;
int r;
if( get_sb(&sb) != 0 )
return 0;
r = my_thread(&sb);
return( r == 0 || r == 1 );
} else {
void *self = dlopen(((void *)0),0);
my_thread = (gc_stack_ptr)dlsym(self,"GC_register_my_thread");
get_sb = (gc_stack_ptr)dlsym(self,"GC_get_stack_base");
unreg_my_thread = (std_func)dlsym(self,"GC_unregister_my_thread");
if( my_thread == ((void *)0) ) my_thread = do_nothing;
if( get_sb == ((void *)0) ) get_sb = do_nothing;
if( unreg_my_thread == ((void *)0) ) unreg_my_thread = (std_func)do_nothing;
return neko_thread_register(t);
}
}
mt_local *neko_alloc_local() {
# 252 "vm/threads.c"
mt_local *l = malloc(sizeof(mt_local));
pthread_key_create(&l->key,((void *)0));
return l;
}
void neko_free_local( mt_local *l ) {
pthread_key_delete(l->key);
free(l);
}
void neko_local_set( mt_local *l, void *v ) {
pthread_setspecific(l->key,v);
}
void *neko_local_get( mt_local *l ) {
if( l == ((void *)0) )
return ((void *)0);
return pthread_getspecific(l->key);
}
mt_lock *neko_alloc_lock() {
mt_lock *l = (mt_lock*)malloc(sizeof(mt_lock));
pthread_mutexattr_t a;
pthread_mutexattr_init(&a);
pthread_mutexattr_settype(&a,2);
pthread_mutex_init(&l->lock,&a);
pthread_mutexattr_destroy(&a);
return l;
}
void neko_lock_acquire( mt_lock *l ) {
pthread_mutex_lock(&l->lock);
}
int neko_lock_try( mt_lock *l ) {
return pthread_mutex_trylock(&l->lock) == 0;
}
void neko_lock_release( mt_lock *l ) {
pthread_mutex_unlock(&l->lock);
}
void neko_free_lock( mt_lock *l ) {
pthread_mutex_destroy(&l->lock);
free(l);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment