Actual source code: adintrinsics.c

      1: #include <stdio.h>
      2: #include <stdlib.h>
      3: #include "knr-compat.h"
      4: #include "report-once.h"

      6: #define ADINTRINSICS_C
      7: #include "adintrinsics.h"

      9: /* Global Variable */
     10: /* Variable initialized in automatically generated file */
     11: /* double ADIntr_Partials[ADINTR_FUNC_MAX][ADINTR_PARTIALS_MAX]; */
     12: #include "initcommon.h"

     14: #if defined(__cplusplus)
     16: #endif

     18: typedef enum ADIntr_Modes Mode;

     20: Mode ADIntr_Mode = ADINTR_REPORTONCE;

     22: /* This provides the first 10 spots in the mode stack.
     23:    Most normal programs will probably not grow beyond this. */

     25: static Mode *ADIntr_mode_stack = 0;
     26: static int ADIntr_mode_depth = 0;
     27: static int ADIntr_mode_max_depth = 10;

     29: #define ADINTR_STACK_GROWTH_INCREMENT 10

     31: Mode
     32: adintr_current_mode ARG0(void)
     33: {
     34:      return ADIntr_Mode;
     35: }

     38: static void
     39: ADIntr_die_malloc_failure ARG0(void)
     40: {
     41:      fprintf(stderr,"ADIntrinsics: out of virtual memory\n");
     42:      fflush(stderr);
     43:      abort();
     44: }

     47: void
     48: adintr_mode_push ARG1(Mode, new_mode)
     49: {
     50:      if (!ADIntr_mode_stack)
     51:      {
     52:           ADIntr_mode_stack = (Mode *) malloc(ADIntr_mode_max_depth *
     53:                                               sizeof(Mode));
     54:           if (!ADIntr_mode_stack)
     55:           {
     56:                ADIntr_die_malloc_failure();
     57:           }
     58:      }

     60:      if (ADIntr_mode_depth >= ADIntr_mode_max_depth)
     61:      {
     62:           ADIntr_mode_max_depth += ADINTR_STACK_GROWTH_INCREMENT;

     64:           ADIntr_mode_stack =
     65:                (Mode *) realloc (ADIntr_mode_stack,
     66:                                  ADIntr_mode_max_depth * sizeof(Mode));

     68:           if (!ADIntr_mode_stack)
     69:           {
     70:                ADIntr_die_malloc_failure();
     71:           }
     72:      }
     73:
     74:      ADIntr_mode_stack[ADIntr_mode_depth] = ADIntr_Mode;
     75:      ADIntr_mode_depth++;

     77:      ADIntr_Mode = new_mode;
     78: }

     81: void
     82: adintr_mode_pop ARG0(void)
     83: {
     84:      if (!ADIntr_mode_stack || !ADIntr_mode_depth)
     85:      {
     86:           fprintf (stderr,"ADIntrinsics warning: more mode POP's than PUSH's (arising from AD_EXCEPTION_BEGIN_IGNORE\n");
     87:           fprintf (stderr,"ADIntrinsics: Ignoring POP request\n");
     88:           fflush(stderr);
     89:      }
     90:      else
     91:      {
     92:           ADIntr_mode_depth --;
     93:           ADIntr_Mode = ADIntr_mode_stack[ADIntr_mode_depth];
     94:      }
     95: }

     97: /************************************************************************/

     99: void
    100: adintr_ehsup ARG3(enum ADIntr_Funcs, func,
    101:                   enum ADIntr_Partials, partial,
    102:                   double, value)
    103: {
    104:      ADIntr_Partials[func][partial] = value;
    105: }

    107: double
    108: adintr_ehgup ARG2(enum ADIntr_Funcs, func,
    109:                   enum ADIntr_Partials, partial)
    110: {
    111:      return ADIntr_Partials[func][partial];
    112: }

    114: void
    115: adintr_ehsout ARG1(FILE *,the_file)
    116: {
    117:      reportonce_set_raw_output(the_file);
    118: }

    120: void
    121: adintr_ehrpt ARG0(void)
    122: {
    123:      reportonce_summary();
    124: }

    126: void
    127: adintr_ehrst ARG0(void)
    128: {
    129:      reportonce_reset();
    130: }

    132: void
    133: adintr_ehsfid ARG3(int*,g_ehfid, char *,routine, char *,filename)
    134: {
    135:      reportonce_ehsfid(g_ehfid, routine, filename);
    136: }

    138: #if defined(__cplusplus)
    139: }
    140: #endif