4 -#ifndef __UCLIBC_COMPAT_H
5 -#define __UCLIBC_COMPAT_H
10 -#include <features.h>
13 -#undef __UCLIBC_HAS_THREADS__
14 -#include <bits/uClibc_mutex.h>
15 -#include <sys/poll.h>
18 -#undef __UCLIBC_MUTEX_LOCK
19 -#undef __UCLIBC_MUTEX_UNLOCK
20 -#define __UCLIBC_MUTEX_LOCK(M) pthread_mutex_lock(&(M))
21 -#define __UCLIBC_MUTEX_UNLOCK(M) pthread_mutex_unlock(&(M))
26 -#define _(...) __VA_ARGS__
27 -#define internal_function
28 -#define attribute_hidden
29 -#define attribute_unused
30 -#define attribute_noreturn
31 -#define libc_hidden_def(...)
33 -#define __set_errno(_val) errno = _val
38 @@ -85,7 +85,6 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (
42 -#include <bits/uClibc_alloc.h>
45 /* some forward declarations */
50 /* The RPC code is not threadsafe, but new code should be threadsafe. */
52 -#include <bits/uClibc_mutex.h>
53 __UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
55 static smallint is_initialized;
58 @@ -257,7 +257,6 @@ static struct rpcent *interpret(register
60 #if defined(__UCLIBC_HAS_REENTRANT_RPC__)
62 -#include <bits/uClibc_mutex.h>
63 __UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
69 cmake_minimum_required(VERSION 2.6)
72 -ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -I. -include compat.h)
73 +ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -I. -include rpc/compat.h)
75 FILE(GLOB SOURCES *.c)
81 #define _RPC_TYPES_H 1
86 /* Some adjustments to make the libc source from glibc
87 * compile more easily with uClibc... */
90 @@ -246,7 +246,7 @@ clnt_sperror (CLIENT * rpch, const char
94 - __glibc_strerror_r (e.re_errno, chrbuf, sizeof chrbuf);
95 + strerror_r (e.re_errno, chrbuf, sizeof chrbuf);
96 len = sprintf (str, "; errno = %s", chrbuf);
99 @@ -336,7 +336,7 @@ clnt_spcreateerror (const char *msg)
100 (void) strcpy(cp, " - ");
103 - __glibc_strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
104 + strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
105 (void) strcpy(cp, chrbuf);
112 #ifdef __UCLIBC_HAS_THREADS__
114 -#include <bits/libc-tsd.h>
115 -#include <bits/libc-lock.h>
117 /* Variable used in non-threaded applications or for the first thread. */
118 static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem;
119 __libc_tsd_define (, RPC_VARS)
120 @@ -52,16 +49,17 @@ rpc_thread_multi (void)
121 __libc_tsd_set (RPC_VARS, &__libc_tsd_RPC_VARS_mem);
124 +__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
126 struct rpc_thread_variables attribute_hidden *
127 __rpc_thread_variables (void)
129 - __libc_once_define (static, once);
130 struct rpc_thread_variables *tvp;
132 + __UCLIBC_MUTEX_LOCK(mylock);
133 tvp = __libc_tsd_get (RPC_VARS);
135 - __libc_once (once, rpc_thread_multi);
136 + rpc_thread_multi();
137 tvp = __libc_tsd_get (RPC_VARS);
139 tvp = calloc (1, sizeof *tvp);
140 @@ -71,6 +69,7 @@ __rpc_thread_variables (void)
141 tvp = __libc_tsd_get (RPC_VARS);
144 + __UCLIBC_MUTEX_UNLOCK(mylock);
151 +#ifndef __UCLIBC_COMPAT_H
152 +#define __UCLIBC_COMPAT_H
154 +#define _XOPEN_SOURCE
157 +#include <features.h>
160 +#ifndef __UCLIBC_HAS_THREADS__
161 +#define __UCLIBC_HAS_THREADS__
164 +#include <sys/poll.h>
165 +#include <pthread.h>
168 +#include <bits/libc-lock.h>
170 +#undef __UCLIBC_MUTEX_STATIC
171 +#undef __UCLIBC_MUTEX_LOCK
172 +#undef __UCLIBC_MUTEX_UNLOCK
173 +#define __UCLIBC_MUTEX_STATIC(M,I) static pthread_mutex_t M = I
174 +#define __UCLIBC_MUTEX_LOCK(M) pthread_mutex_lock(&(M))
175 +#define __UCLIBC_MUTEX_UNLOCK(M) pthread_mutex_unlock(&(M))
178 +#define smallint int
180 +#define _(...) __VA_ARGS__
181 +#define internal_function
182 +#define attribute_hidden
183 +#define attribute_unused
184 +#define attribute_noreturn
185 +#define libc_hidden_def(...)
187 +#ifndef libc_hidden_proto
188 +#define libc_hidden_proto(name, attrs...)
191 +#define __set_errno(_val) errno = _val
193 +# define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
195 +# define __libc_tsd_define(CLASS, KEY) \
196 + CLASS __thread void *__libc_tsd_##KEY attribute_tls_model_ie;
198 +# define __libc_tsd_address(KEY) (&__libc_tsd_##KEY)
199 +# define __libc_tsd_get(KEY) (__libc_tsd_##KEY)
200 +# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE))