/usr/include/pike8.0/pike/object.h is in pike8.0-dev 8.0.164-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | /*
|| 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.
*/
#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 */
size_t flags;
struct program *prog;
struct object *next;
struct object *prev;
#ifdef PIKE_DEBUG
INT32 program_id;
#endif
char *storage;
};
/* Flags used in object->flags. */
#define OBJECT_CLEAR_ON_EXIT 1 /* Overwrite before free. */
PMOD_EXPORT extern struct object *first_object;
extern struct object *gc_internal_object;
PMOD_EXPORT 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;
extern struct program *magic_types_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_TYPE 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,
DESTRUCT_CLEANUP = 1,
DESTRUCT_NO_REFS,
DESTRUCT_GC
};
#include "block_alloc_h.h"
ATTRIBUTE((malloc)) struct object * alloc_object();
void really_free_object(struct object * o);
void count_memory_in_objects(size_t *_num, size_t *_size);
void free_all_object_blocks(void);
PMOD_EXPORT struct object *low_clone(struct program *p);
PMOD_EXPORT void call_c_initializers(struct object *o);
PMOD_EXPORT void call_prog_event(struct object *o, int event);
void call_pike_initializers(struct object *o, int args);
PMOD_EXPORT void do_free_object(struct object *o);
PMOD_EXPORT struct object *debug_clone_object(struct program *p, int args);
PMOD_EXPORT struct object *fast_clone_object(struct program *p);
PMOD_EXPORT struct object *parent_clone_object(struct program *p,
struct object *parent,
ptrdiff_t parent_identifier,
int args);
PMOD_EXPORT struct object *clone_object_from_object(struct object *o, int args);
struct object *decode_value_clone_object(struct svalue *prog);
struct pike_string *low_read_file(const char *file);
PMOD_EXPORT struct object *get_master(void);
PMOD_EXPORT struct object *debug_master(void);
struct destroy_called_mark;
PTR_HASH_ALLOC(destroy_called_mark,128);
PMOD_EXPORT struct program *get_program_for_object_being_destructed(struct object * o);
PMOD_EXPORT void destruct_object (struct object *o, enum object_destruct_reason reason);
#define destruct(o) destruct_object (o, DESTRUCT_EXPLICIT)
PMOD_EXPORT void low_destruct_objects_to_destruct(void);
void destruct_objects_to_destruct_cb(void);
PMOD_EXPORT void schedule_really_free_object(struct object *o);
PMOD_EXPORT int low_object_index_no_free(struct svalue *to,
struct object *o,
ptrdiff_t f);
PMOD_EXPORT int object_index_no_free2(struct svalue *to,
struct object *o,
int inherit_level,
struct svalue *key);
PMOD_EXPORT int object_index_no_free(struct svalue *to,
struct object *o,
int inherit_level,
struct svalue *key);
PMOD_EXPORT void object_low_set_index(struct object *o,
int f,
struct svalue *from);
PMOD_EXPORT void object_set_index2(struct object *o,
int inherit_level,
struct svalue *key,
struct svalue *from);
PMOD_EXPORT void object_set_index(struct object *o,
int inherit_level,
struct svalue *key,
struct svalue *from);
union anything *object_get_item_ptr(struct object *o,
int inherit_level,
struct svalue *key,
TYPE_T type);
PMOD_EXPORT int object_equal_p(struct object *a, struct object *b, struct processing *p);
PMOD_EXPORT struct array *object_indices(struct object *o, int inherit_level);
PMOD_EXPORT struct array *object_values(struct object *o, int inherit_level);
PMOD_EXPORT struct array *object_types(struct object *o, int inherit_level);
PMOD_EXPORT void visit_object (struct object *o, int action, void *extra);
PMOD_EXPORT void visit_function (const struct svalue *s, int ref_type,
void *extra);
PMOD_EXPORT void gc_mark_object_as_referenced(struct object *o);
PMOD_EXPORT void real_gc_cycle_check_object(struct object *o, int weak);
enum memobj_type{
MEMOBJ_NONE,
MEMOBJ_SYSTEM_MEMORY,
MEMOBJ_STRING_BUFFER,
MEMOBJ_STDIO_IOBUFFER,
};
PMOD_EXPORT enum memobj_type get_memory_object_memory( struct object *o, void **ptr, size_t *len, int *shift );
unsigned gc_touch_all_objects(void);
void gc_check_all_objects(void);
void gc_mark_all_objects(void);
void gc_cycle_check_all_objects(void);
void gc_zap_ext_weak_refs_in_objects(void);
size_t gc_free_all_unreferenced_objects(void);
struct magic_index_struct;
void push_magic_index(struct program *type, int inherit_no, int parent_level);
void low_init_object(void);
void init_object(void);
void exit_object(void);
void late_exit_object(void);
void check_object_context(struct object *o,
struct program *context_prog,
char *current_storage);
void check_object(struct object *o);
void check_all_objects(void);
/* Prototypes end here */
#ifdef DEBUG_MALLOC
#define clone_object(X,Y) ((struct object *)debug_malloc_pass(debug_clone_object((X),(Y))))
#else
#define clone_object debug_clone_object
#endif
#ifdef PIKE_DEBUG
#define master() ( get_master() ? get_master() : ( Pike_fatal("Couldn't load master object at %s:%d.\n",__FILE__,__LINE__), (struct object *)NULL) )
#else
#define master() debug_master()
#endif
#define visit_object_ref(O, REF_TYPE, EXTRA) \
visit_ref (pass_object (O), (REF_TYPE), \
(visit_thing_fn *) &visit_object, (EXTRA))
#define gc_cycle_check_object(X, WEAK) \
gc_cycle_enqueue((gc_cycle_check_cb *) real_gc_cycle_check_object, (X), (WEAK))
#define PIKE_OBJ_DESTRUCTED(o) (!(o)->prog)
#define PIKE_OBJ_INITED(o) (o->prog && (o->prog->flags & PROGRAM_PASS_1_DONE) && !((o->prog->flags & PROGRAM_AVOID_CHECK)))
#define destruct_objects_to_destruct() do{ if(objects_to_destruct) low_destruct_objects_to_destruct(); }while(0)
#define low_index_current_object_no_free(TO, FUN) \
low_object_index_no_free((TO), Pike_fp->current_object, \
Pike_fp->context->identifier_level + (FUN))
#endif /* OBJECT_H */
|