1e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti/* Copyright (c) 2011, The Linux Foundation. All rights reserved. 2e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * 3e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * Redistribution and use in source and binary forms, with or without 4e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * modification, are permitted provided that the following conditions are 5e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * met: 6e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * * Redistributions of source code must retain the above copyright 7e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * notice, this list of conditions and the following disclaimer. 8e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * * Redistributions in binary form must reproduce the above 9e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * copyright notice, this list of conditions and the following 10e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * disclaimer in the documentation and/or other materials provided 11e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * with the distribution. 12e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * * Neither the name of The Linux Foundation nor the names of its 13e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * contributors may be used to endorse or promote products derived 14e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * from this software without specific prior written permission. 15e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * 16e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti * 28e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti */ 29e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti#ifndef __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ 30e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti#define __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ 31e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti 32e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti#ifdef __cplusplus 33e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletiextern "C" { 34e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti#endif /* __cplusplus */ 35e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti 36e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti#include <pthread.h> 37e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti 38e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletistruct loc_eng_dmn_conn_thelper { 39e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti unsigned char thread_exit; 40e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti unsigned char thread_ready; 41e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti pthread_cond_t thread_cond; 42e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti pthread_mutex_t thread_mutex; 43e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti pthread_t thread_id; 44e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti void * thread_context; 45e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti int (*thread_proc_init) (void * context); 46e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti int (*thread_proc_pre) (void * context); 47e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti int (*thread_proc) (void * context); 48e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti int (*thread_proc_post) (void * context); 49e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti}; 50e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti 51e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletitypedef pthread_t (* thelper_create_thread)(const char* name, void (*start)(void *), void* arg); 52e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletiint loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper, 53e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti int (*thread_proc_init) (void * context), 54e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti int (*thread_proc_pre) (void * context), 55e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti int (*thread_proc) (void * context), 56e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti int (*thread_proc_post) (void * context), 57e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti thelper_create_thread create_thread_cb, 58e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti void * context); 59e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti 60e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletiint loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper); 61e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletiint loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper); 62e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti 63e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti/* if only need to use signal */ 64e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletiint thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper); 65e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletiint thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper); 66e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletiint thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper); 67e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletiint thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper); 68e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuletiint thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper); 69e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti 70e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti#ifdef __cplusplus 71e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti} 72e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti#endif /* __cplusplus */ 73e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti 74e7c98642e1e156ea6cde1238cd0006f669cfb696Uday Kishore Pasupuleti#endif /* __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ */ 75