libfprint: Use a macro to easily compute TOD padding

This commit is contained in:
Marco Trevisan (Treviño)
2021-10-31 22:22:56 +01:00
parent ec8a9ba0fd
commit 608a9f10df
13 changed files with 68 additions and 42 deletions
+4 -1
View File
@@ -20,6 +20,7 @@
#pragma once #pragma once
#include "fp-image.h" #include "fp-image.h"
#include "tod/tod-macros.h"
/** /**
* fpi_frame: * fpi_frame:
@@ -110,7 +111,9 @@ struct fpi_line_asmbl_ctx
unsigned char (*get_pixel)(struct fpi_line_asmbl_ctx *ctx, unsigned char (*get_pixel)(struct fpi_line_asmbl_ctx *ctx,
GSList *line, GSList *line,
unsigned int x); unsigned int x);
gpointer _padding_dummy[32];
/*< private >*/
TOD_PADDING (32, 0);
}; };
FpImage *fpi_assemble_lines (struct fpi_line_asmbl_ctx *ctx, FpImage *fpi_assemble_lines (struct fpi_line_asmbl_ctx *ctx,
+9 -14
View File
@@ -23,6 +23,7 @@
#include "fp-device.h" #include "fp-device.h"
#include "fp-image.h" #include "fp-image.h"
#include "fpi-print.h" #include "fpi-print.h"
#include "tod/tod-macros.h"
/** /**
* FpiDeviceUdevSubtype: * FpiDeviceUdevSubtype:
@@ -73,13 +74,10 @@ struct _FpIdEntry
/*< private >*/ /*< private >*/
/* padding for future expansion */ /* padding for future expansion */
#if GLIB_SIZEOF_VOID_P == 8 TOD_PADDING_ALIGNED (16,
gpointer _padding_dummy[13]; sizeof (guint) * 2 +
#elif GLIB_SIZEOF_VOID_P == 4 sizeof (FpiDeviceUdevSubtypeFlags) +
gpointer _padding_dummy[11]; sizeof (gpointer));
#else
G_STATIC_ASSERT("Unexpected pointer size")
#endif
}; };
/** /**
@@ -192,13 +190,10 @@ struct _FpDeviceClass
/*< private >*/ /*< private >*/
/* padding for future expansion */ /* padding for future expansion */
#if GLIB_SIZEOF_VOID_P == 8 TOD_PADDING_ALIGNED8 (32,
gpointer _padding_dummy[27]; sizeof (FpDeviceFeature) +
#elif GLIB_SIZEOF_VOID_P == 4 sizeof (gint32) * 2 +
gpointer _padding_dummy[26]; sizeof (gpointer) * 3);
#else
G_STATIC_ASSERT("Unexpected pointer size")
#endif
}; };
void fpi_device_class_auto_initialize_features (FpDeviceClass *device_class); void fpi_device_class_auto_initialize_features (FpDeviceClass *device_class);
+1 -1
View File
@@ -117,7 +117,7 @@ struct _FpImageDeviceClass
/*< private >*/ /*< private >*/
/* padding for future expansion */ /* padding for future expansion */
gpointer _padding_dummy[32]; TOD_PADDING (32, 0);
}; };
void fpi_image_device_set_bz3_threshold (FpImageDevice *self, void fpi_image_device_set_bz3_threshold (FpImageDevice *self,
+2 -1
View File
@@ -21,6 +21,7 @@
#pragma once #pragma once
#include "fp-image.h" #include "fp-image.h"
#include "tod/tod-macros.h"
/** /**
* FpiImageFlags: * FpiImageFlags:
@@ -69,7 +70,7 @@ struct _FpImage
GPtrArray *minutiae; GPtrArray *minutiae;
guint ref_count; guint ref_count;
gpointer _padding_dummy[32]; TOD_PADDING (32, 0);
}; };
gint fpi_std_sq_dev (const guint8 *buf, gint fpi_std_sq_dev (const guint8 *buf,
+1 -1
View File
@@ -75,7 +75,7 @@ struct _FpiSpiTransfer
GDestroyNotify free_buffer_rd; GDestroyNotify free_buffer_rd;
/* padding for future expansion */ /* padding for future expansion */
gpointer _padding_dummy[32]; TOD_PADDING (32, 0);
}; };
GType fpi_spi_transfer_get_type (void) G_GNUC_CONST; GType fpi_spi_transfer_get_type (void) G_GNUC_CONST;
+1 -2
View File
@@ -103,9 +103,8 @@ struct _FpiUsbTransfer
/* Data free function */ /* Data free function */
GDestroyNotify free_buffer; GDestroyNotify free_buffer;
/*< private >*/
/* padding for future expansion */ /* padding for future expansion */
gpointer _padding_dummy[32]; TOD_PADDING (32, 0);
}; };
GType fpi_usb_transfer_get_type (void) G_GNUC_CONST; GType fpi_usb_transfer_get_type (void) G_GNUC_CONST;
+32
View File
@@ -0,0 +1,32 @@
/*
* Shared library loader for libfprint
* Copyright (C) 2021 Marco Trevisan <marco.trevisan@canonical.com>
*
* 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_PADDING(original, wasted) \
char _tod_expansion_padding[(GLIB_SIZEOF_VOID_P * (original)) - (wasted)];
#define TOD_PADDING_ALIGNED(original, wasted) \
TOD_PADDING (original, (wasted) + GLIB_SIZEOF_VOID_P)
#define TOD_PADDING_ALIGNED4(original, wasted) \
TOD_PADDING (original, (wasted) + (GLIB_SIZEOF_VOID_P == 4 ? GLIB_SIZEOF_VOID_P : 0))
#define TOD_PADDING_ALIGNED8(original, wasted) \
TOD_PADDING (original, (wasted) + (GLIB_SIZEOF_VOID_P == 8 ? GLIB_SIZEOF_VOID_P : 0))
+2
View File
@@ -19,6 +19,8 @@
#pragma once #pragma once
#include "tod/tod-macros.h"
typedef struct _FpDevice FpDevice; typedef struct _FpDevice FpDevice;
typedef enum { typedef enum {
+10 -17
View File
@@ -43,7 +43,7 @@ struct _FpIdEntryTODV1_90_1
/*< private >*/ /*< private >*/
/* padding for future expansion */ /* padding for future expansion */
gpointer _padding_dummy[16]; TOD_PADDING (16, 0);
}; };
struct _FpDeviceClassTODV1_90_1 struct _FpDeviceClassTODV1_90_1
@@ -78,7 +78,7 @@ struct _FpDeviceClassTODV1_90_1
/*< private >*/ /*< private >*/
/* padding for future expansion */ /* padding for future expansion */
gpointer _padding_dummy[32]; TOD_PADDING (32, 0);
}; };
typedef struct _FpDeviceClassTODV1_90_1 FpDeviceClassTODV1_90_1; typedef struct _FpDeviceClassTODV1_90_1 FpDeviceClassTODV1_90_1;
@@ -172,13 +172,9 @@ struct _FpIdEntryTODV1_92_0
/*< private >*/ /*< private >*/
/* padding for future expansion */ /* padding for future expansion */
#if GLIB_SIZEOF_VOID_P == 8 TOD_PADDING_ALIGNED (16, sizeof (guint) * 2 +
gpointer _padding_dummy[13]; sizeof (FpiDeviceUdevSubtypeFlagsTODV1_92_0) +
#elif GLIB_SIZEOF_VOID_P == 4 sizeof (gpointer));
gpointer _padding_dummy[11];
#else
G_STATIC_ASSERT("Unexpected pointer size")
#endif
}; };
typedef struct _FpIdEntryTODV1_92_0 FpIdEntryTODV1_92_0; typedef struct _FpIdEntryTODV1_92_0 FpIdEntryTODV1_92_0;
@@ -217,7 +213,7 @@ struct _FpDeviceClassTODV1_92_0
/*< private >*/ /*< private >*/
/* padding for future expansion */ /* padding for future expansion */
gpointer _padding_dummy[31]; TOD_PADDING (32, sizeof (FpDeviceFeatureTODV1_92_0));
}; };
typedef struct _FpDeviceClassTODV1_92_0 FpDeviceClassTODV1_92_0; typedef struct _FpDeviceClassTODV1_92_0 FpDeviceClassTODV1_92_0;
@@ -266,13 +262,10 @@ struct _FpDeviceClassTODV1_94_0
/*< private >*/ /*< private >*/
/* padding for future expansion */ /* padding for future expansion */
#if GLIB_SIZEOF_VOID_P == 8 TOD_PADDING_ALIGNED8 (32,
gpointer _padding_dummy[27]; sizeof (FpDeviceFeatureTODV1_94_0) +
#elif GLIB_SIZEOF_VOID_P == 4 sizeof (gint32) * 2 +
gpointer _padding_dummy[26]; sizeof (gpointer) * 3)
#else
G_STATIC_ASSERT("Unexpected pointer size")
#endif
}; };
typedef struct _FpDeviceClassTODV1_94_0 FpDeviceClassTODV1_94_0; typedef struct _FpDeviceClassTODV1_94_0 FpDeviceClassTODV1_94_0;
+1 -1
View File
@@ -57,5 +57,5 @@ typedef struct _FpImageDeviceClassTODV1_90_1
/*< private >*/ /*< private >*/
/* padding for future expansion */ /* padding for future expansion */
gpointer _padding_dummy[32]; TOD_PADDING (32, 0);
} FpImageDeviceClassTODV1_90_1; } FpImageDeviceClassTODV1_90_1;
+3 -1
View File
@@ -22,6 +22,8 @@
#include <glib.h> #include <glib.h>
#include <glib-object.h> #include <glib-object.h>
#include "tod/tod-macros.h"
typedef struct _FpImage FpImage; typedef struct _FpImage FpImage;
typedef struct _FpImageTODV1_90_1 FpImageTODV1_90_1; typedef struct _FpImageTODV1_90_1 FpImageTODV1_90_1;
@@ -58,5 +60,5 @@ struct _FpImageTODV1_90_1
GPtrArray *minutiae; GPtrArray *minutiae;
guint ref_count; guint ref_count;
gpointer _padding_dummy[32]; TOD_PADDING (32, 0);
}; };
+1 -1
View File
@@ -56,5 +56,5 @@ struct _FpiSpiTransferTODV1_92_0
GDestroyNotify free_buffer_rd; GDestroyNotify free_buffer_rd;
/* padding for future expansion */ /* padding for future expansion */
gpointer _padding_dummy[32]; TOD_PADDING (32, 0);
}; };
+1 -2
View File
@@ -75,7 +75,6 @@ struct _FpiUsbTransferTODV1_90_1
/* Data free function */ /* Data free function */
GDestroyNotify free_buffer; GDestroyNotify free_buffer;
/*< private >*/
/* padding for future expansion */ /* padding for future expansion */
gpointer _padding_dummy[32]; TOD_PADDING (32, 0);
}; };