This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] [portability] avoid nested functions
- From: Mike Frysinger <vapier at gentoo dot org>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Thu, 19 Sep 2013 15:38:00 -0400
- Subject: [PATCH] [portability] avoid nested functions
Trying to build with clang fails due to the use of a small nested
function. Change it to a macro instead.
I don't expect this to be merged into the main git tree, but it'd
be nice if it could be included in the portability patchset.
URL: https://bugs.gentoo.org/451986
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
libelf/elf_begin.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index b9d5cea..11e3131 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -1011,18 +1011,17 @@ elf_begin (fildes, cmd, ref)
return NULL;
}
- Elf *lock_dup_elf ()
- {
- /* We need wrlock to dup an archive. */
- if (ref->kind == ELF_K_AR)
- {
- rwlock_unlock (ref->lock);
- rwlock_wrlock (ref->lock);
- }
-
- /* Duplicate the descriptor. */
- return dup_elf (fildes, cmd, ref);
- }
+#define lock_dup_elf() \
+ ({ \
+ /* We need wrlock to dup an archive. */ \
+ if (ref->kind == ELF_K_AR) \
+ { \
+ rwlock_unlock (ref->lock); \
+ rwlock_wrlock (ref->lock); \
+ } \
+ /* Duplicate the descriptor. */ \
+ return dup_elf (fildes, cmd, ref); \
+ })
switch (cmd)
{
--
1.8.3.2