/*
 * FILE:        FLIBNT.H
 *
 * MODULE:      FactoryLink Main Header File - WIN
 *
 * PROGRAM:     FactoryLink WIN version 4.0
 *
 * AUTHOR:      Clay Waldrop, Jr.
 *
 * HISTORY:       DATE   AUTHOR  DESCRIPTION OF ACTION
 *              07/19/91   CW    Finished WIN version 3.0.
 *              08/16/91   CW    Finished WIN version 4.0.
 */

#ifndef _FLIB_NT_INCLUDED
#define	_FLIB_NT_INCLUDED

/* --- Includes --- */

/* NONE */

/* --- Keyword Definitions --- */

#ifndef FAR
#define FAR
#endif
#ifndef NEAR
#define NEAR
#endif
#define FAST                    register
#define FLENTRY                 
#define ENTRY                   
#define IOFUNC                  

/* --- Special Definitions --- */

#define TASK_NAME_ID		100
#define TASK_EXIT_ID		101
#define EOL_SEQ			"\r\n"	/* end-of-line sequence */

/* --- Size-Specific Data Types --- */

typedef          char  i8;              /* signed 8-bit integer */
typedef unsigned char  u8;              /* unsigned 8-bit integer */
typedef          short i16;             /* signed 16-bit integer */
typedef unsigned short u16;             /* unsigned 16-bit integer */
typedef          long  i32;             /* signed 32-bit integer */
typedef unsigned long  u32;             /* unsigned 32-bit integer */

/* --- Generic Data Types --- */

typedef unsigned char uchar;            /* unsigned character */
typedef unsigned short ushort;          /* unsigned short */
typedef unsigned int uint;              /* unsigned integer */
typedef unsigned long ulong;            /* unsigned long */

/* --- Process & Thread ID Types --- */

typedef u16     pid_t;                  /* process id (PID) type */
typedef u16     tid_t;                  /* thread id (TID) type */

/* --- FactoryLink Data Types --- */

typedef i16	DIG;                    /* digital type (2 bytes) */
typedef	i16	ANA;                    /* analog type (2 bytes) */
typedef	i32	LANA;                   /* long analog type (4 bytes) */
typedef double  FLP;                    /* floating point type (8 bytes) */

/* --- Math function macros --- */

#define fl_isfinite(dblp)       ((*(((u16 *)(dblp))+3) & 0x7FF0) != 0x7FF0)

#define fl_isfzero(dblp)        \
        (((*((u16 *)(dblp)+3) & 0x000F) == 0x0000) \
        && (*((u16 *)(dblp)+2) == 0x0000) \
        && (*((u16 *)(dblp)+1) == 0x0000) \
        && (*(u16 *)(dblp) == 0x0000))

#define fl_isposinf(dblp)       \
        (((*(((u16 *)(dblp))+3) & 0xFFF0) == 0x7FF0) && (fl_isfzero(dblp)))

#define fl_isneginf(dblp)       \
        (((*(((u16 *)(dblp))+3) & 0xFFF0) == 0xFFF0) && (fl_isfzero(dblp)))

#define fl_isnan(dblp)          \
        (((*(((u16 *)(dblp))+3) & 0x7FF0) == 0x7FF0) && (! fl_isfzero(dblp)))

/* --- Special Kernel Prototypes --- */

char	*fll_setvar(char *str);
void    FLENTRY fl_exit_trap(void);
#define	getdate	fl_getdate
#define	gettime	fl_gettime

extern	char	flDomain[];
extern	char	flName[];
extern	char	flUser[];

/* 
 *  If NOCT is defined, then <stdio.h> might not have been included.
 *  Add define FLTMP_PROTO should some need the temp functions w/o
 *  including the CT headers.
 */
#ifndef NOCT
#define FLTMP_PROTO
#endif
#ifdef FLTMP_PROTO
#ifndef _INC_STDIO
#include <stdio.h>
#endif
FILE*   ENTRY fl_tmpfopen(void);
int     ENTRY fl_tmpfclose(FILE *fp);
#endif

/*SPR 8649*/ /* Workaround for NT's broken time() function	*/
#include <time2.h>	/*SPR 8649: Include MS time() bug workaround	*/

#endif
