From fb05e80af2bd7817925bb532220b71d3b52cfbef Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Sun, 8 Oct 2017 17:50:11 -0700 Subject: [PATCH 1/3] Fix building on MacOS There were a number of issues that built up over time as we weren't testing on OS X, and as clang got more pedantic. They are listed below as best I understand them: htonll - OS X defines this. Linux does not. We took a few strategies to get around this: - Remove unused htonll defs/calls - Do not try to redefine htonll - Add HAVE_HTONLL to ifdef around when necessary. The pragmas in libgearman/command and error_code allow us to keep building while gperf fixes their issues that clang exposes. We tried with gperf 3.1, but this only fixed the register issue, not the cast precision warnings. A few things were just minor warnings that clang reports that gcc does not. --- configure.ac | 2 + libgearman-server/byteorder.cc | 76 ----------------------------- libgearman-server/byteorder.h | 67 ------------------------- libgearman-server/common.h | 1 - libgearman-server/gearmand.h | 1 - libgearman-server/include.am | 2 - libgearman-server/server.cc | 2 +- libgearman/byteorder.cc | 4 ++ libgearman/byteorder.h | 10 ---- libgearman/command.cc | 10 +++- libgearman/command.h | 2 +- libgearman/common.h | 1 - libgearman/error_code.cc | 8 +++ libgearman/include.am | 2 - libgearman/job.cc | 8 --- libgearmancore/include.am | 1 - libtest/exception/disconnected.hpp | 2 +- libtest/exception/fatal.cc | 2 +- libtest/server.cc | 6 --- libtest/signal.cc | 13 ++++- tests/libgearman-1.0/worker_test.cc | 6 +++ tests/workers/v2/split.cc | 2 +- util/signal.cc | 10 +++- util/signal.hpp | 3 +- 24 files changed, 56 insertions(+), 185 deletions(-) delete mode 100644 libgearman-server/byteorder.cc delete mode 100644 libgearman-server/byteorder.h diff --git a/configure.ac b/configure.ac index b2af60c66..a93113824 100644 --- a/configure.ac +++ b/configure.ac @@ -175,6 +175,8 @@ AC_CHECK_HEADERS_ONCE([syslog.h]) AC_CHECK_HEADERS_ONCE([unistd.h]) AC_CHECK_HEADERS_ONCE([winsock2.h]) AC_CHECK_HEADERS_ONCE([libmemcached-1.0/types/return.h]) +AC_CHECK_DECL([htonll],[AC_DEFINE([HAVE_HTONLL],[1], + [Define to 1 if you have htonll.])]) AM_CONDITIONAL([BUILD_WIN32_WRAPPERS],[test "x$ac_cv_header_winsock2_h" = "xyes"]) AS_IF([test "x$ac_cv_header_winsock2_h" = "xyes"], diff --git a/libgearman-server/byteorder.cc b/libgearman-server/byteorder.cc deleted file mode 100644 index b985241db..000000000 --- a/libgearman-server/byteorder.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* - Taken from libmemcached. - */ - -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Gearmand client and server library. - * - * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker - * All rights reserved. - * - * 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 "gear_config.h" - -#include - -#ifndef swap64 -/* Byte swap a 64-bit number. */ -static inline uint64_t swap64(uint64_t in) -{ - #ifndef WORDS_BIGENDIAN - /* Little endian, flip the bytes around until someone makes a faster/better - * way to do this. */ - uint64_t rv= 0; - for (uint8_t x= 0; x < 8; ++x) - { - rv= (rv << 8) | (in & 0xff); - in >>= 8; - } - return rv; - #else - /* big-endian machines don't need byte swapping */ - return in; - #endif -} -#endif - -uint64_t ntohll(uint64_t value) -{ - return swap64(value); -} - -uint64_t htonll(uint64_t value) -{ - return swap64(value); -} diff --git a/libgearman-server/byteorder.h b/libgearman-server/byteorder.h deleted file mode 100644 index 93055a13c..000000000 --- a/libgearman-server/byteorder.h +++ /dev/null @@ -1,67 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Gearmand client and server library. - * Taken from libmemcached. - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * 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 - -#ifndef HAVE_HTONLL - -#ifdef __cplusplus -extern "C" { -#endif - -uint64_t ntohll(uint64_t); - -uint64_t htonll(uint64_t); - -#ifdef __cplusplus -} -#endif - -#endif - -#ifdef linux -/* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to - * optimize the conversion functions, but the prototypes generate warnings - * from gcc. The conversion methods isn't the bottleneck for my app, so - * just remove the warnings by undef'ing the optimization .. - */ -#undef ntohs -#undef ntohl -#undef htons -#undef htonl -#endif diff --git a/libgearman-server/common.h b/libgearman-server/common.h index c3487f769..2f30999ee 100644 --- a/libgearman-server/common.h +++ b/libgearman-server/common.h @@ -44,7 +44,6 @@ #pragma once #include -#include #include "libgearman-server/config.hpp" #include "libgearman/assert.hpp" diff --git a/libgearman-server/gearmand.h b/libgearman-server/gearmand.h index 65f555391..8c3615963 100644 --- a/libgearman-server/gearmand.h +++ b/libgearman-server/gearmand.h @@ -57,7 +57,6 @@ #include #include -#include #include #include #include diff --git a/libgearman-server/include.am b/libgearman-server/include.am index 333e5f680..81a119309 100644 --- a/libgearman-server/include.am +++ b/libgearman-server/include.am @@ -31,7 +31,6 @@ noinst_HEADERS+= libgearman-server/queue.hpp noinst_HEADERS+= libgearman-server/text.h noinst_HEADERS+= \ libgearman-server/byte.h \ - libgearman-server/byteorder.h \ libgearman-server/client.h \ libgearman-server/common.h \ libgearman-server/config.h \ @@ -61,7 +60,6 @@ libgearman_server_libgearman_server_la_SOURCES+= libgearman/vector.cc libgearman_server_libgearman_server_la_SOURCES+= libgearman-server/text.cc libgearman_server_libgearman_server_la_SOURCES+= libgearman-server/config.cc libgearman_server_libgearman_server_la_SOURCES+= \ - libgearman-server/byteorder.cc \ libgearman-server/client.cc \ libgearman-server/connection.cc \ libgearman-server/function.cc \ diff --git a/libgearman-server/server.cc b/libgearman-server/server.cc index e9eeea1f2..95ee8a9a2 100644 --- a/libgearman-server/server.cc +++ b/libgearman-server/server.cc @@ -623,7 +623,7 @@ gearmand_error_t gearman_server_run_command(gearman_server_con_st *server_con, server_job->data, server_job->data_size, NULL); } - else if (packet->command == GEARMAN_COMMAND_GRAB_JOB_ALL and server_job->reducer) + else if (packet->command == GEARMAN_COMMAND_GRAB_JOB_ALL and *server_job->reducer != '\0') { gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "Sending reduce submission, Partitioner: %.*s(%lu) Reducer: %.*s(%lu) Unique: %.*s(%lu) with data sized (%lu)" , diff --git a/libgearman/byteorder.cc b/libgearman/byteorder.cc index 674fed966..b2e218280 100644 --- a/libgearman/byteorder.cc +++ b/libgearman/byteorder.cc @@ -65,6 +65,8 @@ static inline uint64_t swap64(uint64_t in) } #endif +#ifndef HAVE_HTONLL + uint64_t ntohll(uint64_t value) { return swap64(value); @@ -74,3 +76,5 @@ uint64_t htonll(uint64_t value) { return swap64(value); } + +#endif diff --git a/libgearman/byteorder.h b/libgearman/byteorder.h index 9f28f4ebd..306ce2891 100644 --- a/libgearman/byteorder.h +++ b/libgearman/byteorder.h @@ -40,16 +40,6 @@ #pragma once -#ifndef HAVE_HTONLL - -GEARMAN_INTERNAL_API -uint64_t ntohll(uint64_t); - -GEARMAN_INTERNAL_API -uint64_t htonll(uint64_t); - -#endif - #ifdef linux /* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to * optimize the conversion functions, but the prototypes generate warnings diff --git a/libgearman/command.cc b/libgearman/command.cc index 07f15adbd..2a7c6b378 100644 --- a/libgearman/command.cc +++ b/libgearman/command.cc @@ -40,7 +40,15 @@ #include #include +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-register" +#pragma clang diagnostic ignored "-Wshorten-64-to-32" +#endif #include "libgearman/command.hpp" +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #include "libgearman/strcommand.h" #include "libgearman/assert.hpp" @@ -133,7 +141,7 @@ const gearman_command_info_st *gearman_command_info(gearman_command_t command) return command_info; } -const struct gearman_command_info_st * gearman_command_lookup (register const char *str, register unsigned int len) +const struct gearman_command_info_st * gearman_command_lookup (const char *str, unsigned int len) { const struct gearman_command_string_st* com_str= String2gearman_command_t::in_word_set(str, len); return gearman_command_info(com_str->code); diff --git a/libgearman/command.h b/libgearman/command.h index bdec8310b..54b7516aa 100644 --- a/libgearman/command.h +++ b/libgearman/command.h @@ -57,7 +57,7 @@ const char *gearman_enum_strcommand(gearman_command_t); const struct gearman_command_info_st *gearman_command_info(gearman_command_t command); -const struct gearman_command_info_st * gearman_command_lookup (register const char *str, register unsigned int len); +const struct gearman_command_info_st * gearman_command_lookup (const char *str, unsigned int len); #ifdef __cplusplus } diff --git a/libgearman/common.h b/libgearman/common.h index b0e5f8988..f3e15ace4 100644 --- a/libgearman/common.h +++ b/libgearman/common.h @@ -61,7 +61,6 @@ struct gearman_universal_st; #include "libgearman/error_code.h" /* These are private not to be installed headers */ -#include "libgearman/byteorder.h" #include "libgearman/strcommand.h" #include "libgearman/vector.hpp" #include "libgearman/unique.hpp" diff --git a/libgearman/error_code.cc b/libgearman/error_code.cc index b3d54704a..f35e537f4 100644 --- a/libgearman/error_code.cc +++ b/libgearman/error_code.cc @@ -38,7 +38,15 @@ #include "gear_config.h" #include "libgearman/error_code.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-register" +#pragma clang diagnostic ignored "-Wshorten-64-to-32" +#endif #include "libgearman/error_code.hpp" +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #include "libgearman-1.0/visibility.h" #include "libgearman-1.0/strerror.h" diff --git a/libgearman/include.am b/libgearman/include.am index 8bdb21b5b..07045b3b6 100644 --- a/libgearman/include.am +++ b/libgearman/include.am @@ -41,7 +41,6 @@ noinst_HEADERS+= \ libgearman/allocator.hpp \ libgearman/assert.hpp \ libgearman/backtrace.hpp \ - libgearman/byteorder.h \ libgearman/command.h \ libgearman/common.h \ libgearman/connection.hpp \ @@ -99,7 +98,6 @@ libgearman_libgearman_la_SOURCES+= \ libgearman/argument.cc \ libgearman/add.cc \ libgearman/backtrace.cc \ - libgearman/byteorder.cc \ libgearman/client.cc \ libgearman/command.cc \ libgearman/connection.cc \ diff --git a/libgearman/job.cc b/libgearman/job.cc index bc7f3076c..2ee25b7b4 100644 --- a/libgearman/job.cc +++ b/libgearman/job.cc @@ -318,14 +318,6 @@ gearman_client_st *gearman_job_use_client(gearman_job_st *job_shell) return NULL; } -static inline void gearman_job_reset_error(Job* job) -{ - if (job) - { - gearman_worker_reset_error(job->_worker); - } -} - gearman_return_t gearman_job_send_data(gearman_job_st *job_shell, const void *data, size_t data_size) { if (job_shell and job_shell->impl()) diff --git a/libgearmancore/include.am b/libgearmancore/include.am index cd48d7aea..e7792535d 100644 --- a/libgearmancore/include.am +++ b/libgearmancore/include.am @@ -13,7 +13,6 @@ noinst_LTLIBRARIES+= libgearman/libgearmancore.la libgearman_libgearmancore_la_SOURCES= libgearman_libgearmancore_la_SOURCES+= libgearman/allocator.cc libgearman_libgearmancore_la_SOURCES+= libgearman/backtrace.cc -libgearman_libgearmancore_la_SOURCES+= libgearman/byteorder.cc libgearman_libgearmancore_la_SOURCES+= libgearman/check.cc libgearman_libgearmancore_la_SOURCES+= libgearman/command.cc libgearman_libgearmancore_la_SOURCES+= libgearman/connection.cc diff --git a/libtest/exception/disconnected.hpp b/libtest/exception/disconnected.hpp index fb3a2adb3..76593c61d 100644 --- a/libtest/exception/disconnected.hpp +++ b/libtest/exception/disconnected.hpp @@ -43,7 +43,7 @@ namespace libtest { class disconnected : public libtest::exception { public: - disconnected(const char *file, int line, const char *func, const std::string&, const in_port_t port, ...); + disconnected(const char *file, int line, const char *func, const std::string&, const int port, ...); disconnected(const disconnected&); diff --git a/libtest/exception/fatal.cc b/libtest/exception/fatal.cc index 21a8ca79b..bb21c1076 100644 --- a/libtest/exception/fatal.cc +++ b/libtest/exception/fatal.cc @@ -89,7 +89,7 @@ void fatal::increment_disabled_counter() throw() #pragma GCC diagnostic ignored "-Wformat-nonliteral" disconnected::disconnected(const char *file_arg, int line_arg, const char *func_arg, - const std::string& instance, const in_port_t port, ...) : + const std::string& instance, const int port, ...) : libtest::exception(file_arg, line_arg, func_arg), _port(port) { diff --git a/libtest/server.cc b/libtest/server.cc index c5d91e95b..f06c02c2e 100644 --- a/libtest/server.cc +++ b/libtest/server.cc @@ -49,12 +49,6 @@ #include #include -// trim from end -static inline std::string &rtrim(std::string &s) -{ - s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(std::isspace))).base(), s.end()); - return s; -} #include #include diff --git a/libtest/signal.cc b/libtest/signal.cc index 90f33c1b6..24a40b1b6 100644 --- a/libtest/signal.cc +++ b/libtest/signal.cc @@ -37,6 +37,10 @@ #include "libtest/yatlcon.h" #include +#include +#include +#include + #include #include @@ -210,7 +214,8 @@ SignalThread::SignalThread() : sigaddset(&set, SIGUSR2); - sem_init(&lock, 0, 0); + strcpy(lock_name, "/XXXXXXXX"); + mktemp(lock_name); sigemptyset(&original_set); pthread_sigmask(SIG_BLOCK, NULL, &original_set); @@ -220,6 +225,12 @@ SignalThread::SignalThread() : bool SignalThread::setup() { set_shutdown(SHUTDOWN_RUNNING); + lock = sem_open(lock_name, O_CREAT|O_EXCL); + if (lock == SEM_FAILED) + { + Error << strerror(errno) << " when opening lock."; + } + if (sigismember(&original_set, SIGQUIT)) { diff --git a/tests/libgearman-1.0/worker_test.cc b/tests/libgearman-1.0/worker_test.cc index bf3556995..020de0d62 100644 --- a/tests/libgearman-1.0/worker_test.cc +++ b/tests/libgearman-1.0/worker_test.cc @@ -529,6 +529,9 @@ static test_return_t gearman_worker_add_server_GEARMAN_GETADDRINFO_TEST(void *) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" +#ifdef __clang__ +#pragma GCC diagnostic ignored "-Wunknown-warning-option" +#endif #pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations" static test_return_t job_order_TEST(void *) { @@ -597,6 +600,9 @@ static test_return_t job_order_TEST(void *) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" +#ifdef __clang__ +#pragma GCC diagnostic ignored "-Wunknown-warning-option" +#endif #pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations" static test_return_t job_order_background_TEST(void *) { diff --git a/tests/workers/v2/split.cc b/tests/workers/v2/split.cc index aa6d2a61a..164d18a0e 100644 --- a/tests/workers/v2/split.cc +++ b/tests/workers/v2/split.cc @@ -62,7 +62,7 @@ gearman_return_t split_worker(gearman_job_st *job, void* /* context */) { if (int(workload[x]) == 0 or int(workload[x]) == int(' ')) { - if ((workload +x -chunk_begin) == 11 and memcmp(chunk_begin, test_literal_param("mapper_fail") == 0)) + if ((workload +x -chunk_begin) == 11 and memcmp(chunk_begin, test_literal_param("mapper_fail")) == 0) { return gearman_job_send_exception(job, test_literal_param("Error occurred on purpose")); } diff --git a/util/signal.cc b/util/signal.cc index f3ca3944a..922671067 100644 --- a/util/signal.cc +++ b/util/signal.cc @@ -203,7 +203,8 @@ SignalThread::SignalThread(bool exit_on_signal_arg) : sigaddset(&set, SIGTERM); sigaddset(&set, SIGUSR2); - sem_init(&lock, 0, 0); + strcpy(lock_name, "/XXXXXXXXX"); + mktemp(lock_name); } @@ -224,7 +225,12 @@ bool SignalThread::setup() return false; } - sem_wait(&lock); + lock = sem_open(lock_name, 0, 0); + if (lock == SEM_FAILED) { + std::cerr << "WARNING: sem_open failed(" << strerror(errno) << ")" << std::endl; + } else { + sem_wait(lock); + } return true; } diff --git a/util/signal.hpp b/util/signal.hpp index fab67be63..0a1e9e4bb 100644 --- a/util/signal.hpp +++ b/util/signal.hpp @@ -65,7 +65,8 @@ enum shutdown_t { class SignalThread { bool _exit_on_signal; sigset_t set; - sem_t lock; + char lock_name[11]; + sem_t *lock; uint64_t magic_memory; volatile shutdown_t __shutdown; pthread_mutex_t shutdown_mutex; From 8da9ee1ec328b96c28d262694d7f85d3332ab1f8 Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Sun, 8 Oct 2017 19:40:26 -0700 Subject: [PATCH 2/3] Switch to named semaphores for compatability Mac OS X has deprecated unnamed semaphores. This solves the problem and maintains compatibility with all other POSIX implementations. --- libtest/signal.cc | 6 +++--- libtest/signal.h | 3 ++- util/signal.cc | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libtest/signal.cc b/libtest/signal.cc index 24a40b1b6..93176da8d 100644 --- a/libtest/signal.cc +++ b/libtest/signal.cc @@ -87,7 +87,7 @@ shutdown_t SignalThread::get_shutdown() void SignalThread::post() { - sem_post(&lock); + sem_post(lock); } void SignalThread::test() @@ -131,7 +131,7 @@ SignalThread::~SignalThread() pthread_join(thread, &retval); } #endif - sem_destroy(&lock); + sem_close(lock); unblock(); } @@ -265,7 +265,7 @@ bool SignalThread::setup() return false; } - sem_wait(&lock); + sem_wait(lock); return true; } diff --git a/libtest/signal.h b/libtest/signal.h index 6e68bb387..47390eb4e 100644 --- a/libtest/signal.h +++ b/libtest/signal.h @@ -50,7 +50,8 @@ namespace libtest { class SignalThread { sigset_t set; - sem_t lock; + char lock_name[10]; + sem_t *lock; uint64_t magic_memory; volatile shutdown_t __shutdown; pthread_mutex_t shutdown_mutex; diff --git a/util/signal.cc b/util/signal.cc index 922671067..adf78b7a3 100644 --- a/util/signal.cc +++ b/util/signal.cc @@ -35,6 +35,8 @@ */ #include "gear_config.h" +#include +#include #include #include @@ -88,7 +90,7 @@ shutdown_t SignalThread::get_shutdown() void SignalThread::post() { - sem_post(&lock); + sem_post(lock); } void SignalThread::test() @@ -129,7 +131,7 @@ SignalThread::~SignalThread() pthread_join(thread, &retval); } #endif - sem_destroy(&lock); + sem_close(lock); } extern "C" { From 97e714fe4a084af0fd62bb36bbcc6b221c9ee0e9 Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Sun, 8 Oct 2017 19:54:51 -0700 Subject: [PATCH 3/3] Enable osx in Travis Newer xcode doesn't include pip, so we have to use get-pip to install pip for sphinx on OSX. --- .travis.yml | 15 ++++----------- scripts/travis-linux.sh | 7 +++++++ scripts/travis-osx.sh | 7 +++++++ 3 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 scripts/travis-linux.sh create mode 100644 scripts/travis-osx.sh diff --git a/.travis.yml b/.travis.yml index 042c0faea..c083bd763 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ +os: + - linux + - osx language: cpp dist: trusty sudo: required @@ -26,17 +29,7 @@ matrix: env: COMPILER=g++-5 before_install: - - sudo apt-get update -qq - - if [ "$COMPILER" = "g++-4.9" ]; then sudo apt-get install -qq g++-4.9; fi - - if [ "$COMPILER" = "g++-4.9" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi - - if [ "$COMPILER" = "g++-5" ]; then sudo apt-get install -qq g++-5; fi - - if [ "$COMPILER" = "g++-5" ]; then export CXX="g++-5" CC="gcc-5"; fi - - sudo apt-get install -y libboost-all-dev - - sudo apt-get install -y gperf - - sudo apt-get install -y libevent-dev - - sudo apt-get install -y uuid-dev - - sudo apt-get install -y python-sphinx - - sudo apt-get install -y libhiredis-dev + - . scripts/travis-$TRAVIS_OS_NAME.sh script: - ./bootstrap.sh -a diff --git a/scripts/travis-linux.sh b/scripts/travis-linux.sh new file mode 100644 index 000000000..947488f1d --- /dev/null +++ b/scripts/travis-linux.sh @@ -0,0 +1,7 @@ +sudo apt-get update -qq +COMPILER_PACKAGE="" +if [ "$COMPILER" = "g++-4.9" ]; then COMPILER_PACKAGE=g++-4.9 +elif [ "$COMPILER" = "g++-5" ]; then COMPILER_PACKAGE=g++-5; fi +sudo apt-get install -y libboost-all-dev gperf libevent-dev uuid-dev python-sphinx libhiredis-dev $COMPILER_PACKAGE +if [ "$COMPILER" = "g++-4.9" ]; then export CXX="g++-4.9" CC="gcc-4.9" +elif [ "$COMPILER" = "g++-5" ]; then export CXX="g++-5" CC="gcc-5"; fi diff --git a/scripts/travis-osx.sh b/scripts/travis-osx.sh new file mode 100644 index 000000000..d8e4c7d97 --- /dev/null +++ b/scripts/travis-osx.sh @@ -0,0 +1,7 @@ +#brew install boost +wget https://bootstrap.pypa.io/get-pip.py +sudo -H python get-pip.py +sudo -H pip install virtualenv +virtualenv sphinx +. sphinx/bin/activate +pip install sphinx