* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
* program developed by the user.
- *
+ *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
+ *
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
- *
+ *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
- *
+ *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
- *
+ *
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
#if defined(__UCLIBC_HAS_REENTRANT_RPC__)
-#if defined(__UCLIBC_HAS_THREADS__)
-# include <pthread.h>
-static pthread_mutex_t rpcdata_lock = PTHREAD_MUTEX_INITIALIZER;
-#endif
-#define LOCK __pthread_mutex_lock(&rpcdata_lock)
-#define UNLOCK __pthread_mutex_unlock(&rpcdata_lock)
+#include <bits/uClibc_mutex.h>
+__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+
-static int __copy_rpcent(struct rpcent *r, struct rpcent *result_buf, char *buffer,
+static int __copy_rpcent(struct rpcent *r, struct rpcent *result_buf, char *buffer,
size_t buflen, struct rpcent **result)
{
size_t i, s;
result_buf->r_number = r->r_number;
- /* copy the aliases ... need to not only copy the alias strings,
+ /* copy the aliases ... need to not only copy the alias strings,
* but the array of pointers to the alias strings */
i = 0;
while (r->r_aliases[i++]) ;
size_t buflen, struct rpcent **result)
{
int ret;
- LOCK;
+ __UCLIBC_MUTEX_LOCK(mylock);
ret = __copy_rpcent(getrpcbynumber(number), result_buf, buffer, buflen, result);
- UNLOCK;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
return ret;
}
size_t buflen, struct rpcent **result)
{
int ret;
- LOCK;
+ __UCLIBC_MUTEX_LOCK(mylock);
ret = __copy_rpcent(getrpcbyname(name), result_buf, buffer, buflen, result);
- UNLOCK;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
return ret;
}
-int getrpcent_r(struct rpcent *result_buf, char *buffer,
+int getrpcent_r(struct rpcent *result_buf, char *buffer,
size_t buflen, struct rpcent **result)
{
int ret;
- LOCK;
+ __UCLIBC_MUTEX_LOCK(mylock);
ret = __copy_rpcent(getrpcent(), result_buf, buffer, buflen, result);
- UNLOCK;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
return ret;
}
FILE *_stdio_openlist = _stdio_streams;
# ifdef __UCLIBC_HAS_THREADS__
-pthread_mutex_t _stdio_openlist_add_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+__UCLIBC_MUTEX_INIT(_stdio_openlist_add_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
#ifdef __STDIO_BUFFERS
-pthread_mutex_t _stdio_openlist_del_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+__UCLIBC_MUTEX_INIT(_stdio_openlist_del_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
volatile int _stdio_openlist_use_count = 0;
int _stdio_openlist_del_count = 0;
#endif
/* 2 if threading not initialized and 0 otherwise; */
int _stdio_user_locking = 2;
-void attribute_hidden __stdio_init_mutex(pthread_mutex_t *m)
+void attribute_hidden __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m)
{
- static const pthread_mutex_t __stdio_mutex_initializer
- = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+ const __UCLIBC_MUTEX_STATIC(__stdio_mutex_initializer,
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
memcpy(m, &__stdio_mutex_initializer, sizeof(__stdio_mutex_initializer));
}
/* First, make sure the open file list is unlocked. If it was
* locked, then I suppose there is a chance that a pointer in the
* chain might be corrupt due to a partial store.
- */
+ */
__stdio_init_mutex(&_stdio_openlist_add_lock);
#warning check
#ifdef __STDIO_BUFFERS
__STDIO_STREAM_DISABLE_PUTC(ptr);
__STDIO_STREAM_INIT_BUFREAD_BUFPOS(ptr);
}
-
+
ptr->__user_locking = 1; /* Set locking mode to "by caller". */
__stdio_init_mutex(&ptr->__lock); /* Shouldn't be necessary, but... */
}
/* On multi-threaded systems, the heap includes a lock. */
#ifdef __UCLIBC_HAS_THREADS__
-# include <pthread.h>
+# include <bits/uClibc_mutex.h>
# define HEAP_USE_LOCKING
#endif
/* A lock that can be used by callers to control access to the heap.
The heap code _does not_ use this lock, it's merely here for the
convenience of users! */
- pthread_mutex_t lock;
+ __UCLIBC_MUTEX_TYPE lock;
#endif
};
extern void __heap_check (struct heap *heap, const char *str);
-#define __heap_lock(heap) __pthread_mutex_lock (&(heap)->lock)
-#define __heap_unlock(heap) __pthread_mutex_unlock (&(heap)->lock)
+#define __heap_lock(heap) __UCLIBC_MUTEX_LOCK (&(heap)->lock)
+#define __heap_unlock(heap) __UCLIBC_MUTEX_UNLOCK (&(heap)->lock)
/* Delete the free-area FA from HEAP. */
/* Locking for multithreaded apps. */
#ifdef __UCLIBC_HAS_THREADS__
-# include <pthread.h>
+# include <bits/uClibc_mutex.h>
# define MALLOC_USE_LOCKING
-typedef pthread_mutex_t malloc_mutex_t;
+typedef __UCLIBC_MUTEX_TYPE malloc_mutex_t;
# define MALLOC_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
# ifdef MALLOC_USE_SBRK
things will break if these multiple calls are interleaved with another
thread's use of sbrk!). */
extern malloc_mutex_t __malloc_sbrk_lock;
-# define __malloc_lock_sbrk() __pthread_mutex_lock (&__malloc_sbrk_lock)
-# define __malloc_unlock_sbrk() __pthread_mutex_unlock (&__malloc_sbrk_lock)
+# define __malloc_lock_sbrk() __UCLIBC_MUTEX_LOCK (&__malloc_sbrk_lock)
+# define __malloc_unlock_sbrk() __UCLIBC_MUTEX_UNLOCK (&__malloc_sbrk_lock)
# endif /* MALLOC_USE_SBRK */
#else /* !__UCLIBC_HAS_THREADS__ */