Add support for non-glibc systems

MaxScale can now be built on systems that use an alternative libc
implementation e.g. musl.
This commit is contained in:
Markus Mäkelä
2017-07-28 14:14:47 +03:00
parent 782b8db2aa
commit 854c4a1ed3
17 changed files with 104 additions and 77 deletions

View File

@ -39,19 +39,12 @@
#include <pwd.h>
#include <maxscale/version.h>
#include <maxscale/maxadmin.h>
#ifdef HISTORY
#include <histedit.h>
#endif
#include <maxscale/maxadmin.h>
/*
* We need a common.h file that is included by every component.
*/
#if !defined(STRERROR_BUFLEN)
#define STRERROR_BUFLEN 512
#endif
#define MAX_PASSWORD_LEN 80
static int connectUsingUnixSocket(const char *socket);
@ -441,27 +434,22 @@ connectUsingUnixSocket(const char *socket_path)
}
else
{
char errbuf[STRERROR_BUFLEN];
fprintf(stderr, "Could not set SO_PASSCRED: %s\n",
strerror_r(errno, errbuf, sizeof(errbuf)));
fprintf(stderr, "Could not set SO_PASSCRED: %s\n", strerror(errno));
close(so);
so = -1;
}
}
else
{
char errbuf[STRERROR_BUFLEN];
fprintf(stderr, "Unable to connect to MaxScale at %s: %s\n",
socket_path, strerror_r(errno, errbuf, sizeof(errbuf)));
socket_path, strerror(errno));
close(so);
so = -1;
}
}
else
{
char errbuf[STRERROR_BUFLEN];
fprintf(stderr, "Unable to create socket: %s\n",
strerror_r(errno, errbuf, sizeof(errbuf)));
fprintf(stderr, "Unable to create socket: %s\n", strerror(errno));
}
return so;
@ -505,18 +493,15 @@ connectUsingInetSocket(const char *hostname, const char *port,
}
else
{
char errbuf[STRERROR_BUFLEN];
fprintf(stderr, "Unable to connect to MaxScale at %s, %s: %s\n",
hostname, port, strerror_r(errno, errbuf, sizeof(errbuf)));
hostname, port, strerror(errno));
close(so);
so = -1;
}
}
else
{
char errbuf[STRERROR_BUFLEN];
fprintf(stderr, "Unable to create socket: %s\n",
strerror_r(errno, errbuf, sizeof(errbuf)));
fprintf(stderr, "Unable to create socket: %s\n", strerror(errno));
}
return so;
@ -532,7 +517,7 @@ connectUsingInetSocket(const char *hostname, const char *port,
static int
setipaddress(struct in_addr *a, const char *p)
{
#ifdef __USE_POSIX
struct addrinfo *ai = NULL, hint;
int rc;
struct sockaddr_in * res_addr;
@ -557,28 +542,6 @@ setipaddress(struct in_addr *a, const char *p)
return 1;
}
#else
struct hostent *h;
spinlock_acquire(&tmplock);
h = gethostbyname(p);
spinlock_release(&tmplock);
if (h == NULL)
{
if ((a->s_addr = inet_addr(p)) == -1)
{
return 0;
}
}
else
{
/* take the first one */
memcpy(a, h->h_addr, h->h_length);
return 1;
}
#endif
return 0;
}