~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to erts/emulator/beam/erl_db.h

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "erl_db_tree.h" /* DbTableTree */
33
33
/*TT*/
34
34
 
35
 
Uint erts_ets_memory_size(void);
 
35
Uint erts_get_ets_misc_mem_size(void);
36
36
 
37
37
/*
38
38
 * So, the structure for a database table, NB this is only
45
45
    /*TT*/
46
46
};
47
47
 
48
 
/* This should be a prime number. Find them with super:/usr/games/prime */
49
48
#define DB_DEF_MAX_TABS 2053 /* Superseeded by environment variable 
50
49
                                "ERL_MAX_ETS_TABLES" */
51
50
#define ERL_MAX_ETS_TABLES_ENV "ERL_MAX_ETS_TABLES"
52
51
 
53
52
void init_db(void);
54
 
void db_proc_dead(Eterm pid);
 
53
int erts_db_process_exiting(Process *, ErtsProcLocks);
55
54
void db_info(int, void *, int);
56
55
void erts_db_foreach_table(void (*)(DbTable *, void *), void *);
57
56
void erts_db_foreach_offheap(DbTable *,
63
62
extern Export ets_select_delete_continue_exp;
64
63
extern Export ets_select_count_continue_exp;
65
64
extern Export ets_select_continue_exp;
 
65
extern erts_smp_atomic_t erts_ets_misc_mem_size;
66
66
 
67
 
Eterm erts_ets_slot_to_atom(Uint slot);
 
67
Eterm erts_ets_colliding_names(Process*, Eterm name, Uint cnt);
68
68
 
69
69
#endif
70
70
 
73
73
 
74
74
#include "erl_alloc.h"
75
75
 
76
 
extern erts_smp_atomic_t erts_tot_ets_memory_size; /* NOTE: Memory size in bytes! */
77
 
 
78
76
/*
79
77
 * _fnf : Failure Not Fatal (same as for erts_alloc/erts_realloc/erts_free)
80
78
 * _nt  : No Table (i.e. memory not associated with a specific table)
83
81
#define ERTS_DB_ALC_MEM_UPDATE_(TAB, FREE_SZ, ALLOC_SZ)                 \
84
82
do {                                                                    \
85
83
    long sz__ = ((long) (ALLOC_SZ)) - ((long) (FREE_SZ));               \
86
 
    erts_smp_atomic_add(&erts_tot_ets_memory_size, sz__);               \
87
84
    ASSERT((TAB));                                                      \
88
85
    erts_smp_atomic_add(&(TAB)->common.memory_size, sz__);              \
89
86
} while (0)
90
87
 
91
 
#define ERTS_DB_ALC_MEM_UPDATE_NT_(FREE_SZ, ALLOC_SZ)                   \
92
 
do {                                                                    \
93
 
    long sz__ = ((long) (ALLOC_SZ)) - ((long) (FREE_SZ));               \
94
 
    erts_smp_atomic_add(&erts_tot_ets_memory_size, sz__);               \
95
 
} while (0)
 
88
#define ERTS_ETS_MISC_MEM_ADD(SZ) \
 
89
  erts_smp_atomic_add(&erts_ets_misc_mem_size, (SZ));
96
90
 
97
91
ERTS_GLB_INLINE void *erts_db_alloc(ErtsAlcType_t type,
98
92
                                    DbTable *tab,
127
121
erts_db_alloc_nt(ErtsAlcType_t type, Uint size)
128
122
{
129
123
    void *res = erts_alloc(type, size);
130
 
    ERTS_DB_ALC_MEM_UPDATE_NT_(0, size);
131
124
    return res;
132
125
}
133
126
 
137
130
    void *res = erts_alloc_fnf(type, size);
138
131
    if (!res)
139
132
        return NULL;
140
 
    ERTS_DB_ALC_MEM_UPDATE_NT_(0, size);
141
133
    return res;
142
134
}
143
135
 
195
187
    void *res;
196
188
    ASSERT(!ptr || old_size == ERTS_ALC_DBG_BLK_SZ(ptr));
197
189
    res = erts_realloc(type, ptr, size);
198
 
    ERTS_DB_ALC_MEM_UPDATE_NT_(old_size, size);
199
190
    return res;
200
191
}
201
192
 
208
199
    res = erts_realloc_fnf(type, ptr, size);
209
200
    if (!res)
210
201
        return NULL;
211
 
    ERTS_DB_ALC_MEM_UPDATE_NT_(old_size, size);
212
202
    return res;
213
203
}
214
204
 
219
209
                                  void *ptr,
220
210
                                  Uint size);
221
211
 
 
212
ERTS_GLB_INLINE void erts_db_free_nt(ErtsAlcType_t type,
 
213
                                     void *ptr,
 
214
                                     Uint size);
 
215
 
222
216
#if ERTS_GLB_INLINE_INCL_FUNC_DEF
223
217
 
224
218
ERTS_GLB_INLINE void
233
227
 
234
228
    erts_free(type, ptr);
235
229
}
 
230
 
 
231
ERTS_GLB_INLINE void
 
232
erts_db_free_nt(ErtsAlcType_t type, void *ptr, Uint size)
 
233
{
 
234
    ASSERT(ptr != 0);
 
235
    ASSERT(size == ERTS_ALC_DBG_BLK_SZ(ptr));
 
236
 
 
237
    erts_free(type, ptr);
 
238
}
 
239
 
236
240
#endif /* #if ERTS_GLB_INLINE_INCL_FUNC_DEF */
237
241
 
238
 
#undef ERTS_DB_ALC_MEM_UPDATE_NT_
239
242
#undef ERTS_DB_ALC_MEM_UPDATE_
240
243
 
241
244
#endif /* #if defined(ERTS_WANT_DB_INTERNAL__) && !defined(ERTS_HAVE_DB_INTERNAL__) */