1 /* 2 * Copyright 2017 Bruno Haible <bruno@clisp.org> 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18 #include "config.h" 19 20 #define __TR_function obsolete__TR_function 21 #include "callback.h" 22 #undef __TR_function 23 #include "trampoline_r.h" 24 25 /* This is the implementation of the library API. 26 The symbols that the linker sees are all prefixed with 'callback_', 27 to avoid potential collisions with other libraries. */ 28 alloc_callback(callback_function_t address,void * data)29callback_t alloc_callback (callback_function_t address, void* data) 30 { 31 return alloc_trampoline_r((__TR_function)callback_get_receiver(),(void*)address,data); 32 } 33 free_callback(callback_t callback)34void free_callback (callback_t callback) 35 { 36 free_trampoline_r (callback); 37 } 38 is_callback(void * callback)39int is_callback (void* callback) 40 { 41 return is_trampoline_r(callback) 42 && trampoline_r_address((__TR_function)callback) == (__TR_function)callback_get_receiver(); 43 } 44 callback_address(callback_t callback)45callback_function_t callback_address (callback_t callback) 46 { 47 return (callback_function_t)trampoline_r_data0(callback); 48 } 49 callback_data(callback_t callback)50void* callback_data (callback_t callback) 51 { 52 return trampoline_r_data1(callback); 53 } 54