librpc: update to the latest version, fixes musl compatibility issues (#19445)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 45366
owl
Felix Fietkau 2015-04-10 20:02:55 +00:00
parent e4bf2d73f6
commit baef360adb
3 changed files with 2 additions and 546 deletions

View File

@ -1,13 +1,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=librpc
PKG_VERSION:=0.9.32-rc2
PKG_VERSION:=2015-04-10
PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=git://nbd.name/uclibc-rpc.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=0a2179bbc0844928f2a0ec01dba93d9b5d6d41a7
PKG_SOURCE_VERSION:=308e9964bfb623773dc0dcc99ef9d18d1551d6ae
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
CMAKE_INSTALL:=1
PKG_USE_MIPS16:=0

View File

@ -1,214 +0,0 @@
--- a/compat.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __UCLIBC_COMPAT_H
-#define __UCLIBC_COMPAT_H
-
-#define _XOPEN_SOURCE
-#define _GNU_SOURCE
-
-#include <features.h>
-#include <errno.h>
-
-#undef __UCLIBC_HAS_THREADS__
-#include <bits/uClibc_mutex.h>
-#include <sys/poll.h>
-
-#if 0
-#undef __UCLIBC_MUTEX_LOCK
-#undef __UCLIBC_MUTEX_UNLOCK
-#define __UCLIBC_MUTEX_LOCK(M) pthread_mutex_lock(&(M))
-#define __UCLIBC_MUTEX_UNLOCK(M) pthread_mutex_unlock(&(M))
-#endif
-
-#define smallint int
-
-#define _(...) __VA_ARGS__
-#define internal_function
-#define attribute_hidden
-#define attribute_unused
-#define attribute_noreturn
-#define libc_hidden_def(...)
-
-#define __set_errno(_val) errno = _val
-
-#endif
--- a/rcmd.c
+++ b/rcmd.c
@@ -85,7 +85,6 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (
#include <wchar.h>
#endif
#include <sys/uio.h>
-#include <bits/uClibc_alloc.h>
/* some forward declarations */
--- a/create_xid.c
+++ b/create_xid.c
@@ -28,7 +28,6 @@
/* The RPC code is not threadsafe, but new code should be threadsafe. */
-#include <bits/uClibc_mutex.h>
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
static smallint is_initialized;
--- a/getrpcent.c
+++ b/getrpcent.c
@@ -257,7 +257,6 @@ static struct rpcent *interpret(register
#if defined(__UCLIBC_HAS_REENTRANT_RPC__)
-#include <bits/uClibc_mutex.h>
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.6)
PROJECT(rpc C)
-ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -I. -include compat.h)
+ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -I. -include rpc/compat.h)
FILE(GLOB SOURCES *.c)
--- a/rpc/types.h
+++ b/rpc/types.h
@@ -33,6 +33,8 @@
#ifndef _RPC_TYPES_H
#define _RPC_TYPES_H 1
+#include "compat.h"
+
#ifdef _LIBC
/* Some adjustments to make the libc source from glibc
* compile more easily with uClibc... */
--- a/clnt_perror.c
+++ b/clnt_perror.c
@@ -246,7 +246,7 @@ clnt_sperror (CLIENT * rpch, const char
case RPC_CANTSEND:
case RPC_CANTRECV:
- __glibc_strerror_r (e.re_errno, chrbuf, sizeof chrbuf);
+ strerror_r (e.re_errno, chrbuf, sizeof chrbuf);
len = sprintf (str, "; errno = %s", chrbuf);
str += len;
break;
@@ -336,7 +336,7 @@ clnt_spcreateerror (const char *msg)
(void) strcpy(cp, " - ");
cp += strlen(cp);
- __glibc_strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
+ strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
(void) strcpy(cp, chrbuf);
cp += strlen(cp);
break;
--- a/rpc_thread.c
+++ b/rpc_thread.c
@@ -13,9 +13,6 @@
#ifdef __UCLIBC_HAS_THREADS__
-#include <bits/libc-tsd.h>
-#include <bits/libc-lock.h>
-
/* Variable used in non-threaded applications or for the first thread. */
static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem;
__libc_tsd_define (, RPC_VARS)
@@ -52,16 +49,17 @@ rpc_thread_multi (void)
__libc_tsd_set (RPC_VARS, &__libc_tsd_RPC_VARS_mem);
}
+__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
struct rpc_thread_variables attribute_hidden *
__rpc_thread_variables (void)
{
- __libc_once_define (static, once);
struct rpc_thread_variables *tvp;
+ __UCLIBC_MUTEX_LOCK(mylock);
tvp = __libc_tsd_get (RPC_VARS);
if (tvp == NULL) {
- __libc_once (once, rpc_thread_multi);
+ rpc_thread_multi();
tvp = __libc_tsd_get (RPC_VARS);
if (tvp == NULL) {
tvp = calloc (1, sizeof *tvp);
@@ -71,6 +69,7 @@ __rpc_thread_variables (void)
tvp = __libc_tsd_get (RPC_VARS);
}
}
+ __UCLIBC_MUTEX_UNLOCK(mylock);
return tvp;
}
--- /dev/null
+++ b/rpc/compat.h
@@ -0,0 +1,53 @@
+#ifndef __UCLIBC_COMPAT_H
+#define __UCLIBC_COMPAT_H
+
+#define _XOPEN_SOURCE
+#define _GNU_SOURCE
+
+#include <features.h>
+#include <errno.h>
+
+#ifndef __UCLIBC_HAS_THREADS__
+#define __UCLIBC_HAS_THREADS__
+#endif
+
+#include <sys/poll.h>
+#include <pthread.h>
+
+#ifdef __UCLIBC__
+#include <bits/libc-lock.h>
+#else
+#undef __UCLIBC_MUTEX_STATIC
+#undef __UCLIBC_MUTEX_LOCK
+#undef __UCLIBC_MUTEX_UNLOCK
+#define __UCLIBC_MUTEX_STATIC(M,I) static pthread_mutex_t M = I
+#define __UCLIBC_MUTEX_LOCK(M) pthread_mutex_lock(&(M))
+#define __UCLIBC_MUTEX_UNLOCK(M) pthread_mutex_unlock(&(M))
+#endif
+
+#define smallint int
+
+#define _(...) __VA_ARGS__
+#define internal_function
+#define attribute_hidden
+#define attribute_unused
+#define attribute_noreturn
+#define libc_hidden_def(...)
+
+#ifndef libc_hidden_proto
+#define libc_hidden_proto(name, attrs...)
+#endif
+
+#define __set_errno(_val) errno = _val
+
+# define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
+
+# define __libc_tsd_define(CLASS, KEY) \
+ CLASS __thread void *__libc_tsd_##KEY attribute_tls_model_ie;
+
+# define __libc_tsd_address(KEY) (&__libc_tsd_##KEY)
+# define __libc_tsd_get(KEY) (__libc_tsd_##KEY)
+# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE))
+
+
+#endif
--- a/rpc/netdb.h
+++ b/rpc/netdb.h
@@ -41,6 +41,8 @@
#define __need_size_t
#include <stddef.h>
+#include "types.h"
+
__BEGIN_DECLS
struct rpcent

View File

@ -1,330 +0,0 @@
--- a/rpc/types.h
+++ b/rpc/types.h
@@ -79,22 +79,6 @@ typedef unsigned long rpcport_t;
#include <sys/types.h>
#endif
-#ifndef __u_char_defined
-typedef __u_char u_char;
-typedef __u_short u_short;
-typedef __u_int u_int;
-typedef __u_long u_long;
-typedef __quad_t quad_t;
-typedef __u_quad_t u_quad_t;
-typedef __fsid_t fsid_t;
-# define __u_char_defined
-#endif
-#ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-# define __daddr_t_defined
-#endif
-
#include <sys/time.h>
#include <sys/param.h>
--- a/bindresvport.c
+++ b/bindresvport.c
@@ -39,6 +39,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netdb.h>
/*
--- a/rpc/netdb.h
+++ b/rpc/netdb.h
@@ -37,12 +37,17 @@
#define _RPC_NETDB_H 1
#include <features.h>
+#include <netdb.h>
#define __need_size_t
#include <stddef.h>
#include "types.h"
+#ifndef NETDB_INTERNAL
+#define NETDB_INTERNAL -1
+#endif
+
__BEGIN_DECLS
struct rpcent
--- a/create_xid.c
+++ b/create_xid.c
@@ -31,7 +31,6 @@
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
static smallint is_initialized;
-static struct drand48_data __rpc_lrand48_data;
u_long _create_xid (void) attribute_hidden;
u_long _create_xid (void)
@@ -45,11 +44,11 @@ u_long _create_xid (void)
struct timeval now;
gettimeofday (&now, (struct timezone *) 0);
- srand48_r (now.tv_sec ^ now.tv_usec, &__rpc_lrand48_data);
+ srand48 (now.tv_sec ^ now.tv_usec);
is_initialized = 1;
}
- lrand48_r (&__rpc_lrand48_data, &res);
+ res = lrand48();
__UCLIBC_MUTEX_UNLOCK(mylock);
--- a/clnt_tcp.c
+++ b/clnt_tcp.c
@@ -58,7 +58,7 @@ static char sccsid[] = "@(#)clnt_tcp.c 1
#include <stdio.h>
#include <unistd.h>
#include <rpc/rpc.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/socket.h>
#include <rpc/pmap_clnt.h>
#ifdef USE_IN_LIBIO
--- a/clnt_udp.c
+++ b/clnt_udp.c
@@ -45,7 +45,7 @@ static char sccsid[] = "@(#)clnt_udp.c 1
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <rpc/clnt.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netdb.h>
--- a/clnt_unix.c
+++ b/clnt_unix.c
@@ -55,7 +55,7 @@
#include <unistd.h>
#include <rpc/rpc.h>
#include <sys/uio.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/socket.h>
#include <rpc/pmap_clnt.h>
#ifdef USE_IN_LIBIO
--- a/pmap_rmt.c
+++ b/pmap_rmt.c
@@ -48,7 +48,7 @@ static char sccsid[] = "@(#)pmap_rmt.c 1
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
#include <rpc/pmap_rmt.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/socket.h>
#include <stdio.h>
#include <errno.h>
--- a/rcmd.c
+++ b/rcmd.c
@@ -62,9 +62,10 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (
#define __UCLIBC_HIDE_DEPRECATED__
#include <features.h>
#include <sys/param.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -86,6 +87,11 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (
#endif
#include <sys/uio.h>
+#ifndef _PATH_HEQUIV
+#define _PATH_HEQUIV "/etc/hosts.equiv"
+#endif
+
+int rresvport(int *alport);
/* some forward declarations */
static int __ivaliduser2(FILE *hostf, u_int32_t raddr,
@@ -106,7 +112,7 @@ int rcmd(char **ahost, u_short rport, co
struct hostent *hp;
struct sockaddr_in sin, from;
struct pollfd pfd[2];
- int32_t oldmask;
+ sigset_t sig, osig;
pid_t pid;
int s, lport, timo;
char c;
@@ -145,7 +151,9 @@ int rcmd(char **ahost, u_short rport, co
pfd[1].events = POLLIN;
*ahost = hp->h_name;
- oldmask = sigblock(sigmask(SIGURG)); /* __sigblock */
+ sigemptyset(&sig);
+ sigaddset(&sig, SIGURG);
+ sigprocmask(SIG_BLOCK, &sig, &osig);
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
s = rresvport(&lport);
if (s < 0) {
@@ -154,7 +162,7 @@ int rcmd(char **ahost, u_short rport, co
"rcmd: socket: All ports in use\n");
else
(void)fprintf(stderr, "rcmd: socket: %m\n");
- sigsetmask(oldmask); /* sigsetmask */
+ sigprocmask(SIG_SETMASK, &osig, NULL);
return -1;
}
fcntl(s, F_SETOWN, pid);
@@ -189,7 +197,7 @@ int rcmd(char **ahost, u_short rport, co
continue;
}
(void)fprintf(stderr, "%s: %m\n", hp->h_name);
- sigsetmask(oldmask); /* __sigsetmask */
+ sigprocmask(SIG_SETMASK, &osig, NULL);
return -1;
}
lport--;
@@ -256,14 +264,14 @@ int rcmd(char **ahost, u_short rport, co
}
goto bad2;
}
- sigsetmask(oldmask);
+ sigprocmask(SIG_SETMASK, &osig, NULL);
return s;
bad2:
if (lport)
(void)close(*fd2p);
bad:
(void)close(s);
- sigsetmask(oldmask);
+ sigprocmask(SIG_SETMASK, &osig, NULL);
return -1;
}
--- a/rpc/compat.h
+++ b/rpc/compat.h
@@ -11,7 +11,7 @@
#define __UCLIBC_HAS_THREADS__
#endif
-#include <sys/poll.h>
+#include <poll.h>
#include <pthread.h>
#ifdef __UCLIBC__
--- a/rpc_commondata.c
+++ b/rpc_commondata.c
@@ -27,7 +27,7 @@
* Mountain View, California 94043
*/
#include <rpc/rpc.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/select.h>
#undef svc_fdset
--- a/rtime.c
+++ b/rtime.c
@@ -51,13 +51,16 @@ static char sccsid[] = "@(#)rtime.c 2.2
#include <rpc/rpc.h>
#include <rpc/clnt.h>
#include <sys/types.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <rpc/auth_des.h>
#include <errno.h>
#include <netinet/in.h>
+#ifndef IPPORT_TIMESERVER
+#define IPPORT_TIMESERVER 37
+#endif
#define NYEARS (u_long)(1970 - 1900)
#define TOFFSET (u_long)(60*60*24*(365*NYEARS + (NYEARS/4)))
--- a/svc.c
+++ b/svc.c
@@ -44,7 +44,7 @@
#include "rpc_private.h"
#include <rpc/svc.h>
#include <rpc/pmap_clnt.h>
-#include <sys/poll.h>
+#include <poll.h>
/* used by svc_[max_]pollfd */
/* used by svc_fdset */
--- a/svc_run.c
+++ b/svc_run.c
@@ -36,7 +36,7 @@
#include <errno.h>
#include <unistd.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <rpc/rpc.h>
/* used by svc_[max_]pollfd */
--- a/svc_tcp.c
+++ b/svc_tcp.c
@@ -49,7 +49,7 @@ static char sccsid[] = "@(#)svc_tcp.c 1.
#include <string.h>
#include <rpc/rpc.h>
#include <sys/socket.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <errno.h>
#include <stdlib.h>
--- a/svc_unix.c
+++ b/svc_unix.c
@@ -47,7 +47,7 @@
#include <rpc/svc.h>
#include <sys/socket.h>
#include <sys/uio.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <errno.h>
#include <stdlib.h>
--- a/sa_len.c
+++ b/sa_len.c
@@ -20,9 +20,9 @@
#include <features.h>
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netipx/ipx.h>
#include <sys/un.h>
#if 0
+#include <netipx/ipx.h>
#include <netash/ash.h>
#include <netatalk/at.h>
#include <netax25/ax25.h>
@@ -49,13 +49,13 @@ int __libc_sa_len (sa_family_t af)
return sizeof (struct sockaddr_rose);
case AF_PACKET:
return sizeof (struct sockaddr_ll);
+ case AF_IPX:
+ return sizeof (struct sockaddr_ipx);
#endif
case AF_INET:
return sizeof (struct sockaddr_in);
case AF_INET6:
return sizeof (struct sockaddr_in6);
- case AF_IPX:
- return sizeof (struct sockaddr_ipx);
case AF_LOCAL:
return sizeof (struct sockaddr_un);
}
--- a/xdr_float.c
+++ b/xdr_float.c
@@ -55,7 +55,7 @@ static char sccsid[] = "@(#)xdr_float.c
* This routine works on Suns (Sky / 68000's) and Vaxen.
*/
-#define LSW (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
+#define LSW (__BYTE_ORDER == __BIG_ENDIAN)
#ifdef vax