From 4d8cd3afc05e15f393be4caf4b605c0cd520732d Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 8 Jun 2012 15:10:18 +0000 Subject: [PATCH] make librpc compatible with eglibc, unconditionally enable it for packages that need rpc support SVN-Revision: 32129 --- package/busybox/Config.in | 1 - package/librpc/Makefile | 36 +--- package/librpc/patches/100-compat_fix.patch | 203 ++++++++++++++++++++ rules.mk | 4 +- 4 files changed, 207 insertions(+), 37 deletions(-) create mode 100644 package/librpc/patches/100-compat_fix.patch diff --git a/package/busybox/Config.in b/package/busybox/Config.in index 407e95e1e760..a954a25c8ae3 100644 --- a/package/busybox/Config.in +++ b/package/busybox/Config.in @@ -21,7 +21,6 @@ config BUSYBOX_CONFIG_HUSH config BUSYBOX_USE_LIBRPC bool - depends USE_UCLIBC default y if BUSYBOX_CONFIG_FEATURE_HAVE_RPC source "package/busybox/config/Config.in" diff --git a/package/librpc/Makefile b/package/librpc/Makefile index 5a469211643c..34cedbb4ed9c 100644 --- a/package/librpc/Makefile +++ b/package/librpc/Makefile @@ -9,18 +9,7 @@ PKG_SOURCE_URL:=git://nbd.name/uclibc-rpc.git PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_VERSION:=0a2179bbc0844928f2a0ec01dba93d9b5d6d41a7 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz - -ifndef CONFIG_NATIVE_TOOLCHAIN - ifndef CONFIG_EXTERNAL_TOOLCHAIN - ifdef CONFIG_USE_UCLIBC - BUILD_LIBRPC=1 - endif - endif -endif - -ifdef BUILD_LIBRPC - CMAKE_INSTALL:=1 -endif +CMAKE_INSTALL:=1 include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk @@ -29,30 +18,11 @@ define Package/librpc SECTION:=libs CATEGORY:=Libraries TITLE:=uClibc RPC library - MDEPENDS:=@USE_UCLIBC endef -ifdef BUILD_LIBRPC - define Package/librpc/install +define Package/librpc/install $(INSTALL_DIR) $(1)/lib/ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/librpc.so $(1)/lib/ - endef -else - define Build/Prepare - endef - - define Build/Configure - endef - - define Build/Compile - endef - - define Build/Install - endef - - define Package/librpc/install - true - endef -endif +endef $(eval $(call BuildPackage,librpc)) diff --git a/package/librpc/patches/100-compat_fix.patch b/package/librpc/patches/100-compat_fix.patch new file mode 100644 index 000000000000..6040567c3162 --- /dev/null +++ b/package/librpc/patches/100-compat_fix.patch @@ -0,0 +1,203 @@ +--- a/compat.h ++++ /dev/null +@@ -1,32 +0,0 @@ +-#ifndef __UCLIBC_COMPAT_H +-#define __UCLIBC_COMPAT_H +- +-#define _XOPEN_SOURCE +-#define _GNU_SOURCE +- +-#include +-#include +- +-#undef __UCLIBC_HAS_THREADS__ +-#include +-#include +- +-#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 + #endif + #include +-#include + + + /* 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 + __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 + __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 +-#include +- + /* 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 ++#include ++ ++#ifndef __UCLIBC_HAS_THREADS__ ++#define __UCLIBC_HAS_THREADS__ ++#endif ++ ++#include ++#include ++ ++#ifdef __UCLIBC__ ++#include ++#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 diff --git a/rules.mk b/rules.mk index 73a015e7a03b..83bc62216693 100644 --- a/rules.mk +++ b/rules.mk @@ -119,10 +119,8 @@ else LIBGCC_A=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.a) LIBGCC_S=$(if $(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so),-L$(TOOLCHAIN_DIR)/lib -lgcc_s,$(LIBGCC_A)) endif -ifdef CONFIG_USE_UCLIBC LIBRPC=-lrpc -endif -LIBRPC_DEPENDS=+USE_UCLIBC:librpc +LIBRPC_DEPENDS=+librpc ifndef DUMP ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) -- 2.30.2