diff options
author | Ulrich Drepper <[email protected]> | 2008-08-16 03:09:13 +0000 |
---|---|---|
committer | Ulrich Drepper <[email protected]> | 2008-08-16 03:09:13 +0000 |
commit | d56e232fb8f8cd97a336ed612c89145ec121f785 (patch) | |
tree | 5bd8fe5f1f73bb258eecd2cd4dae5c30a33a016e /libelf/gelf_getehdr.c | |
parent | 1d8bb25cac06b5af57f8733e5ea7a068a79edfe0 (diff) |
propagate from branch 'com.redhat.elfutils.pmachata.threads' (head 8bd3bc10eb015c96f7bafcc6a22c973620b57dd8)
to branch 'com.redhat.elfutils' (head c5a11b6b3329382f1b5ffd0020f0d93c64176f20)
Diffstat (limited to 'libelf/gelf_getehdr.c')
-rw-r--r-- | libelf/gelf_getehdr.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/libelf/gelf_getehdr.c b/libelf/gelf_getehdr.c index f56d65a9..ddc77072 100644 --- a/libelf/gelf_getehdr.c +++ b/libelf/gelf_getehdr.c @@ -61,9 +61,10 @@ GElf_Ehdr * -gelf_getehdr (elf, dest) +__gelf_getehdr_internal (elf, dest, locked) Elf *elf; GElf_Ehdr *dest; + lockstat_t locked; { GElf_Ehdr *result = NULL; @@ -76,7 +77,8 @@ gelf_getehdr (elf, dest) return NULL; } - rwlock_rdlock (elf->lock); + if (locked == LS_UNLOCKED) + RWLOCK_RDLOCK (elf->lock); /* The following is an optimization: the ehdr element is at the same position in both the elf32 and elf64 structure. */ @@ -114,8 +116,19 @@ gelf_getehdr (elf, dest) else result = memcpy (dest, elf->state.elf64.ehdr, sizeof (*dest)); - rwlock_unlock (elf->lock); + if (locked == LS_UNLOCKED) + RWLOCK_UNLOCK (elf->lock); return result; } -INTDEF(gelf_getehdr) + +GElf_Ehdr * +gelf_getehdr (elf, dest) + Elf *elf; + GElf_Ehdr *dest; +{ + if (elf == NULL) + return NULL; + + return __gelf_getehdr_internal (elf, dest, LS_UNLOCKED); +} |