This directory contains the functions windows functions for handling some system calls. Has not been integrated ... simply committing the directory into the tree, so it will not get commpiled
This commit was SVN r3086.
Этот коммит содержится в:
родитель
6884069b5f
Коммит
f38cb014d6
39
src/win32/ompi_time.c
Обычный файл
39
src/win32/ompi_time.c
Обычный файл
@ -0,0 +1,39 @@
|
||||
/*
|
||||
$HEADER$
|
||||
*/
|
||||
|
||||
#include "ompi_config.h"
|
||||
#include "win32/ompi_time.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# include<time.h>
|
||||
#endif
|
||||
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz) {
|
||||
|
||||
FILETIME file_time;
|
||||
ULARGE_INTEGER place_holder;
|
||||
__int64 time;
|
||||
|
||||
|
||||
/* returns 64 bit value which is the number of 100 nanosecond
|
||||
intervals since 1601(UTC) */
|
||||
GetSystemTimeAsFileTime (&file_time);
|
||||
|
||||
/* Windows recommends that we should copy the FILETIME returned
|
||||
into a ULARGE_INTEGER and then perform the arithmetic on that */
|
||||
place_holder.LowPart = file_time.dwLowDateTime;
|
||||
place_holder.HighPart = file_time.dwHighDateTime;
|
||||
time = place_holder.QuadPart;
|
||||
|
||||
/* Now we can use arithmetic operations on time which is nothing but
|
||||
a 64 bit integer holding time in 100 nanosec intervals */
|
||||
|
||||
/* convert 100 nanoseconds intervals into microseconds .. divide by 10 */
|
||||
time /= 10;
|
||||
|
||||
tv->tv_sec = (long)(time / 1000000);
|
||||
tv->tv_usec = (long)(time % 1000000);
|
||||
|
||||
return 0;
|
||||
}
|
145
src/win32/ompi_time.h
Обычный файл
145
src/win32/ompi_time.h
Обычный файл
@ -0,0 +1,145 @@
|
||||
/*
|
||||
$HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_TIME_H
|
||||
#define OMPI_TIME_H
|
||||
|
||||
#ifdef WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include<windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#define DST_NONE 0 /* not on dst */
|
||||
#define DST_USA 1 /* USA style dst */
|
||||
#define DST_AUST 2 /* Australian style dst */
|
||||
#define DST_WET 3 /* Western European dst */
|
||||
#define DST_MET 4 /* Middle European dst */
|
||||
#define DST_EET 5 /* Eastern European dst */
|
||||
#define DST_CAN 6 /* Canada */
|
||||
|
||||
#define TIMEVAL_TO_TIMESPEC(tv, ts) \
|
||||
(ts)->tv_sec = (tv)->tv_sec; \
|
||||
(ts)->tv_nsec = (tv)->tv_usec * 1000;
|
||||
|
||||
# define TIMESPEC_TO_TIMEVAL(tv, ts) \
|
||||
(tv)->tv_sec = (ts)->tv_sec; \
|
||||
(tv)->tv_usec = (ts)->tv_nsec / 1000;
|
||||
|
||||
|
||||
/* some more utility functions */
|
||||
/* Operations on timevals. */
|
||||
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
||||
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
||||
#define timercmp(tvp, uvp, cmp) \
|
||||
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
|
||||
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
|
||||
((tvp)->tv_sec cmp (uvp)->tv_sec))
|
||||
#define timeradd(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec >= 1000000) { \
|
||||
(vvp)->tv_sec++; \
|
||||
(vvp)->tv_usec -= 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
#define timersub(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec < 0) { \
|
||||
(vvp)->tv_sec--; \
|
||||
(vvp)->tv_usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Operations on timespecs. */
|
||||
#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0
|
||||
#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec)
|
||||
#define timespeccmp(tsp, usp, cmp) \
|
||||
(((tsp)->tv_sec == (usp)->tv_sec) ? \
|
||||
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
|
||||
((tsp)->tv_sec cmp (usp)->tv_sec))
|
||||
#define timespecadd(tsp, usp, vsp) \
|
||||
do { \
|
||||
(vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \
|
||||
(vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \
|
||||
if ((vsp)->tv_nsec >= 1000000000L) { \
|
||||
(vsp)->tv_sec++; \
|
||||
(vsp)->tv_nsec -= 1000000000L; \
|
||||
} \
|
||||
} while (0)
|
||||
#define timespecsub(tsp, usp, vsp) \
|
||||
do { \
|
||||
(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
|
||||
(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
|
||||
if ((vsp)->tv_nsec < 0) { \
|
||||
(vsp)->tv_sec--; \
|
||||
(vsp)->tv_nsec += 1000000000L; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Names of the interval timers, and structure
|
||||
* defining a timer setting.
|
||||
*/
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
|
||||
struct itimerval {
|
||||
struct timeval it_interval; /* timer interval */
|
||||
struct timeval it_value; /* current value */
|
||||
};
|
||||
|
||||
/*
|
||||
* Getkerninfo clock information structure
|
||||
*/
|
||||
struct clockinfo {
|
||||
int hz; /* clock frequency */
|
||||
int tick; /* micro-seconds per hz tick */
|
||||
int tickadj; /* clock skew rate for adjtime() */
|
||||
int stathz; /* statistics clock frequency */
|
||||
int profhz; /* profiling clock frequency */
|
||||
};
|
||||
|
||||
#define CLOCK_REALTIME 0
|
||||
#define CLOCK_VIRTUAL 1
|
||||
#define CLOCK_PROF 2
|
||||
|
||||
#define TIMER_RELTIME 0x0 /* relative timer */
|
||||
#define TIMER_ABSTIME 0x1 /* absolute timer */
|
||||
|
||||
|
||||
struct timespec
|
||||
{
|
||||
long tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
NOTE: The use of timezone is obsolete even in linux and my gettimeofday
|
||||
function is not going to support it either. So, please be aware of the
|
||||
fact that if you expect to pass anything here, then you are DEAD :-D */
|
||||
struct timezone
|
||||
{
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
};
|
||||
|
||||
#if defined(c_plusplus) || defined (__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
int gettimeofday (struct timeval *tv, struct timezone *tz);
|
||||
|
||||
#if defined(c_plusplus) || defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OMPI_TIME_H */
|
122
src/win32/ompi_uio.c
Обычный файл
122
src/win32/ompi_uio.c
Обычный файл
@ -0,0 +1,122 @@
|
||||
/*
|
||||
$HEADER$
|
||||
*/
|
||||
|
||||
#include "ompi_config.h"
|
||||
#include "win32/ompi_uio.h"
|
||||
#include <errno.h>
|
||||
|
||||
/*
|
||||
Highly doubt if the windows sockets ever set errno to EAGAIN. There might
|
||||
be some weird conversion to map this or I might have to rewrite this piece
|
||||
of code to handle the windows error flags
|
||||
*/
|
||||
|
||||
int writev(int fd,struct iovec * iov,int cnt) {
|
||||
|
||||
int i;
|
||||
int ret = 0;
|
||||
int rc;
|
||||
|
||||
for( i = 0; i < cnt; i++ ) {
|
||||
rc=writeconn( (SOCKET)fd, (char *)iov[i].iov_base, iov[i].iov_len );
|
||||
|
||||
/* return 0 if this is a non-blocking socket and no data was available
|
||||
for reading. Else, return the error back to the users */
|
||||
if(rc < 0) {
|
||||
return (errno == EAGAIN) ? ret : rc;
|
||||
}
|
||||
ret += rc;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int readv(int fd,struct iovec * iov,int cnt) {
|
||||
|
||||
int i;
|
||||
int ret = 0;
|
||||
int rc;
|
||||
|
||||
for( i = 0; i < cnt; i++ ) {
|
||||
rc=readconn( (SOCKET)fd, (char *)iov[i].iov_base, iov[i].iov_len );
|
||||
|
||||
/* return 0 if this is a non-blocking socket and no data was available
|
||||
for reading. Else, return the error back to the users */
|
||||
if(rc < 0) {
|
||||
return (errno == EAGAIN) ? ret : rc;
|
||||
}
|
||||
ret += rc;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
ANJU: This function does not handle the non-blocking IO at all. Yet
|
||||
to add modifications which will enable non-blocking IO */
|
||||
int writeconn (int s, char *data, int len) {
|
||||
|
||||
int i;
|
||||
int tosend = len;
|
||||
int gone = 0;
|
||||
int fluffed = 0;
|
||||
|
||||
for (i=0; tosend > 0; ) {
|
||||
|
||||
gone = write(s, &data[i], tosend);
|
||||
|
||||
if (0 > gone) {
|
||||
fluffed++;
|
||||
if (RETRIES == fluffed) {
|
||||
/* There was code in here to close the socket. I think
|
||||
that would not be the best thing to do in case of
|
||||
nono-blocking sockets. In any case, I need to look
|
||||
up hpw winsocks function before making concrete
|
||||
changes. This will do for compilation for now */
|
||||
return (i);
|
||||
}
|
||||
} else {
|
||||
i += gone;
|
||||
tosend -= gone;
|
||||
fluffed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
ANJU: This function does not handle the non-blocking IO at all. Yet
|
||||
to add modifications which will enable non-blocking IO */
|
||||
int readconn (int s, char *data, int len) {
|
||||
|
||||
int i;
|
||||
unsigned int toget = (unsigned)len;
|
||||
int got, fluffed = 0;
|
||||
|
||||
for (i=0; toget > 0; ) {
|
||||
|
||||
got = read(s, &data[i], toget);
|
||||
|
||||
/* Check if some error has occured */
|
||||
if (0 > got) {
|
||||
fluffed++;
|
||||
if (RETRIES == fluffed) {
|
||||
/* There was code in here to close the socket. I think
|
||||
that would not be the best thing to do in case of
|
||||
nono-blocking sockets. In any case, I need to look
|
||||
up hpw winsocks function before making concrete
|
||||
changes. This will do for compilation for now */
|
||||
return (i);
|
||||
}
|
||||
} else {
|
||||
i += got;
|
||||
toget -= got;
|
||||
fluffed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
53
src/win32/ompi_uio.h
Обычный файл
53
src/win32/ompi_uio.h
Обычный файл
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_UIO_H
|
||||
#define OMPI_UIO_H
|
||||
|
||||
#define RETRIES 2 /* ft-mpi defines it this way */
|
||||
|
||||
/* define the iovec structure */
|
||||
struct iovec{
|
||||
void * iov_base;
|
||||
size_t iov_len;
|
||||
};
|
||||
|
||||
|
||||
#if defined(c_plusplus) || defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* writev:
|
||||
writev writes data to file descriptor fd, and from the buffers
|
||||
described by iov. The number of buffers is specified by cnt. The
|
||||
buffers are used in the order specified. Operates just like write
|
||||
except that data is taken from iov instead of a contiguous buffer.
|
||||
*/
|
||||
int writev (int fd, struct iovec *iov, int cnt);
|
||||
|
||||
/*
|
||||
readv reads data from file descriptor fd, and puts the result in the
|
||||
buffers described by iov. The number of buffers is specified by
|
||||
cnt. The buffers are filled in the order specified. Operates just
|
||||
like read except that data is put in iov instead of a contiguous
|
||||
buffer.
|
||||
*/
|
||||
int readv (int fd, struct iovec *iov, int cnt);
|
||||
|
||||
/* static inlined helper functions to push the write through.
|
||||
This was almost completely lifted from ft-mpi code. please
|
||||
check Harness/hcore/share/snipe_lite.c for more details.
|
||||
The only difference being that harness code was implemented
|
||||
for blocking operations only */
|
||||
|
||||
int writeconn (int s,char * data,int len);
|
||||
|
||||
int readconn (int s,char * data,int len);
|
||||
|
||||
|
||||
#if defined(c_plusplus) || defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OMPI_UIO_H */
|
50
src/win32/ompi_util.h
Обычный файл
50
src/win32/ompi_util.h
Обычный файл
@ -0,0 +1,50 @@
|
||||
/*
|
||||
$HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_UTIL_H
|
||||
#define OMPI_UTIL_H
|
||||
|
||||
static __inline int getpagesize(void) {
|
||||
SYSTEM_INFO sys_info;
|
||||
|
||||
GetSystemInfo(&sys_info);
|
||||
return (int)sys_info.dwPageSize;
|
||||
}
|
||||
|
||||
static __inline char *dirname(char *path) {
|
||||
|
||||
/* remember, this is the windows version, so path is bound to contain
|
||||
the drive letter. Although, we are merely concerned with removing
|
||||
the last \ from the path offered. A new string should be allocated?? */
|
||||
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static __inline char *basename(char *path) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static __inline int strcasecmp(char *s1, char *s2) {
|
||||
|
||||
return strncasecmp (s1, s2, strlen(s1));
|
||||
}
|
||||
|
||||
static __inline int strncasecmp (char *s1, char *s2, int n) {
|
||||
|
||||
int ret;
|
||||
|
||||
while (0 <= --n && (tolower(*s1) == tolower(*s2++))) {
|
||||
if ('\0' == tolower(*s1++)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ret = (n < 0 ? 0 : tolower(*s1) - tolower(*--s2));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
63
src/win32/ompi_utsname.c
Обычный файл
63
src/win32/ompi_utsname.c
Обычный файл
@ -0,0 +1,63 @@
|
||||
/*
|
||||
$HEADER$
|
||||
*/
|
||||
|
||||
#include "ompi_utsname.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
/*
|
||||
This has to fill in the following information
|
||||
|
||||
1. sysname: name of the operating system --
|
||||
2. nodename: GetComputerName
|
||||
3. release: GetVersionEx
|
||||
4. version: GetVersionEx
|
||||
5. machine: GetSystemInfo
|
||||
*/
|
||||
|
||||
int uname (struct utsname *un) {
|
||||
|
||||
/* 1. get the OS name */
|
||||
TCHAR env_variable[] = "OS=%OS%";
|
||||
DWORD info_buf_count;
|
||||
OSVERSIONINFO version_info;
|
||||
SYSTEM_INFO sys_info;
|
||||
TCHAR info_buf[OMPI_UTSNAME_LEN];
|
||||
|
||||
info_buf_count = ExpandEnvironmentStrings( env_variable, info_buf, OMPI_UTSNAME_LEN);
|
||||
if (0 == info_buf_count) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* unfortunately, we need to trim the first three characters from un->sysname */
|
||||
sprintf (un->sysname,"%s", info_buf+3);
|
||||
|
||||
info_buf_count = OMPI_UTSNAME_LEN;
|
||||
if (!GetComputerName( un->nodename, &info_buf_count)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if (!GetVersionEx(&version_info)) {
|
||||
return 1;
|
||||
} else {
|
||||
/* fill in both release and version information */
|
||||
sprintf (un->release, "%d.%d.%d", version_info.dwMajorVersion,
|
||||
version_info.dwMinorVersion,
|
||||
version_info.dwBuildNumber);
|
||||
}
|
||||
|
||||
/* get machine information */
|
||||
GetSystemInfo(&sys_info);
|
||||
sprintf(un->machine, "%u", sys_info.dwProcessorType);
|
||||
|
||||
/* version : need to ask Jeff */
|
||||
sprintf(un->version, "undefined");
|
||||
|
||||
return 0;
|
||||
}
|
33
src/win32/ompi_utsname.h
Обычный файл
33
src/win32/ompi_utsname.h
Обычный файл
@ -0,0 +1,33 @@
|
||||
/*
|
||||
$HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_UTSNAME_H
|
||||
#define OMPI_UTSNAME_H
|
||||
|
||||
#ifdef WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#define OMPI_UTSNAME_LEN 20
|
||||
/* cygwin defines this to be 20 as well ... verify */
|
||||
|
||||
struct utsname {
|
||||
char sysname[OMPI_UTSNAME_LEN];
|
||||
char nodename[OMPI_UTSNAME_LEN];
|
||||
char release[OMPI_UTSNAME_LEN];
|
||||
char version[OMPI_UTSNAME_LEN];
|
||||
char machine[OMPI_UTSNAME_LEN];
|
||||
};
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
int uname(struct utsname *un);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* oMPI_UTSNAME_H */
|
49
src/win32/win_compat.h
Обычный файл
49
src/win32/win_compat.h
Обычный файл
@ -0,0 +1,49 @@
|
||||
/*
|
||||
$HEADER&
|
||||
*/
|
||||
|
||||
#ifndef OMPI_WIN_COMPAT_H
|
||||
#define OMPI_WIN_COMPAT_H
|
||||
|
||||
/* It is always better to include windows.h with the lean and mean option.
|
||||
So, include it with that option and then include some which are required
|
||||
for us in ompi. Note: this file is included only on windows */
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
|
||||
/* other utility header files */
|
||||
#include <cderr.h>
|
||||
#include <dde.h>
|
||||
#include <ddeml.h>
|
||||
#include <dlgs.h>
|
||||
#include <imm.h>
|
||||
#include <lzexpand.h>
|
||||
#include <mmsystem.h>
|
||||
#include <nb30.h>
|
||||
#include <rpc.h>
|
||||
#include <shellapi.h>
|
||||
#include <winperf.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <io.h>
|
||||
#include "win32/ompi_uio.h"
|
||||
#include "win32/ompi_time.h"
|
||||
#include "win32/ompi_utsname.h"
|
||||
#include "win32/ompi_util.h"
|
||||
|
||||
#define MAXPATHLEN MAX_PATH
|
||||
#define MAXHOSTNAMELEN MAX_PATH
|
||||
typedef unsigned short mode_t;
|
||||
typedef unsigned long size_t;
|
||||
typedef long ssize_t;
|
||||
#define OMPI_WINDOWS
|
||||
|
||||
/* Anju: some random #defines which I know offhand, but need to configure it */
|
||||
#define OMPI_ALIGNMENT_CXX_BOOL OMPI_ALIGNMENT_INT
|
||||
#define SIZEOF_BOOL SIZEOF_INT
|
||||
#define __func__ __FUNCTION__
|
||||
|
||||
#endif /* compat */
|
Загрузка…
x
Ссылка в новой задаче
Block a user