Skip to content
Snippets Groups Projects
winjunk.h 1.85 KiB
Newer Older
  • Learn to ignore specific revisions
  • #ifndef WINJUNK_H
    #define WINJUNK_H
    
    teuben's avatar
    teuben committed
    #ifdef WIN32
    
    /*
     * Assorted functions needed for Windows port.
     * Stuart Levy, slevy@ncsa.uiuc.edu
     * National Center for Supercomputing Applications,
     * University of Illinois 2001.
    
     * This file is part of partiview, released under the
     * Illinois Open Source License; see the file LICENSE.partiview for details.
    
    teuben's avatar
    teuben committed
    
    #define  htonl  htonl_hosed_by_win32
    #define  ntohl  ntohl_hosed_by_win32
    
    #define  WINDOWS_LEAN_AND_MEAN	1	/* ugh */
    
    teuben's avatar
    teuben committed
    #include <windows.h>
    #include <malloc.h>
    
    #include <math.h>
    #include <float.h>
    
    #include <stdarg.h>
    
    slevy's avatar
    slevy committed
    #include "config.h"
    
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    teuben's avatar
    teuben committed
    
    #undef htonl
    #undef ntohl
    extern unsigned int htonl(unsigned int v);
    #define ntohl(x)  htonl(x)
    
    
    #ifndef HAVE_STRCASECMP
    
      extern int strcasecmp(const char *s1, const char *s2);
      extern int strncasecmp(const char *s1, const char *s2, int maxlen);
    
    
    #ifndef HAVE_SNPRINTF
    
      /* we'll use FLTK's fl_vsnprintf since non-MINGW Win32 lacks it */
      extern int snprintf(char *dest, int maxlen, const char *fmt, ...);
    
    
    #ifndef HUGE
      #define  HUGE		FLT_MAX
    #endif
    #ifndef M_LN10
      #define  M_LN10	2.30258509299404568402
    #endif
    #ifndef M_PI
      #define  M_PI		3.14159265358979323846
    #endif
    
    #define finite(x)	_finite(x)
    
    teuben's avatar
    teuben committed
    
    extern void srandom(int seed);
    extern int random();
    
    
    #ifndef HAVE_RINT
    
    slevy's avatar
     
    slevy committed
    extern double rint(double);
    
    slevy's avatar
     
    slevy committed
    
    
    #ifndef HAVE_SQRTF
    
    #define sqrtf(_) sqrt(_)
    #define sinf(_)  sin(_)
    #define cosf(_)  cos(_)
    
    #define tanf(_)  tan(_)
    #define expf(_)  exp(_)
    #define log10f(_) log10(_)
    
    #endif /*!HAVE_SQRTF*/
    
    #include <io.h>		/* for access() */
    
    #ifndef R_OK
    # define R_OK 004	/* No Windows include-file defines this?! */
    #endif
    
    
    #ifdef __cplusplus
    }	/* end extern "C" */
    #endif /*__cplusplus__*/
    
    teuben's avatar
    teuben committed
    #endif /*WIN32*/
    
    #endif /*WINJUNK_H*/