Return-Path: X-Original-To: apmail-zookeeper-dev-archive@www.apache.org Delivered-To: apmail-zookeeper-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D6A4717F9B for ; Fri, 1 May 2015 19:36:06 +0000 (UTC) Received: (qmail 24744 invoked by uid 500); 1 May 2015 19:36:06 -0000 Delivered-To: apmail-zookeeper-dev-archive@zookeeper.apache.org Received: (qmail 24696 invoked by uid 500); 1 May 2015 19:36:06 -0000 Mailing-List: contact dev-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list dev@zookeeper.apache.org Received: (qmail 24684 invoked by uid 99); 1 May 2015 19:36:06 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 May 2015 19:36:06 +0000 Date: Fri, 1 May 2015 19:36:06 +0000 (UTC) From: "Chris Nauroth (JIRA)" To: dev@zookeeper.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (ZOOKEEPER-1077) C client lib doesn't build on Solaris MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/ZOOKEEPER-1077?page=3Dcom.atla= ssian.jira.plugin.system.issuetabpanels:all-tabpanel ] Chris Nauroth updated ZOOKEEPER-1077: ------------------------------------- Attachment: ZOOKEEPER-1077.002.patch @Raul, thank you for the code review. bq. "cast the pid to long for use by the snprintf format string." - do we w= e want to do this on all platforms? I expect this is fine cross-platform, but let me know if you prefer to have= it wrapped in an {{#ifdef}}. POSIX dicates that the width of {{pid_t}} is= no more than {{long}}. http://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/types.h.html {quote} ...the widths of ..., pid_t, ... are no greater than the width of type long= . {quote} I checked the BSD and Linux source. It looks like BSD can use either {{int= }} or {{long}} depending on options. I see Linux using 32-bit signed as we= ll. For the 32-bit case, this code would store the 32-bit value in a 64-bi= t field just for printing. bq. dropped for Apple? The patch keeps using {{SO_NOSIGPIPE}} on Apple, but the diff makes it diff= icult to read. Here is what it looks like after applying the patch: {code} #ifdef _WIN32 typedef SOCKET socket_t; typedef int sendsize_t; #define SEND_FLAGS 0 #else #ifdef __APPLE__ #define SEND_FLAGS SO_NOSIGPIPE #endif #ifdef __linux__ #define SEND_FLAGS MSG_NOSIGNAL #endif #ifndef SEND_FLAGS #define SEND_FLAGS 0 #endif typedef int socket_t; typedef ssize_t sendsize_t; #endif {code} I'm attaching a v002 patch. This fixes some additional compilation problem= s I found in the tests. We need to use the same extra compiler and linker = flags for the cppunit tests. The {{$(shell)}} construct in makefiles is a = GNU-ism, so I needed to do that differently on Solaris. The {{realloc}} st= ub declaration needed to be wrapped like the others to avoid a symbol redef= inition error. I'm not sure why this one wasn't triggering on Linux. I'm = guessing there is some subtle difference in the Solaris standard headers th= at this file includes so that it walks back to an earlier {{realloc}} decla= ration. I'll provide a branch-3.4 patch too later. > C client lib doesn't build on Solaris > ------------------------------------- > > Key: ZOOKEEPER-1077 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1077 > Project: ZooKeeper > Issue Type: Bug > Components: build, c client > Affects Versions: 3.3.4 > Environment: uname -a: SunOS [redacted] 5.10 Generic_142910-17 i8= 6pc i386 i86pc > GNU toolchain (gcc 3.4.3, GNU Make etc.) > Reporter: Tadeusz Andrzej Kad=C5=82ubowski > Assignee: Chris Nauroth > Priority: Critical > Fix For: 3.5.2, 3.6.0 > > Attachments: ZOOKEEPER-1077.001.patch, ZOOKEEPER-1077.002.patch, = zookeeper.patch > > > Hello, > Some minor trouble with building ZooKeeper C client library on Sun^H^H^HO= racle Solaris 5.10. > 1. You need to link against "-lnsl -lsocket" > 2. ctime_r needs a buffer size. The signature is: "char *ctime_r(const ti= me_t *clock, char *buf, int buflen)" > 3. In zk_log.c you need to manually cast pid_t to int (-Werror can be cum= bersome ;) ) > 4. getpwuid_r()returns pointer to struct passwd, which works as the last = parameter on Linux. > Solaris signature: struct passwd *getpwuid_r(uid_t uid, struct passwd = *pwd, char *buffer, int buflen);=20 > Linux signature: int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,= size_t buflen, struct passwd **result); -- This message was sent by Atlassian JIRA (v6.3.4#6332)