Skip to content
Snippets Groups Projects
winjunk.h 2.13 KiB
Newer Older
#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  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

slevy's avatar
slevy committed
/*
 * This was taken out because it was throwing compiler errors of
 * redefining htonl, even though we say #undef. Not sure if it's
 * important right now.
 *
 */
teuben's avatar
teuben committed
#undef htonl
#undef ntohl
slevy's avatar
slevy committed
#define htonl(x)  my_htonl(x)
#define ntohl(x)  my_ntohl(x)
extern "C" {
  extern unsigned int my_htonl(unsigned int v);
  extern unsigned int my_ntohl(unsigned int v);
};
teuben's avatar
teuben committed

#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

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

slevy's avatar
slevy committed
#define access(fname, mode)   _access(fname, mode)
#define stat(fname, buf)      _stat(fname, buf)

#ifdef __cplusplus
}	/* end extern "C" */
#endif /*__cplusplus__*/
teuben's avatar
teuben committed
#endif /*WIN32*/
#endif /*WINJUNK_H*/