zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Nauroth (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (ZOOKEEPER-1077) C client lib doesn't build on Solaris
Date Fri, 01 May 2015 19:36:06 GMT

     [ https://issues.apache.org/jira/browse/ZOOKEEPER-1077?page=com.atlassian.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 we 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 well.  For the 32-bit case, this
code would store the 32-bit value in a 64-bit field just for printing.

bq. dropped for Apple?

The patch keeps using {{SO_NOSIGPIPE}} on Apple, but the diff makes it difficult 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 problems 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}} stub declaration needed to be wrapped like the others to avoid a symbol redefinition
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 that this file includes so that it walks
back to an earlier {{realloc}} declaration.

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 i86pc i386 i86pc
> GNU toolchain (gcc 3.4.3, GNU Make etc.)
>            Reporter: Tadeusz Andrzej Kadłubowski
>            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^HOracle 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 time_t *clock,
char *buf, int buflen)"
> 3. In zk_log.c you need to manually cast pid_t to int (-Werror can be cumbersome ;) )
> 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); 
> 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)

Mime
View raw message