* [PATCH] opensm - standardize on a single Windows #define
@ 2009-10-08 16:08 Stan C. Smith
2009-10-08 17:06 ` Sean Hefty
0 siblings, 1 reply; 9+ messages in thread
From: Stan C. Smith @ 2009-10-08 16:08 UTC (permalink / raw)
To: 'Sasha Khapyorsky'; +Cc: ofw, 'linux-rdma'
Code cleanup, standardize on a single Windows #define '__WIN__'; WIN32 --> __WIN__.
Flip usage of ifndef WIN32 --> ifdef __GNUC__
Signed-off-by: stan smith <stan.smith@intel.com>
diff --git a/opensm/include/iba/ib_cm_types.h b/opensm/include/iba/ib_cm_types.h
index c1fbfaf..7e46d27 100644
--- a/opensm/include/iba/ib_cm_types.h
+++ b/opensm/include/iba/ib_cm_types.h
@@ -36,7 +36,7 @@
#if !defined(__IB_CM_TYPES_H__)
#define __IB_CM_TYPES_H__
-#ifndef WIN32
+#ifdef __GNUC__
#include <iba/ib_types.h>
@@ -199,5 +199,5 @@ typedef uint16_t ib_sidr_status_t;
#define IB_SIDR_UNSUPPORTED_VER 5
END_C_DECLS
-#endif /* ndef WIN32 */
+#endif /* def __GNUC__ */
#endif /* __IB_CM_TYPES_H__ */
diff --git a/opensm/include/iba/ib_types.h b/opensm/include/iba/ib_types.h
index 25ed35f..74f2e34 100644
--- a/opensm/include/iba/ib_types.h
+++ b/opensm/include/iba/ib_types.h
@@ -50,7 +50,7 @@
#endif /* __cplusplus */
BEGIN_C_DECLS
-#if defined( WIN32 ) || defined( _WIN64 )
+#if defined( __WIN__ )
#if defined( EXPORT_AL_SYMBOLS )
#define OSM_EXPORT __declspec(dllexport)
#else
@@ -8310,7 +8310,7 @@ typedef struct _ib_mcast *__ptr64 ib_mcast_handle_t;
in order to be compliant with Infinicon ib_types; later we'll change it to support
OpenSM ib_types.h */
-#ifndef WIN32
+#ifdef __GNUC__
/****d* Access Layer/ib_api_status_t
* NAME
* ib_api_status_t
@@ -10634,7 +10634,7 @@ typedef struct _ib_ci_op {
*****/
END_C_DECLS
-#endif /* ndef WIN32 */
+#endif /* def __GNUC__ */
#if defined( __WIN__ )
#include <iba/ib_types_extended.h>
#endif
diff --git a/opensm/libvendor/osm_pkt_randomizer.c b/opensm/libvendor/osm_pkt_randomizer.c
index 3e77b56..f4a83ed 100644
--- a/opensm/libvendor/osm_pkt_randomizer.c
+++ b/opensm/libvendor/osm_pkt_randomizer.c
@@ -47,7 +47,7 @@
#include <stdlib.h>
#include <string.h>
-#ifndef WIN32
+#ifdef __GNUC__
#include <sys/time.h>
#include <unistd.h>
#endif
@@ -130,23 +130,23 @@ __osm_pkt_randomizer_process_path(IN osm_log_t * p_log,
if (rand_value_init == FALSE) {
int seed;
-#ifdef WIN32
+#ifdef __WIN__
SYSTEMTIME st;
#else
struct timeval tv;
struct timezone tz;
-#endif /* WIN32 */
+#endif
/* initiate the rand_value according to timeofday */
rand_value_init = TRUE;
-#ifdef WIN32
+#ifdef __WIN__
GetLocalTime(&st);
seed = st.wMilliseconds;
#else
gettimeofday(&tv, &tz);
seed = tv.tv_usec;
-#endif /* WIN32 */
+#endif
srand(seed);
}
diff --git a/opensm/opensm/osm_log.c b/opensm/opensm/osm_log.c
index 8f30784..24ce55f 100644
--- a/opensm/opensm/osm_log.c
+++ b/opensm/opensm/osm_log.c
@@ -55,7 +55,7 @@
static int log_exit_count = 0;
-#ifndef WIN32
+#ifdef __GNUC__
#include <sys/time.h>
#include <unistd.h>
#include <complib/cl_timer.h>
@@ -76,9 +76,9 @@ static char *month_str[] = {
};
#else
void OsmReportState(IN const char *p_str);
-#endif /* ndef WIN32 */
+#endif /* def __GNUC__ */
-#ifndef WIN32
+#ifdef __GNUC__
static void truncate_log_file(osm_log_t * p_log)
{
@@ -99,7 +99,7 @@ static void truncate_log_file(osm_log_t * p_log)
fprintf(stderr,
"truncate_log_file: cannot truncate on windows system (yet)\n");
}
-#endif /* ndef WIN32 */
+#endif /* def __GNUC__ */
void osm_log(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
IN const char *p_str, ...)
@@ -107,7 +107,7 @@ void osm_log(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
char buffer[LOG_ENTRY_SIZE_MAX];
va_list args;
int ret;
-#ifdef WIN32
+#ifdef __WIN__
SYSTEMTIME st;
uint32_t pid = GetCurrentThreadId();
#else
@@ -116,7 +116,7 @@ void osm_log(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
struct tm result;
uint64_t time_usecs;
uint32_t usecs;
-#endif /* WIN32 */
+#endif
/* If this is a call to syslog - always print it */
if (!(verbosity & (OSM_LOG_SYS | p_log->level)))
@@ -135,9 +135,9 @@ void osm_log(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
printf("%s\n", buffer);
fflush(stdout);
}
-#ifdef WIN32
+#ifdef __WIN__
OsmReportState(buffer);
-#endif /* WIN32 */
+#endif
}
/* regular log to default out_port */
@@ -150,7 +150,7 @@ void osm_log(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
p_log->max_size);
truncate_log_file(p_log);
}
-#ifdef WIN32
+#ifdef __WIN__
GetLocalTime(&st);
_retry:
ret =
@@ -158,7 +158,7 @@ _retry:
"[%02d:%02d:%02d:%03d][%04X] 0x%02x -> %s",
st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
pid, verbosity, buffer);
-#else
+#else /* __GNUC__ */
time_usecs = cl_get_time_stamp();
tim = time_usecs / 1000000;
usecs = time_usecs % 1000000;
@@ -172,7 +172,7 @@ _retry:
12 ? month_str[result.tm_mon] : "???"),
result.tm_mday, result.tm_hour, result.tm_min,
result.tm_sec, usecs, pid, verbosity, buffer);
-#endif
+#endif /* def __WIN__ */
/* flush log */
if (ret > 0 &&
diff --git a/opensm/opensm/st.c b/opensm/opensm/st.c
index c5a2f53..ea76038 100644
--- a/opensm/opensm/st.c
+++ b/opensm/opensm/st.c
@@ -43,10 +43,6 @@
#include <string.h>
#include <opensm/st.h>
-#ifdef _WIN32
-#include <malloc.h>
-#endif
-
typedef struct st_table_entry st_table_entry;
struct st_table_entry {
diff --git a/opensm/osmtest/include/osmtest_base.h b/opensm/osmtest/include/osmtest_base.h
index cda3a31..40a8201 100644
--- a/opensm/osmtest/include/osmtest_base.h
+++ b/opensm/osmtest/include/osmtest_base.h
@@ -48,7 +48,7 @@
#endif
#define OSMTEST_MAX_LINE_LEN 120
-#ifdef WIN32
+#ifdef __WIN__
#define OSMTEST_FILE_PATH_MAX 4096
#else
#define OSMTEST_FILE_PATH_MAX PATH_MAX
^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH] opensm - standardize on a single Windows #define
2009-10-08 16:08 [PATCH] opensm - standardize on a single Windows #define Stan C. Smith
@ 2009-10-08 17:06 ` Sean Hefty
2009-10-08 17:16 ` Smith, Stan
0 siblings, 1 reply; 9+ messages in thread
From: Sean Hefty @ 2009-10-08 17:06 UTC (permalink / raw)
To: Smith, Stan, 'Sasha Khapyorsky'; +Cc: ofw, 'linux-rdma'
>Code cleanup, standardize on a single Windows #define '__WIN__'; WIN32 -->
>__WIN__.
>Flip usage of ifndef WIN32 --> ifdef __GNUC__
GNUC indicates a specific compiler, not a platform, which is what the check is
for.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] opensm - standardize on a single Windows #define
2009-10-08 17:06 ` Sean Hefty
@ 2009-10-08 17:16 ` Smith, Stan
2009-10-08 17:22 ` Sean Hefty
2009-10-12 22:00 ` Sasha Khapyorsky
0 siblings, 2 replies; 9+ messages in thread
From: Smith, Stan @ 2009-10-08 17:16 UTC (permalink / raw)
To: Hefty, Sean, 'Sasha Khapyorsky'; +Cc: ofw, 'linux-rdma'
Hefty, Sean wrote:
>> Code cleanup, standardize on a single Windows #define '__WIN__';
>> WIN32 --> __WIN__. Flip usage of ifndef WIN32 --> ifdef __GNUC__
>
> GNUC indicates a specific compiler, not a platform, which is what the
> check is for.
To the best of my understanding OpenSM is built for Linux/OFED, Solaris and Windows.
What would you suggest, given you did not like the ifndef __WIN__ in terms of readability?
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] opensm - standardize on a single Windows #define
2009-10-08 17:16 ` Smith, Stan
@ 2009-10-08 17:22 ` Sean Hefty
2009-10-08 18:12 ` Smith, Stan
2009-10-12 22:00 ` Sasha Khapyorsky
1 sibling, 1 reply; 9+ messages in thread
From: Sean Hefty @ 2009-10-08 17:22 UTC (permalink / raw)
To: Smith, Stan, 'Sasha Khapyorsky'; +Cc: ofw, 'linux-rdma'
>What would you suggest, given you did not like the ifndef __WIN__ in terms of
>readability?
I was saying that it is slightly easier for me to read:
#ifdef __WIN__
// windows stuff
#else // <- not __WIN__
// other stuff
#endif
versus
#ifndef __WIN_
// other stuff
#else // <- not not __WIN__
// windows stuff
#endif
I don't have a problem with the use of __WIN__ or
#ifndef __WIN__
// other stuff
#endif
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] opensm - standardize on a single Windows #define
2009-10-08 17:22 ` Sean Hefty
@ 2009-10-08 18:12 ` Smith, Stan
0 siblings, 0 replies; 9+ messages in thread
From: Smith, Stan @ 2009-10-08 18:12 UTC (permalink / raw)
To: Hefty, Sean, 'Sasha Khapyorsky'; +Cc: ofw, 'linux-rdma'
Hefty, Sean wrote:
>> What would you suggest, given you did not like the ifndef __WIN__ in
>> terms of readability?
>
> I was saying that it is slightly easier for me to read:
>
> #ifdef __WIN__
> // windows stuff
> #else // <- not __WIN__
> // other stuff
> #endif
>
> versus
>
> #ifndef __WIN_
> // other stuff
> #else // <- not not __WIN__
> // windows stuff
> #endif
>
> I don't have a problem with the use of __WIN__ or
>
> #ifndef __WIN__
> // other stuff
> #endif
There is a fair amount of code hoisting to flip the ifndef __WIN__ --> ifdef __WIN__ for readability reasons.
There are bigger fish to fry at this juncture. Perhaps into the future.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] opensm - standardize on a single Windows #define
2009-10-08 17:16 ` Smith, Stan
2009-10-08 17:22 ` Sean Hefty
@ 2009-10-12 22:00 ` Sasha Khapyorsky
2009-10-12 22:24 ` Smith, Stan
1 sibling, 1 reply; 9+ messages in thread
From: Sasha Khapyorsky @ 2009-10-12 22:00 UTC (permalink / raw)
To: Smith, Stan; +Cc: ofw, 'linux-rdma'
On 10:16 Thu 08 Oct , Smith, Stan wrote:
> Hefty, Sean wrote:
> >> Code cleanup, standardize on a single Windows #define '__WIN__';
> >> WIN32 --> __WIN__. Flip usage of ifndef WIN32 --> ifdef __GNUC__
> >
> > GNUC indicates a specific compiler, not a platform, which is what the
> > check is for.
>
> To the best of my understanding OpenSM is built for Linux/OFED, Solaris and Windows.
Also some embedded platforms and we don't know what in a future.
'#ifdef __WIN__' and '#ifndef __GNUC__' are not equivalent.
Sasha
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] opensm - standardize on a single Windows #define
2009-10-12 22:00 ` Sasha Khapyorsky
@ 2009-10-12 22:24 ` Smith, Stan
2009-10-12 22:29 ` Smith, Stan
0 siblings, 1 reply; 9+ messages in thread
From: Smith, Stan @ 2009-10-12 22:24 UTC (permalink / raw)
To: Sasha Khapyorsky; +Cc: ofw, 'linux-rdma'
Sasha Khapyorsky wrote:
> On 10:16 Thu 08 Oct , Smith, Stan wrote:
>> Hefty, Sean wrote:
>>>> Code cleanup, standardize on a single Windows #define '__WIN__';
>>>> WIN32 --> __WIN__. Flip usage of ifndef WIN32 --> ifdef __GNUC__
>>>
>>> GNUC indicates a specific compiler, not a platform, which is what
>>> the check is for.
>>
>> To the best of my understanding OpenSM is built for Linux/OFED,
>> Solaris and Windows.
>
> Also some embedded platforms and we don't know what in a future.
>
> '#ifdef __WIN__' and '#ifndef __GNUC__' are not equivalent.
>
> Sasha
You wish to live with the negative logic of ifndef __WIN__ ?
How about ifdef __linux__ ?
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] opensm - standardize on a single Windows #define
2009-10-12 22:24 ` Smith, Stan
@ 2009-10-12 22:29 ` Smith, Stan
[not found] ` <3F6F638B8D880340AB536D29CD4C1E1912C896BBFC-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Smith, Stan @ 2009-10-12 22:29 UTC (permalink / raw)
To: Smith, Stan, Sasha Khapyorsky; +Cc: ofw, 'linux-rdma'
Smith, Stan wrote:
> Sasha Khapyorsky wrote:
>> On 10:16 Thu 08 Oct , Smith, Stan wrote:
>>> Hefty, Sean wrote:
>>>>> Code cleanup, standardize on a single Windows #define '__WIN__';
>>>>> WIN32 --> __WIN__. Flip usage of ifndef WIN32 --> ifdef __GNUC__
>>>>
>>>> GNUC indicates a specific compiler, not a platform, which is what
>>>> the check is for.
>>>
>>> To the best of my understanding OpenSM is built for Linux/OFED,
>>> Solaris and Windows.
>>
>> Also some embedded platforms and we don't know what in a future.
>>
>> '#ifdef __WIN__' and '#ifndef __GNUC__' are not equivalent.
>>
>> Sasha
>
> You wish to live with the negative logic of ifndef __WIN__ ?
>
> How about ifdef __linux__ ?
If __linux__ doesn't work for you, then please create a Linux Platform define I can use.
>
>
>
> _______________________________________________
> ofw mailing list
> ofw@lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [ofw] [PATCH] opensm - standardize on a single Windows #define
[not found] ` <3F6F638B8D880340AB536D29CD4C1E1912C896BBFC-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2009-10-13 4:15 ` Jason Gunthorpe
0 siblings, 0 replies; 9+ messages in thread
From: Jason Gunthorpe @ 2009-10-13 4:15 UTC (permalink / raw)
To: Smith, Stan
Cc: Sasha Khapyorsky, ofw-ZwoEplunGu1OwGhvXhtEPSCwEArCW2h5,
'linux-rdma'
On Mon, Oct 12, 2009 at 03:29:38PM -0700, Smith, Stan wrote:
> If __linux__ doesn't work for you, then please create a Linux Platform define I can use.
Pretty much all the patches I've seen you make should be guarded by
__WIN__, you shouldn't be using __linux__.
opensm and the other OFA stuff is POSIX. If you need to deviate from
POSIX because Windows isn't, then you should use __WIN__ as the guard.
It is inappropriate to guard POSIX code with __linux__
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-10-13 4:15 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-08 16:08 [PATCH] opensm - standardize on a single Windows #define Stan C. Smith
2009-10-08 17:06 ` Sean Hefty
2009-10-08 17:16 ` Smith, Stan
2009-10-08 17:22 ` Sean Hefty
2009-10-08 18:12 ` Smith, Stan
2009-10-12 22:00 ` Sasha Khapyorsky
2009-10-12 22:24 ` Smith, Stan
2009-10-12 22:29 ` Smith, Stan
[not found] ` <3F6F638B8D880340AB536D29CD4C1E1912C896BBFC-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2009-10-13 4:15 ` [ofw] " Jason Gunthorpe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.