All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <oliva@lsd.ic.unicamp.br>
To: ceph-devel@vger.kernel.org
Subject: fix build with tcmalloc on Freed-ora 13
Date: Wed, 02 Mar 2011 15:24:00 -0300	[thread overview]
Message-ID: <orwrkh8jpb.fsf@oliva.athome.lsd.ic.unicamp.br> (raw)

G++ complains about the difference between the return type of tcmalloc's
IsHeapProfilerRunning (int) and the return type of the function that
g_conf.profiler_running is supposed to point to (bool).  We could
probably get away with a type-cast, but as a compiler developer and
former C++ language lawyer, I'd rather not take the risk of destroying
the universe by invoking undefined behavior ;-)

The one thing I'm not sure about is whether the type of profiler_running
is always going to be bool.  If you know otherwise, let me know, and
I'll come up with some C++ template trickery to infer the appropriate
type.

        Signed-off-by: Alexandre Oliva <oliva@lsd.ic.unicamp.br>

diff --git a/src/cmds.cc b/src/cmds.cc
index 4264f36..f4adf9d 100644
--- a/src/cmds.cc
+++ b/src/cmds.cc
@@ -46,6 +46,13 @@ void usage()
   generic_server_usage();
 }
 
+#ifdef HAVE_LIBTCMALLOC
+/* Adjust the return type.  */
+static bool isHeapProfilerRunning(void) {
+  return IsHeapProfilerRunning();
+}
+#endif
+
 int main(int argc, const char **argv) 
 {
   vector<const char*> args;
@@ -58,7 +65,7 @@ int main(int argc, const char **argv)
   common_set_defaults(true);
 #ifdef HAVE_LIBTCMALLOC
   g_conf.profiler_start = HeapProfilerStart;
-  g_conf.profiler_running = IsHeapProfilerRunning;
+  g_conf.profiler_running = isHeapProfilerRunning;
   g_conf.profiler_stop = HeapProfilerStop;
   g_conf.profiler_dump = HeapProfilerDump;
   g_conf.tcmalloc_have = true;
diff --git a/src/cosd.cc b/src/cosd.cc
index 7e77799..28730ce 100644
--- a/src/cosd.cc
+++ b/src/cosd.cc
@@ -42,6 +42,12 @@ void usage()
   generic_server_usage();
 }
 
+#ifdef HAVE_LIBTCMALLOC
+/* Adjust the return type.  */
+static bool isHeapProfilerRunning(void) {
+  return IsHeapProfilerRunning();
+}
+#endif
 
 int main(int argc, const char **argv) 
 {
@@ -62,7 +68,7 @@ int main(int argc, const char **argv)
   common_set_defaults(true);
 #ifdef HAVE_LIBTCMALLOC
   g_conf.profiler_start = HeapProfilerStart;
-  g_conf.profiler_running = IsHeapProfilerRunning;
+  g_conf.profiler_running = isHeapProfilerRunning;
   g_conf.profiler_stop = HeapProfilerStop;
   g_conf.profiler_dump = HeapProfilerDump;
   g_conf.tcmalloc_have = true;


-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

             reply	other threads:[~2011-03-02 18:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-02 18:24 Alexandre Oliva [this message]
2011-03-02 21:25 ` fix build with tcmalloc on Freed-ora 13 Gregory Farnum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=orwrkh8jpb.fsf@oliva.athome.lsd.ic.unicamp.br \
    --to=oliva@lsd.ic.unicamp.br \
    --cc=ceph-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.