pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.86 1999/01/21 09:15:19 hubbe Exp $"); + RCSID("$Id: threads.c,v 1.87 1999/02/01 02:41:50 hubbe Exp $");      int num_threads = 1;   int threads_disabled = 0;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "mapping.h"   #include "object.h"   #include "pike_macros.h"
pike.git/src/threads.c:983:    "function(int:void)", OPT_SIDE_EFFECT);   #endif    add_efun("this_thread",f_this_thread,"function(:object)",    OPT_EXTERNAL_DEPEND);    add_efun("all_threads",f_all_threads,"function(:array(object))",    OPT_EXTERNAL_DEPEND);       add_efun("thread_local",f_thread_local,"function(:object)",OPT_SIDE_EFFECT);       start_new_program(); -  add_storage(sizeof(struct mutex_storage)); +  ADD_STORAGE(struct mutex_storage);    add_function("lock",f_mutex_lock,"function(int|void:object)",0);    add_function("trylock",f_mutex_trylock,"function(int|void:object)",0);    set_init_callback(init_mutex_obj);    set_exit_callback(exit_mutex_obj);    end_class("mutex", 0);       start_new_program(); -  mutex_key_offset = add_storage(sizeof(struct key_storage)); +  mutex_key_offset = ADD_STORAGE(struct key_storage);    /* This is needed to allow the gc to find the possible circular reference.    * It also allows a process to take over ownership of a key.    */    map_variable("_owner", "object", 0,    mutex_key_offset + OFFSETOF(key_storage, owner), T_OBJECT);    set_init_callback(init_mutex_key_obj);    set_exit_callback(exit_mutex_key_obj);    mutex_key=end_program();    mutex_key->flags|=PROGRAM_DESTRUCT_IMMEDIATE;   #ifdef PIKE_DEBUG    if(!mutex_key)    fatal("Failed to initialize mutex_key program!\n");   #endif       start_new_program(); -  add_storage(sizeof(COND_T)); +  ADD_STORAGE(COND_T);    add_function("wait",f_cond_wait,"function(void|object:void)",0);    add_function("signal",f_cond_signal,"function(:void)",0);    add_function("broadcast",f_cond_broadcast,"function(:void)",0);    set_init_callback(init_cond_obj);    set_exit_callback(exit_cond_obj);    end_class("condition", 0);       {    struct program *tmp;    start_new_program();    set_init_callback(init_threads_disable);    set_exit_callback(exit_threads_disable);    tmp = end_program();    tmp->flags|=PROGRAM_DESTRUCT_IMMEDIATE;    add_global_program("_disable_threads", tmp);    free_program(tmp);    }       start_new_program(); -  add_storage(sizeof(struct thread_local)); +  ADD_STORAGE(struct thread_local);    add_function("get",f_thread_local_get,"function(:mixed)",0);    add_function("set",f_thread_local_set,"function(mixed:mixed)",0);    thread_local_prog=end_program();    if(!thread_local_prog)    fatal("Failed to initialize thread_local program!\n");       start_new_program(); -  add_storage(sizeof(struct thread_state)); +  ADD_STORAGE(struct thread_state);    thread_id_result_variable=simple_add_variable("result","mixed",0);    add_function("backtrace",f_thread_backtrace,"function(:array)",0);    add_function("wait",f_thread_id_result,"function(:mixed)",0);    add_function("status",f_thread_id_status,"function(:int)",0);    set_gc_mark_callback(thread_was_marked);    set_gc_check_callback(thread_was_checked);    set_init_callback(init_thread_obj);    set_exit_callback(exit_thread_obj);    thread_id_prog=end_program();