PIPS
pypips.c File Reference
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdarg.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "database.h"
#include "misc.h"
#include "ri-util.h"
#include "pipsdbm.h"
#include "resources.h"
#include "phases.h"
#include "properties.h"
#include "pipsmake.h"
#include "text-util.h"
#include "top-level.h"
#include <Python.h>
+ Include dependency graph for pypips.c:

Go to the source code of this file.

Functions

statement find_loop_from_label (statement, entity)
 hmmm... More...
 
static void pyps_log_handler (const char *fmt, va_list *args)
 
static void pyps_error_handler (const char *calling_function_name, const char *a_message_format, va_list *args)
 
void close_log_buffer (void)
 
void open_log_buffer (void)
 
char * get_log_buffer (void)
 
void verbose (bool on)
 
 DEFINE_LOCAL_STACK (properties, property)
 stack of properties, so that the previous value can be reinstated when going out of a phase. More...
 
void set_property (const char *propname, const char *value)
 
void push_property (const char *name, const char *value)
 
void pop_property (const char *name)
 
void atinit (void)
 
void create (char *workspace_name, char **filenames)
 create a new workspace... More...
 
char * info (char *about)
 
void apply (char *phasename, char *target)
 apply a transformation on a module More...
 
void capply (char *phasename, char **targets)
 apply a transformation on a set of modules, concurrently More...
 
void display (char *rname, char *mname)
 display resource rname about module mname More...
 
char * show (char *rname, char *mname)
 return the rname[mname] resource, which must be a string containing a file name More...
 
char * get_callers_of (char *module_name)
 Returns the list of the modules that call that specific module, separated by ' '. More...
 
char * get_callees_of (char *module_name)
 Returns the list of the modules called by that specific module, separated by ' '. More...
 
char * pyps_get_stubs (void)
 Returns the list of the modules called by that specific module, separated by ' '. More...
 
void setenviron (char *name, char *value)
 add an environment variable of a given value More...
 
char * getenviron (char *name)
 get environment variable More...
 
bool add_a_file (string file)
 Add a source file to the workspace We wrap process_user_file() here with a hack to define the workspace language so that some pipsmake activate specific to the language will be defined. More...
 
char * get_module_language (string mod_name)
 
static string get_stub_from_broker (string str)
 
void set_python_missing_module_resolver_handler (PyObject *PyObj)
 
bool get_loop_execution_parallel (const char *module_name, const char *loop_label)
 Read execution mode for a loop. More...
 
void set_loop_execution_parallel (const char *module_name, const char *loop_label, bool exec_parallel_p)
 Change execution mode for a loop. More...
 

Variables

static FILE * logstream = NULL
 
static list log_list = list_undefined
 
char * pyps_last_error = NULL
 
static PyObject * stub_broker = NULL
 

Function Documentation

◆ add_a_file()

bool add_a_file ( string  file)

Add a source file to the workspace We wrap process_user_file() here with a hack to define the workspace language so that some pipsmake activate specific to the language will be defined.

This function will be removed when pipsmake will be improved to handle multilanguage workspace !

Definition at line 466 of file pypips.c.

467 {
468  gen_array_t filename_list = gen_array_make(0);
469  gen_array_append(filename_list,file);
471  language l = workspace_language(filename_list);
473  free_language(l);
474  gen_array_free(filename_list);
475  bool process_user_file(string file);
476  if(process_user_file(file)==false) {
477  pips_user_error("Error adding new file.");
478  return false;
479  }
480  return true;
481 }
void free_language(language p)
Definition: ri.c:1205
void activate_language(language l)
Choose the right combination of activate and setproperty for a given language.
Definition: activate.c:254
gen_array_t gen_array_make(size_t size)
declarations...
Definition: array.c:40
void gen_array_append(gen_array_t a, void *what)
Definition: array.c:105
void gen_array_free(gen_array_t a)
Definition: array.c:70
#define pips_user_error
Definition: misc-local.h:147
bool process_user_file(string)
Definition: source_file.c:1090
language workspace_language(gen_array_t)
Choose a language if all filenames in "files" have the same C or Fortran extensions.
Definition: source_file.c:667

References activate_language(), free_language(), gen_array_append(), gen_array_free(), gen_array_make(), pips_user_error, process_user_file(), and workspace_language().

+ Here is the call graph for this function:

◆ apply()

void apply ( char *  phasename,
char *  target 
)

apply a transformation on a module

Definition at line 324 of file pypips.c.

325 {
326  if (!safe_apply(phasename,target)) {
327  if(!pyps_last_error)
328  asprintf(&pyps_last_error, "phase %s on module %s failed" ,
329  phasename, target);
331  }
332 }
@ user_exception_error
#define THROW(what)
#define asprintf
Definition: misc-local.h:225
bool safe_apply(const char *phase_n, const char *module_n)
Definition: pipsmake.c:1723
char * pyps_last_error
Definition: pypips.c:109

References asprintf, pyps_last_error, safe_apply(), THROW, and user_exception_error.

+ Here is the call graph for this function:

◆ atinit()

void atinit ( void  )

init various composants

Definition at line 222 of file pypips.c.

223 {
224  /* init various composants */
225  // FIXME
226  set_pips_meta_informations("<unknown>", "<unknown>", "<unknown>");
227 
233  make_properties_stack();
234 }
void(* pips_log_handler)(const char *fmt, va_list *args)
USER_LOG is a function that should be called to log the current PIPS request, as soon as it is releva...
Definition: message.c:216
void(* pips_error_handler)(const char *, const char *, va_list *)
PROMPT_USER schould be implemented.
Definition: message.c:455
void set_pips_meta_informations(const char *revs, const char *date, const char *comp)
Definition: message.c:102
void set_exception_callbacks(exception_callback_t, exception_callback_t)
void push_pips_context(char const *file, char const *function, int line)
exception.c
Definition: exception.c:43
void pop_pips_context(char const *file, char const *function, int line)
Definition: exception.c:50
void initialize_newgen()
cproto-generated files
Definition: newgen.c:48
static void pyps_log_handler(const char *fmt, va_list *args)
Definition: pypips.c:85
static void pyps_error_handler(const char *calling_function_name, const char *a_message_format, va_list *args)
Definition: pypips.c:111
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
void initialize_sc(char *(*var_to_string)(Variable))
Definition: sc_debug.c:253
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60

References entity_local_name(), initialize_newgen(), initialize_sc(), pips_error_handler, pips_log_handler, pop_pips_context(), push_pips_context(), pyps_error_handler(), pyps_log_handler(), set_exception_callbacks(), and set_pips_meta_informations().

+ Here is the call graph for this function:

◆ capply()

void capply ( char *  phasename,
char **  targets 
)

apply a transformation on a set of modules, concurrently

Definition at line 336 of file pypips.c.

337 {
338  // create the array of arguments
339  gen_array_t target_list = gen_array_make(0);
340  while (*targets)
341  {
342  gen_array_append(target_list,*targets);
343  targets++;
344  }
345  bool ok = safe_concurrent_apply(phasename, target_list);
346  gen_array_free(target_list);
347  if(!ok) {
348  if(!pyps_last_error)
350  "capply phase %s failed without setting error message",
351  phasename);
353  }
354 }
bool safe_concurrent_apply(const char *phase_n, gen_array_t modules)
Definition: pipsmake.c:1729
static bool ok

References asprintf, gen_array_append(), gen_array_free(), gen_array_make(), ok, pyps_last_error, safe_concurrent_apply(), THROW, and user_exception_error.

+ Here is the call graph for this function:

◆ close_log_buffer()

void close_log_buffer ( void  )

Definition at line 137 of file pypips.c.

138 {
140  {
143  }
144 }
#define list_undefined_p(c)
Return if a list is undefined.
Definition: newgen_list.h:75
void gen_free_string_list(list ls)
Definition: list.c:564
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
static list log_list
Definition: pypips.c:83

References gen_free_string_list(), list_undefined, list_undefined_p, and log_list.

Referenced by open_log_buffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

void create ( char *  workspace_name,
char **  filenames 
)

create a new workspace...

FC: what about opening an existing one?

Definition at line 239 of file pypips.c.

240 {
241  if (workspace_exists_p(workspace_name))
242  pips_user_error("Workspace %s already exists. Delete it!\n",
243  workspace_name);
244  else if (db_get_current_workspace_name()) {
245  pips_user_error("Close current workspace %s before "
246  "creating another one!\n",
248  }
249  else
250  {
251  if (db_create_workspace(workspace_name))
252  {
253  // create the array of arguments
254  gen_array_t filename_list = gen_array_make(0);
255  while(*filenames)
256  {
257  gen_array_append(filename_list,*filenames);
258  filenames++;
259  }
260 
261  bool success = create_workspace(filename_list);
262 
263  gen_array_free(filename_list);
264 
265  if (!success)
266  {
267  db_close_workspace(false);
268  pips_user_error("Could not create workspace %s\n", workspace_name);
269  }
270  }
271  else {
272  pips_user_error("Cannot create directory for workspace, "
273  "check rights!\n");
274  }
275  }
276 }
bool create_workspace(gen_array_t files)
FI: should be called "initialize_workspace()"; a previous call to db_create_workspace() is useful to ...
Definition: dbm.c:180
bool success
Definition: gpips-local.h:59
bool workspace_exists_p(const char *)
Definition: workspace.c:266
bool db_close_workspace(bool)
Definition: workspace.c:367
bool db_create_workspace(const char *)
Definition: workspace.c:282
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
Definition: workspace.c:82

References create_workspace(), db_close_workspace(), db_create_workspace(), db_get_current_workspace_name(), gen_array_append(), gen_array_free(), gen_array_make(), pips_user_error, and workspace_exists_p().

+ Here is the call graph for this function:

◆ DEFINE_LOCAL_STACK()

DEFINE_LOCAL_STACK ( properties  ,
property   
)

stack of properties, so that the previous value can be reinstated when going out of a phase.

◆ display()

void display ( char *  rname,
char *  mname 
)

display resource rname about module mname

Definition at line 358 of file pypips.c.

359 {
360  string old_current_module_name = db_get_current_module_name();
361  if(old_current_module_name) {
362  old_current_module_name = strdup(old_current_module_name);
364  }
365 
367  string fname = build_view_file(rname);
369  if(old_current_module_name) {
370  db_set_current_module_name(old_current_module_name);
371  free(old_current_module_name);
372  }
373 
374  if (!fname)
375  {
376  pips_user_error("Cannot build view file %s\n", rname);
377  return;
378  }
379 
380  safe_display(fname);
381  free(fname);
382  return;
383 }
void db_reset_current_module_name(void)
Definition: database.c:1064
string db_get_current_module_name(void)
Also used to check whether set...
Definition: database.c:1059
bool db_set_current_module_name(const char *name)
Definition: database.c:1045
int safe_display(char *fname)
Display a file through $PIPS_MORE (or $PAGER) if stdout is a TTY, on stdout otherwise.
Definition: file.c:722
void free(void *)
string build_view_file(const char *)
view.c
Definition: view.c:97
char * strdup()

References build_view_file(), db_get_current_module_name(), db_reset_current_module_name(), db_set_current_module_name(), free(), pips_user_error, safe_display(), and strdup().

+ Here is the call graph for this function:

◆ find_loop_from_label()

statement find_loop_from_label ( statement  s,
entity  label 
)

hmmm...

when all header files are not yet generated cproto may silently fail to generate these headers. this few declarations allow to generate headers without anything else. ri needed for statement_mapping in pipsdbm...

Parameters
labelabel

Definition at line 218 of file util.c.

219 {
220  struct flfl ctx = { label, statement_undefined };
221  gen_context_recurse(s, &ctx,
223  return ctx.found;
224 }
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
Definition: genClib.c:2758
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define statement_undefined
Definition: ri.h:2419
Definition: util.c:199
entity label
Definition: util.c:200
statement found
Definition: util.c:201
static bool find_loop_from_label_walker(loop l, struct flfl *p)
Definition: util.c:204

Referenced by get_loop_execution_parallel(), and set_loop_execution_parallel().

+ Here is the caller graph for this function:

◆ get_callees_of()

char* get_callees_of ( char *  module_name)

Returns the list of the modules called by that specific module, separated by ' '.

Definition at line 420 of file pypips.c.

421 {
422  safe_make("CALLERS",module_name);
424 
425  char * callees_string = strdup(string_array_join(callees, " "));
426 
428 
429  return callees_string;
430 }
string string_array_join(gen_array_t array, string separator)
Join a string array with a string separator.
Definition: array.c:198
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
gen_array_t get_callees(string module)
Get all the callers of the specified module.
Definition: pipsmake.c:1816
bool safe_make(const char *res_n, const char *module_n)
Definition: pipsmake.c:1717

References gen_array_free(), get_callees(), module_name(), safe_make(), strdup(), and string_array_join().

+ Here is the call graph for this function:

◆ get_callers_of()

char* get_callers_of ( char *  module_name)

Returns the list of the modules that call that specific module, separated by ' '.

Definition at line 408 of file pypips.c.

409 {
410  safe_make("CALLERS", module_name);
412  char * callers_string = strdup(string_array_join(callers, " "));
413  gen_array_free(callers);
414  return callers_string;
415 }
gen_array_t get_callers(string module)
Get all the callers of the specified module.
Definition: pipsmake.c:1799

References gen_array_free(), get_callers(), module_name(), safe_make(), strdup(), and string_array_join().

+ Here is the call graph for this function:

◆ get_log_buffer()

char* get_log_buffer ( void  )

Definition at line 153 of file pypips.c.

154 {
156  list log_list_tmp=gen_copy_seq(log_list);
157  log_list_tmp = gen_nreverse(log_list_tmp);
158  char* ret = words_to_string(log_list_tmp);
159  gen_free_list(log_list_tmp);
160  return ret;
161 }
#define ret(why, what)
true if not a remapping for old.
Definition: dynamic.c:986
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define assert(ex)
Definition: newgen_assert.h:41
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
string words_to_string(cons *lw)
Definition: print.c:211

References assert, gen_copy_seq(), gen_free_list(), gen_nreverse(), list_undefined_p, log_list, ret, and words_to_string().

+ Here is the call graph for this function:

◆ get_loop_execution_parallel()

bool get_loop_execution_parallel ( const char *  module_name,
const char *  loop_label 
)

Read execution mode for a loop.

Definition at line 561 of file pypips.c.

564 {
565  // prelude
568  ((statement) db_get_memory_resource(DBR_CODE, module_name, true) );
569 
571  if(entity_undefined_p(label))
572  pips_user_error("label '%s' does not exist\n",loop_label);
575  pips_user_error("label '%s' is not on a loop\n",loop_label);
576  bool is_exec_parallel_p =
578 
579  // reset current state
582  return is_exec_parallel_p;
583 }
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
statement find_loop_from_label(statement, entity)
hmmm...
Definition: util.c:218
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
entity find_label_entity(const char *, const char *)
util.c
Definition: util.c:43
#define loop_execution(x)
Definition: ri.h:1648
#define entity_undefined_p(x)
Definition: ri.h:2762
#define loop_label(x)
Definition: ri.h:1646
#define statement_undefined_p(x)
Definition: ri.h:2420
#define execution_parallel_p(x)
Definition: ri.h:1211
Definition: statement.c:54

References db_get_memory_resource(), entity_undefined_p, execution_parallel_p, find_label_entity(), find_loop_from_label(), get_current_module_statement(), loop_execution, loop_label, module_name(), module_name_to_entity(), pips_user_error, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_loop(), and statement_undefined_p.

+ Here is the call graph for this function:

◆ get_module_language()

char* get_module_language ( string  mod_name)

Definition at line 487 of file pypips.c.

488 {
490 
491  switch(language_tag(l)) {
492  case is_language_fortran: return "fortran";
493  case is_language_fortran95: return "fortran95";
494  case is_language_c: return "c";
495  default: return "unknown";
496  }
497 }
#define module_language(e)
implemented as a macro to allow lhs
#define language_tag(x)
Definition: ri.h:1590
@ is_language_fortran
Definition: ri.h:1566
@ is_language_fortran95
Definition: ri.h:1568
@ is_language_c
Definition: ri.h:1567

References is_language_c, is_language_fortran, is_language_fortran95, language_tag, module_language, and module_name_to_entity().

+ Here is the call graph for this function:

◆ get_stub_from_broker()

static string get_stub_from_broker ( string  str)
static

Definition at line 514 of file pypips.c.

515 {
516  string result = NULL;
517 
518  // Assert that a broker is defined !
519  if (stub_broker) {
520 
521  // Get the stub file (implemented in a python method...)
522  PyObject *pyStubFile =
523  PyEval_CallMethod(stub_broker, "stub_file_for_module", "(s)", str);
524 
525  // Sanity check
526  if(pyStubFile) {
527  // Convert to a regular C string
528 #if PY_MAJOR_VERSION >= 3
529  result = strdup(PyUnicode_AsUTF8(pyStubFile));
530 #else // PYTHON 2
531  result = strdup(PyString_AsString(pyStubFile));
532 #endif
533  Py_XDECREF(pyStubFile);
534  } else {
535  // NULL is returned, error managed by the caller
536  fprintf(stderr,"Callback failed !\n");
537  PyErr_Print();
538  }
539  }
540  // else NULL...
541 
542  return result;
543 }
static PyObject * stub_broker
Definition: pypips.c:506
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References fprintf(), strdup(), and stub_broker.

Referenced by set_python_missing_module_resolver_handler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getenviron()

char* getenviron ( char *  name)

get environment variable

Definition at line 452 of file pypips.c.

453 {
454  return getenv(name);
455 }

◆ info()

char* info ( char *  about)

Definition at line 278 of file pypips.c.

279 {
280  string sinfo = NULL;
281  if (same_string_p(about, "workspace"))
282  {
284  if (sinfo) sinfo = strdup(sinfo);
285  }
286  else if (same_string_p(about, "module"))
287  {
288  sinfo = db_get_current_module_name();
289  if(sinfo) sinfo=strdup(sinfo);
290  }
291  else if (same_string_p(about, "modules") && db_get_current_workspace_name())
292  {
293  gen_array_t modules = db_get_module_list();
294  int n = gen_array_nitems(modules), i;
295 
296  size_t sinfo_size=0;
297  for(i=0; i<n; i++)
298  {
299  string m = gen_array_item(modules, i);
300  sinfo_size+=strlen(m)+1;
301  }
302  sinfo = strdup(string_array_join(modules, " "));
303  if(!sinfo)
304  fprintf(stderr,"not enough memory to hold all module names\n");
305  gen_array_full_free(modules);
306  }
307  else if (same_string_p(about, "directory"))
308  {
309  char pathname[MAXPATHLEN];
310  sinfo = getcwd(pathname, MAXPATHLEN);
311  if(sinfo)
312  sinfo=strdup(sinfo);
313  else
314  fprintf(stderr,"failer to retreive current working directory\n");
315  }
316 
317  if (!sinfo)
318  sinfo = strdup("");
319  return sinfo;
320 }
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
void gen_array_full_free(gen_array_t a)
Definition: array.c:77
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
gen_array_t db_get_module_list(void)
Get an array of all the modules (functions, procedures and compilation units) of a workspace.
Definition: database.c:1266
#define MAXPATHLEN
MAXPATHLEN is defined in <sys/param.h> for SunOS...
Definition: misc-local.h:203
#define same_string_p(s1, s2)

References db_get_current_module_name(), db_get_current_workspace_name(), db_get_module_list(), fprintf(), gen_array_full_free(), gen_array_item(), gen_array_nitems(), MAXPATHLEN, same_string_p, strdup(), and string_array_join().

Referenced by constraints_sort_info(), constraints_sort_with_compare(), sc_build_triang_elim_redund(), and sc_triang_elim_redund().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ open_log_buffer()

void open_log_buffer ( void  )

Definition at line 146 of file pypips.c.

147 {
150  log_list = NIL;
151 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
void close_log_buffer(void)
Definition: pypips.c:137

References close_log_buffer(), list_undefined_p, log_list, and NIL.

+ Here is the call graph for this function:

◆ pop_property()

void pop_property ( const char *  name)

Definition at line 209 of file pypips.c.

210 {
211  property p = properties_pop();
212  if(property_bool_p(p))
214  else if(property_string_p(p))
216  else
218 }
void set_bool_property(const char *, bool)
void set_int_property(const char *, int)
void set_string_property(const char *, const char *)
#define property_string(x)
Definition: property.h:71
#define property_bool(x)
Definition: property.h:68
#define property_int(x)
Definition: property.h:65
#define property_string_p(x)
Definition: property.h:69
#define property_bool_p(x)
Definition: property.h:66

References property_bool, property_bool_p, property_int, property_string, property_string_p, set_bool_property(), set_int_property(), and set_string_property().

+ Here is the call graph for this function:

◆ push_property()

void push_property ( const char *  name,
const char *  value 
)

Definition at line 202 of file pypips.c.

203 {
204  property p = copy_property(get_property(name,false));
205  set_property(strdup(name),value);
206  properties_push(p);
207 }
property copy_property(property p)
PROPERTY.
Definition: property.c:16
property get_property(const char *, bool)
void set_property(const char *propname, const char *value)
Definition: pypips.c:176

References copy_property(), get_property(), set_property(), and strdup().

+ Here is the call graph for this function:

◆ pyps_error_handler()

static void pyps_error_handler ( const char *  calling_function_name,
const char *  a_message_format,
va_list *  args 
)
static

Definition at line 111 of file pypips.c.

115 {
116  // Save pre-existing error message
117  char *old_error = pyps_last_error;
118 
119  char * tmp;
120  va_list acpy;
121  va_copy(acpy, *args);
122  vasprintf(&tmp, a_message_format, acpy);
123  va_end(acpy);
124 
125  asprintf(&pyps_last_error,"in %s: %s",calling_function_name,tmp);
126  free(tmp);
127 
128  // If we already had a message before, we stack it over the new one
129  if(old_error) {
130  char *tmp = pyps_last_error;
131  asprintf(&pyps_last_error,"%s%s",old_error,tmp);
132  free(old_error);
133  free(tmp);
134  }
135 }
int vasprintf(char **resultp, const char *format, va_list args)
Formatted output to strings.
Definition: vasprintf.c:33

References asprintf, free(), pyps_last_error, and vasprintf().

Referenced by atinit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pyps_get_stubs()

char* pyps_get_stubs ( void  )

Returns the list of the modules called by that specific module, separated by ' '.

Definition at line 435 of file pypips.c.

436 {
437  gen_array_t stubs = get_stubs();
438  char * stubs_string = strdup(string_array_join(stubs, " "));
439  gen_array_free(stubs);
440  return stubs_string;
441 }
gen_array_t get_stubs()
Get all stubs.
Definition: dbm.c:433

References gen_array_free(), get_stubs(), strdup(), and string_array_join().

+ Here is the call graph for this function:

◆ pyps_log_handler()

static void pyps_log_handler ( const char *  fmt,
va_list *  args 
)
static

Definition at line 85 of file pypips.c.

86 {
87  va_list args_copy;
88 
89  // avoid a repeat as pips_log_display called by pips_log_alist
90  // already sent it to stderr
91  if (logstream != stderr)
92  {
93  va_copy (args_copy, *args);
94  vfprintf(logstream, fmt, args_copy);
95  va_end(args_copy);
96  fflush(logstream);
97  }
98 
100  {
101  char* tmp;
102  va_copy (args_copy, *args);
103  vasprintf(&tmp, fmt, args_copy);
104  va_end(args_copy);
105  log_list = CONS(STRING,tmp,log_list);
106  }
107 }
#define STRING(x)
Definition: genC.h:87
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
static FILE * logstream
Definition: pypips.c:82

References CONS, list_undefined_p, log_list, logstream, STRING, and vasprintf().

Referenced by atinit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_loop_execution_parallel()

void set_loop_execution_parallel ( const char *  module_name,
const char *  loop_label,
bool  exec_parallel_p 
)

Change execution mode for a loop.

Definition at line 586 of file pypips.c.

590 {
591  // prelude
594  ((statement) db_get_memory_resource(DBR_CODE, module_name, true) );
595 
597  if(entity_undefined_p(label))
598  pips_user_error("label '%s' does not exist\n",loop_label);
601  pips_user_error("label '%s' is not on a loop\n",loop_label);
603  = (exec_parallel_p ? is_execution_parallel : is_execution_sequential);
604 
605  // Store the new code
607 
608  // reset current state
611 }
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define execution_tag(x)
Definition: ri.h:1207
@ is_execution_parallel
Definition: ri.h:1190
@ is_execution_sequential
Definition: ri.h:1189

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, entity_undefined_p, execution_tag, find_label_entity(), find_loop_from_label(), get_current_module_statement(), is_execution_parallel, is_execution_sequential, loop_execution, loop_label, module_name(), module_name_to_entity(), pips_user_error, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_loop(), and statement_undefined_p.

+ Here is the call graph for this function:

◆ set_property()

void set_property ( const char *  propname,
const char *  value 
)

Definition at line 176 of file pypips.c.

177 {
178  // thank's to rk, this hack is no longer needed
179 #if 0
180  /* nice hack to temporarly redirect stderr */
181  int saved_stderr = dup(STDERR_FILENO);
182  char *buf;
183  freopen("/dev/null","w",stderr);
184  asprintf(&buf, "/dev/fd/%d", saved_stderr);
185 #endif
186  if (!safe_set_property(propname, value)) {
187 #if 0
188  freopen(buf,"w",stderr);
189  free(buf);
190 #endif
191  pips_user_error("error in setting property %s to %s\n",
192  propname, value);
193  }
194 #if 0
195  else {
196  freopen(buf,"w",stderr);
197  free(buf);
198  }
199 #endif
200 }
#define STDERR_FILENO
Definition: unistd.in.h:214
bool safe_set_property(const char *propname, const char *value)
Definition: pipsmake.c:1781
static char buf[BSZ]
Definition: split_file.c:157

References asprintf, buf, free(), pips_user_error, safe_set_property(), and STDERR_FILENO.

Referenced by push_property().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_python_missing_module_resolver_handler()

void set_python_missing_module_resolver_handler ( PyObject *  PyObj)

Dispose of previous callback

Remember new callback

Record of new callback

Definition at line 550 of file pypips.c.

551 {
552  Py_XDECREF(stub_broker); /* Dispose of previous callback */
553  stub_broker = PyObj; /* Remember new callback */
554  Py_XINCREF(stub_broker); /* Record of new callback */
555 
556  void set_internal_missing_module_resolver_handler(string (*)(string));
558 }
void set_internal_missing_module_resolver_handler(string(*_internal_resolver)(const char *))
Definition: initializer.c:612
static string get_stub_from_broker(string str)
Definition: pypips.c:514

References get_stub_from_broker(), set_internal_missing_module_resolver_handler(), and stub_broker.

+ Here is the call graph for this function:

◆ setenviron()

void setenviron ( char *  name,
char *  value 
)

add an environment variable of a given value

Definition at line 445 of file pypips.c.

446 {
447  setenv(name, value, 1);
448 }

◆ show()

char* show ( char *  rname,
char *  mname 
)

return the rname[mname] resource, which must be a string containing a file name

Definition at line 388 of file pypips.c.

389 {
390  if (!db_resource_p(rname, mname)) {
391  pips_user_warning("no resource %s[%s].\n", rname, mname);
392  return strdup("");
393  }
394 
395  // ensure that it is a filename, hence a string
396  if (!displayable_file_p(rname)) {
397  pips_user_warning("resource %s cannot be displayed.\n", rname);
398  return strdup("");
399  }
400 
401  // now returns the name of the file.
402  return strdup(db_get_memory_resource(rname, mname, true));
403 }
bool db_resource_p(const char *rname, const char *oname)
true if exists and in loaded or stored state.
Definition: database.c:524
bool displayable_file_p(const char *name)
rather approximated.
Definition: lowlevel.c:361
#define pips_user_warning
Definition: misc-local.h:146

References db_get_memory_resource(), db_resource_p(), displayable_file_p(), pips_user_warning, and strdup().

+ Here is the call graph for this function:

◆ verbose()

void verbose ( bool  on)

Definition at line 163 of file pypips.c.

164 {
165  if(on) logstream = stderr;
166  else logstream = fopen("/dev/null","w");
167 }

References logstream.

Variable Documentation

◆ log_list

list log_list = list_undefined
static

Definition at line 83 of file pypips.c.

Referenced by close_log_buffer(), get_log_buffer(), open_log_buffer(), and pyps_log_handler().

◆ logstream

FILE* logstream = NULL
static

Definition at line 82 of file pypips.c.

Referenced by pyps_log_handler(), and verbose().

◆ pyps_last_error

char* pyps_last_error = NULL

Definition at line 109 of file pypips.c.

Referenced by apply(), capply(), and pyps_error_handler().

◆ stub_broker

PyObject* stub_broker = NULL
static

Definition at line 506 of file pypips.c.

Referenced by get_stub_from_broker(), and set_python_missing_module_resolver_handler().