-#ifndef _OSM_COMMON_H_
-#define _OSM_COMMON_H_
-
-#include <winsock2.h>
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <ctype.h>
-
-#pragma warning(disable : 4996)
-#pragma warning(disable : 4100)
-
-struct timezone {
- int tz_minuteswest; /* minutes west of Greenwich */
- int tz_dsttime; /* type of dst correction */
-};
-
-
-# define no_argument 0
-# define required_argument 1
-# define optional_argument 2
-/* Global variables for getopt_long */
-char *optarg;
-/*
-extern int optind;
-extern int opterr;
-extern int optopt;
-extern int iArg;
- */
-struct option
-{
- const char *name;
- int has_arg;
- int *flag;
- int val;
-};
-
-
-/************************************************************************/
-static char*
-get_char_option(const char* optstring,
- char*const* argv,int argc,
- int iArg, int* opt_ind,char* opt_p);
-int
-getopt_long_only(int argc, char *const*argv,
- const char *optstring,
- const struct option *longopts, int *longindex);
-/**************************************************************************/
-static __inline
-void FileTimeToTimeval(LPFILETIME pft, struct timeval * ptv)
-{ /* Note that LONGLONG is a 64-bit value */
-LONGLONG ll;
-
-if(!pft || !ptv)
-goto Exit;
-
-ll = ((LONGLONG) pft->dwHighDateTime << 32);
-ll += (LONGLONG) pft->dwLowDateTime;
-#ifdef __GNUC__
-ll -= 116444736000000000ll;
-#else
-ll -= 116444736000000000;
-#endif
-
-ptv->tv_sec = (long) (ll / 10000000);
-ptv->tv_usec = (long) (ll - ((LONGLONG)(ptv->tv_sec) * 10000000)) / 10;
-
-Exit:;
-}/* FileTimeToTimeval */
-
-/********************************************************************************/
-static __inline
-int gettimeofday(struct timeval *ptv, struct timezone *tzp)
-{
-static int QueryCounter = 2;
-FILETIME CurrentTime;
-/* TODO : We need to add it , since in DDK - compiler does not like vars that are not in use */
-UNREFERENCED_PARAMETER(tzp);
-if(!ptv)
-goto Exit;
-
-if(QueryCounter)
-{
-static LARGE_INTEGER Frequency;
-static LARGE_INTEGER Offset; /* counter offset for right time*/
-static LARGE_INTEGER LastCounter;
-LARGE_INTEGER Time;
-LARGE_INTEGER Counter;
-/* HANDLE hThread = GetCurrentThread();
-int ThreadPrio = GetThreadPriority(hThread);
-
-SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); */
-GetSystemTimeAsFileTime(&CurrentTime);
-QueryPerformanceCounter(&Counter);
-/* SetThreadPriority(hThread, ThreadPrio); */
-
-if(QueryCounter == 2)
-{
-QueryCounter = 1;
-if(!QueryPerformanceFrequency(&Frequency))
-{
-QueryCounter = 0;
-Frequency.QuadPart = 10000000; /* prevent division by 0 */
-}
-
-/* get time as a large integer */
-Counter.HighPart &= 0x7fl; /* Clear the highest bits to prevent overflows */
-Offset.LowPart = CurrentTime.dwLowDateTime;
-Offset.HighPart = (LONG) CurrentTime.dwHighDateTime;
-Offset.QuadPart -= Counter.QuadPart * 10000000 / Frequency.QuadPart;
-}
-
-/* Convert counter to a 100 nanoseconds resolution timer value. */
-
-Counter.HighPart &= 0x7fl; /* Clear the highest bits to prevent overflows */
-Counter.QuadPart *= 10000000; /* Because we need time stamp in units of 100 ns */
-Counter.QuadPart /= Frequency.QuadPart; /* counter of 0.1 microseconds */
-
-if(LastCounter.QuadPart > Counter.QuadPart)
-{ /* Counter value wrapped */
-#ifdef __GNUC__
-Offset.QuadPart += (0x7f00000000ll * 10000000ll) / Frequency.QuadPart;
-#else
-Offset.QuadPart += (0x7f00000000 * 10000000) / Frequency.QuadPart;
-#endif
-}
-LastCounter = Counter;
-
-/* Add the in previous call calculated offset */
-Counter.QuadPart += Offset.QuadPart;
-
-/* get time as a large integer */
-Time.LowPart = CurrentTime.dwLowDateTime;
-Time.HighPart = (LONG) CurrentTime.dwHighDateTime;
-
-/* keep time difference within an interval of +- 0.1 seconds
-relative to the time function by adjusting the counters offset */
-
-if(((Time.QuadPart + 1000000) < Counter.QuadPart) ||
-((Time.QuadPart - 1000000) > Counter.QuadPart))
-{ /* Adjust the offset */
-Offset.QuadPart += Time.QuadPart - Counter.QuadPart;
-Counter.QuadPart = Time.QuadPart;
-}
-
-/* Now let's use the adjusted performance counter time for the time stamp */
-CurrentTime.dwLowDateTime = Counter.LowPart;
-CurrentTime.dwHighDateTime = Counter.HighPart;
-}
-else
-{
-GetSystemTimeAsFileTime(&CurrentTime);
-}
-
-FileTimeToTimeval(&CurrentTime,ptv);
-
-Exit:;
-return(0);
-}/* int gettimeofday(struct timeval *ptv, void *tzp) */
-/*****************************************************************************/
-
-
-
-
-#define getpid() GetCurrentProcessId()
-#define sleep(sec) SleepEx((sec)*1000,TRUE)
-#define usleep(usec) SleepEx(usec/1000,TRUE)
-//#define MT_ALIGN8 __declspec(align(8))
-/* Verify the correct ETIMEDOUT value is defined in all compiled files */
-#ifndef ETIMEDOUT
-#define ETIMEDOUT (10060)
-#endif
-#define strtoull _strtoui64
-#define OSM_MAX_LOG_NAME_SIZE 2048
-#define unlink(str) _unlink(str)
-#define strnicmp _strnicmp
-
-/* The following defines replace syslog.h */
-#define openlog(a,b,c)
-
-#define closelog()
-
-static __inline void
-syslog(int priority, ...) {}
-
-#define LOG_INFO 0
-#define LOG_WARNING 1
-#define LOG_ERR 2
-/*****************************************/
-
-/****f* OpenSM: osm_common/GetOsmTempPath
-* NAME
-* GetOsmTempPath
-*
-* DESCRIPTION
-* The function retrieves the temp path defined in Windows using its API
-*
-* SYNOPSIS
-*/
-char*
-GetOsmTempPath(void);
-/*
-* PARAMETERS
-* NONE
-*
-* RETURN VALUE
-* This function returns string containing the default temp path in windows
-*
-* NOTES
-*/
-
-/****f* OpenSM: osm_common/GetOsmCachePath
-* NAME
-* GetOsmCachePath
-*
-* DESCRIPTION
-* The function retrieves the path the cache directory. This directory is
-* the etc dir under the installation directory of the mellanox stack.
-* The installation directory should be pointed out by the WinIB_HOME variable.
-* If WinIB_HOME variable is missing, or there is not /etc/ dir under it - then
-* the function will return the getOsmTempPath() value.
-*
-* SYNOPSIS
-*/
-char*
-GetOsmCachePath(void);
-/*
-* PARAMETERS
-* NONE
-*
-* RETURN VALUE
-* This function returns string containing the default cache path for osm use.
-*
-* NOTES
-*/
-
-/* Implementation of strtok_r for windows: since strtok in windows is safe,
- just ignore the last variable, and call strtok. */
-static inline
-char *strtok_r(char *s1, const char *s2, char **lasts)
-{
- return strtok(s1, s2);
-}
-#endif /* _OSM_COMMON_H_ */
+#ifndef _OSM_COMMON_H_\r
+#define _OSM_COMMON_H_\r
+\r
+#include <winsock2.h>\r
+#include <windows.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <stdarg.h>\r
+#include <ctype.h>\r
+\r
+#pragma warning(disable : 4996)\r
+#pragma warning(disable : 4100)\r
+\r
+struct timezone {\r
+ int tz_minuteswest; /* minutes west of Greenwich */\r
+ int tz_dsttime; /* type of dst correction */\r
+};\r
+\r
+\r
+\r
+#ifndef _GETOPT_H_ \r
+\r
+# define no_argument 0\r
+# define required_argument 1\r
+# define optional_argument 2\r
+\r
+/* Global variables for getopt_long */\r
+char *optarg;\r
+\r
+struct option\r
+{\r
+ const char *name;\r
+ int has_arg;\r
+ int *flag;\r
+ int val;\r
+};\r
+#endif\r
+\r
+\r
+/************************************************************************/\r
+static char* \r
+get_char_option(const char* optstring,\r
+ char*const* argv,int argc, \r
+ int iArg, int* opt_ind,char* opt_p); \r
+int \r
+getopt_long_only(int argc, char *const*argv,\r
+ const char *optstring,\r
+ const struct option *longopts, int *longindex);\r
+/**************************************************************************/\r
+static __inline\r
+void FileTimeToTimeval(LPFILETIME pft, struct timeval * ptv)\r
+{ /* Note that LONGLONG is a 64-bit value */\r
+LONGLONG ll;\r
+\r
+if(!pft || !ptv)\r
+goto Exit;\r
+\r
+ll = ((LONGLONG) pft->dwHighDateTime << 32);\r
+ll += (LONGLONG) pft->dwLowDateTime;\r
+#ifdef __GNUC__\r
+ll -= 116444736000000000ll;\r
+#else\r
+ll -= 116444736000000000;\r
+#endif\r
+\r
+ptv->tv_sec = (long) (ll / 10000000);\r
+ptv->tv_usec = (long) (ll - ((LONGLONG)(ptv->tv_sec) * 10000000)) / 10;\r
+\r
+Exit:;\r
+}/* FileTimeToTimeval */\r
+\r
+/********************************************************************************/\r
+static __inline\r
+int gettimeofday(struct timeval *ptv, struct timezone *tzp)\r
+{\r
+static int QueryCounter = 2;\r
+FILETIME CurrentTime;\r
+/* TODO : We need to add it , since in DDK - compiler does not like vars that are not in use */\r
+UNREFERENCED_PARAMETER(tzp); \r
+if(!ptv)\r
+goto Exit;\r
+\r
+if(QueryCounter)\r
+{\r
+static LARGE_INTEGER Frequency;\r
+static LARGE_INTEGER Offset; /* counter offset for right time*/\r
+static LARGE_INTEGER LastCounter;\r
+LARGE_INTEGER Time;\r
+LARGE_INTEGER Counter;\r
+/* HANDLE hThread = GetCurrentThread();\r
+int ThreadPrio = GetThreadPriority(hThread);\r
+\r
+SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); */\r
+GetSystemTimeAsFileTime(&CurrentTime);\r
+QueryPerformanceCounter(&Counter);\r
+/* SetThreadPriority(hThread, ThreadPrio); */\r
+\r
+if(QueryCounter == 2)\r
+{\r
+QueryCounter = 1;\r
+if(!QueryPerformanceFrequency(&Frequency))\r
+{\r
+QueryCounter = 0;\r
+Frequency.QuadPart = 10000000; /* prevent division by 0 */\r
+}\r
+\r
+/* get time as a large integer */\r
+Counter.HighPart &= 0x7fl; /* Clear the highest bits to prevent overflows */\r
+Offset.LowPart = CurrentTime.dwLowDateTime;\r
+Offset.HighPart = (LONG) CurrentTime.dwHighDateTime;\r
+Offset.QuadPart -= Counter.QuadPart * 10000000 / Frequency.QuadPart;\r
+}\r
+\r
+/* Convert counter to a 100 nanoseconds resolution timer value. */\r
+\r
+Counter.HighPart &= 0x7fl; /* Clear the highest bits to prevent overflows */\r
+Counter.QuadPart *= 10000000; /* Because we need time stamp in units of 100 ns */\r
+Counter.QuadPart /= Frequency.QuadPart; /* counter of 0.1 microseconds */\r
+\r
+if(LastCounter.QuadPart > Counter.QuadPart)\r
+{ /* Counter value wrapped */\r
+#ifdef __GNUC__\r
+Offset.QuadPart += (0x7f00000000ll * 10000000ll) / Frequency.QuadPart;\r
+#else\r
+Offset.QuadPart += (0x7f00000000 * 10000000) / Frequency.QuadPart;\r
+#endif\r
+}\r
+LastCounter = Counter;\r
+\r
+/* Add the in previous call calculated offset */\r
+Counter.QuadPart += Offset.QuadPart;\r
+\r
+/* get time as a large integer */\r
+Time.LowPart = CurrentTime.dwLowDateTime;\r
+Time.HighPart = (LONG) CurrentTime.dwHighDateTime;\r
+\r
+/* keep time difference within an interval of +- 0.1 seconds\r
+relative to the time function by adjusting the counters offset */\r
+\r
+if(((Time.QuadPart + 1000000) < Counter.QuadPart) ||\r
+((Time.QuadPart - 1000000) > Counter.QuadPart))\r
+{ /* Adjust the offset */\r
+Offset.QuadPart += Time.QuadPart - Counter.QuadPart;\r
+Counter.QuadPart = Time.QuadPart;\r
+}\r
+\r
+/* Now let's use the adjusted performance counter time for the time stamp */\r
+CurrentTime.dwLowDateTime = Counter.LowPart;\r
+CurrentTime.dwHighDateTime = Counter.HighPart;\r
+}\r
+else\r
+{\r
+GetSystemTimeAsFileTime(&CurrentTime);\r
+}\r
+\r
+FileTimeToTimeval(&CurrentTime,ptv);\r
+\r
+Exit:;\r
+return(0);\r
+}/* int gettimeofday(struct timeval *ptv, void *tzp) */\r
+/*****************************************************************************/\r
+\r
+\r
+#ifndef getpid\r
+#define getpid() GetCurrentProcessId()\r
+#endif\r
+\r
+#define sleep(sec) SleepEx((sec)*1000,TRUE)\r
+#define usleep(usec) SleepEx(usec/1000,TRUE)\r
+//#define MT_ALIGN8 __declspec(align(8))\r
+/* Verify the correct ETIMEDOUT value is defined in all compiled files */\r
+#ifndef ETIMEDOUT\r
+#define ETIMEDOUT (10060)\r
+#endif\r
+\r
+#ifndef strtoull \r
+#define strtoull _strtoui64\r
+#endif\r
+\r
+#define OSM_MAX_LOG_NAME_SIZE 2048\r
+#define unlink(str) _unlink(str)\r
+#define strnicmp _strnicmp\r
+\r
+/* The following defines replace syslog.h */\r
+#define openlog(a,b,c)\r
+\r
+#define closelog()\r
+\r
+static __inline void\r
+syslog(int priority, ...) {}\r
+\r
+#define LOG_INFO 0\r
+#define LOG_WARNING 1\r
+#define LOG_ERR 2\r
+/*****************************************/\r
+\r
+/****f* OpenSM: osm_common/GetOsmTempPath\r
+* NAME\r
+* GetOsmTempPath\r
+*\r
+* DESCRIPTION\r
+* The function retrieves the temp path defined in Windows using its API\r
+*\r
+* SYNOPSIS\r
+*/\r
+char*\r
+GetOsmTempPath(void);\r
+/*\r
+* PARAMETERS\r
+* NONE\r
+*\r
+* RETURN VALUE\r
+* This function returns string containing the default temp path in windows\r
+*\r
+* NOTES\r
+*/\r
+\r
+/****f* OpenSM: osm_common/GetOsmCachePath\r
+* NAME\r
+* GetOsmCachePath\r
+*\r
+* DESCRIPTION\r
+* The function retrieves the path the cache directory. This directory is \r
+* the etc dir under the installation directory of the mellanox stack. \r
+* The installation directory should be pointed out by the WinIB_HOME variable.\r
+* If WinIB_HOME variable is missing, or there is not /etc/ dir under it - then\r
+* the function will return the getOsmTempPath() value.\r
+*\r
+* SYNOPSIS\r
+*/\r
+char*\r
+GetOsmCachePath(void);\r
+/*\r
+* PARAMETERS\r
+* NONE\r
+*\r
+* RETURN VALUE\r
+* This function returns string containing the default cache path for osm use.\r
+*\r
+* NOTES\r
+*/\r
+\r
+/* Implementation of strtok_r for windows: since strtok in windows is safe,\r
+ just ignore the last variable, and call strtok. */\r
+static inline \r
+char *strtok_r(char *s1, const char *s2, char **lasts)\r
+{\r
+ return strtok(s1, s2);\r
+}\r
+#endif /* _OSM_COMMON_H_ */\r