Hi,
When porting a newer version of OFED to FreeBSD and running the compile
against clang with all of the warnings enabled, I ran into build failures
because osm_log, etc assumes that pthread_t is an integral type (which is valid
on Linux, but not necessarily correct on other platforms). The fix I
implemented was attached, but that doesn't necessarily seem correct either, so
I was wondering what was trying to be gained by printing out the thread ID
(especially because syslog(9) isn't necessarily an asynch safe syscall [1]).
Thanks,
-Garrett
1. http://linux.die.net/man/7/signal
From 55c3bafa1d866dc045e16fbf792dc64d03d25431 Mon Sep 17 00:00:00 2001
From: Garrett Cooper <garrett.coo...@isilon.com>
Date: Thu, 6 Dec 2012 21:41:17 -0800
Subject: [PATCH 2/2] Use %p when printing out pthread_t in the logging fns on
FreeBSD
A [slightly] more portable way to do this would be to use
pthread_set(_)?name_np, but even that is not super well-defined across
BSD versions, Linux, and OSX. See
http://stackoverflow.com/questions/2369738/can-i-set-the-name-of-a-thread-in-pthreads-linux
for more details.
---
contrib/ofed/management/opensm/opensm/osm_log.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/contrib/ofed/management/opensm/opensm/osm_log.c
b/contrib/ofed/management/opensm/opensm/osm_log.c
index deadc57..f4ef394 100644
--- a/contrib/ofed/management/opensm/opensm/osm_log.c
+++ b/contrib/ofed/management/opensm/opensm/osm_log.c
@@ -189,7 +189,11 @@ _retry:
_retry:
ret =
fprintf(p_log->out_port,
+#if defined(__FreeBSD__)
+ "%s %02d %02d:%02d:%02d %06d [%p] 0x%02x -> %s",
+#else
"%s %02d %02d:%02d:%02d %06d [%04X] 0x%02x -> %s",
+#endif
(result.tm_mon <
12 ? month_str[result.tm_mon] : "???"),
result.tm_mday, result.tm_hour, result.tm_min,
@@ -302,7 +306,12 @@ _retry:
_retry:
ret =
fprintf(p_log->out_port,
+#if defined(__FreeBSD__)
+ "%s %02d %02d:%02d:%02d %06d [%p] 0x%02x -> %s",
+#else
"%s %02d %02d:%02d:%02d %06d [%04X] 0x%02x -> %s",
+
+#endif
(result.tm_mon <
12 ? month_str[result.tm_mon] : "???"),
result.tm_mday, result.tm_hour, result.tm_min,
--
1.8.0.1
From 55c3bafa1d866dc045e16fbf792dc64d03d25431 Mon Sep 17 00:00:00 2001
From: Garrett Cooper <garrett.coo...@isilon.com>
Date: Thu, 6 Dec 2012 21:41:17 -0800
Subject: [PATCH 2/2] Use %p when printing out pthread_t in the logging fns on
FreeBSD
A [slightly] more portable way to do this would be to use
pthread_set(_)?name_np, but even that is not super well-defined across
BSD versions, Linux, and OSX. See
http://stackoverflow.com/questions/2369738/can-i-set-the-name-of-a-thread-in-pthreads-linux
for more details.
---
contrib/ofed/management/opensm/opensm/osm_log.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/contrib/ofed/management/opensm/opensm/osm_log.c
b/contrib/ofed/management/opensm/opensm/osm_log.c
index deadc57..f4ef394 100644
--- a/contrib/ofed/management/opensm/opensm/osm_log.c
+++ b/contrib/ofed/management/opensm/opensm/osm_log.c
@@ -189,7 +189,11 @@ _retry:
_retry:
ret =
fprintf(p_log->out_port,
+#if defined(__FreeBSD__)
+ "%s %02d %02d:%02d:%02d %06d [%p] 0x%02x -> %s",
+#else
"%s %02d %02d:%02d:%02d %06d [%04X] 0x%02x -> %s",
+#endif
(result.tm_mon <
12 ? month_str[result.tm_mon] : "???"),
result.tm_mday, result.tm_hour, result.tm_min,
@@ -302,7 +306,12 @@ _retry:
_retry:
ret =
fprintf(p_log->out_port,
+#if defined(__FreeBSD__)
+ "%s %02d %02d:%02d:%02d %06d [%p] 0x%02x -> %s",
+#else
"%s %02d %02d:%02d:%02d %06d [%04X] 0x%02x -> %s",
+
+#endif
(result.tm_mon <
12 ? month_str[result.tm_mon] : "???"),
result.tm_mday, result.tm_hour, result.tm_min,
--
1.8.0.1