Browse Source

Additional fixes for build.

Brian Aker 12 years ago
parent
commit
d3c67112a7
5 changed files with 165 additions and 19 deletions
  1. 60 0
      libhostile/dummy.c
  2. 22 15
      libhostile/hostile.h
  3. 5 0
      libhostile/include.am
  4. 77 0
      libhostile/visibility.h
  5. 1 4
      tests/start_worker.cc

+ 60 - 0
libhostile/dummy.c

@@ -0,0 +1,60 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  Data Differential's libhostle
+ *
+ *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "config.h"
+
+#include "libhostile/hostile.h"
+
+bool libhostile_is_accept()
+{
+  return false;
+}
+
+void set_poll_close(bool, int, int, enum hostile_poll_t)
+{
+}
+
+void set_accept_close(bool, int, int)
+{
+}
+
+void set_recv_close(bool, int, int)
+{
+}
+
+void set_send_close(bool, int, int)
+{
+}

+ 22 - 15
libhostile/hostile.h

@@ -38,31 +38,38 @@
 
 #include <stdbool.h>
 
-typedef enum hostile_poll_t
+#include "libhostile/visibility.h"
+
+enum hostile_poll_t
 {
   HOSTILE_POLL_CLOSED,
   HOSTILE_POLL_SHUT_WR,
   HOSTILE_POLL_SHUT_RD
-} hostile_poll_t;
+};
+
+#ifndef __cplusplus
+typedef enum hostile_poll_t hostile_poll_t;
+#endif
 
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#if defined(HAVE_LIBHOSTILE) && HAVE_LIBHOSTILE
-bool libhostile_is_accept();
-void set_poll_close(bool arg, int frequency, int not_until_arg, enum hostile_poll_t poll_type);
-void set_accept_close(bool arg, int frequency, int not_until_arg);
-void set_recv_close(bool arg, int frequency, int not_until_arg);
-void set_send_close(bool arg, int frequency, int not_until_arg);
-#else
-#  define set_accept_close( __arg, __frequency, __not_until_arg);
-#  define set_poll_close( __arg, __frequency, __not_until_arg, __poll_type);
-#  define set_recv_close( __arg, __frequency, __not_until_arg);
-#  define set_send_close( __arg, __frequency, __not_until_arg);
-static bool libhostile_is_accept(void)  { return false; }
-#endif
+LIBHOSTILE_API
+  bool libhostile_is_accept();
+
+LIBHOSTILE_API
+  void set_poll_close(bool arg, int frequency, int not_until_arg, enum hostile_poll_t poll_type);
+
+LIBHOSTILE_API
+  void set_accept_close(bool arg, int frequency, int not_until_arg);
+
+LIBHOSTILE_API
+  void set_recv_close(bool arg, int frequency, int not_until_arg);
+
+LIBHOSTILE_API
+  void set_send_close(bool arg, int frequency, int not_until_arg);
 
 #ifdef __cplusplus
 }

+ 5 - 0
libhostile/include.am

@@ -26,6 +26,7 @@ noinst_HEADERS+= libhostile/realloc.h
 noinst_HEADERS+= libhostile/recv.h
 noinst_HEADERS+= libhostile/send.h
 noinst_HEADERS+= libhostile/setsockopt.h
+noinst_HEADERS+= libhostile/visibility.h
 noinst_HEADERS+= libhostile/write.h
 
 libhostile_libhostile_la_CFLAGS=
@@ -33,6 +34,8 @@ libhostile_libhostile_la_LIBADD=
 libhostile_libhostile_la_SOURCES=
 libhostile_libhostile_la_DEPENDENCIES=
 
+libhostile_libhostile_la_CXXFLAGS= -DBUILDING_LIBHOSTILE
+
 libhostile_libhostile_la_SOURCES+= libhostile/initialize.c
 
 if TARGET_LINUX
@@ -53,4 +56,6 @@ libhostile_libhostile_la_SOURCES+= libhostile/recv.c
 libhostile_libhostile_la_SOURCES+= libhostile/send.c
 libhostile_libhostile_la_SOURCES+= libhostile/setsockopt.c
 libhostile_libhostile_la_SOURCES+= libhostile/write.c
+else
+libhostile_libhostile_la_SOURCES+= libhostile/dummy.c
 endif

+ 77 - 0
libhostile/visibility.h

@@ -0,0 +1,77 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  Data Differential YATL (i.e. libtest)  library
+ *
+ *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+#if defined(BUILDING_LIBHOSTILE)
+# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
+#  define LIBHOSTILE_API __attribute__ ((visibility("default")))
+#  define LIBHOSTILE_LOCAL  __attribute__ ((visibility("default")))
+# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+#  define LIBHOSTILE_API __global
+#  define LIBHOSTILE_LOCAL __global
+# elif defined(_MSC_VER)
+#  define LIBHOSTILE_API extern __declspec(dllexport) 
+#  define LIBHOSTILE_LOCAL extern __declspec(dllexport)
+# else
+#  define LIBHOSTILE_API
+#  define LIBHOSTILE_LOCAL
+# endif
+#else
+# if defined(BUILDING_LIBHOSTILE)
+#  if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
+#   define LIBHOSTILE_API __attribute__ ((visibility("default")))
+#   define LIBHOSTILE_LOCAL  __attribute__ ((visibility("hidden")))
+#  elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+#   define LIBHOSTILE_API __global
+#   define LIBHOSTILE_LOCAL __hidden
+#  elif defined(_MSC_VER)
+#   define LIBHOSTILE_API extern __declspec(dllexport) 
+#   define LIBHOSTILE_LOCAL
+#  else
+#   define LIBHOSTILE_API
+#   define LIBHOSTILE_LOCAL
+#  endif /* defined(HAVE_VISIBILITY) */
+# else  /* defined(BUILDING_LIBHOSTILE) */
+#  if defined(_MSC_VER)
+#   define LIBHOSTILE_API extern __declspec(dllimport) 
+#   define LIBHOSTILE_LOCAL
+#  else
+#   define LIBHOSTILE_API
+#   define LIBHOSTILE_LOCAL
+#  endif /* defined(_MSC_VER) */
+# endif /* defined(BUILDING_LIBHOSTILE) */
+#endif /* defined(BUILDING_LIBHOSTILEINTERNAL) */

+ 1 - 4
tests/start_worker.cc

@@ -181,10 +181,7 @@ static void thread_runner(context_st* con)
 
     if (success == false)
     {
-      if (libhostile_is_accept() == false)
-      {
-        Out << "gearman_worker_set_server_option() failed";
-      }
+      Out << "gearman_worker_set_server_option() failed";
       context->fail();
       return;
     }