PIPS
misc-local.h File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <setjmp.h>
+ Include dependency graph for misc-local.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TIMEOUT_CODE   (128+14)
 
#define STRINGIFY_SECOND_STAGE(symbol)   #symbol
 To generate a string from a macro: More...
 
#define STRINGIFY(symbol)   STRINGIFY_SECOND_STAGE(symbol)
 If not using this 2-stage macro evaluation, the generated string is not the value of the macro but the name of the macro... More...
 
#define abort()   pips_stop(internal_error_log, -1, "abort() called")
 
#define exit(code)   pips_stop(user_error_log, code, "exit(%d) called", code)
 
#define pips_unknown_function   "Unknown Function Name"
 
#define CURRENT_FUNCTION   pips_unknown_function
 
#define pips_debug   pips_debug_func2
 these macros use the GNU extensions that allow variadic macros, including with an empty list. More...
 
#define pips_user_warning   pips_user_warning_func2
 
#define pips_user_error   pips_user_error_func2
 
#define pips_user_irrecoverable_error   pips_user_irrecoverable_error_func2
 
#define pips_internal_error   pips_internal_error_func2
 
#define pips_log   pips_log_func2
 
#define pips_stop   pips_stop_func2
 
#define pips_where(out)    fprintf(out, "[%s] (%s:%d) ", CURRENT_FUNCTION, __FILE__, __LINE__)
 
#define debug_on(env)    debug_on_function(env, CURRENT_FUNCTION, __FILE__, __LINE__)
 
#define debug_off()    debug_off_function(CURRENT_FUNCTION, __FILE__, __LINE__)
 
#define pips_assert(what, predicate)
 common macros, two flavors depending on NDEBUG More...
 
#define pips_user_assert(what, predicate)
 
#define ifdebug(l)   if (the_current_debug_level>=(l))
 
#define pips_exit(code, format, args...)    pips_user_warning(format, ##args), exit(code)
 
#define same_string_p(s1, s2)   function_same_string_p(s1,s2)
 FI:need to breakpoint while inlining is available. More...
 
#define same_stringn_p(a, b, c)   (!strncmp((a),(b),(c)))
 
#define MAXPATHLEN   1024
 MAXPATHLEN is defined in <sys/param.h> for SunOS... More...
 
#define PIPS_CATCH(what)
 
#define SIGN_EQ(a, b)   ((((a)>0 && (b)>0) || ((a)<0 && (b)<0)) ? true : false)
 SG moved there from transformation.h. More...
 
#define FORTRAN_DIV(n, d)   (SIGN_EQ((n),(d)) ? ABS(n)/ABS(d) : -(ABS(n)/ABS(d)))
 
#define C_DIVISION(n, d)   ((n)/(d))
 
#define FORTRAN_MOD(n, m)   (SIGN_EQ((n),(m)) ? ABS(n)%ABS(m) : -(ABS(n)%ABS(m)))
 
#define C_MODULO(n, m)   ((n)%(m))
 
#define asprintf   safe_asprintf
 
#define vasprintf   safe_vasprintf
 
#define __has_attribute(att)   0
 
#define _UNUSED_   __attribute__((unused))
 
#define _NORETURN_   __attribute__((noreturn))
 
#define _FALLTHROUGH_
 
#define user_warning(fn, ...)    pips_user_warning_func(fn, __FILE__, __LINE__, __VA_ARGS__)
 
#define user_error(fn, ...)    pips_user_error_func(fn, __FILE__, __LINE__, __VA_ARGS__)
 

Typedefs

typedef void(* reset_func_t) (void)
 

Enumerations

enum  pips_log_t {
  none_log , info_log , warning_log , spear_warning_log ,
  spear_error_log , user_error_log , internal_error_log , irrecoverable_error_log ,
  none_log , info_log , warning_log , spear_warning_log ,
  spear_error_log , user_error_log , internal_error_log , irrecoverable_error_log
}
 
enum  measurement_type {
  SBRK_MEASURE , NET_MEASURE , GROSS_MEASURE , SBRK_MEASURE ,
  NET_MEASURE , GROSS_MEASURE
}
 Measurement type for mem_spy.c. More...
 

Functions

void _NORETURN_ pips_stop_func (const char *, const char *, const int, pips_log_t, int, const string,...)
 expecititely declare "noreturn" functions... More...
 
void _NORETURN_ pips_internal_error_func (const char *, const char *, const int, const char *,...)
 
void _NORETURN_ pips_user_error_func (const char *, const char *, const int, const char *,...)
 
void _NORETURN_ pips_user_irrecoverable_error_alist (const char *, const char *, const int, const char *, va_list *)
 
void _NORETURN_ pips_user_irrecoverable_error_func (const char *, const char *, const int, const char *,...)
 
void _NORETURN_ pips_stop_func2 (pips_log_t, int, const string,...)
 
void _NORETURN_ pips_internal_error_func2 (const char *,...)
 
void _NORETURN_ pips_user_error_func2 (const char *,...)
 
void _NORETURN_ pips_user_irrecoverable_error_func2 (const char *,...)
 

Variables

int the_current_debug_level
 Debugging functions. More...
 

Macro Definition Documentation

◆ __has_attribute

#define __has_attribute (   att)    0

Definition at line 229 of file misc-local.h.

◆ _FALLTHROUGH_

#define _FALLTHROUGH_

Definition at line 238 of file misc-local.h.

◆ _NORETURN_

#define _NORETURN_   __attribute__((noreturn))

Definition at line 233 of file misc-local.h.

◆ _UNUSED_

#define _UNUSED_   __attribute__((unused))

Definition at line 232 of file misc-local.h.

◆ abort

#define abort ( )    pips_stop(internal_error_log, -1, "abort() called")

Definition at line 53 of file misc-local.h.

◆ asprintf

#define asprintf   safe_asprintf

Definition at line 225 of file misc-local.h.

◆ C_DIVISION

#define C_DIVISION (   n,
 
)    ((n)/(d))

Definition at line 214 of file misc-local.h.

◆ C_MODULO

#define C_MODULO (   n,
 
)    ((n)%(m))

Definition at line 216 of file misc-local.h.

◆ CURRENT_FUNCTION

#define CURRENT_FUNCTION   pips_unknown_function

Definition at line 71 of file misc-local.h.

◆ debug_off

#define debug_off ( )     debug_off_function(CURRENT_FUNCTION, __FILE__, __LINE__)

Definition at line 160 of file misc-local.h.

◆ debug_on

#define debug_on (   env)     debug_on_function(env, CURRENT_FUNCTION, __FILE__, __LINE__)

Definition at line 157 of file misc-local.h.

◆ exit

#define exit (   code)    pips_stop(user_error_log, code, "exit(%d) called", code)

Definition at line 54 of file misc-local.h.

◆ FORTRAN_DIV

#define FORTRAN_DIV (   n,
 
)    (SIGN_EQ((n),(d)) ? ABS(n)/ABS(d) : -(ABS(n)/ABS(d)))

Definition at line 213 of file misc-local.h.

◆ FORTRAN_MOD

#define FORTRAN_MOD (   n,
 
)    (SIGN_EQ((n),(m)) ? ABS(n)%ABS(m) : -(ABS(n)%ABS(m)))

Definition at line 215 of file misc-local.h.

◆ ifdebug

#define ifdebug (   l)    if (the_current_debug_level>=(l))

Definition at line 189 of file misc-local.h.

◆ MAXPATHLEN

#define MAXPATHLEN   1024

MAXPATHLEN is defined in <sys/param.h> for SunOS...

but not for all OS!

Definition at line 203 of file misc-local.h.

◆ pips_assert

#define pips_assert (   what,
  predicate 
)
Value:
do { \
if (!(predicate)) { \
pips_internal_error("assertion failed\n\n '%s' not verified\n\n", \
what); \
abort(); \
} \
} while(0)

common macros, two flavors depending on NDEBUG

Definition at line 172 of file misc-local.h.

◆ PIPS_CATCH

#define PIPS_CATCH (   what)
Value:
if (push_debug_status(), \
setjmp(*push_exception_on_stack(what, __CURRENT_FUNCTION_NAME__, \
__FILE__, __LINE__, pop_debug_status)))
jmp_buf * push_exception_on_stack(const int, const char *, const char *, const int)

Definition at line 206 of file misc-local.h.

◆ pips_debug

#define pips_debug   pips_debug_func2

these macros use the GNU extensions that allow variadic macros, including with an empty list.

if not available, function calls are used.

a slightly better job could be done if C99 is assumed.

Definition at line 145 of file misc-local.h.

◆ pips_exit

#define pips_exit (   code,
  format,
  args... 
)     pips_user_warning(format, ##args), exit(code)

Definition at line 193 of file misc-local.h.

◆ pips_internal_error

#define pips_internal_error   pips_internal_error_func2

Definition at line 149 of file misc-local.h.

◆ pips_log

#define pips_log   pips_log_func2

Definition at line 150 of file misc-local.h.

◆ pips_stop

#define pips_stop   pips_stop_func2

Definition at line 151 of file misc-local.h.

◆ pips_unknown_function

#define pips_unknown_function   "Unknown Function Name"

Definition at line 63 of file misc-local.h.

◆ pips_user_assert

#define pips_user_assert (   what,
  predicate 
)
Value:
do { \
if (!(predicate)) { \
pips_user_error("assertion failed\n\n '%s' not verified\n\n" \
"this is a USER ERROR, I guess\n", what); \
} \
} while(0)

Definition at line 181 of file misc-local.h.

◆ pips_user_error

#define pips_user_error   pips_user_error_func2

Definition at line 147 of file misc-local.h.

◆ pips_user_irrecoverable_error

#define pips_user_irrecoverable_error   pips_user_irrecoverable_error_func2

Definition at line 148 of file misc-local.h.

◆ pips_user_warning

#define pips_user_warning   pips_user_warning_func2

Definition at line 146 of file misc-local.h.

◆ pips_where

#define pips_where (   out)     fprintf(out, "[%s] (%s:%d) ", CURRENT_FUNCTION, __FILE__, __LINE__)

Definition at line 154 of file misc-local.h.

◆ same_string_p

#define same_string_p (   s1,
  s2 
)    function_same_string_p(s1,s2)

FI:need to breakpoint while inlining is available.

#define same_string_p(s1, s2) (strcmp((s1), (s2)) == 0)

Definition at line 198 of file misc-local.h.

◆ same_stringn_p

#define same_stringn_p (   a,
  b,
 
)    (!strncmp((a),(b),(c)))

Definition at line 199 of file misc-local.h.

◆ SIGN_EQ

#define SIGN_EQ (   a,
 
)    ((((a)>0 && (b)>0) || ((a)<0 && (b)<0)) ? true : false)

SG moved there from transformation.h.

Definition at line 212 of file misc-local.h.

◆ STRINGIFY

#define STRINGIFY (   symbol)    STRINGIFY_SECOND_STAGE(symbol)

If not using this 2-stage macro evaluation, the generated string is not the value of the macro but the name of the macro...

Who said C was a simple language? :-/

Definition at line 50 of file misc-local.h.

◆ STRINGIFY_SECOND_STAGE

#define STRINGIFY_SECOND_STAGE (   symbol)    #symbol

To generate a string from a macro:

Definition at line 46 of file misc-local.h.

◆ TIMEOUT_CODE

#define TIMEOUT_CODE   (128+14)

Definition at line 43 of file misc-local.h.

◆ user_error

#define user_error (   fn,
  ... 
)     pips_user_error_func(fn, __FILE__, __LINE__, __VA_ARGS__)

Definition at line 265 of file misc-local.h.

◆ user_warning

#define user_warning (   fn,
  ... 
)     pips_user_warning_func(fn, __FILE__, __LINE__, __VA_ARGS__)

Definition at line 262 of file misc-local.h.

◆ vasprintf

#define vasprintf   safe_vasprintf

Definition at line 226 of file misc-local.h.

Typedef Documentation

◆ reset_func_t

typedef void(* reset_func_t) (void)

Definition at line 222 of file misc-local.h.

Enumeration Type Documentation

◆ measurement_type

Measurement type for mem_spy.c.

Enumerator
SBRK_MEASURE 
NET_MEASURE 
GROSS_MEASURE 
SBRK_MEASURE 
NET_MEASURE 
GROSS_MEASURE 

Definition at line 57 of file misc-local.h.

measurement_type
Measurement type for mem_spy.c.
Definition: misc-local.h:57
@ SBRK_MEASURE
Definition: misc-local.h:57
@ GROSS_MEASURE
Definition: misc-local.h:57
@ NET_MEASURE
Definition: misc-local.h:57

◆ pips_log_t

enum pips_log_t
Enumerator
none_log 
info_log 
warning_log 
spear_warning_log 
spear_error_log 
user_error_log 
internal_error_log 
irrecoverable_error_log 
none_log 
info_log 
warning_log 
spear_warning_log 
spear_error_log 
user_error_log 
internal_error_log 
irrecoverable_error_log 

Definition at line 31 of file misc-local.h.

31  {
32  none_log, // nought
33  info_log, // some information
34  warning_log, // just a warning
37  user_error_log, // phase is stopped because of user, exception
38  internal_error_log, // phase is stopped because of pips, exception
39  irrecoverable_error_log // phase is stopped because of pips + exit/abort
40 } pips_log_t;
pips_log_t
Definition: misc-local.h:31
@ warning_log
Definition: misc-local.h:34
@ internal_error_log
Definition: misc-local.h:38
@ user_error_log
Definition: misc-local.h:37
@ spear_warning_log
Definition: misc-local.h:35
@ spear_error_log
Definition: misc-local.h:36
@ none_log
Definition: misc-local.h:32
@ info_log
Definition: misc-local.h:33
@ irrecoverable_error_log
Definition: misc-local.h:39

Function Documentation

◆ pips_internal_error_func()

void _NORETURN_ pips_internal_error_func ( const char *  funcname,
const char *  funcfile,
const int  funcline,
const char *  fmt,
  ... 
)
Parameters
funcnameuncname
funcfileuncfile
funclineuncline
fmtmt

Definition at line 394 of file message.c.

400 {
401  va_list args;
402  va_start(args, fmt);
403  pips_internal_error_alist(funcname, funcfile, funcline, fmt, &args);
404  va_end(args);
405 }
static void _NORETURN_ pips_internal_error_alist(const char *funcname, const char *funcfile, const int funcline, const char *format, va_list *args)
Definition: message.c:375

◆ pips_internal_error_func2()

void _NORETURN_ pips_internal_error_func2 ( const char *  format,
  ... 
)
Parameters
formatormat

Definition at line 408 of file message.c.

411 {
412  va_list args;
413  va_start(args, format);
415  format, &args);
416  va_end(args);
417 }
#define pips_unknown_function
Definition: misc-local.h:63

◆ pips_stop_func()

void _NORETURN_ pips_stop_func ( const char *  pips_func,
const char *  pips_file,
const int  pips_line,
pips_log_t  tag,
int  code,
const  string,
  ... 
)

expecititely declare "noreturn" functions...

because cproto generated headers seem to ignore attributes

Parameters
pips_funcips_func
pips_fileips_file
pips_lineips_line
codeode
stringormat

Definition at line 904 of file message.c.

914 {
915  va_list args;
916  va_start(args, format);
918  (const string) pips_func, (const string) pips_file, pips_line,
919  format, &args);
920  va_end(args);
921 }
static void _NORETURN_ pips_stop_alist(pips_log_t tag, int code, const string pips_func, const string pips_file, const int pips_line, const string format, va_list *args)
Definition: message.c:883
int tag
TAG.
Definition: newgen_types.h:92

◆ pips_stop_func2()

void _NORETURN_ pips_stop_func2 ( pips_log_t  tag,
int  code,
const  string,
  ... 
)
Parameters
codeode
stringormat

Definition at line 924 of file message.c.

929 {
930  va_list args;
931  va_start(args, format);
932  pips_stop_alist(tag, code, NULL, NULL, -1, format, &args);
933  va_end(args);
934 }

◆ pips_user_error_func()

void _NORETURN_ pips_user_error_func ( const char *  func_name,
const char *  funcfile,
const int  funcline,
const char *  format,
  ... 
)
Parameters
func_nameunc_name
funcfileuncfile
funclineuncline
formatormat

Definition at line 478 of file message.c.

484 {
485  va_list args;
486  va_start(args, format);
487  pips_user_error_alist(func_name, funcfile, funcline, format, &args);
488  va_end(args);
489 }
static void _NORETURN_ pips_user_error_alist(const char *calling_function_name, const char *funcfile, const int funcline, const char *format, va_list *args)
Definition: message.c:458

◆ pips_user_error_func2()

void _NORETURN_ pips_user_error_func2 ( const char *  format,
  ... 
)
Parameters
formatormat

Definition at line 492 of file message.c.

495 {
496  va_list args;
497  va_start(args, format);
498  pips_user_error_alist(pips_unknown_function, NULL, -1, format, &args);
499  va_end(args);
500 }

◆ pips_user_irrecoverable_error_alist()

void _NORETURN_ pips_user_irrecoverable_error_alist ( const char *  func_name,
const char *  funcfile,
const int  funcline,
const char *  format,
va_list *  args 
)
Parameters
func_nameunc_name
funcfileuncfile
funclineuncline
formatormat
argsrgs

Definition at line 516 of file message.c.

522 {
526  (const string) func_name, (const string) funcfile, funcline,
527  NULL, NULL, -1, -1,
528  NULL, NULL, (const string) format, args);
529 
530  // dead code, stopped in previous call
531  exit(1);
532 }
void pips_log_alist(const pips_log_t tag, const string pips_pass, const string pips_owner, const string pips_func, const string pips_file, const int pips_line, const string user_func, const string user_file, const int user_line, const int user_line2, const string stmt, const string suggestion, const string format, va_list *args)
log entry with unprocessed format/alist arguments
Definition: message.c:1200
string get_pips_current_pass_name(void)
Export this piece of information to customize warning functions in passes.
Definition: message.c:77
string get_pips_current_module(void)
Definition: message.c:82
#define exit(code)
Definition: misc-local.h:54

◆ pips_user_irrecoverable_error_func()

void _NORETURN_ pips_user_irrecoverable_error_func ( const char *  func_name,
const char *  funcfile,
const int  funcline,
const char *  format,
  ... 
)
Parameters
func_nameunc_name
funcfileuncfile
funclineuncline
formatormat

Definition at line 535 of file message.c.

541 {
542  va_list args;
543  va_start(args, format);
544  pips_user_irrecoverable_error_alist(func_name, funcfile, funcline,
545  format, &args);
546  va_end(args);
547 }
void _NORETURN_ pips_user_irrecoverable_error_alist(const char *func_name, const char *funcfile, const int funcline, const char *format, va_list *args)
Definition: message.c:516

◆ pips_user_irrecoverable_error_func2()

void _NORETURN_ pips_user_irrecoverable_error_func2 ( const char *  format,
  ... 
)
Parameters
formatormat

Definition at line 550 of file message.c.

553 {
554  va_list args;
555  va_start(args, format);
556  pips_user_irrecoverable_error_alist("UNKNOWN...", NULL, -1, format, &args);
557  va_end(args);
558 }

Variable Documentation

◆ the_current_debug_level

int the_current_debug_level
extern

Debugging functions.

cproto-generated files

Modifications:

  • set_debug_level function has been changed. Mainly the condition test, from (l >= 0 || l <= 9) to (l >= 0 && l <= 9) and else clause has been added, that is pips_error function. (Mar. 21,91 L.Zhou )
  • debug_off(): idls– was replaced by (–idls)-1 (April 7, 1991, Francois Irigoin) I switched this variable from static to non-static in order to avoid a function call in the pips_debug macro. This does not mean that this variable is intended to be touch by anyone directly. the interface remains the set/get functions. Just to reduce the debuging impact on the performance (from low to very low:-) FC, May 95.

debug.c

Definition at line 53 of file debug.c.