Skip to content
Snippets Groups Projects
Select Git revision
21 results Searching

Process.pmod

Blame
  • object.h 6.49 KiB
    /*
    || This file is part of Pike. For copyright information see COPYRIGHT.
    || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
    || for more information.
    || $Id: object.h,v 1.98 2008/06/03 14:52:47 mast Exp $
    */
    
    #ifndef OBJECT_H
    #define OBJECT_H
    
    #include "global.h"
    #include "svalue.h"
    #include "dmalloc.h"
    
    /* a destructed object has no program */
    
    #ifndef STRUCT_OBJECT_DECLARED
    #define STRUCT_OBJECT_DECLARED
    #endif
    struct object
    {
      PIKE_MEMORY_OBJECT_MEMBERS; /* Must be first */
      struct program *prog;
      struct object *next;
      struct object *prev;
    #ifdef PIKE_DEBUG
      INT32 program_id;
    #endif
      char *storage;
    };
    
    PMOD_EXPORT extern struct object *first_object;
    extern struct object *gc_internal_object;
    extern struct object *objects_to_destruct;
    extern struct object *master_object;
    extern struct program *master_program;
    extern struct program *magic_index_program;
    extern struct program *magic_set_index_program;
    extern struct program *magic_indices_program;
    extern struct program *magic_values_program;
    #ifdef DO_PIKE_CLEANUP
    PMOD_EXPORT extern int gc_external_refs_zapped;
    PMOD_EXPORT void gc_check_zapped (void *a, TYPE_T type, const char *file, int line);
    #endif
    
    #define free_object(O) do{						\
        struct object *o_=(O);						\
        debug_malloc_touch(o_);						\
        debug_malloc_touch(o_->storage);					\
        DO_IF_DEBUG (							\
          DO_IF_PIKE_CLEANUP (						\
    	if (gc_external_refs_zapped)					\
    	  gc_check_zapped (o_, PIKE_T_OBJECT, __FILE__, __LINE__)));	\
        if(!sub_ref(o_))							\
          schedule_really_free_object(o_);					\
      }while(0)
    
    #ifdef DEBUG_MALLOC
    #define PIKE_OBJ_STORAGE(O) ((char *)debug_malloc_pass( (O)->storage ))
    #else
    #define PIKE_OBJ_STORAGE(O) ((O)->storage)
    #endif
    
    #define LOW_GET_GLOBAL(O,I,ID) (PIKE_OBJ_STORAGE((O))+INHERIT_FROM_INT((O)->prog, (I))->storage_offset+(ID)->func.offset)
    #define GET_GLOBAL(O,I) LOW_GET_GLOBAL(O,I,ID_FROM_INT((O)->prog,I))
    
    #define this_object() (add_ref(Pike_fp->current_object), Pike_fp->current_object)
    
    enum object_destruct_reason {
      DESTRUCT_EXPLICIT = 0,