blob: 346a56a9ad83dc838eca3f9f99db86a20f49072f [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From 630086cf1b3fba71822319a268d3711734cd6aa8 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 31 Jan 2019 12:56:13 -0800
4Subject: [PATCH] linux-port: Rename pthread_mutex_t variable 'lock'
5
6lock is also used by libc++ in std namespace and using it here causes
7clang to fail e.g.
8
9dibbler-client.cpp:47:25: error: reference to 'lock' is ambiguous
10 pthread_mutex_lock(&lock);
11 ^
12../../../../../../../workspace/sources/dibbler/Port-linux/dibbler-client.cpp:29:26: note: candidate found by name lookup is 'lock'
13extern ::pthread_mutex_t lock;
14 ^
15/mnt/a/yoe/build/tmp/work/aarch64-yoe-linux/dibbler/1.0.1+1.0.2RC1+gitc4b0ed52e751da7823dd9a36e91f93a6310e5525-r0/recipe-sysroot/usr/include/c++/v1/mutex:446:1: note: candidate found by name lookup is 'std::__1::lock'
16lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
17
18Upstream-Status: Submitted [https://github.com/tomaszmrugalski/dibbler/pull/37]
19
20Signed-off-by: Khem Raj <raj.khem@gmail.com>
21---
22 Port-linux/dibbler-client.cpp | 6 +++---
23 Port-linux/lowlevel-linux-link-state.c | 6 +++---
24 2 files changed, 6 insertions(+), 6 deletions(-)
25
26diff --git a/Port-linux/dibbler-client.cpp b/Port-linux/dibbler-client.cpp
27index 78f34241..b5ebb9f0 100644
28--- a/Port-linux/dibbler-client.cpp
29+++ b/Port-linux/dibbler-client.cpp
30@@ -26,7 +26,7 @@ using namespace std;
31
32 #define IF_RECONNECTED_DETECTED -1
33
34-extern pthread_mutex_t lock;
35+extern pthread_mutex_t dibbler_lock;
36
37 TDHCPClient* ptr = 0;
38
39@@ -44,8 +44,8 @@ void signal_handler(int n) {
40 #ifdef MOD_CLNT_CONFIRM
41 void signal_handler_of_linkstate_change(int n) {
42 Log(Notice) << "Network switch off event detected. initiating CONFIRM." << LogEnd;
43- pthread_mutex_lock(&lock);
44- pthread_mutex_unlock(&lock);
45+ pthread_mutex_lock(&dibbler_lock);
46+ pthread_mutex_unlock(&dibbler_lock);
47 }
48 #endif
49
50diff --git a/Port-linux/lowlevel-linux-link-state.c b/Port-linux/lowlevel-linux-link-state.c
51index 76293ea1..e6b94063 100644
52--- a/Port-linux/lowlevel-linux-link-state.c
53+++ b/Port-linux/lowlevel-linux-link-state.c
54@@ -34,7 +34,7 @@ volatile int * notifier = 0;
55 int isDone = 0;
56 pthread_t parent_id;
57 pthread_t ntid;
58-pthread_mutex_t lock;
59+pthread_mutex_t dibbler_lock;
60
61 struct state {
62 int id;
63@@ -86,9 +86,9 @@ void link_state_changed(int ifindex)
64 {
65 if (changed_links->cnt<16)
66 changed_links->ifindex[changed_links->cnt++] = ifindex;
67- pthread_mutex_lock(&lock);
68+ pthread_mutex_lock(&dibbler_lock);
69 *notifier = 1; /* notify that change has occured */
70- pthread_mutex_unlock(&lock);
71+ pthread_mutex_unlock(&dibbler_lock);
72 pthread_kill(parent_id,SIGUSR1);
73 } else
74 {