/* min.c - support for F77 min() function variable arg transls by FOR_C (TM) */ /* * copyright Cobalt Blue, Inc., 1988 - 1995 * ALL RIGHTS RESERVED */ #ifdef _MSC_VER # pragma warning( disable : 4244 )/* disable bogus conv int to short warning in MS VS*/ # pragma warning( disable : 4056 )/* disable bogus underflow warning in MS VS*/ #endif #include /* ANSI variable arg macros */ #include "cdminmax.h" #define VA_START(a,v) va_start(a,v) #ifdef min # undef min #endif long min( long a, long b ) { return( a < b ? a : b ); } #ifdef fmin # undef fmin #endif double fmin(double a, double b) { return( a < b ? a : b ); } /* NOTE: All of the functions in the rest of this file are, VARIABLE NUMBER OF ARGRUMENT FUNCTIONS! */ double vfmin( double mn, ... ) { double a; va_list args; /* arg ptr */ if( mn == FEND ) return( 0. ); /* NULL arg list */ VA_START(args,mn); /* initialize variable args */ while( (a=va_arg(args,double)) != FEND ) mn = (mn < a) ? mn : a; return( mn ); } /* * * * */ #if 0 long vmin( long mn, ... ) { long a; va_list args; /* arg ptr */ if( mn == IEND ) return( 0L ); /* NULL arg list */ VA_START(args,mn); /* initialize variable args */ while( (a=va_arg(args,long)) != IEND ) mn = (mn < a) ? mn : a; return( mn ); } #endif /* max.c - support for F77 max() function variable arg transls by FOR_C (TM) */ /* * copyright Cobalt Blue, Inc., 1988 - 1995 * ALL RIGHTS RESERVED */ /* NOTE: These functions guarantee max() problems won't occur due to side effects - at the cost of an extra function call. */ #ifdef smax # undef smax #endif short smax( short a, short b) { return( a > b ? a : b ); } #if 0 #ifdef max # undef max #endif long max( long a, long b ) { return( a > b ? a : b ); } #endif #ifdef fmax # undef fmax #endif double fmax(double a, double b) { return( a > b ? a : b ); } double vfmax( double mx, ... ) { double a; va_list args; /* arg ptr */ if( mx == FEND ) return( 0. ); /* NULL arg list */ VA_START(args,mx); /* initialize variable args */ while( (a=va_arg(args,double)) != FEND ) mx = (mx > a) ? mx : a; return( mx ); } /* * * * */ #if 0 long vmax( long mx, ... ) { long a; va_list args; /* arg ptr */ if( mx == IEND ) return( 0L ); /* NULL arg list */ VA_START(args,mx); /* initialize variable args */ while( (a=va_arg(args,long)) != IEND ) mx = (mx > a) ? mx : a; return( mx ); } #endif