]> granicus.if.org Git - pgbouncer/commitdiff
Build fixes for Solaris
authorMarko Kreen <markokr@gmail.com>
Wed, 25 Jun 2008 14:47:54 +0000 (14:47 +0000)
committerMarko Kreen <markokr@gmail.com>
Wed, 25 Jun 2008 14:47:54 +0000 (14:47 +0000)
* Use __func__ and define it to __FUNCTION__ if not defined.
  it's the C99 standard.

* Tests for certain linking libraries (libnsl, libsocket, libresolv) (configure.ac)

* Defines INADDR_NONE  if not defined

* Search for <ucred.h> in addition to <sys/ucred.h> (configure.ac)

* Changes include of <sys/errno.h> to <errno.h>.
  I _think_ this should be safe on all platforms (and it's the standard)

* Changes local variable name s_addr to saddr in takeover.c.
  s_addr is a Single Unix Specification defined name.

* Checks if LOG_AUTHPRIV exists (it does not in Solaris)

Original patch by Magne Mæhre, applied with minor changes

configure.ac
include/system.h
include/util.h
src/system.c
src/takeover.c
src/util.c

index d8d9d324391a5b41fbf032a63573e8a7601670ac..3f1b047639962d19d82f07d5d68a676dae41b9df 100644 (file)
@@ -21,6 +21,15 @@ if test "$GCC" = "yes"; then
      LDFLAGS="$old_LDFLAGS"])
 fi
 
+dnl Check if compiler supports __func__
+AC_CACHE_CHECK([whether compiler supports __func__], pgac_cv_funcname_func,
+  [AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
+                  [pgac_cv_funcname_func=yes], [pgac_cv_funcname_func=no])])
+if test x"$pgac_cv_funcname_func" = xyes ; then
+  AC_DEFINE(HAVE_FUNCNAME__FUNC, 1,
+            [Define to 1 if your compiler understands __func__.])
+fi
+
 dnl asciidoc >= 8.2
 AC_CHECK_PROGS(ASCIIDOC, asciidoc)
 if test -n "$ASCIIDOC"; then
@@ -67,8 +76,9 @@ fi
 
 dnl Checks for header files.
 AC_CHECK_HEADERS([crypt.h sys/param.h sys/socket.h libgen.h])
+
 dnl ucred.h may have prereqs
-AC_CHECK_HEADERS([sys/ucred.h], [], [], [
+AC_CHECK_HEADERS([ucred.h sys/ucred.h], [], [], [
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -100,6 +110,9 @@ dnl Checks for library functions.
 AC_CHECK_FUNCS(strlcpy strlcat getpeereid getpeerucred basename)
 AC_SEARCH_LIBS(crypt, crypt, [], AC_MSG_ERROR([crypt not found]))
 AC_SEARCH_LIBS(clock_gettime, rt)
+AC_SEARCH_LIBS(getsockname, socket)
+AC_SEARCH_LIBS(gethostbyname, nsl)
+AC_SEARCH_LIBS(hstrerror, resolv)
 
 dnl Find libevent
 AC_MSG_CHECKING([for libevent])
index 6e07e3821a59410d1832b2efaf98acf755094b88..a9151a6139c8f2318f2552ec746f3b80bfdd61ad 100644 (file)
@@ -24,7 +24,7 @@
 #include "config.h"
 #endif
 
-#include <sys/errno.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/socket.h>
@@ -127,6 +127,21 @@ typedef unsigned char bool;
 #define INT4OID 23
 #define TEXTOID 25
 
+/*
+ * Make sure __func__ works.
+ */
+
+#ifndef HAVE_FUNCNAME__FUNC
+#define __func__ __FUNCTION__
+#endif
+
+/*
+ * Some systems (Solaris) does not define INADDR_NONE
+ */
+#ifndef INADDR_NONE
+#define INADDR_NONE ((unsigned long) -1)
+#endif
+
 /*
  * libc compat functions.
  */
index 1f4540fb22676bc34d712c790a30a7662ea00ee6..944bcb1aa53c4a1575a80655268dd46446f7e945 100644 (file)
@@ -69,11 +69,11 @@ void slog_level(const char *level, const PgSocket *sock, const char *fmt, ...)
 void _fatal(const char *file, int line, const char *func, bool do_exit, const char *s, ...) _PRINTF(5, 6);
 void _fatal_perror(const char *file, int line, const char *func, const char *s, ...)  _PRINTF(4, 5);
 #define fatal(args...) \
-       _fatal(__FILE__, __LINE__, __FUNCTION__, true, ## args)
+       _fatal(__FILE__, __LINE__, __func__, true, ## args)
 #define fatal_noexit(args...) \
-       _fatal(__FILE__, __LINE__, __FUNCTION__, false, ## args)
+       _fatal(__FILE__, __LINE__, __func__, false, ## args)
 #define fatal_perror(args...) \
-       _fatal_perror(__FILE__, __LINE__, __FUNCTION__, ## args)
+       _fatal_perror(__FILE__, __LINE__, __func__, ## args)
 
 /*
  * non-interruptible operations
index ce81948968fd47e596d54af5b3cbed86874347bf..ca0295ac1d4b076921690ed76887a8169dd181f9 100644 (file)
@@ -25,6 +25,9 @@
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
+#ifdef HAVE_UCRED_H
+#include <ucred.h>
+#endif
 #ifdef HAVE_SYS_UCRED_H
 #include <sys/ucred.h>
 #endif
index 85332974613ebe65292db661ec9811f4e25d0ecd..fe74c649594f8576d6dbd58f380ffd67cf767449 100644 (file)
@@ -78,7 +78,7 @@ static void takeover_finish_part1(PgSocket *bouncer)
 static void takeover_load_fd(MBuf *pkt, const struct cmsghdr *cmsg)
 {
        int fd;
-       char *task, *s_addr, *user, *db;
+       char *task, *saddr, *user, *db;
        char *client_enc, *std_string, *datestyle, *timezone;
        int oldfd, port, linkfd;
        int got;
@@ -100,9 +100,9 @@ static void takeover_load_fd(MBuf *pkt, const struct cmsghdr *cmsg)
 
        /* parse row contents */
        got = scan_text_result(pkt, "issssiqissss", &oldfd, &task, &user, &db,
-                              &s_addr, &port, &ckey, &linkfd,
+                              &saddr, &port, &ckey, &linkfd,
                               &client_enc, &std_string, &datestyle, &timezone);
-       if (task == NULL || s_addr == NULL)
+       if (task == NULL || saddr == NULL)
                fatal("NULL data from old process");
 
        log_debug("FD row: fd=%d(%d) linkfd=%d task=%s user=%s db=%s enc=%s",
@@ -111,11 +111,11 @@ static void takeover_load_fd(MBuf *pkt, const struct cmsghdr *cmsg)
                  client_enc ? client_enc : "NULL");
 
        /* fill address */
-       addr.is_unix = strcmp(s_addr, "unix") == 0 ? true : false;
+       addr.is_unix = strcmp(saddr, "unix") == 0 ? true : false;
        if (addr.is_unix) {
                addr.port = cf_listen_port;
        } else {
-               addr.ip_addr.s_addr = inet_addr(s_addr);
+               addr.ip_addr.s_addr = inet_addr(saddr);
                addr.port = port;
        }
 
index 274884b0b21d4f8b8a605908d736aff357fd2864..937879dc145f0e178007520f0f3cd5ce03014440 100644 (file)
@@ -32,7 +32,9 @@ static int log_fd = 0;
 struct FacName { const char *name; int code; };
 static struct FacName facility_names [] = {
        { "auth",       LOG_AUTH },
-       { "authpriv",   LOG_AUTHPRIV },
+#ifdef LOG_AUTHPRIV
+        { "authpriv",  LOG_AUTHPRIV },
+#endif
        { "daemon",     LOG_DAEMON },
        { "user",       LOG_USER },
        { "local0",     LOG_LOCAL0 },