/*
 * fcdslib.h    Header for FCDS runtime support library routines.
 *
 * Copyright (c) Siemens AG 1993
 * All rights reserved.
 *
 * $Header:   P:/VCS/FCCLIB/FCDSLIB.H_V   1.1   10 Dec 1993 12:44:40   ror  $
 */

/*********************
 * Macroed functions *
 *********************/

/*
 * The following macros are used in an attempt to optimize multiplication and
 * division of integer values to reduce code size and execution time.  They
 * succeed quite well for Microsoft C V 7.0 or later on 8086-family processors
 * but have little effect for some other compilers and processors.
 */

    /* Add a uword and a uword, resulting in a ulong */

#define FCCAWWL(a,b)    (((ULONG) (UWORD) (a)) + ((ULONG) (UWORD) (b)))

    /* Multiply a ubyte times a ubyte, resulting in a uword */

#define FCCMBBW(a,b)    (((UWORD) (UBYTE) (a)) * ((UWORD) (UBYTE) (b)))

    /* Multiply a uword times a uword, resulting in a ulong */

#define FCCMWWL(a,b)    (((ULONG) (UWORD) (a)) * ((ULONG) (UWORD) (b)))

    /* Divide a uword by a ubyte, resulting in a ubyte */

#define FCCDWBB(a,b)    ((UBYTE) (((UWORD) (a)) / ((UBYTE) (b))))

    /* Divide a ulong by a uword, resulting in a uword */

#define FCCDLWW(a,b)    ((UWORD) (((ULONG) (a)) / ((UWORD) (b))))

/****************************
 * Constants and parameters *
 ****************************/

#define WINFO_WORDS 5               /* Number of moment words, FUWORD alpha */

#ifndef TRUE
#define TRUE    1
#endif

#ifndef FALSE
#define FALSE   0
#endif

#ifndef FAR
#ifdef  I86                         /* 8086-family machines have far pointers */
#define FAR     far
#else
#define FAR
#endif
#endif

/*
 * FPL type codes.
 */

#ifndef IO_FLOAT

#define IO_FLOAT        0           /* float */
#define IO_UBYTE        1           /* unsigned byte */
#define IO_SBYTE        2           /* signed byte */
#define IO_UWORD        3           /* unsigned word */
#define IO_SWORD        4           /* signed word */
#define IO_SLONG        5           /* signed long */
#define IO_ULONG        6           /* unsigned long */
#define IO_FUBYTE       7           /* fixed unsigned byte */
#define IO_FSBYTE       8           /* fixed signed byte */
#define IO_FUWORD       9           /* fixed unsigned word */
#define IO_FSWORD       10          /* fixed signed word */

#endif

/* Representations of membership functions for user-defined IDMs */

#define OMBF_POINTS     0
#define OMBF_SFUNC      1
#define OMBF_ZFUNC      2
#define OMBF_PIFUNC     3
#define OMBF_EXPR       4

/*
 * Maximum represented truth values for the possible truth types, and
 * maximum truth values squared.
 */

#ifdef  FCC_STDC_STYLE

#define MAXALPHAB   255u
#define MAXALPHABSQ 65025u
#define MAXALPHAW   65535u
#define MAXALPHAWSQ 4294836225uL

#else

#define MAXALPHAB   0x0ff
#define MAXALPHABSQ 0x0fe01
#define MAXALPHAW   0x0ffff
#define MAXALPHAWSQ 0x0fffe0001L

#endif

/*******************
 * Abuses of C :-) *
 *******************/

#ifdef  _MSC_VER
#if _MSC_VER >= 7
/* Shut the compiler up about "alignment of structure member was sensitive to packing" */
#pragma warning (disable:4121)
#endif
#endif

/*
 * If you're using MSC and want to compile to make a DLL, #define FCCATTRIB
 * as "far pascal".
 */

#ifndef FCCATTRIB
#define FCCATTRIB
#endif

/********************
 * Debugger strings *
 ********************/

#define FCCsync "SYNC"  /* Ring buffer sync string */

/*********************
 * Macro'd functions *
 *********************/

#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
#endif

#ifndef max
#define max(a,b) ((a)<(b)?(b):(a))
#endif

#define FCCcvtub(a) (((double) a) / 255.0)
#define FCCcvtsb(a) (((double) a) / 127.0)
#define FCCcvtuw(a) (((double) a) / 65535.0)
#define FCCcvtsw(a) (((double) a) / 32767.0)

/* Premise truth-value macros */

#define FCCmorb(a,b)        ((FUBYTE) max((a),(b)))
#define FCCmorf(a,b)        (max((a),(b)))
#define FCCmorw(a,b)        ((FUWORD) max((a),(b)))

#define FCCmandb(a,b)       ((FUBYTE) min((a),(b)))
#define FCCmandf(a,b)       (min((a),(b)))
#define FCCmandw(a,b)       ((FUWORD) min((a),(b)))

#define FCCmdpb(a,b)        ((FUBYTE) ((max((a),(b))==MAXALPHAB)?(min((a),(b))):0))
#define FCCmdpf(a,b)        ((max((a),(b))==1.0)?(min((a),(b))):0.0)
#define FCCmdpw(a,b)        ((FUWORD) ((max((a),(b))==MAXALPHAW)?(min((a),(b))):0))

#define FCCmdsb(a,b)        ((FUBYTE) ((min((a),(b))==0)?(max((a),(b))):MAXALPHAB))
#define FCCmdsf(a,b)        ((min((a),(b))==0.0)?(max((a),(b))):1.0)
#define FCCmdsw(a,b)        ((FUWORD) ((min((a),(b))==0)?(max((a),(b))):MAXALPHAW))

#define FCCmbdb(a,b)        ((FUBYTE) (max(((SWORD) 0),(((SWORD) (a))+((SWORD) (b))-((SWORD) MAXALPHAB)))))
#define FCCmbdf(a,b)        (max(0.0,(a)+(b)-1.0))
#define FCCmbdw(a,b)        ((FUWORD) (max(((SLONG) 0),(((SLONG) (a))+((SLONG) (b))-((SLONG) MAXALPHAW)))))

#define FCCmbsb(a,b)        ((FUBYTE) (min(MAXALPHAB,(a)+(b))))
#define FCCmbsf(a,b)        (min(1.0,(a)+(b)))
#define FCCmbsw(a,b)        ((FUWORD) (min(MAXALPHAW,FCCAWWL((a),(b)))))

#define FCCmapb(a,b)        ((FUBYTE) (FCCDWBB(FCCMBBW((a),(b)),MAXALPHAB)))
#define FCCmapf(a,b)        ((a)*(b))
#define FCCmapw(a,b)        ((FUWORD) (FCCDLWW(FCCMWWL((a),(b)),MAXALPHAW)))

#define FCCmasb(a,b)        ((FUBYTE) ((a)+(b)-FCCmapb((a),(b))))
#define FCCmasf(a,b)        ((a)+(b)-FCCmapf((a),(b)))
#define FCCmasw(a,b)        ((FUWORD) (FCCAWWL((a),(b))-FCCmapw((a),(b))))

#define FCCmepb(a,b)        ((FUBYTE) (FCCMBBW((a),(b))/(FCCMBBW(2,MAXALPHAB)-FCCmasb((a),(b)))))
#define FCCmepf(a,b)        ((a)*(b)/(2.0-FCCmasf((a),(b))))
#define FCCmepw(a,b)        ((FUWORD) (FCCMWWL((a),(b))/(FCCMWWL(2,MAXALPHAW)-FCCmasw((a),(b)))))

#define FCCmesb(a,b)        ((FUBYTE) (FCCDLWW(FCCMWWL((a)+(b),MAXALPHAB),MAXALPHAB+FCCmapb((a),(b)))))
#define FCCmesf(a,b)        (((a)+(b))/(1.0+FCCmapf((a),(b))))
#define FCCmesw(a,b)        ((FUWORD) ((FCCAWWL((a),(b))*((FLOAT) MAXALPHAW))/FCCAWWL(MAXALPHAW,FCCmapw((a),(b)))))

#define FCCmhpb(a,b)        ((FUBYTE) (((a)==0&&(b)==0)?(0):FCCDWBB(FCCMBBW((a),(b)),FCCmasb((a),(b)))))
#define FCCmhpf(a,b)        (((a)==0.0&&(b)==0.0)?(0.0):((a)*(b)/FCCmasf((a),(b))))
#define FCCmhpw(a,b)        ((FUWORD) (((a)==0&&(b)==0)?(0):FCCDLWW(FCCMWWL((a),(b)),FCCmasw((a),(b)))))

#define FCCmhsb(a,b)        ((FUBYTE) (((a)==MAXALPHAB&&(b)==MAXALPHAB)?(MAXALPHAB):((((a)+(b)-FCCMBBW(2,FCCmapb((a),(b))))*MAXALPHAB)/(MAXALPHAB-FCCmapb((a),(b))))))
#define FCCmhsf(a,b)        (((a)==1.0&&(b)==1.0)?(1.0):(((a)+(b)-2*FCCmapf((a),(b)))/(1.0-FCCmapf((a),(b)))))
#define FCCmhsw(a,b)        ((FUWORD) (((a)==MAXALPHAW&&(b)==MAXALPHAW)?(MAXALPHAW):(FCCDLWW((FCCAWWL((a),(b))-FCCMWWL(2,FCCmapw((a),(b))))*MAXALPHAW,MAXALPHAW-FCCmapw((a),(b))))))

/*********
 * Types *
 *********/

/* Portable data types */

#ifndef ANSI
#define signed
#endif

/*
 * Primary types - compiler & environment dependent
 */

typedef unsigned char       UBYTE;
typedef signed char         SBYTE;
typedef unsigned short int  UWORD;
typedef signed short int    SWORD;
typedef unsigned long       ULONG;
typedef signed long         SLONG;
typedef double              FLOAT;

/*
 * Derived types
 */

typedef UBYTE FUBYTE;
typedef SBYTE FSBYTE;
typedef UWORD FUWORD;
typedef SWORD FSWORD;

/* Abstract "handle" type for user-defined objects and IDMs */

typedef char *FCCMEM;

/* Points-list structure types */

struct FCCptsbb {               /* [F]SBYTE variable, FUBYTE alpha */
    SBYTE x;
    FUBYTE y;
};

struct FCCptsbw {               /* [F]SBYTE variable, FUWORD alpha */
    SBYTE x;
    FUWORD y;
};

struct FCCptsbf {               /* [F]SBYTE variable, FLOAT alpha */
    SBYTE x;
    FLOAT y;
};

struct FCCptubb {               /* [F]UBYTE variable, FUBYTE alpha */
    UBYTE x;
    FUBYTE y;
};

struct FCCptubw {               /* [F]UBYTE variable, FUWORD alpha */
    UBYTE x;
    FUWORD y;
};

struct FCCptubf {               /* [F]UBYTE variable, FLOAT alpha */
    UBYTE x;
    FLOAT y;
};

struct FCCptswb {               /* [F]SWORD variable, FUBYTE alpha */
    SWORD x;
    FUBYTE y;
};

struct FCCptsww {               /* [F]SWORD variable, FUWORD alpha */
    SWORD x;
    FUWORD y;
};

struct FCCptswf {               /* [F]SWORD variable, FLOAT alpha */
    SWORD x;
    FLOAT y;
};

struct FCCptuwb {               /* [F]UWORD variable, FUBYTE alpha */
    UWORD x;
    FUBYTE y;
};

struct FCCptuww {               /* [F]UWORD variable, FUWORD alpha */
    UWORD x;
    FUWORD y;
};

struct FCCptuwf {               /* [F]UWORD variable, FLOAT alpha */
    UWORD x;
    FLOAT y;
};

struct FCCptfb {               /* FLOAT variable, FUBYTE alpha */
    FLOAT x;
    FUBYTE y;
};

struct FCCptfw {               /* FLOAT variable, FUWORD alpha */
    FLOAT x;
    FUWORD y;
};

struct FCCptff {               /* FLOAT variable, FLOAT alpha */
    FLOAT x;
    FLOAT y;
};

/* Output temp structure types */

struct FCCils {                /* centroid/height, "small" integer alpha and signed VAR */
    long n;
    long d;
};

struct FCCilu {                /* centroid/height, "small" integer alpha and signed VAR */
    unsigned long n;
    unsigned long d;
};

struct FCCih {                 /* centroid/height, FUWORD alpha */
    UWORD nneg;
    UWORD n[WINFO_WORDS];
    UWORD d[WINFO_WORDS];
};

struct FCCif {                 /* centroid/height, FLOAT alpha or VAR */
    double n;
    double d;
};

/* Parameter structure for FCC_link_init */
/* Warning: subject to change! */

typedef struct {
    int portno;             /* 1 or 2 representing COM1 or COM2 (for pc) */
    unsigned bps;           /* data rate, bits per second */
    int data_bits;          /* number of data bits, 5 .. 8 */
    int stop_bits;          /* number of stop bits, 1 or 2 */
    int enable_parity : 1;  /* != 0 to enable parity generation/checking */
    int stick_parity : 1;   /* != 0 for mark (even_parity=1) or space (even_parity=0) parity */
    int even_parity : 1;    /* 1 for even parity, 0 for odd (if enabled) */
} LINKPARAMS;

/* Typedef for an item in the debug table */

typedef struct
{
    unsigned char type;
    unsigned char iclass;
    unsigned char flags;
    unsigned char var_iotype;
    unsigned char truth_iotype;
    unsigned short nelem;
    void *addr;
} DTITEM;

/* Types for pointers to premise truth-value functions */

#ifdef  FCC_STDC_STYLE

typedef FUBYTE (*FCC_OPPTRTB)(FUBYTE a, FUBYTE b);
typedef FLOAT  (*FCC_OPPTRTF)(FLOAT a, FLOAT b);
typedef FUWORD (*FCC_OPPTRTW)(FUWORD a, FUWORD b);
typedef FUBYTE (*FCC_OPPTRIB)(void);
typedef FLOAT  (*FCC_OPPTRIF)(void);
typedef FUWORD (*FCC_OPPTRIW)(void);

#else

typedef FUBYTE (*FCC_OPPTRTB)();
typedef FLOAT  (*FCC_OPPTRTF)();
typedef FUWORD (*FCC_OPPTRTW)();
typedef FUBYTE (*FCC_OPPTRIB)();
typedef FLOAT  (*FCC_OPPTRIF)();
typedef FUWORD (*FCC_OPPTRIW)();

#endif

/*******************
 * Library globals *
 *******************/

#ifdef  NEVER

/*
 * All of the compile time macros supported by the online debugging library
 * modules need to appear here.
 */

#define NO_FLOAT
#define FCC_CMD_BUFSIZE
#define FCC_CAPTURE_BUFSIZE
#define PKT_TIMEOUT_US
#define DEFER_TIMEOUT_US

/*
 * All of the external symbols required by the online debugging library
 * modules need to appear here, even though these externs are not ever
 * directly used by the compiler.
 */

extern DTITEM FCC_debug_table[];        /* The debugging table */
extern UWORD FCC_capture_bufsize;       /* Target data capture buffer size (bytes) */
extern UBYTE FCC_online_flags;          /* global flags */
extern ULONG FCC_online_iteration;      /* iteration count */
extern UWORD FCC_post_trigger;          /* #samples from capture trigger to end */
extern UWORD FCC_samples_per_autosend;  /* Number of sampling cycles per autosend */
extern UBYTE FCC_fp_precision;          /* #significant digits in FLOAT->ASCII */

#endif

/**************
 * Prototypes *
 **************/

#ifdef  FCC_STDC_STYLE

/* Miscellaneous library functions */

  FLOAT  FCCbline (FLOAT x, FLOAT x0, FLOAT y0, FLOAT x1, FLOAT y1);
  FLOAT  FCCbnormal (FLOAT mean, FLOAT sd);
  void   FCCbreseed (FLOAT seed);
  FLOAT  FCCbrexp (FLOAT mean);
  FUBYTE FCCbsfb (FLOAT x, FLOAT a, FLOAT b);
  FLOAT FCCbsff (FLOAT x, FLOAT a, FLOAT b);
  FUWORD FCCbsfw (FLOAT x, FLOAT a, FLOAT b);
  FUBYTE FCCbssbb (SBYTE x, SBYTE a, SBYTE b);
  FUWORD FCCbssbw (SBYTE x, SBYTE a, SBYTE b);
  FUBYTE FCCbsswb (SWORD x, SWORD a, SWORD b);
  FUWORD FCCbssww (SWORD x, SWORD a, SWORD b);
  FLOAT  FCCbstep (FLOAT x, FLOAT edge);
  FUBYTE FCCbsubb (UBYTE x, UBYTE a, UBYTE b);
  FUWORD FCCbsubw (UBYTE x, UBYTE a, UBYTE b);
  FUBYTE FCCbsuwb (UWORD x, UWORD a, UWORD b);
  FUWORD FCCbsuww (UWORD x, UWORD a, UWORD b);
  FLOAT  FCCbuniform (FLOAT low, FLOAT high);

/* Defuzzification routines */

  void FCCdabf (FUBYTE* map, UWORD mapsize, FLOAT *v, FLOAT minv, FLOAT maxv);
  void FCCdabsb (FUBYTE* map, UWORD mapsize, SBYTE *v, SBYTE minv, SBYTE maxv);
  void FCCdabsw (FUBYTE* map, UWORD mapsize, SWORD *v, SWORD minv, SWORD maxv);
  void FCCdabub (FUBYTE* map, UWORD mapsize, UBYTE *v, UBYTE minv, UBYTE maxv);
  void FCCdabuw (FUBYTE* map, UWORD mapsize, UWORD *v, UWORD minv, UWORD maxv);
  void FCCdaff (FLOAT* map, UWORD mapsize, FLOAT *v, FLOAT minv, FLOAT maxv);
  void FCCdafsb (FLOAT* map, UWORD mapsize, SBYTE *v, SBYTE minv, SBYTE maxv);
  void FCCdafsw (FLOAT* map, UWORD mapsize, SWORD *v, SWORD minv, SWORD maxv);
  void FCCdafub (FLOAT* map, UWORD mapsize, UBYTE *v, UBYTE minv, UBYTE maxv);
  void FCCdafuw (FLOAT* map, UWORD mapsize, UWORD *v, UWORD minv, UWORD maxv);
  void FCCdawf (FUWORD* map, UWORD mapsize, FLOAT *v, FLOAT minv, FLOAT maxv);
  void FCCdawsb (FUWORD* map, UWORD mapsize, SBYTE *v, SBYTE minv, SBYTE maxv);
  void FCCdawsw (FUWORD* map, UWORD mapsize, SWORD *v, SWORD minv, SWORD maxv);
  void FCCdawub (FUWORD* map, UWORD mapsize, UBYTE *v, UBYTE minv, UBYTE maxv);
  void FCCdawuw (FUWORD* map, UWORD mapsize, UWORD *v, UWORD minv, UWORD maxv);

  void FCCdcbf (FUBYTE* map, UWORD mapsize, FLOAT *v, FLOAT minv, FLOAT maxv);
  void FCCdcbsb (FUBYTE* map, UWORD mapsize, SBYTE *v, SBYTE minv, SBYTE maxv);
  void FCCdcbsw (FUBYTE* map, UWORD mapsize, SWORD *v, SWORD minv, SWORD maxv);
  void FCCdcbub (FUBYTE* map, UWORD mapsize, UBYTE *v, UBYTE minv, UBYTE maxv);
  void FCCdcbuw (FUBYTE* map, UWORD mapsize, UWORD *v, UWORD minv, UWORD maxv);
  void FCCdcff (FLOAT* map, UWORD mapsize, FLOAT *v, FLOAT minv, FLOAT maxv);
  void FCCdcfsb (FLOAT* map, UWORD mapsize, SBYTE *v, SBYTE minv, SBYTE maxv);
  void FCCdcfsw (FLOAT* map, UWORD mapsize, SWORD *v, SWORD minv, SWORD maxv);
  void FCCdcfub (FLOAT* map, UWORD mapsize, UBYTE *v, UBYTE minv, UBYTE maxv);
  void FCCdcfuw (FLOAT* map, UWORD mapsize, UWORD *v, UWORD minv, UWORD maxv);
  void FCCdcwf (FUWORD* map, UWORD mapsize, FLOAT *v, FLOAT minv, FLOAT maxv);
  void FCCdcwsb (FUWORD* map, UWORD mapsize, SBYTE *v, SBYTE minv, SBYTE maxv);
  void FCCdcwsw (FUWORD* map, UWORD mapsize, SWORD *v, SWORD minv, SWORD maxv);
  void FCCdcwub (FUWORD* map, UWORD mapsize, UBYTE *v, UBYTE minv, UBYTE maxv);
  void FCCdcwuw (FUWORD* map, UWORD mapsize, UWORD *v, UWORD minv, UWORD maxv);

  int FCCdhsb (struct FCCih *temp, SBYTE *out);
  int FCCdhub (struct FCCih *temp, UBYTE *out);
  int FCCdhsw (struct FCCih *temp, SWORD *out);
  int FCCdhuw (struct FCCih *temp, UWORD *out);

/* Points-list interpolation functions */

  FUBYTE FCCpsbb (SBYTE var, int n, struct FCCptsbb const * pts);
  FLOAT  FCCpsbf (SBYTE var, int n, struct FCCptsbf const * pts);
  FUWORD FCCpsbw (SBYTE var, int n, struct FCCptsbw const * pts);
  FUBYTE FCCpubb (UBYTE var, int n, struct FCCptubb const * pts);
  FLOAT  FCCpubf (UBYTE var, int n, struct FCCptubf const * pts);
  FUWORD FCCpubw (UBYTE var, int n, struct FCCptubw const * pts);
  FUBYTE FCCpswb (SWORD var, int n, struct FCCptswb const * pts);
  FLOAT  FCCpswf (SWORD var, int n, struct FCCptswf const * pts);
  FUWORD FCCpsww (SWORD var, int n, struct FCCptsww const * pts);
  FUBYTE FCCpuwb (UWORD var, int n, struct FCCptuwb const * pts);
  FLOAT  FCCpuwf (UWORD var, int n, struct FCCptuwf const * pts);
  FUWORD FCCpuww (UWORD var, int n, struct FCCptuww const * pts);
  FUBYTE FCCpfb  (FLOAT var, int n, struct FCCptfb const * pts);
  FLOAT  FCCpff  (FLOAT var, int n, struct FCCptff const * pts);
  FUWORD FCCpfw  (FLOAT var, int n, struct FCCptfw const * pts);

/* RULE RHS routines */

  void FCCrhs (struct FCCih *temp, UWORD alpha, FUBYTE weight, struct FCCih const *mbf);
  void FCCrhu (struct FCCih *temp, UWORD alpha, FUBYTE weight, struct FCCih const *mbf);

  void FCCrmdb (FUBYTE alpha, FUBYTE weight, FUBYTE* var, UWORD mapsize, const FUBYTE* mbf);
  void FCCrmdf (FLOAT alpha, FUBYTE weight, FLOAT* var, UWORD mapsize, const FLOAT* mbf);
  void FCCrmdw (FUWORD alpha, FUBYTE weight, FUWORD* var, UWORD mapsize, const FUWORD* mbf);

  void FCCrmmb (FUBYTE alpha, FUBYTE weight, FUBYTE* var, UWORD mapsize, const FUBYTE* mbf);
  void FCCrmmf (FLOAT alpha, FUBYTE weight, FLOAT* var, UWORD mapsize, const FLOAT* mbf);
  void FCCrmmw (FUWORD alpha, FUBYTE weight, FUWORD* var, UWORD mapsize, const FUWORD* mbf);

/* Premise truth-value functions - arguments on the stack */

  FUBYTE FCCtorb (FUBYTE a, FUBYTE b);
  FLOAT  FCCtorf (FLOAT a,  FLOAT b);
  FUWORD FCCtorw (FUWORD a, FUWORD b);

  FUBYTE FCCtandb (FUBYTE a, FUBYTE b);
  FLOAT  FCCtandf (FLOAT a,  FLOAT b);
  FUWORD FCCtandw (FUWORD a, FUWORD b);

  FUBYTE FCCtdpb (FUBYTE a, FUBYTE b);
  FLOAT  FCCtdpf (FLOAT a,  FLOAT b);
  FUWORD FCCtdpw (FUWORD a, FUWORD b);

  FUBYTE FCCtdsb (FUBYTE a, FUBYTE b);
  FLOAT  FCCtdsf (FLOAT a,  FLOAT b);
  FUWORD FCCtdsw (FUWORD a, FUWORD b);

  FUBYTE FCCtbdb (FUBYTE a, FUBYTE b);
  FLOAT  FCCtbdf (FLOAT a,  FLOAT b);
  FUWORD FCCtbdw (FUWORD a, FUWORD b);

  FUBYTE FCCtbsb (FUBYTE a, FUBYTE b);
  FLOAT  FCCtbsf (FLOAT a,  FLOAT b);
  FUWORD FCCtbsw (FUWORD a, FUWORD b);

  FUBYTE FCCtapb (FUBYTE a, FUBYTE b);
  FLOAT  FCCtapf (FLOAT a,  FLOAT b);
  FUWORD FCCtapw (FUWORD a, FUWORD b);

  FUBYTE FCCtasb (FUBYTE a, FUBYTE b);
  FLOAT  FCCtasf (FLOAT a,  FLOAT b);
  FUWORD FCCtasw (FUWORD a, FUWORD b);

  FUBYTE FCCtepb (FUBYTE a, FUBYTE b);
  FLOAT  FCCtepf (FLOAT a,  FLOAT b);
  FUWORD FCCtepw (FUWORD a, FUWORD b);

  FUBYTE FCCtesb (FUBYTE a, FUBYTE b);
  FLOAT  FCCtesf (FLOAT a,  FLOAT b);
  FUWORD FCCtesw (FUWORD a, FUWORD b);

  FUBYTE FCCthpb (FUBYTE a, FUBYTE b);
  FLOAT  FCCthpf (FLOAT a,  FLOAT b);
  FUWORD FCCthpw (FUWORD a, FUWORD b);

  FUBYTE FCCthsb (FUBYTE a, FUBYTE b);
  FLOAT  FCCthsf (FLOAT a,  FLOAT b);
  FUWORD FCCthsw (FUWORD a, FUWORD b);

/* Premise truth-value functions - arguments in static variables */

  FUBYTE FCCiorb (void);
  FLOAT  FCCiorf (void);
  FUWORD FCCiorw (void);

  FUBYTE FCCiandb (void);
  FLOAT  FCCiandf (void);
  FUWORD FCCiandw (void);

  FUBYTE FCCidpb (void);
  FLOAT  FCCidpf (void);
  FUWORD FCCidpw (void);

  FUBYTE FCCidsb (void);
  FLOAT  FCCidsf (void);
  FUWORD FCCidsw (void);

  FUBYTE FCCibdb (void);
  FLOAT  FCCibdf (void);
  FUWORD FCCibdw (void);

  FUBYTE FCCibsb (void);
  FLOAT  FCCibsf (void);
  FUWORD FCCibsw (void);

  FUBYTE FCCiapb (void);
  FLOAT  FCCiapf (void);
  FUWORD FCCiapw (void);

  FUBYTE FCCiasb (void);
  FLOAT  FCCiasf (void);
  FUWORD FCCiasw (void);

  FUBYTE FCCiepb (void);
  FLOAT  FCCiepf (void);
  FUWORD FCCiepw (void);

  FUBYTE FCCiesb (void);
  FLOAT  FCCiesf (void);
  FUWORD FCCiesw (void);

  FUBYTE FCCihpb (void);
  FLOAT  FCCihpf (void);
  FUWORD FCCihpw (void);

  FUBYTE FCCihsb (void);
  FLOAT  FCCihsf (void);
  FUWORD FCCihsw (void);

/* Online debugging routines */

  int  FCC_online_init    (LINKPARAMS *psetup);
  void FCC_online_sample  (void);
  void FCC_online_cancel  (void);
  void FCC_online_cleanup (void);

#else

/* Miscellaneous library functions */

  FLOAT  FCCbline ();
  FLOAT  FCCbnormal ();
  void   FCCbreseed ();
  FLOAT  FCCbrexp ();
  FUBYTE FCCbsfb ();
  FLOAT  FCCbsff ();
  FUWORD FCCbsfw ();
  FUBYTE FCCbssbb ();
  FUWORD FCCbssbw ();
  FUBYTE FCCbsswb ();
  FUWORD FCCbssww ();
  FLOAT  FCCbstep ();
  FUBYTE FCCbsubb ();
  FUWORD FCCbsubw ();
  FUBYTE FCCbsuwb ();
  FUWORD FCCbsuww ();
  FLOAT  FCCbuniform ();

/* Defuzzification routines */

  void FCCdabf ();
  void FCCdabsb ();
  void FCCdabsw ();
  void FCCdabub ();
  void FCCdabuw ();
  void FCCdaff ();
  void FCCdafsb ();
  void FCCdafsw ();
  void FCCdafub ();
  void FCCdafuw ();
  void FCCdawf ();
  void FCCdawsb ();
  void FCCdawsw ();
  void FCCdawub ();
  void FCCdawuw ();

  void FCCdcbf ();
  void FCCdcbsb ();
  void FCCdcbsw ();
  void FCCdcbub ();
  void FCCdcbuw ();
  void FCCdcff ();
  void FCCdcfsb ();
  void FCCdcfsw ();
  void FCCdcfub ();
  void FCCdcfuw ();
  void FCCdcwf ();
  void FCCdcwsb ();
  void FCCdcwsw ();
  void FCCdcwub ();
  void FCCdcwuw ();

  int FCCdhsb ();
  int FCCdhub ();
  int FCCdhsw ();
  int FCCdhuw ();

/* Points-list interpolation functions */

  FUBYTE FCCpsbb ();
  FLOAT  FCCpsbf ();
  FUWORD FCCpsbw ();
  FUBYTE FCCpubb ();
  FLOAT  FCCpubf ();
  FUWORD FCCpubw ();
  FUBYTE FCCpswb ();
  FLOAT  FCCpswf ();
  FUWORD FCCpsww ();
  FUBYTE FCCpuwb ();
  FLOAT  FCCpuwf ();
  FUWORD FCCpuww ();
  FUBYTE FCCpfb ();
  FLOAT  FCCpff ();
  FUWORD FCCpfw ();

/* FUWORD alpha inference functions */

  void FCCrhs ();
  void FCCrhu ();
  void FCCrmdb ();
  void FCCrmdf ();
  void FCCrmdw ();
  void FCCrmmb ();
  void FCCrmmf ();
  void FCCrmmw ();

/* Premise truth-value functions - arguments on the stack */

  FUBYTE FCCtorb ();
  FLOAT  FCCtorf ();
  FUWORD FCCtorw ();

  FUBYTE FCCtandb ();
  FLOAT  FCCtandf ();
  FUWORD FCCtandw ();

  FUBYTE FCCtdpb ();
  FLOAT  FCCtdpf ();
  FUWORD FCCtdpw ();

  FUBYTE FCCtdsb ();
  FLOAT  FCCtdsf ();
  FUWORD FCCtdsw ();

  FUBYTE FCCtbdb ();
  FLOAT  FCCtbdf ();
  FUWORD FCCtbdw ();

  FUBYTE FCCtbsb ();
  FLOAT  FCCtbsf ();
  FUWORD FCCtbsw ();

  FUBYTE FCCtapb ();
  FLOAT  FCCtapf ();
  FUWORD FCCtapw ();

  FUBYTE FCCtasb ();
  FLOAT  FCCtasf ();
  FUWORD FCCtasw ();

  FUBYTE FCCtepb ();
  FLOAT  FCCtepf ();
  FUWORD FCCtepw ();

  FUBYTE FCCtesb ();
  FLOAT  FCCtesf ();
  FUWORD FCCtesw ();

  FUBYTE FCCthpb ();
  FLOAT  FCCthpf ();
  FUWORD FCCthpw ();

  FUBYTE FCCthsb ();
  FLOAT  FCCthsf ();
  FUWORD FCCthsw ();

/* Premise truth-value functions - arguments in static variables */

  FUBYTE FCCiorb ();
  FLOAT  FCCiorf ();
  FUWORD FCCiorw ();

  FUBYTE FCCiandb ();
  FLOAT  FCCiandf ();
  FUWORD FCCiandw ();

  FUBYTE FCCidpb ();
  FLOAT  FCCidpf ();
  FUWORD FCCidpw ();

  FUBYTE FCCidsb ();
  FLOAT  FCCidsf ();
  FUWORD FCCidsw ();

  FUBYTE FCCibdb ();
  FLOAT  FCCibdf ();
  FUWORD FCCibdw ();

  FUBYTE FCCibsb ();
  FLOAT  FCCibsf ();
  FUWORD FCCibsw ();

  FUBYTE FCCiapb ();
  FLOAT  FCCiapf ();
  FUWORD FCCiapw ();

  FUBYTE FCCiasb ();
  FLOAT  FCCiasf ();
  FUWORD FCCiasw ();

  FUBYTE FCCiepb ();
  FLOAT  FCCiepf ();
  FUWORD FCCiepw ();

  FUBYTE FCCiesb ();
  FLOAT  FCCiesf ();
  FUWORD FCCiesw ();

  FUBYTE FCCihpb ();
  FLOAT  FCCihpf ();
  FUWORD FCCihpw ();

  FUBYTE FCCihsb ();
  FLOAT  FCCihsf ();
  FUWORD FCCihsw ();

/* Online debugging routines */

  int  FCC_online_init    ();
  void FCC_online_sample  ();
  void FCC_online_cancel  ();
  void FCC_online_cleanup ();

#endif
