This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH] Unify names of all lock objects
- From: Freddie Chopin <freddie_chopin at op dot pl>
- To: newlib <newlib at sourceware dot org>
- Date: Sun, 29 Jan 2017 23:04:25 +0100
- Subject: [PATCH] Unify names of all lock objects
- Authentication-results: sourceware.org; auth=none
Hello!
I would like to propose another patch which renames lock objects. It
would be great if it could be merged before Thomas' change which
introduces retargeting of locks. I know it changes Thomas' work, but in
the next e-mail I'll send last Thomas' patch which includes my changes,
so that he won't have to do any additional work resulting from my
change.
The rationale for my change is simple - let all locks be named
consistently and let their name reflect whether they are "recursive" or
not.
Newlib with this change can be compiled without issues and works fine.
It also works fine with Thomas' patch (with my changes) applied on top.
Regards,
FCh
From 629e76fa25106d438683f34d301ff556b47d026f Mon Sep 17 00:00:00 2001
From: Freddie Chopin <freddie.chopin@gmail.com>
Date: Sun, 29 Jan 2017 10:27:17 +0100
Subject: [PATCH] Unify names of all lock objects
In preparation for the patch that would allow retargeting of locking
routines, rename all lock objects to follow this pattern:
"__<name>_[recursive_]lock_object".
Following locks were renamed:
__dd_hash_lock -> __dd_hash_lock_object
__sfp_lock -> __sfp_recursive_lock_object
__sinit_lock -> __sinit_recursive_lock_object
__atexit_lock -> __atexit_recursive_lock_object
_arc4random_mutex -> __arc4random_lock_object
__env_lock_object -> __env_recursive_lock_object
__malloc_lock_object -> __malloc_recursive_lock_object
__atexit_mutex -> __at_quick_exit_lock_object
---
newlib/libc/posix/telldir.c | 16 ++++++++--------
newlib/libc/stdio/findfp.c | 12 ++++++------
newlib/libc/stdlib/__atexit.c | 16 ++++++++--------
newlib/libc/stdlib/__call_atexit.c | 6 +++---
newlib/libc/stdlib/arc4random.h | 6 +++---
newlib/libc/stdlib/envlock.c | 6 +++---
newlib/libc/stdlib/mlock.c | 6 +++---
newlib/libc/stdlib/quick_exit.c | 6 +++---
8 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/newlib/libc/posix/telldir.c b/newlib/libc/posix/telldir.c
index d4cf4a8c1..577a78fb6 100644
--- a/newlib/libc/posix/telldir.c
+++ b/newlib/libc/posix/telldir.c
@@ -71,7 +71,7 @@ static long dd_loccnt = 1; /* Index of entry for sequential readdir's */
static struct ddloc *dd_hash[NDIRHASH]; /* Hash list heads for ddlocs */
#ifdef HAVE_DD_LOCK
-__LOCK_INIT(static, __dd_hash_lock);
+__LOCK_INIT(static, __dd_hash_lock_object);
#endif
/*
@@ -92,7 +92,7 @@ _DEFUN(telldir, (dirp),
#ifdef HAVE_DD_LOCK
__lock_acquire_recursive(dirp->dd_lock);
- __lock_acquire(__dd_hash_lock);
+ __lock_acquire(__dd_hash_lock_object);
#endif
index = dd_loccnt++;
lp->loc_index = index;
@@ -102,7 +102,7 @@ _DEFUN(telldir, (dirp),
lp->loc_next = dd_hash[LOCHASH(index)];
dd_hash[LOCHASH(index)] = lp;
#ifdef HAVE_DD_LOCK
- __lock_release(__dd_hash_lock);
+ __lock_release(__dd_hash_lock_object);
__lock_release_recursive(dirp->dd_lock);
#endif
return (index);
@@ -124,7 +124,7 @@ _DEFUN(_seekdir, (dirp, loc),
struct dirent *dp;
#ifdef HAVE_DD_LOCK
- __lock_acquire(__dd_hash_lock);
+ __lock_acquire(__dd_hash_lock_object);
#endif
if (loc != 0) {
prevlp = &dd_hash[LOCHASH(loc)];
@@ -137,7 +137,7 @@ _DEFUN(_seekdir, (dirp, loc),
}
if (lp == NULL) {
#ifdef HAVE_DD_LOCK
- __lock_release(__dd_hash_lock);
+ __lock_release(__dd_hash_lock_object);
#endif
return;
}
@@ -163,7 +163,7 @@ found:
dirp->dd_loc = 0;
}
#ifdef HAVE_DD_LOCK
- __lock_release(__dd_hash_lock);
+ __lock_release(__dd_hash_lock_object);
#endif
}
@@ -175,7 +175,7 @@ _DEFUN(_cleanupdir, (dirp),
int i;
#ifdef HAVE_DD_LOCK
- __lock_acquire(__dd_hash_lock);
+ __lock_acquire(__dd_hash_lock_object);
#endif
for (i = 0; i < NDIRHASH; ++i) {
struct ddloc head;
@@ -200,7 +200,7 @@ _DEFUN(_cleanupdir, (dirp),
dd_hash[i] = head.loc_next;
}
#ifdef HAVE_DD_LOCK
- __lock_release(__dd_hash_lock);
+ __lock_release(__dd_hash_lock_object);
#endif
}
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index 975a855c2..0cc8006d6 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -261,31 +261,31 @@ _DEFUN(__sinit, (s),
#ifndef __SINGLE_THREAD__
-__LOCK_INIT_RECURSIVE(static, __sfp_lock);
-__LOCK_INIT_RECURSIVE(static, __sinit_lock);
+__LOCK_INIT_RECURSIVE(static, __sfp_recursive_lock_object);
+__LOCK_INIT_RECURSIVE(static, __sinit_recursive_lock_object);
_VOID
_DEFUN_VOID(__sfp_lock_acquire)
{
- __lock_acquire_recursive (__sfp_lock);
+ __lock_acquire_recursive (__sfp_recursive_lock_object);
}
_VOID
_DEFUN_VOID(__sfp_lock_release)
{
- __lock_release_recursive (__sfp_lock);
+ __lock_release_recursive (__sfp_recursive_lock_object);
}
_VOID
_DEFUN_VOID(__sinit_lock_acquire)
{
- __lock_acquire_recursive (__sinit_lock);
+ __lock_acquire_recursive (__sinit_recursive_lock_object);
}
_VOID
_DEFUN_VOID(__sinit_lock_release)
{
- __lock_release_recursive (__sinit_lock);
+ __lock_release_recursive (__sinit_recursive_lock_object);
}
/* Walkable file locking routine. */
diff --git a/newlib/libc/stdlib/__atexit.c b/newlib/libc/stdlib/__atexit.c
index d07f6c122..2186b44ef 100644
--- a/newlib/libc/stdlib/__atexit.c
+++ b/newlib/libc/stdlib/__atexit.c
@@ -48,7 +48,7 @@ const void * __atexit_dummy = &__call_exitprocs;
#endif
#ifndef __SINGLE_THREAD__
-extern _LOCK_RECURSIVE_T __atexit_lock;
+extern _LOCK_RECURSIVE_T __atexit_recursive_lock_object;
#endif
#ifdef _REENT_GLOBAL_ATEXIT
@@ -74,7 +74,7 @@ _DEFUN (__register_exitproc,
register struct _atexit *p;
#ifndef __SINGLE_THREAD__
- __lock_acquire_recursive(__atexit_lock);
+ __lock_acquire_recursive(__atexit_recursive_lock_object);
#endif
p = _GLOBAL_ATEXIT;
@@ -91,7 +91,7 @@ _DEFUN (__register_exitproc,
{
#ifndef _ATEXIT_DYNAMIC_ALLOC
#ifndef __SINGLE_THREAD__
- __lock_release_recursive(__atexit_lock);
+ __lock_release_recursive(__atexit_recursive_lock_object);
#endif
return -1;
#else
@@ -100,7 +100,7 @@ _DEFUN (__register_exitproc,
if (!malloc)
{
#ifndef __SINGLE_THREAD__
- __lock_release_recursive(__atexit_lock);
+ __lock_release_recursive(__atexit_recursive_lock_object);
#endif
return -1;
}
@@ -109,7 +109,7 @@ _DEFUN (__register_exitproc,
if (p == NULL)
{
#ifndef __SINGLE_THREAD__
- __lock_release_recursive(__atexit_lock);
+ __lock_release_recursive(__atexit_recursive_lock_object);
#endif
return -1;
}
@@ -133,7 +133,7 @@ _DEFUN (__register_exitproc,
{
#ifndef _ATEXIT_DYNAMIC_ALLOC
#ifndef __SINGLE_THREAD__
- __lock_release_recursive(__atexit_lock);
+ __lock_release_recursive(__atexit_recursive_lock_object);
#endif
return -1;
#else
@@ -143,7 +143,7 @@ _DEFUN (__register_exitproc,
if (args == NULL)
{
#ifndef __SINGLE_THREAD__
- __lock_release(__atexit_lock);
+ __lock_release(__atexit_recursive_lock_object);
#endif
return -1;
}
@@ -163,7 +163,7 @@ _DEFUN (__register_exitproc,
}
p->_fns[p->_ind++] = fn;
#ifndef __SINGLE_THREAD__
- __lock_release_recursive(__atexit_lock);
+ __lock_release_recursive(__atexit_recursive_lock_object);
#endif
return 0;
}
diff --git a/newlib/libc/stdlib/__call_atexit.c b/newlib/libc/stdlib/__call_atexit.c
index 1e6e71044..8be969cd2 100644
--- a/newlib/libc/stdlib/__call_atexit.c
+++ b/newlib/libc/stdlib/__call_atexit.c
@@ -11,7 +11,7 @@
/* Make this a weak reference to avoid pulling in free. */
void free(void *) _ATTRIBUTE((__weak__));
-__LOCK_INIT_RECURSIVE(, __atexit_lock);
+__LOCK_INIT_RECURSIVE(, __atexit_recursive_lock_object);
#ifdef _REENT_GLOBAL_ATEXIT
struct _atexit *_global_atexit = _NULL;
@@ -75,7 +75,7 @@ _DEFUN (__call_exitprocs, (code, d),
#ifndef __SINGLE_THREAD__
- __lock_acquire_recursive(__atexit_lock);
+ __lock_acquire_recursive(__atexit_recursive_lock_object);
#endif
restart:
@@ -157,7 +157,7 @@ _DEFUN (__call_exitprocs, (code, d),
#endif
}
#ifndef __SINGLE_THREAD__
- __lock_release_recursive(__atexit_lock);
+ __lock_release_recursive(__atexit_recursive_lock_object);
#endif
}
diff --git a/newlib/libc/stdlib/arc4random.h b/newlib/libc/stdlib/arc4random.h
index 54bcbe8ae..ee61a2272 100644
--- a/newlib/libc/stdlib/arc4random.h
+++ b/newlib/libc/stdlib/arc4random.h
@@ -39,11 +39,11 @@
#ifndef _ARC4_LOCK_INIT
-#define _ARC4_LOCK_INIT __LOCK_INIT(static, _arc4random_mutex);
+#define _ARC4_LOCK_INIT __LOCK_INIT(static, __arc4random_lock_object);
-#define _ARC4_LOCK() __lock_acquire(_arc4random_mutex)
+#define _ARC4_LOCK() __lock_acquire(__arc4random_lock_object)
-#define _ARC4_UNLOCK() __lock_release(_arc4random_mutex)
+#define _ARC4_UNLOCK() __lock_release(__arc4random_lock_object)
#endif /* _ARC4_LOCK_INIT */
diff --git a/newlib/libc/stdlib/envlock.c b/newlib/libc/stdlib/envlock.c
index ce7ae2e26..da5e7a49b 100644
--- a/newlib/libc/stdlib/envlock.c
+++ b/newlib/libc/stdlib/envlock.c
@@ -39,7 +39,7 @@ that it already holds.
#include <sys/lock.h>
#ifndef __SINGLE_THREAD__
-__LOCK_INIT_RECURSIVE(static, __env_lock_object);
+__LOCK_INIT_RECURSIVE(static, __env_recursive_lock_object);
#endif
void
@@ -47,7 +47,7 @@ __env_lock (ptr)
struct _reent *ptr;
{
#ifndef __SINGLE_THREAD__
- __lock_acquire_recursive (__env_lock_object);
+ __lock_acquire_recursive (__env_recursive_lock_object);
#endif
}
@@ -56,6 +56,6 @@ __env_unlock (ptr)
struct _reent *ptr;
{
#ifndef __SINGLE_THREAD__
- __lock_release_recursive (__env_lock_object);
+ __lock_release_recursive (__env_recursive_lock_object);
#endif
}
diff --git a/newlib/libc/stdlib/mlock.c b/newlib/libc/stdlib/mlock.c
index 888c986a9..28d5ce43d 100644
--- a/newlib/libc/stdlib/mlock.c
+++ b/newlib/libc/stdlib/mlock.c
@@ -40,7 +40,7 @@ that it already holds.
#include <sys/lock.h>
#ifndef __SINGLE_THREAD__
-__LOCK_INIT_RECURSIVE(static, __malloc_lock_object);
+__LOCK_INIT_RECURSIVE(static, __malloc_recursive_lock_object);
#endif
void
@@ -48,7 +48,7 @@ __malloc_lock (ptr)
struct _reent *ptr;
{
#ifndef __SINGLE_THREAD__
- __lock_acquire_recursive (__malloc_lock_object);
+ __lock_acquire_recursive (__malloc_recursive_lock_object);
#endif
}
@@ -57,7 +57,7 @@ __malloc_unlock (ptr)
struct _reent *ptr;
{
#ifndef __SINGLE_THREAD__
- __lock_release_recursive (__malloc_lock_object);
+ __lock_release_recursive (__malloc_recursive_lock_object);
#endif
}
diff --git a/newlib/libc/stdlib/quick_exit.c b/newlib/libc/stdlib/quick_exit.c
index 34f41b737..e3bdee770 100644
--- a/newlib/libc/stdlib/quick_exit.c
+++ b/newlib/libc/stdlib/quick_exit.c
@@ -44,7 +44,7 @@ struct quick_exit_handler {
/**
* Lock protecting the handlers list.
*/
-__LOCK_INIT(static, __atexit_mutex);
+__LOCK_INIT(static, __at_quick_exit_lock_object);
/**
* Stack of cleanup handlers. These will be invoked in reverse order when
*/
@@ -60,10 +60,10 @@ at_quick_exit(void (*func)(void))
if (NULL == h)
return (1);
h->cleanup = func;
- __lock_acquire(__atexit_mutex);
+ __lock_acquire(__at_quick_exit_lock_object);
h->next = handlers;
handlers = h;
- __lock_release(__atexit_mutex);
+ __lock_release(__at_quick_exit_lock_object);
return (0);
}
--
2.11.0