1 /*
2  * Copyright (c) 2018-2021, OARC, Inc.
3  * All rights reserved.
4  *
5  * This file is part of dnsjit.
6  *
7  * dnsjit is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * dnsjit is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with dnsjit.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 //lua:require("dnsjit.core.compat_h")
22 //lua:require("dnsjit.core.log")
23 
24 typedef struct core_thread_item core_thread_item_t;
25 struct core_thread_item {
26     core_thread_item_t* next;
27     void*               ptr;
28     char *              type, *module;
29 
30     char*   str;
31     int64_t i64;
32 };
33 
34 typedef struct core_thread {
35     core_log_t                _log;
36     pthread_t                 thr_id;
37     core_thread_item_t *      stack, *last;
38     const core_thread_item_t* at;
39 
40     pthread_mutex_t lock;
41     pthread_cond_t  cond;
42 
43     char*  bytecode;
44     size_t bytecode_len;
45 } core_thread_t;
46 
47 core_log_t* core_thread_log();
48 
49 void                      core_thread_init(core_thread_t* self);
50 void                      core_thread_destroy(core_thread_t* self);
51 int                       core_thread_start(core_thread_t* self, const char* bytecode, size_t len);
52 int                       core_thread_stop(core_thread_t* self);
53 void                      core_thread_push(core_thread_t* self, void* ptr, const char* type, size_t type_len, const char* module, size_t module_len);
54 void                      core_thread_push_string(core_thread_t* self, const char* str, size_t len);
55 void                      core_thread_push_int64(core_thread_t* self, int64_t i64);
56 const core_thread_item_t* core_thread_pop(core_thread_t* self);
57