diff --git a/libfprint/fpi-ssm.c b/libfprint/fpi-ssm.c index 8ceab674..8080f550 100644 --- a/libfprint/fpi-ssm.c +++ b/libfprint/fpi-ssm.c @@ -747,3 +747,7 @@ fpi_ssm_spi_transfer_with_weak_pointer_cb (FpiSpiTransfer *transfer, fpi_ssm_spi_transfer_cb (transfer, device, weak_ptr, error); } + +#ifdef TOD_LIBRARY +#include "tod/tod-fpi-ssm.c" +#endif diff --git a/libfprint/tod/libfprint-tod.ver.in b/libfprint/tod/libfprint-tod.ver.in index 0027338f..c0de483b 100644 --- a/libfprint/tod/libfprint-tod.ver.in +++ b/libfprint/tod/libfprint-tod.ver.in @@ -1,6 +1,10 @@ LIBFPRINT_TOD_@tod_soversion@.0.0 { global: fpi_*; + fpi_ssm_new_full; + fpi_ssm_jump_to_state_delayed; + fpi_ssm_mark_completed_delayed; + fpi_ssm_next_state_delayed; local: *; }; diff --git a/libfprint/tod/meson.build b/libfprint/tod/meson.build index d7c6d872..ba395c16 100644 --- a/libfprint/tod/meson.build +++ b/libfprint/tod/meson.build @@ -26,12 +26,19 @@ libfprint_tod_private = static_library('fprint-tod-private', install: false, ) -tod_sources = [] +tod_sources = [ + 'tod-wrappers.c', + 'tod-symbols.h', +] foreach source: libfprint_private_sources tod_sources += '..' / source endforeach libfprint_tod = library(versioned_libname.split('lib')[1] + '-tod', + c_args: [ + '-DTOD_LIBRARY=1', + '-include', '@0@'.format(files('tod-symbols.h')[0]), + ], sources: [ tod_sources, ], diff --git a/libfprint/tod/tod-fpi-ssm.c b/libfprint/tod/tod-fpi-ssm.c new file mode 100644 index 00000000..32e282f7 --- /dev/null +++ b/libfprint/tod/tod-fpi-ssm.c @@ -0,0 +1,67 @@ +/* + * Shared library loader for libfprint + * Copyright (C) 2021 Marco Trevisan + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "tod-wrappers.h" +#include "fpi-ssm.h" + +static gboolean +check_delayed_cancellable (FpiSsm *machine, + GCancellable *cancellable) +{ + if (g_cancellable_is_cancelled (cancellable)) + { + fpi_ssm_mark_failed (machine, g_error_new (G_IO_ERROR, + G_IO_ERROR_CANCELLED, + "Action cancelled")); + return FALSE; + } + + if (cancellable) + fp_err ("GCancellable in SSM Delayed actions is ignored as per libfprint 1.92"); + + return TRUE; +} + +void +fpi_ssm_next_state_delayed_1_90 (FpiSsm *machine, + int delay, + GCancellable *cancellable) +{ + if (check_delayed_cancellable (machine, cancellable)) + fpi_ssm_next_state_delayed (machine, delay); +} + +void +fpi_ssm_jump_to_state_delayed_1_90 (FpiSsm *machine, + int state, + int delay, + GCancellable *cancellable) +{ + if (check_delayed_cancellable (machine, cancellable)) + fpi_ssm_jump_to_state_delayed (machine, state, delay); +} + +void +fpi_ssm_mark_completed_delayed_1_90 (FpiSsm *machine, + int delay, + GCancellable *cancellable) +{ + if (check_delayed_cancellable (machine, cancellable)) + fpi_ssm_mark_completed_delayed (machine, delay); +} diff --git a/libfprint/tod/tod-symbols.h b/libfprint/tod/tod-symbols.h new file mode 100644 index 00000000..d4f497bc --- /dev/null +++ b/libfprint/tod/tod-symbols.h @@ -0,0 +1,45 @@ +/* + * Shared library loader for libfprint + * Copyright (C) 2021 Marco Trevisan + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#pragma once + +#define TOD_1_SYMBOL_VERSION_1_90 "LIBFPRINT_TOD_1.0.0" +#define TOD_1_SYMBOL_VERSION_1_92 "LIBFPRINT_TOD_1_1.92" +#define TOD_1_SYMBOL_VERSION_1_94 "LIBFPRINT_TOD_1_1.94" +#define TOD_1_SYMBOL_VERSION(major, minor) \ + TOD_1_SYMBOL_VERSION_ ## major ## _ ## minor + +#define TOD_DEFAULT_VERSION_SYMBOL(symbol, major, minor) \ + __asm__ (".symver " # symbol "," # symbol "@@@" \ + TOD_1_SYMBOL_VERSION (major, minor)); +#define TOD_VERSIONED_SYMBOL(symbol, major, minor) \ + __asm__ (".symver " # symbol "_" # major "_" #minor "," # symbol "@" \ + TOD_1_SYMBOL_VERSION (major, minor)); + +TOD_DEFAULT_VERSION_SYMBOL (fpi_ssm_new_full, 1, 92) +TOD_VERSIONED_SYMBOL (fpi_ssm_new_full, 1, 90) + +TOD_DEFAULT_VERSION_SYMBOL (fpi_ssm_next_state_delayed, 1, 92) +TOD_VERSIONED_SYMBOL (fpi_ssm_next_state_delayed, 1, 90) + +TOD_DEFAULT_VERSION_SYMBOL (fpi_ssm_jump_to_state_delayed, 1, 92) +TOD_VERSIONED_SYMBOL (fpi_ssm_jump_to_state_delayed, 1, 90) + +TOD_DEFAULT_VERSION_SYMBOL (fpi_ssm_mark_completed_delayed, 1, 92) +TOD_VERSIONED_SYMBOL (fpi_ssm_mark_completed_delayed, 1, 90) diff --git a/libfprint/tod/tod-wrappers.c b/libfprint/tod/tod-wrappers.c new file mode 100644 index 00000000..181dbb13 --- /dev/null +++ b/libfprint/tod/tod-wrappers.c @@ -0,0 +1,31 @@ +/* + * Shared library loader for libfprint + * Copyright (C) 2021 Marco Trevisan + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define FP_COMPONENT "tod" + +#include "tod-wrappers.h" + +FpiSsm * +fpi_ssm_new_full_1_90 (FpDevice *dev, + FpiSsmHandlerCallback handler, + int nr_states, + const char *machine_name) +{ + return fpi_ssm_new_full (dev, handler, nr_states, nr_states, machine_name); +} diff --git a/libfprint/tod/tod-wrappers.h b/libfprint/tod/tod-wrappers.h new file mode 100644 index 00000000..b01aad44 --- /dev/null +++ b/libfprint/tod/tod-wrappers.h @@ -0,0 +1,39 @@ +/* + * Shared library loader for libfprint + * Copyright (C) 2021 Marco Trevisan + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#pragma once + +#include "drivers_api.h" +#include "tod-symbols.h" + +extern FpiSsm *fpi_ssm_new_full_1_90 (FpDevice *dev, + FpiSsmHandlerCallback handler, + int nr_states, + const char *machine_name); + +extern void fpi_ssm_next_state_delayed_1_90 (FpiSsm *machine, + int delay, + GCancellable *cancellable); +extern void fpi_ssm_jump_to_state_delayed_1_90 (FpiSsm *machine, + int state, + int delay, + GCancellable *cancellable); +extern void fpi_ssm_mark_completed_delayed_1_90 (FpiSsm *machine, + int delay, + GCancellable *cancellable); diff --git a/tests/meson.build b/tests/meson.build index 0ec194df..5a93b345 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -326,11 +326,6 @@ if get_option('tod') } } - if tod_version != 'v1+1.94' - # TODO: Adapt symbols to new ABI - continue - endif - tod_driver_infos += { tod_ssm_test_driver_name + '_' + tod_version: { 'tod-driver': tod_ssm_test_driver_name,