summaryrefslogtreecommitdiffstats
path: root/bcmdhd/wifi_hal/sync.h
diff options
context:
space:
mode:
authorVinit Deshapnde <vinitd@google.com>2014-04-08 15:36:03 -0700
committerVinit Deshapnde <vinitd@google.com>2014-05-07 18:29:24 -0700
commit1a526434ae215b48970501ccb463d4e77af39c9e (patch)
treedf5161de1a1ec920db3a18b61be83196c13efde1 /bcmdhd/wifi_hal/sync.h
parent996ef5b74f50d2fb2e1347fc6ab01904855c9867 (diff)
downloadhardware_broadcom_wlan-1a526434ae215b48970501ccb463d4e77af39c9e.zip
hardware_broadcom_wlan-1a526434ae215b48970501ccb463d4e77af39c9e.tar.gz
hardware_broadcom_wlan-1a526434ae215b48970501ccb463d4e77af39c9e.tar.bz2
Moving Wifi HAL to hardware
This change moves all Wifi HAL headers to libhardware_legacy; and moves hal implementation under hardware/<vendor>/wlan. This way different vendors will be able to tailor implementation to their drivers. Change-Id: I55789bb6788ab694f4896aa36d76f7887b32dad6
Diffstat (limited to 'bcmdhd/wifi_hal/sync.h')
-rw-r--r--bcmdhd/wifi_hal/sync.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/bcmdhd/wifi_hal/sync.h b/bcmdhd/wifi_hal/sync.h
new file mode 100644
index 0000000..cea2ea9
--- /dev/null
+++ b/bcmdhd/wifi_hal/sync.h
@@ -0,0 +1,54 @@
+
+#include <pthread.h>
+
+#ifndef __WIFI_HAL_SYNC_H__
+#define __WIFI_HAL_SYNC_H__
+
+class Mutex
+{
+private:
+ pthread_mutex_t mMutex;
+public:
+ Mutex() {
+ pthread_mutex_init(&mMutex, NULL);
+ }
+ ~Mutex() {
+ pthread_mutex_destroy(&mMutex);
+ }
+ int tryLock() {
+ return pthread_mutex_trylock(&mMutex);
+ }
+ int lock() {
+ return pthread_mutex_lock(&mMutex);
+ }
+ void unlock() {
+ pthread_mutex_unlock(&mMutex);
+ }
+};
+
+class Condition
+{
+private:
+ pthread_cond_t mCondition;
+ pthread_mutex_t mMutex;
+
+public:
+ Condition() {
+ pthread_mutex_init(&mMutex, NULL);
+ pthread_cond_init(&mCondition, NULL);
+ }
+ ~Condition() {
+ pthread_cond_destroy(&mCondition);
+ pthread_mutex_destroy(&mMutex);
+ }
+
+ int wait() {
+ return pthread_cond_wait(&mCondition, &mMutex);
+ }
+
+ void signal() {
+ pthread_cond_signal(&mCondition);
+ }
+};
+
+#endif \ No newline at end of file