25 #include "pips_config.h"
46 #define IGNORE_RX "PIPS_IGNORE_FUNCTION_RX"
52 #define db_resource_stored_p(r) db_status_stored_p(db_resource_db_status(r))
53 #define db_resource_loaded_p(r) db_status_loaded_p(db_resource_db_status(r))
54 #define db_resource_required_p(r) \
55 db_status_required_p(db_resource_db_status(r))
56 #define db_resource_loaded_and_stored_p(r) \
57 db_status_loaded_and_stored_p(db_resource_db_status(r))
104 #define DB_OK pips_assert("defined database", !pips_database_undefined_p())
105 #define DB_UNDEF pips_assert("undefined database", pips_database_undefined_p())
125 set_pips_database(rs);
158 if (!pips_database_undefined_p()) reset_pips_database();
176 return "loaded&stored";
184 const char* rname,
const char* oname,
db_resource r)
188 pips_debug(1,
"rname=%s, oname=%s, r=%p\n", rname, oname, r);
191 pips_debug(1,
"pointer=%p, status=%s, time=%td, file_time=%td\n",
208 fprintf(file,
"resource %s[%s] status '%s' since %td (%td) 0x%p\n",
217 get_pips_database());
221 #define debug_db_resource(l, r, o, p) ifdebug(l) { dump_db_resource(r, o, p);}
227 if (!bound_pips_database_p(s))
234 return bound_pips_database_p(o)?
252 pips_debug(1,
"creating or for %s...\n", oname);
274 pips_debug(1,
"module %s should have been registered\n", oname);
306 pips_debug(8,
"considering %s[%s] (0x%p)\n", rn, on, (
void*) r);
310 pips_debug(1,
"resource %s[%s] in state required...\n", rn, on);
320 pips_debug(1,
"resource %s[%s] file vanished...\n", rn, on);
326 pips_debug(1,
"resource %s[%s] set as stored\n", rn, on);
333 get_pips_database());
336 for (; lr && lo; lr =
CDR(lr), lo =
CDR(lo))
340 pips_debug(1,
"deleting required %s[%s]\n", rn, on);
401 #define gen_DB_VOID_cons(i,l) gen_cons(i,l)
414 if ((*p1)->time != (*p2)->time)
415 return (*p1)->time - (*p2)->time;
416 if ((*p1)->owner_name != (*p2)->owner_name)
417 return strcmp((*p1)->owner_name, (*p2)->owner_name);
418 return strcmp((*p1)->res_name, (*p2)->res_name);
443 get_pips_database());
452 "resource %s[%s] is in 'required' status since %d\n",
473 pips_debug(8,
"considering %s[%s] (%p)\n", rn, on, (
void*) r);
589 pips_debug(7,
"loading %s[%s]\n", rname, oname);
629 pips_debug(7,
"saving %s[%s]\n", rname, oname);
649 const char* rname,
const char* oname,
db_resource r,
bool do_free)
652 do_free?
" and freeing":
"", rname, oname);
762 pips_debug(2,
"get %s[%s] (%s)\n", rname, oname, pure?
"pure":
"not pure");
803 pips_debug(5,
"set %s[%s] as required at %d\n", rname, oname,
814 pips_debug(1,
"set %s[%s] as 'required' from '%s' at %d\n",
855 void * p,
bool update_is_ok) {
861 pips_debug(2,
"putting or updating %s[%s]\n", rname, oname);
930 get_pips_database());
952 pips_debug(9,
"Resources for owner \"%s\"\n", (
string) s);
961 get_pips_database());
995 get_pips_database());
1013 (
const char* rname,
const char* oname,
bool do_free)
1019 do_free?
" and freeing":
"", rname, oname);
1034 for (i=0; i<nr; i++)
1084 pips_debug(4,
"building list of resources to delete... (keep=%p)\n", keep_p);
1090 pips_debug(8,
"considering %s of %s (%p)\n", rn, on, (
void *) r);
1092 pips_debug(8,
"to be destroyed: %s of %s\n", rn, on);
1101 pips_debug(4,
"deleting obsolete resources...\n");
1102 for(lrp=lr, lop=lo; !
ENDP(lrp);
POP(lrp),
POP(lop))
1111 pips_debug(4,
"deleting obsolete resources done.\n");
1133 if (!pips_database_undefined_p())
1162 if (ignore_rx && regcomp(&ignore, ignore_rx, 0))
1168 dbr = get_pips_database();
1193 (!ignore_rx || regexec(&ignore, name, 0, NULL, 0)))
1239 if (ignore_rx && regcomp(&ignore, ignore_rx, 0))
1246 pips_debug(9,
"considering %s -> %p\n", on, or);
1249 && (module_p || (func_p && !cu_p) || (!func_p && cu_p))
1250 && (!ignore_rx || regexec(&ignore, on, 0, NULL, 0)))
db_status make_db_status(enum db_status_utype tag, void *val)
db_resource apply_db_owned_resources(db_owned_resources f, db_symbol k)
db_owned_resources apply_db_resources(db_resources f, db_symbol k)
bool bound_db_owned_resources_p(db_owned_resources f, db_symbol k)
void free_db_resource(db_resource p)
db_resource delete_db_owned_resources(db_owned_resources f, db_symbol k)
db_owned_resources make_db_owned_resources(void)
db_status make_db_status_loaded(void)
db_resources read_db_resources(FILE *f)
db_symbol make_db_symbol(string a1)
bool bound_db_resources_p(db_resources f, db_symbol k)
void write_db_resources(FILE *f, db_resources p)
db_owned_resources delete_db_resources(db_resources f, db_symbol k)
db_resource make_db_resource(db_void a1, db_status a2, intptr_t a3, intptr_t a4)
void extend_db_owned_resources(db_owned_resources f, db_symbol k, db_resource v)
#define db_resource_loaded_and_stored_p(r)
static void db_check_time(const char *rname, const char *oname, db_resource r)
static p_tmp_result make_tmp_result(int t, const char *on, const char *rn)
static db_resource get_db_resource(const char *rname, const char *oname)
static db_resource get_real_db_resource(const char *rname, const char *oname)
static db_resource get_resource(const char *rname, db_owned_resources or)
string db_resource_name(void *dbr)
To be used for debugging.
bool db_resource_is_required_p(const char *rname, const char *oname)
true if exists and in required state.
void db_print_all_required_resources(FILE *file)
void db_clean_all_required_resources(void)
#define db_resource_required_p(r)
list db_retrieve_resources(const char *rname)
Retrieve all the db resources of a given resource type, "rname".
void dump_all_db_resource_status(FILE *file, string where)
void db_reset_current_module_name(void)
static char * current_module_name
when telling the database about a module name, the module is registered as a db_symbol,...
gen_array_t db_get_module_list_initial_order(void)
static int tmp_result_cmp(const p_tmp_result *p1, const p_tmp_result *p2)
int db_time_of_resource(const char *rname, const char *oname)
static void db_save_and_free_resource(const char *rname, const char *oname, db_resource r, bool do_free)
static bool simple_name_p(const char *name)
Module names must use some characters.
static db_symbol find_or_create_db_symbol(const char *name)
#define db_resource_stored_p(r)
shorthands
static void db_load_resource(const char *rname, const char *oname, db_resource r)
bool db_resource_p(const char *rname, const char *oname)
true if exists and in loaded or stored state.
string db_get_current_module_name(void)
Also used to check whether set...
void db_save_pips_database(FILE *fd)
bool db_open_pips_database(FILE *fd)
struct t_tmp_result * p_tmp_result
static string db_status_string(db_status s)
bool db_resource_required_or_available_p(const char *rname, const char *oname)
from now on we must not know about the database internals?
void db_create_pips_database(void)
exported interface is minimal.
void db_set_resource_as_required(const char *rname, const char *oname)
void db_reset_pips_database_if_necessary(void)
bool db_touch_resource(const char *rname, const char *oname)
touch logical time for resource[owner], possibly behind the back of pipsdbm.
static string db_resource_name_or_owner_name(db_resource dbr, bool owner_p)
Retrieve the resource name, a.k.a.
static void db_save_resource(const char *rname, const char *oname, db_resource r)
#define DB_OK
the pips_database stores pips resources.
static db_resource find_or_create_db_resource(const char *rname, const char *oname)
int db_delete_obsolete_resources(bool(*keep_p)(const char *, const char *))
delete all obsolete resources before a close.
void db_save_and_free_memory_resource_if_any(const char *rname, const char *oname, bool do_free)
void db_delete_all_resources(void)
FC: I added this function to clean all resources, hence avoiding to save them.
int db_unput_resources(const char *rname)
Delete all the resources of a given type "rname".
static void init_owned_resources_if_necessary(const char *name)
static db_owned_resources get_db_owned_resources(const char *oname)
void db_invalidate_memory_resource(const char *rname, const char *oname)
#define db_resource_loaded_p(r)
string db_get_resource_id(const char *rname, const char *oname)
some way to identify a resource...
static void dump_db_resource(const char *rname, const char *oname, db_resource r)
void db_delete_resource(const char *rname, const char *oname)
Delete a resource.
void db_close_pips_database(void)
static void db_clean_db_resources()
latter
#define debug_db_resource(l, r, o, p)
string db_resource_owner_name(void *dbr)
To be used for debugging.
bool db_update_time(const char *rname, const char *oname)
this should really be a put.
bool db_set_current_module_name(const char *name)
gen_array_t gen_array_make(size_t size)
declarations...
void gen_array_sort(gen_array_t a)
void gen_array_dupappend(gen_array_t a, void *what)
bool compilation_unit_p(const char *module_name)
The names of PIPS entities carry information about their nature.
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
#define ENDP(l)
Test if a list is empty.
#define POP(l)
Modify a list pointer to point on the next element of the list.
#define NIL
The empty list (nil in Lisp)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
#define CAR(pcons)
Get the value of the first element of a list.
void gen_free_list(list l)
free the spine of the list
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
#define CDR(pcons)
Get the list less its first element.
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
void gen_sort_list(list l, gen_cmp_func_t compare)
Sorts a list of gen_chunks in place, to avoid allocations...
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
gen_array_t db_get_compilation_unit_list(void)
Get an array of all the compilation units of a workspace.
gen_array_t db_get_module_list(void)
Get an array of all the modules (functions, procedures and compilation units) of a workspace.
bool db_module_exists_p(const char *name)
Return whether name is a "valid" module.
static gen_array_t db_get_module_or_function_list(bool module_p, bool func_p)
Returns an allocated array a with the sorted list of modules.
gen_array_t db_get_function_list(void)
Get an array of all the functions and procedures (not compilation units) of a workspace.
void db_put_or_update_memory_resource(const char *rname, const char *oname, void *p, bool update_is_ok)
Put a resource into the current workspace database.
int hash_table_entry_count(hash_table htp)
now we define observers in order to hide the hash_table type...
static void symbol(Pproblem XX, int v)
N note: if use janus.c then not static DN.
bool dbll_database_managed_file_p(const char *name)
returns whether the file is managed within the database.
bool dbll_very_special_resource_p(const char *rname, const char *oname)
int dbll_stat_local_file(const char *file_name, bool okifnotthere)
It is impportant that the workspace directory does not appear in the file name so as to allow workspa...
bool displayable_file_p(const char *name)
rather approximated.
void dbll_free_resource(const char *rname, const char *oname, void *p)
int dbll_number_of_resources(void)
int dbll_stat_resource_file(const char *rname, const char *oname, bool okifnotthere)
void dbll_save_resource(const char *rname, const char *oname, void *p)
save rname of oname p.
void dbll_unlink_resource_file(const char *rname, const char *oname, bool erroriffailed)
bool dbll_check_resource(const char *rname, const char *oname, void *p)
Internal consistency of the resource, not the global consistency wrt other resources and pipsmake rul...
bool dbll_storable_p(const char *rname)
string dbll_get_ith_resource_name(int i)
void * dbll_load_resource(const char *rname, const char *oname)
void dbll_save_and_free_resource(const char *rname, const char *oname, void *p, bool do_free)
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
#define MODULE_NAME_CHARS
#define same_string_p(s1, s2)
void * gen_find_tabulated(const char *, int)
list gen_filter_tabulated(bool(*)(gen_chunk *), int)
returns the list of entities with this caracteristics.
#define string_undefined_p(s)
int(* gen_cmp_func_t)(const void *, const void *)
int db_inc_logical_time(void)
0 means not set...
int db_get_logical_time(void)
#define DB_RESOURCE(x)
DB_RESOURCE.
#define DB_SYMBOL(x)
DB_SYMBOL.
#define db_resource_db_status(x)
#define db_owned_resources_undefined_p(x)
#define db_resource_pointer(x)
#define db_status_undefined
#define db_owned_resources_undefined
#define db_status_loaded_and_stored_p(x)
#define db_status_undefined_p(x)
#define db_resource_undefined
#define db_resources_undefined_p(x)
@ is_db_status_loaded_and_stored
#define DB_RESOURCES_MAP(k, v, c, f)
#define db_symbol_name(x)
#define DB_RESOURCES_FOREACH(k, v, f)
#define DB_OWNED_RESOURCES_FOREACH(k, v, f)
#define db_resource_undefined_p(x)
#define db_resource_time(x)
#define DB_OWNED_RESOURCES_MAP(k, v, c, f)
#define db_symbol_undefined_p(x)
#define db_status_loaded_p(x)
#define db_symbol_domain
newgen_db_status_domain_defined
#define db_resource_file_time(x)
#define db_owned_resources_hash_table(x)
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
GENERIC_LOCAL_FUNCTION(directives, step_directives)
Copyright 2007, 2008, 2009 Alain Muller, Frederique Silber-Chaussumier.
The structure used to build lists in NewGen.