1
1

Windows dependent files offer now a viable solution. More to come ...

This commit was SVN r11272.
Этот коммит содержится в:
George Bosilca 2006-08-20 18:50:47 +00:00
родитель 97956a2987
Коммит 423b5ecf93
7 изменённых файлов: 99 добавлений и 98 удалений

Просмотреть файл

@ -29,11 +29,11 @@ static __inline char* getenv (const char *name)
{
int ret;
char *buffer;
DWORD length = GetEnvironmentVariable( name, NULL, 0 );
DWORD length = GetEnvironmentVariable( (LPCSTR)((void*)name), NULL, 0 );
if( 0 == length ) return NULL;
buffer = (char *)malloc(sizeof(char) * length);
ret = GetEnvironmentVariable(name, buffer, length);
ret = GetEnvironmentVariable((LPCSTR)((void*)name), (LPSTR)((void*)buffer), length);
return (ret > 0) ? buffer: NULL;
}
@ -41,7 +41,7 @@ static __inline char* getenv (const char *name)
static __inline int setenv (const char *name, const char *value, int rewrite) {
/* just push it back to the windows thingy */
int ret = SetEnvironmentVariable (name, value);
int ret = SetEnvironmentVariable ((LPCSTR)((void*)name), (LPCSTR)((void*)value));
return (0 != ret)? 1: 0;
}

Просмотреть файл

@ -23,8 +23,7 @@
#define EPOCHFILETIME (116444736000000000LL)
OPAL_DECLSPEC int
gettimeofday(struct timeval *tv, struct timezone *tz)
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
FILETIME file_time;

Просмотреть файл

@ -26,8 +26,7 @@
of code to handle the windows error flags
*/
OPAL_DECLSPEC int
writev( int fd, struct iovec * iov, int cnt )
int writev( int fd, struct iovec * iov, int cnt )
{
int err;
DWORD sendlen;
@ -41,8 +40,7 @@ writev( int fd, struct iovec * iov, int cnt )
}
OPAL_DECLSPEC int
readv( int fd, struct iovec * iov, int cnt )
int readv( int fd, struct iovec * iov, int cnt )
{
int err;
DWORD recvlen = 0;

Просмотреть файл

@ -19,8 +19,6 @@
#ifndef OMPI_UTIL_H
#define OMPI_UTIL_H
#include <string.h>
static __inline int getpagesize(void)
{
SYSTEM_INFO sys_info;
@ -29,58 +27,17 @@ static __inline int getpagesize(void)
return (int)sys_info.dwPageSize;
}
static __inline char *basename(char *path)
/**
* Case insensitive comparaison of strings.
*/
static __inline int strncasecmp( const char *s1, const char *s2, int n)
{
char *p = path;
char *ret;
if (path[strlen(path)-1] == '\\') {
path[strlen(path)-1] = '\0';
}
while (*p != '\0') p++;
while (*p != '\\') p--;
ret = _strdup(++p);
return ret;
return _strnicmp( s1, s2, (size_t)n );
}
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?? */
char *dirname;
char *base;
base = basename(path);
dirname = _strdup(path);
strncpy(dirname, path, strlen(path)-strlen(base));
dirname[strlen(path)-strlen(base)] = '\0';
return dirname;
static __inline int strcasecmp(char *s1, char *s2)
{
return _stricmp(s1, s2);
}
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;
}
static __inline int strcasecmp(char *s1, char *s2) {
return strncasecmp (s1, s2, (int)strlen(s1));
}
#endif

Просмотреть файл

@ -29,11 +29,8 @@
5. machine: GetSystemInfo
*/
OPAL_DECLSPEC int
uname( struct utsname *un )
int uname( struct utsname *un )
{
/* 1. get the OS name */
TCHAR env_variable[] = "OS=%OS%";
DWORD info_buf_count;
OSVERSIONINFO version_info;
@ -42,33 +39,48 @@ uname( struct utsname *un )
info_buf_count = ExpandEnvironmentStrings( env_variable, info_buf, OMPI_UTSNAME_LEN);
if (0 == info_buf_count) {
return 1;
snprintf( un->sysname, OMPI_UTSNAME_LEN, "Unknown" );
} else {
/* remove the "OS=" from the beginning of the string */
strncpy( un->sysname, info_buf + 3, OMPI_UTSNAME_LEN );
}
/* 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;
snprintf(un->nodename, OMPI_UTSNAME_LEN, "undefined");
}
version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (!GetVersionEx(&version_info)) {
return 1;
snprintf(un->release, OMPI_UTSNAME_LEN, "undefined");
snprintf(un->version, OMPI_UTSNAME_LEN, "undefined");
} else {
/* fill in both release and version information */
sprintf (un->release, "%d.%d.%d", version_info.dwMajorVersion,
version_info.dwMinorVersion,
version_info.dwBuildNumber);
snprintf( un->release, OMPI_UTSNAME_LEN, "%d.%d.%d",
version_info.dwMajorVersion,
version_info.dwMinorVersion,
version_info.dwBuildNumber);
snprintf( un->version, OMPI_UTSNAME_LEN, "%s", version_info.szCSDVersion );
}
/* get machine information */
GetSystemInfo(&sys_info);
sprintf(un->machine, "%u", sys_info.dwProcessorType);
switch( sys_info.wProcessorArchitecture ) {
case PROCESSOR_ARCHITECTURE_UNKNOWN:
snprintf( un->machine, OMPI_UTSNAME_LEN, "Unknown %d", sys_info.wProcessorLevel );
break;
case PROCESSOR_ARCHITECTURE_INTEL:
snprintf( un->machine, OMPI_UTSNAME_LEN, "Intel %d", sys_info.wProcessorLevel );
break;
case PROCESSOR_ARCHITECTURE_IA64:
snprintf( un->machine, OMPI_UTSNAME_LEN, "IA64 %d", sys_info.wProcessorLevel );
break;
case PROCESSOR_ARCHITECTURE_AMD64:
snprintf( un->machine, OMPI_UTSNAME_LEN, "AMD %d", sys_info.wProcessorLevel );
break;
default:
snprintf( un->machine, OMPI_UTSNAME_LEN, "UFO hardware %d", sys_info.wProcessorLevel );
break;
}
/* version : need to ask Jeff */
sprintf(un->version, "undefined");
return 0;
}

Просмотреть файл

@ -19,14 +19,7 @@
#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 */
#define OMPI_UTSNAME_LEN 64
struct utsname {
char sysname[OMPI_UTSNAME_LEN];

Просмотреть файл

@ -2,7 +2,7 @@
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -19,15 +19,29 @@
#ifndef OMPI_WIN_COMPAT_H
#define OMPI_WIN_COMPAT_H
/**
* don't complain about all the deprecated functions.
*/
#define _CRT_SECURE_NO_DEPRECATE
/**
* Allow usage of some recent functions (such as SwitchToThread)
* 0x0400 - for SwitchToThread
* 0x0500 - for using Event Objects
*/
#define _WIN32_WINNT 0x0500
/* 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
#endif /* WIN32_LEAN_AND_MEAN */
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN
#endif /* VC_EXTRALEAN */
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#endif
/* FD_SETSIZE determines how many sockets windows can select() on. If not defined
before including winsock2.h, it is defined to be 64. We are going to go ahead and
@ -40,6 +54,12 @@
#include <ws2tcpip.h>
#include <process.h>
#include <signal.h>
/**
* For all file io operations
*/
#include <direct.h>
#include <io.h>
/*#if defined(OMPI_BUILDING) && OMPI_BUILDING */
#include "opal/win32/ompi_uio.h"
#include "opal/win32/ompi_time.h"
@ -58,7 +78,7 @@
typedef unsigned short mode_t;
typedef long ssize_t;
typedef DWORD in_port_t;
typedef int caddr_t;
typedef char* caddr_t;
typedef unsigned int uint;
/* Defines for the access functions */
@ -68,24 +88,46 @@ typedef unsigned int uint;
#define X_OK 0x06
#define WTERMSIG(EXIT_CODE) (1)
#define WIFEXITED(EXIT_CODE) (1)
#define WEXITSTATUS(EXIT_CODE) (1)
#define WEXITSTATUS(EXIT_CODE) (EXIT_CODE)
#define WIFSIGNALED(EXIT_CODE) (0)
#define WIFSTOPPED(EXIT_CODE) (0)
#define WSTOPSIG(EXIT_CODE) (11)
/* 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 getpid _getpid
#define getcwd _getcwd
#define mkdir _mkdir
#define OMPI_ALIGNMENT_CXX_BOOL OMPI_ALIGNMENT_INT
#define SIZEOF_BOOL SIZEOF_INT
/**
* Microsoft compiler complain about non conformance of the default UNIX function.
* Non conformance to the POSIX standard, and they suggest to use the version
* starting with an _ instead. So, in order to keep cl.exe happy (and quiet) we can
* use the followings defines.
*/
#define getpid _getpid
#define strdup(STRING) _strdup((STRING))
#define putenv(STRING) _putenv((STRING))
#define getcwd(BUF, SIZE) _getcwd((BUF), (SIZE))
#define mkdir(PATH, MODE) _mkdir((PATH))
#define rmdir(PATH) _rmdir((PATH))
#define chdir(PATH) _chdir((PATH))
#define chmod(PATH, MODE) _chmod( (PATH), (MODE) )
#define access(PATH, MODE) _access((PATH), (MODE))
#define open(PATH, FLAGS, MODE) _open((PATH), (FLAGS), (MODE))
#define close(FD) _close((FD))
#define unlink(PATH) _unlink((PATH))
#define dup2(OLDFD, NEWFD) _dup2((OLDFD), (NEWFD))
#define write(FD, BUF, SIZE) _write((FD), (BUF), (SIZE))
#define read(FD, BUF, SIZE) _read((FD), (BUF), (SIZE))
#define fileno(FD) _fileno((FD))
#define isatty(FD) _isatty((FD))
#define execvp _execvp
#define pipe(array_fd) _pipe(array_fd, 1024, O_BINARY )
#define S_ISDIR(STAT_MODE) ((STAT_MODE) & _S_IFDIR)
#define UINT32_MAX _UI32_MAX
#define INT32_MAX _I32_MAX
#define UINT8_MAX _UI8_MAX
#define SIZEOF_SIZE_T 4
/* If we now support __func__ set the HAVE_DECL___FUNC__ */
#define __func__ __FUNCTION__
#undef HAVE_DECL___FUNC__