Commit 87f0d4395dbfe0ae559e964668b71f85819378a0

Authored by Bassam Tabbara
1 parent 22352ca0
Exists in master and in 1 other branch v3

Add support for printing functions selected in gf_init

There is currently no way to figure out which functions were selected
during gf_init and as a result of SIMD options. This is not even possible
in gdb since most functions are static.

This commit adds a new macro SET_FUNCTION that records the name of the
function selected during init inside the gf_internal structure. This macro
only works when DEBUG_FUNCTIONS is defined during compile. Otherwise the
code works exactly as it did before this change.

The names of selected functions will be used during testing of SIMD
runtime detection.

All calls such as:

gf->multiply.w32 = gf_w16_shift_multiply;

need to be replaced with the following:

SET_FUNCTION(gf,multiply,w32,gf_w16_shift_multiply)

Also added a new flag to tools/gf_methods that will print the names of
functions selected during gf_init.
include/gf_int.h
... ... @@ -30,8 +30,24 @@ typedef struct {
30 30 int arg2;
31 31 gf_t *base_gf;
32 32 void *private;
  33 +#ifdef DEBUG_FUNCTIONS
  34 + const char *multiply;
  35 + const char *divide;
  36 + const char *inverse;
  37 + const char *multiply_region;
  38 + const char *extract_word;
  39 +#endif
33 40 } gf_internal_t;
34 41  
  42 +#ifdef DEBUG_FUNCTIONS
  43 +#define SET_FUNCTION(gf,method,size,func) \
  44 + { (gf)->method.size = (func); \
  45 + ((gf_internal_t*)(gf)->scratch)->method = #func; }
  46 +#else
  47 +#define SET_FUNCTION(gf,method,size,func) \
  48 + (gf)->method.size = (func);
  49 +#endif
  50 +
35 51 extern int gf_w4_init (gf_t *gf);
36 52 extern int gf_w4_scratch_size(int mult_type, int region_type, int divide_type, int arg1, int arg2);
37 53  
... ...
src/gf_w128.c
... ... @@ -1405,14 +1405,14 @@ int gf_w128_composite_init(gf_t *gf)
1405 1405 gf_internal_t *h = (gf_internal_t *) gf->scratch;
1406 1406  
1407 1407 if (h->region_type & GF_REGION_ALTMAP) {
1408   - gf->multiply_region.w128 = gf_w128_composite_multiply_region_alt;
  1408 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_composite_multiply_region_alt)
1409 1409 } else {
1410   - gf->multiply_region.w128 = gf_w128_composite_multiply_region;
  1410 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_composite_multiply_region)
1411 1411 }
1412 1412  
1413   - gf->multiply.w128 = gf_w128_composite_multiply;
1414   - gf->divide.w128 = gf_w128_divide_from_inverse;
1415   - gf->inverse.w128 = gf_w128_composite_inverse;
  1413 + SET_FUNCTION(gf,multiply,w128,gf_w128_composite_multiply)
  1414 + SET_FUNCTION(gf,divide,w128,gf_w128_divide_from_inverse)
  1415 + SET_FUNCTION(gf,inverse,w128,gf_w128_composite_inverse)
1416 1416  
1417 1417 return 1;
1418 1418 }
... ... @@ -1421,9 +1421,9 @@ static
1421 1421 int gf_w128_cfm_init(gf_t *gf)
1422 1422 {
1423 1423 #if defined(INTEL_SSE4_PCLMUL)
1424   - gf->inverse.w128 = gf_w128_euclid;
1425   - gf->multiply.w128 = gf_w128_clm_multiply;
1426   - gf->multiply_region.w128 = gf_w128_clm_multiply_region_from_single;
  1424 + SET_FUNCTION(gf,inverse,w128,gf_w128_euclid)
  1425 + SET_FUNCTION(gf,multiply,w128,gf_w128_clm_multiply)
  1426 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_clm_multiply_region_from_single)
1427 1427 return 1;
1428 1428 #endif
1429 1429  
... ... @@ -1433,9 +1433,9 @@ int gf_w128_cfm_init(gf_t *gf)
1433 1433 static
1434 1434 int gf_w128_shift_init(gf_t *gf)
1435 1435 {
1436   - gf->multiply.w128 = gf_w128_shift_multiply;
1437   - gf->inverse.w128 = gf_w128_euclid;
1438   - gf->multiply_region.w128 = gf_w128_multiply_region_from_single;
  1436 + SET_FUNCTION(gf,multiply,w128,gf_w128_shift_multiply)
  1437 + SET_FUNCTION(gf,inverse,w128,gf_w128_euclid)
  1438 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_multiply_region_from_single)
1439 1439 return 1;
1440 1440 }
1441 1441  
... ... @@ -1446,16 +1446,16 @@ int gf_w128_bytwo_init(gf_t *gf)
1446 1446 h = (gf_internal_t *) gf->scratch;
1447 1447  
1448 1448 if (h->mult_type == GF_MULT_BYTWO_p) {
1449   - gf->multiply.w128 = gf_w128_bytwo_p_multiply;
1450   - /*gf->multiply.w128 = gf_w128_sse_bytwo_p_multiply;*/
  1449 + SET_FUNCTION(gf,multiply,w128,gf_w128_bytwo_p_multiply)
  1450 + /*SET_FUNCTION(gf,multiply,w128,gf_w128_sse_bytwo_p_multiply)*/
1451 1451 /* John: the sse function is slower.*/
1452 1452 } else {
1453   - gf->multiply.w128 = gf_w128_bytwo_b_multiply;
1454   - /*gf->multiply.w128 = gf_w128_sse_bytwo_b_multiply;
  1453 + SET_FUNCTION(gf,multiply,w128,gf_w128_bytwo_b_multiply)
  1454 + /*SET_FUNCTION(gf,multiply,w128,gf_w128_sse_bytwo_b_multiply)
1455 1455 Ben: This sse function is also slower. */
1456 1456 }
1457   - gf->inverse.w128 = gf_w128_euclid;
1458   - gf->multiply_region.w128 = gf_w128_bytwo_b_multiply_region;
  1457 + SET_FUNCTION(gf,inverse,w128,gf_w128_euclid)
  1458 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_bytwo_b_multiply_region)
1459 1459 return 1;
1460 1460 }
1461 1461  
... ... @@ -1525,20 +1525,20 @@ int gf_w128_split_init(gf_t *gf)
1525 1525  
1526 1526 h = (gf_internal_t *) gf->scratch;
1527 1527  
1528   - gf->multiply.w128 = gf_w128_bytwo_p_multiply;
  1528 + SET_FUNCTION(gf,multiply,w128,gf_w128_bytwo_p_multiply)
1529 1529 #if defined(INTEL_SSE4_PCLMUL)
1530 1530 if (!(h->region_type & GF_REGION_NOSIMD)){
1531   - gf->multiply.w128 = gf_w128_clm_multiply;
  1531 + SET_FUNCTION(gf,multiply,w128,gf_w128_clm_multiply)
1532 1532 }
1533 1533 #endif
1534 1534  
1535   - gf->inverse.w128 = gf_w128_euclid;
  1535 + SET_FUNCTION(gf,inverse,w128,gf_w128_euclid)
1536 1536  
1537 1537 if ((h->arg1 != 4 && h->arg2 != 4) || h->mult_type == GF_MULT_DEFAULT) {
1538 1538 sd8 = (struct gf_w128_split_8_128_data *) h->private;
1539 1539 sd8->last_value[0] = 0;
1540 1540 sd8->last_value[1] = 0;
1541   - gf->multiply_region.w128 = gf_w128_split_8_128_multiply_region;
  1541 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_split_8_128_multiply_region)
1542 1542 } else {
1543 1543 sd4 = (struct gf_w128_split_4_128_data *) h->private;
1544 1544 sd4->last_value[0] = 0;
... ... @@ -1547,7 +1547,7 @@ int gf_w128_split_init(gf_t *gf)
1547 1547 {
1548 1548 #ifdef INTEL_SSE4
1549 1549 if(!(h->region_type & GF_REGION_NOSIMD))
1550   - gf->multiply_region.w128 = gf_w128_split_4_128_sse_altmap_multiply_region;
  1550 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_split_4_128_sse_altmap_multiply_region)
1551 1551 else
1552 1552 return 0;
1553 1553 #else
... ... @@ -1557,11 +1557,11 @@ int gf_w128_split_init(gf_t *gf)
1557 1557 else {
1558 1558 #ifdef INTEL_SSE4
1559 1559 if(!(h->region_type & GF_REGION_NOSIMD))
1560   - gf->multiply_region.w128 = gf_w128_split_4_128_sse_multiply_region;
  1560 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_split_4_128_sse_multiply_region)
1561 1561 else
1562   - gf->multiply_region.w128 = gf_w128_split_4_128_multiply_region;
  1562 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_split_4_128_multiply_region)
1563 1563 #else
1564   - gf->multiply_region.w128 = gf_w128_split_4_128_multiply_region;
  1564 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_split_4_128_multiply_region)
1565 1565 #endif
1566 1566 }
1567 1567 }
... ... @@ -1586,9 +1586,9 @@ int gf_w128_group_init(gf_t *gf)
1586 1586 gt->m_table[2] = 0;
1587 1587 gt->m_table[3] = 0;
1588 1588  
1589   - gf->multiply.w128 = gf_w128_group_multiply;
1590   - gf->inverse.w128 = gf_w128_euclid;
1591   - gf->multiply_region.w128 = gf_w128_group_multiply_region;
  1589 + SET_FUNCTION(gf,multiply,w128,gf_w128_group_multiply)
  1590 + SET_FUNCTION(gf,inverse,w128,gf_w128_euclid)
  1591 + SET_FUNCTION(gf,multiply_region,w128,gf_w128_group_multiply_region)
1592 1592  
1593 1593 gf_w128_group_r_init(gf);
1594 1594  
... ... @@ -1738,10 +1738,10 @@ int gf_w128_init(gf_t *gf)
1738 1738 }
1739 1739 }
1740 1740  
1741   - gf->multiply.w128 = NULL;
1742   - gf->divide.w128 = NULL;
1743   - gf->inverse.w128 = NULL;
1744   - gf->multiply_region.w128 = NULL;
  1741 + SET_FUNCTION(gf,multiply,w128,NULL)
  1742 + SET_FUNCTION(gf,divide,w128,NULL)
  1743 + SET_FUNCTION(gf,inverse,w128,NULL)
  1744 + SET_FUNCTION(gf,multiply_region,w128,NULL)
1745 1745 switch(h->mult_type) {
1746 1746 case GF_MULT_BYTWO_p:
1747 1747 case GF_MULT_BYTWO_b: if (gf_w128_bytwo_init(gf) == 0) return 0; break;
... ... @@ -1757,22 +1757,22 @@ int gf_w128_init(gf_t *gf)
1757 1757 /* Ben: Used to be h->region_type == GF_REGION_ALTMAP, but failed since there
1758 1758 are multiple flags in h->region_type */
1759 1759 if (h->mult_type == GF_MULT_SPLIT_TABLE && (h->region_type & GF_REGION_ALTMAP)) {
1760   - gf->extract_word.w128 = gf_w128_split_extract_word;
  1760 + SET_FUNCTION(gf,extract_word,w128,gf_w128_split_extract_word)
1761 1761 } else if (h->mult_type == GF_MULT_COMPOSITE && h->region_type == GF_REGION_ALTMAP) {
1762   - gf->extract_word.w128 = gf_w128_composite_extract_word;
  1762 + SET_FUNCTION(gf,extract_word,w128,gf_w128_composite_extract_word)
1763 1763 } else {
1764   - gf->extract_word.w128 = gf_w128_extract_word;
  1764 + SET_FUNCTION(gf,extract_word,w128,gf_w128_extract_word)
1765 1765 }
1766 1766  
1767 1767 if (h->divide_type == GF_DIVIDE_EUCLID) {
1768   - gf->divide.w128 = gf_w128_divide_from_inverse;
  1768 + SET_FUNCTION(gf,divide,w128,gf_w128_divide_from_inverse)
1769 1769 }
1770 1770  
1771 1771 if (gf->inverse.w128 != NULL && gf->divide.w128 == NULL) {
1772   - gf->divide.w128 = gf_w128_divide_from_inverse;
  1772 + SET_FUNCTION(gf,divide,w128,gf_w128_divide_from_inverse)
1773 1773 }
1774 1774 if (gf->inverse.w128 == NULL && gf->divide.w128 != NULL) {
1775   - gf->inverse.w128 = gf_w128_inverse_from_divide;
  1775 + SET_FUNCTION(gf,inverse,w128,gf_w128_inverse_from_divide)
1776 1776 }
1777 1777 return 1;
1778 1778 }
... ...
src/gf_w16.c
... ... @@ -548,7 +548,7 @@ gf_w16_shift_multiply (gf_t *gf, gf_val_32_t a16, gf_val_32_t b16)
548 548 static
549 549 int gf_w16_shift_init(gf_t *gf)
550 550 {
551   - gf->multiply.w32 = gf_w16_shift_multiply;
  551 + SET_FUNCTION(gf,multiply,w32,gf_w16_shift_multiply)
552 552 return 1;
553 553 }
554 554  
... ... @@ -563,14 +563,14 @@ int gf_w16_cfm_init(gf_t *gf)
563 563 /*Ben: Determining how many reductions to do */
564 564  
565 565 if ((0xfe00 & h->prim_poly) == 0) {
566   - gf->multiply.w32 = gf_w16_clm_multiply_2;
567   - gf->multiply_region.w32 = gf_w16_clm_multiply_region_from_single_2;
  566 + SET_FUNCTION(gf,multiply,w32,gf_w16_clm_multiply_2)
  567 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_clm_multiply_region_from_single_2)
568 568 } else if((0xf000 & h->prim_poly) == 0) {
569   - gf->multiply.w32 = gf_w16_clm_multiply_3;
570   - gf->multiply_region.w32 = gf_w16_clm_multiply_region_from_single_3;
  569 + SET_FUNCTION(gf,multiply,w32,gf_w16_clm_multiply_3)
  570 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_clm_multiply_region_from_single_3)
571 571 } else if ((0xe000 & h->prim_poly) == 0) {
572   - gf->multiply.w32 = gf_w16_clm_multiply_4;
573   - gf->multiply_region.w32 = gf_w16_clm_multiply_region_from_single_4;
  572 + SET_FUNCTION(gf,multiply,w32,gf_w16_clm_multiply_4)
  573 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_clm_multiply_region_from_single_4)
574 574 } else {
575 575 return 0;
576 576 }
... ... @@ -705,10 +705,10 @@ int gf_w16_log_init(gf_t *gf)
705 705 ltd->inv_tbl[i] = ltd->antilog_tbl[GF_MULT_GROUP_SIZE-ltd->log_tbl[i]];
706 706 }
707 707  
708   - gf->inverse.w32 = gf_w16_log_inverse;
709   - gf->divide.w32 = gf_w16_log_divide;
710   - gf->multiply.w32 = gf_w16_log_multiply;
711   - gf->multiply_region.w32 = gf_w16_log_multiply_region;
  708 + SET_FUNCTION(gf,inverse,w32,gf_w16_log_inverse)
  709 + SET_FUNCTION(gf,divide,w32,gf_w16_log_divide)
  710 + SET_FUNCTION(gf,multiply,w32,gf_w16_log_multiply)
  711 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_log_multiply_region)
712 712  
713 713 return 1;
714 714 }
... ... @@ -1260,8 +1260,8 @@ int gf_w16_split_init(gf_t *gf)
1260 1260 }
1261 1261 for (i = 0; i < 8; i++) basep = GF_MULTBY_TWO(basep);
1262 1262 }
1263   - gf->multiply.w32 = gf_w16_split_8_8_multiply;
1264   - gf->multiply_region.w32 = gf_w16_split_8_16_lazy_multiply_region;
  1263 + SET_FUNCTION(gf,multiply,w32,gf_w16_split_8_8_multiply)
  1264 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_split_8_16_lazy_multiply_region)
1265 1265 return 1;
1266 1266  
1267 1267 }
... ... @@ -1274,34 +1274,34 @@ int gf_w16_split_init(gf_t *gf)
1274 1274 /* Defaults */
1275 1275  
1276 1276 if (issse3) {
1277   - gf->multiply_region.w32 = gf_w16_split_4_16_lazy_sse_multiply_region;
  1277 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_split_4_16_lazy_sse_multiply_region)
1278 1278 } else if (isneon) {
1279 1279 #ifdef ARM_NEON
1280 1280 gf_w16_neon_split_init(gf);
1281 1281 #endif
1282 1282 } else {
1283   - gf->multiply_region.w32 = gf_w16_split_8_16_lazy_multiply_region;
  1283 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_split_8_16_lazy_multiply_region)
1284 1284 }
1285 1285  
1286 1286  
1287 1287 if ((h->arg1 == 8 && h->arg2 == 16) || (h->arg2 == 8 && h->arg1 == 16)) {
1288   - gf->multiply_region.w32 = gf_w16_split_8_16_lazy_multiply_region;
  1288 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_split_8_16_lazy_multiply_region)
1289 1289  
1290 1290 } else if ((h->arg1 == 4 && h->arg2 == 16) || (h->arg2 == 4 && h->arg1 == 16)) {
1291 1291 if (issse3 || isneon) {
1292 1292 if(h->region_type & GF_REGION_ALTMAP && h->region_type & GF_REGION_NOSIMD)
1293   - gf->multiply_region.w32 = gf_w16_split_4_16_lazy_nosse_altmap_multiply_region;
  1293 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_split_4_16_lazy_nosse_altmap_multiply_region)
1294 1294 else if(h->region_type & GF_REGION_NOSIMD)
1295   - gf->multiply_region.w32 = gf_w16_split_4_16_lazy_multiply_region;
  1295 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_split_4_16_lazy_multiply_region)
1296 1296 else if(h->region_type & GF_REGION_ALTMAP && issse3)
1297   - gf->multiply_region.w32 = gf_w16_split_4_16_lazy_sse_altmap_multiply_region;
  1297 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_split_4_16_lazy_sse_altmap_multiply_region)
1298 1298 } else {
1299 1299 if(h->region_type & GF_REGION_SIMD)
1300 1300 return 0;
1301 1301 else if(h->region_type & GF_REGION_ALTMAP)
1302   - gf->multiply_region.w32 = gf_w16_split_4_16_lazy_nosse_altmap_multiply_region;
  1302 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_split_4_16_lazy_nosse_altmap_multiply_region)
1303 1303 else
1304   - gf->multiply_region.w32 = gf_w16_split_4_16_lazy_multiply_region;
  1304 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_split_4_16_lazy_multiply_region)
1305 1305 }
1306 1306 }
1307 1307  
... ... @@ -1313,7 +1313,7 @@ int gf_w16_table_init(gf_t *gf)
1313 1313 {
1314 1314 gf_w16_log_init(gf);
1315 1315  
1316   - gf->multiply_region.w32 = gf_w16_table_lazy_multiply_region;
  1316 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_table_lazy_multiply_region)
1317 1317 return 1;
1318 1318 }
1319 1319  
... ... @@ -1844,26 +1844,26 @@ int gf_w16_bytwo_init(gf_t *gf)
1844 1844 }
1845 1845  
1846 1846 if (h->mult_type == GF_MULT_BYTWO_p) {
1847   - gf->multiply.w32 = gf_w16_bytwo_p_multiply;
  1847 + SET_FUNCTION(gf,multiply,w32,gf_w16_bytwo_p_multiply)
1848 1848 #ifdef INTEL_SSE2
1849 1849 if (h->region_type & GF_REGION_NOSIMD)
1850   - gf->multiply_region.w32 = gf_w16_bytwo_p_nosse_multiply_region;
  1850 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_bytwo_p_nosse_multiply_region)
1851 1851 else
1852   - gf->multiply_region.w32 = gf_w16_bytwo_p_sse_multiply_region;
  1852 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_bytwo_p_sse_multiply_region)
1853 1853 #else
1854   - gf->multiply_region.w32 = gf_w16_bytwo_p_nosse_multiply_region;
  1854 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_bytwo_p_nosse_multiply_region)
1855 1855 if(h->region_type & GF_REGION_SIMD)
1856 1856 return 0;
1857 1857 #endif
1858 1858 } else {
1859   - gf->multiply.w32 = gf_w16_bytwo_b_multiply;
  1859 + SET_FUNCTION(gf,multiply,w32,gf_w16_bytwo_b_multiply)
1860 1860 #ifdef INTEL_SSE2
1861 1861 if (h->region_type & GF_REGION_NOSIMD)
1862   - gf->multiply_region.w32 = gf_w16_bytwo_b_nosse_multiply_region;
  1862 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_bytwo_b_nosse_multiply_region)
1863 1863 else
1864   - gf->multiply_region.w32 = gf_w16_bytwo_b_sse_multiply_region;
  1864 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_bytwo_b_sse_multiply_region)
1865 1865 #else
1866   - gf->multiply_region.w32 = gf_w16_bytwo_b_nosse_multiply_region;
  1866 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_bytwo_b_nosse_multiply_region)
1867 1867 if(h->region_type & GF_REGION_SIMD)
1868 1868 return 0;
1869 1869 #endif
... ... @@ -1904,10 +1904,10 @@ int gf_w16_log_zero_init(gf_t *gf)
1904 1904 ltd->inv_tbl[i] = ltd->antilog_tbl[GF_MULT_GROUP_SIZE-ltd->log_tbl[i]];
1905 1905 }
1906 1906  
1907   - gf->inverse.w32 = gf_w16_log_zero_inverse;
1908   - gf->divide.w32 = gf_w16_log_zero_divide;
1909   - gf->multiply.w32 = gf_w16_log_zero_multiply;
1910   - gf->multiply_region.w32 = gf_w16_log_zero_multiply_region;
  1907 + SET_FUNCTION(gf,inverse,w32,gf_w16_log_zero_inverse)
  1908 + SET_FUNCTION(gf,divide,w32,gf_w16_log_zero_divide)
  1909 + SET_FUNCTION(gf,multiply,w32,gf_w16_log_zero_multiply)
  1910 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_log_zero_multiply_region)
1911 1911 return 1;
1912 1912 }
1913 1913  
... ... @@ -2145,18 +2145,18 @@ int gf_w16_composite_init(gf_t *gf)
2145 2145 cd->mult_table = gf_w8_get_mult_table(h->base_gf);
2146 2146  
2147 2147 if (h->region_type & GF_REGION_ALTMAP) {
2148   - gf->multiply_region.w32 = gf_w16_composite_multiply_region_alt;
  2148 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_composite_multiply_region_alt)
2149 2149 } else {
2150   - gf->multiply_region.w32 = gf_w16_composite_multiply_region;
  2150 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_composite_multiply_region)
2151 2151 }
2152 2152  
2153 2153 if (cd->mult_table == NULL) {
2154   - gf->multiply.w32 = gf_w16_composite_multiply_recursive;
  2154 + SET_FUNCTION(gf,multiply,w32,gf_w16_composite_multiply_recursive)
2155 2155 } else {
2156   - gf->multiply.w32 = gf_w16_composite_multiply_inline;
  2156 + SET_FUNCTION(gf,multiply,w32,gf_w16_composite_multiply_inline)
2157 2157 }
2158   - gf->divide.w32 = NULL;
2159   - gf->inverse.w32 = gf_w16_composite_inverse;
  2158 + SET_FUNCTION(gf,divide,w32,NULL)
  2159 + SET_FUNCTION(gf,inverse,w32,gf_w16_composite_inverse)
2160 2160  
2161 2161 return 1;
2162 2162 }
... ... @@ -2277,10 +2277,10 @@ int gf_w16_group_init(gf_t *gf)
2277 2277 d44->reduce[p>>16] = (p&0xffff);
2278 2278 }
2279 2279  
2280   - gf->multiply.w32 = gf_w16_group_4_4_multiply;
2281   - gf->divide.w32 = NULL;
2282   - gf->inverse.w32 = NULL;
2283   - gf->multiply_region.w32 = gf_w16_group_4_4_region_multiply;
  2280 + SET_FUNCTION(gf,multiply,w32,gf_w16_group_4_4_multiply)
  2281 + SET_FUNCTION(gf,divide,w32,NULL)
  2282 + SET_FUNCTION(gf,inverse,w32,NULL)
  2283 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_group_4_4_region_multiply)
2284 2284  
2285 2285 return 1;
2286 2286 }
... ... @@ -2360,10 +2360,10 @@ int gf_w16_init(gf_t *gf)
2360 2360  
2361 2361 if (h->mult_type != GF_MULT_COMPOSITE) h->prim_poly |= (1 << 16);
2362 2362  
2363   - gf->multiply.w32 = NULL;
2364   - gf->divide.w32 = NULL;
2365   - gf->inverse.w32 = NULL;
2366   - gf->multiply_region.w32 = NULL;
  2363 + SET_FUNCTION(gf,multiply,w32,NULL)
  2364 + SET_FUNCTION(gf,divide,w32,NULL)
  2365 + SET_FUNCTION(gf,inverse,w32,NULL)
  2366 + SET_FUNCTION(gf,multiply_region,w32,NULL)
2367 2367  
2368 2368 switch(h->mult_type) {
2369 2369 case GF_MULT_LOG_ZERO: if (gf_w16_log_zero_init(gf) == 0) return 0; break;
... ... @@ -2380,34 +2380,34 @@ int gf_w16_init(gf_t *gf)
2380 2380 default: return 0;
2381 2381 }
2382 2382 if (h->divide_type == GF_DIVIDE_EUCLID) {
2383   - gf->divide.w32 = gf_w16_divide_from_inverse;
2384   - gf->inverse.w32 = gf_w16_euclid;
  2383 + SET_FUNCTION(gf,divide,w32,gf_w16_divide_from_inverse)
  2384 + SET_FUNCTION(gf,inverse,w32,gf_w16_euclid)
2385 2385 } else if (h->divide_type == GF_DIVIDE_MATRIX) {
2386   - gf->divide.w32 = gf_w16_divide_from_inverse;
2387   - gf->inverse.w32 = gf_w16_matrix;
  2386 + SET_FUNCTION(gf,divide,w32,gf_w16_divide_from_inverse)
  2387 + SET_FUNCTION(gf,inverse,w32,gf_w16_matrix)
2388 2388 }
2389 2389  
2390 2390 if (gf->divide.w32 == NULL) {
2391   - gf->divide.w32 = gf_w16_divide_from_inverse;
2392   - if (gf->inverse.w32 == NULL) gf->inverse.w32 = gf_w16_euclid;
  2391 + SET_FUNCTION(gf,divide,w32,gf_w16_divide_from_inverse)
  2392 + if (gf->inverse.w32 == NULL) SET_FUNCTION(gf,inverse,w32,gf_w16_euclid)
2393 2393 }
2394 2394  
2395   - if (gf->inverse.w32 == NULL) gf->inverse.w32 = gf_w16_inverse_from_divide;
  2395 + if (gf->inverse.w32 == NULL) SET_FUNCTION(gf,inverse,w32,gf_w16_inverse_from_divide)
2396 2396  
2397 2397 if (h->region_type & GF_REGION_ALTMAP) {
2398 2398 if (h->mult_type == GF_MULT_COMPOSITE) {
2399   - gf->extract_word.w32 = gf_w16_composite_extract_word;
  2399 + SET_FUNCTION(gf,extract_word,w32,gf_w16_composite_extract_word)
2400 2400 } else {
2401   - gf->extract_word.w32 = gf_w16_split_extract_word;
  2401 + SET_FUNCTION(gf,extract_word,w32,gf_w16_split_extract_word)
2402 2402 }
2403 2403 } else if (h->region_type == GF_REGION_CAUCHY) {
2404   - gf->multiply_region.w32 = gf_wgen_cauchy_region;
2405   - gf->extract_word.w32 = gf_wgen_extract_word;
  2404 + SET_FUNCTION(gf,multiply_region,w32,gf_wgen_cauchy_region)
  2405 + SET_FUNCTION(gf,extract_word,w32,gf_wgen_extract_word)
2406 2406 } else {
2407   - gf->extract_word.w32 = gf_w16_extract_word;
  2407 + SET_FUNCTION(gf,extract_word,w32,gf_w16_extract_word)
2408 2408 }
2409 2409 if (gf->multiply_region.w32 == NULL) {
2410   - gf->multiply_region.w32 = gf_w16_multiply_region_from_single;
  2410 + SET_FUNCTION(gf,multiply_region,w32,gf_w16_multiply_region_from_single)
2411 2411 }
2412 2412 return 1;
2413 2413 }
... ...
src/gf_w32.c
... ... @@ -589,15 +589,15 @@ gf_w32_shift_multiply (gf_t *gf, uint32_t a32, uint32_t b32)
589 589 static
590 590 int gf_w32_cfmgk_init(gf_t *gf)
591 591 {
592   - gf->inverse.w32 = gf_w32_euclid;
593   - gf->multiply_region.w32 = gf_w32_multiply_region_from_single;
  592 + SET_FUNCTION(gf,inverse,w32,gf_w32_euclid)
  593 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_multiply_region_from_single)
594 594  
595 595 #if defined(INTEL_SSE4_PCLMUL)
596 596 gf_internal_t *h;
597 597  
598 598 h = (gf_internal_t *) gf->scratch;
599   - gf->multiply.w32 = gf_w32_cfmgk_multiply;
600   - gf->multiply_region.w32 = gf_w32_cfmgk_multiply_region_from_single;
  599 + SET_FUNCTION(gf,multiply,w32,gf_w32_cfmgk_multiply)
  600 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_cfmgk_multiply_region_from_single)
601 601  
602 602 uint64_t *q_plus = (uint64_t *) h->private;
603 603 uint64_t *g_star = (uint64_t *) h->private + 1;
... ... @@ -624,8 +624,8 @@ int gf_w32_cfmgk_init(gf_t *gf)
624 624 static
625 625 int gf_w32_cfm_init(gf_t *gf)
626 626 {
627   - gf->inverse.w32 = gf_w32_euclid;
628   - gf->multiply_region.w32 = gf_w32_multiply_region_from_single;
  627 + SET_FUNCTION(gf,inverse,w32,gf_w32_euclid)
  628 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_multiply_region_from_single)
629 629  
630 630 /*Ben: We also check to see if the prim poly will work for pclmul */
631 631 /*Ben: Check to see how many reduction steps it will take*/
... ... @@ -636,14 +636,14 @@ int gf_w32_cfm_init(gf_t *gf)
636 636 h = (gf_internal_t *) gf->scratch;
637 637  
638 638 if ((0xfffe0000 & h->prim_poly) == 0){
639   - gf->multiply.w32 = gf_w32_clm_multiply_2;
640   - gf->multiply_region.w32 = gf_w32_clm_multiply_region_from_single_2;
  639 + SET_FUNCTION(gf,multiply,w32,gf_w32_clm_multiply_2)
  640 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_clm_multiply_region_from_single_2)
641 641 }else if ((0xffc00000 & h->prim_poly) == 0){
642   - gf->multiply.w32 = gf_w32_clm_multiply_3;
643   - gf->multiply_region.w32 = gf_w32_clm_multiply_region_from_single_3;
  642 + SET_FUNCTION(gf,multiply,w32,gf_w32_clm_multiply_3)
  643 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_clm_multiply_region_from_single_3)
644 644 }else if ((0xfe000000 & h->prim_poly) == 0){
645   - gf->multiply.w32 = gf_w32_clm_multiply_4;
646   - gf->multiply_region.w32 = gf_w32_clm_multiply_region_from_single_4;
  645 + SET_FUNCTION(gf,multiply,w32,gf_w32_clm_multiply_4)
  646 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_clm_multiply_region_from_single_4)
647 647 } else {
648 648 return 0;
649 649 }
... ... @@ -656,9 +656,9 @@ int gf_w32_cfm_init(gf_t *gf)
656 656 static
657 657 int gf_w32_shift_init(gf_t *gf)
658 658 {
659   - gf->inverse.w32 = gf_w32_euclid;
660   - gf->multiply_region.w32 = gf_w32_multiply_region_from_single;
661   - gf->multiply.w32 = gf_w32_shift_multiply;
  659 + SET_FUNCTION(gf,inverse,w32,gf_w32_euclid)
  660 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_multiply_region_from_single)
  661 + SET_FUNCTION(gf,multiply,w32,gf_w32_shift_multiply)
662 662 return 1;
663 663 }
664 664  
... ... @@ -1380,32 +1380,32 @@ int gf_w32_bytwo_init(gf_t *gf)
1380 1380 }
1381 1381  
1382 1382 if (h->mult_type == GF_MULT_BYTWO_p) {
1383   - gf->multiply.w32 = gf_w32_bytwo_p_multiply;
  1383 + SET_FUNCTION(gf,multiply,w32,gf_w32_bytwo_p_multiply)
1384 1384 #ifdef INTEL_SSE2
1385 1385 if (h->region_type & GF_REGION_NOSIMD)
1386   - gf->multiply_region.w32 = gf_w32_bytwo_p_nosse_multiply_region;
  1386 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_bytwo_p_nosse_multiply_region)
1387 1387 else
1388   - gf->multiply_region.w32 = gf_w32_bytwo_p_sse_multiply_region;
  1388 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_bytwo_p_sse_multiply_region)
1389 1389 #else
1390   - gf->multiply_region.w32 = gf_w32_bytwo_p_nosse_multiply_region;
  1390 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_bytwo_p_nosse_multiply_region)
1391 1391 if(h->region_type & GF_REGION_SIMD)
1392 1392 return 0;
1393 1393 #endif
1394 1394 } else {
1395   - gf->multiply.w32 = gf_w32_bytwo_b_multiply;
  1395 + SET_FUNCTION(gf,multiply,w32,gf_w32_bytwo_b_multiply)
1396 1396 #ifdef INTEL_SSE2
1397 1397 if (h->region_type & GF_REGION_NOSIMD)
1398   - gf->multiply_region.w32 = gf_w32_bytwo_b_nosse_multiply_region;
  1398 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_bytwo_b_nosse_multiply_region)
1399 1399 else
1400   - gf->multiply_region.w32 = gf_w32_bytwo_b_sse_multiply_region;
  1400 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_bytwo_b_sse_multiply_region)
1401 1401 #else
1402   - gf->multiply_region.w32 = gf_w32_bytwo_b_nosse_multiply_region;
  1402 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_bytwo_b_nosse_multiply_region)
1403 1403 if(h->region_type & GF_REGION_SIMD)
1404 1404 return 0;
1405 1405 #endif
1406 1406 }
1407 1407  
1408   - gf->inverse.w32 = gf_w32_euclid;
  1408 + SET_FUNCTION(gf,inverse,w32,gf_w32_euclid)
1409 1409 return 1;
1410 1410 }
1411 1411  
... ... @@ -2252,7 +2252,7 @@ int gf_w32_split_init(gf_t *gf)
2252 2252  
2253 2253 /* Defaults */
2254 2254  
2255   - gf->inverse.w32 = gf_w32_euclid;
  2255 + SET_FUNCTION(gf,inverse,w32,gf_w32_euclid)
2256 2256  
2257 2257 /* JSP: First handle single multiplication:
2258 2258 If args == 8, then we're doing split 8 8.
... ... @@ -2261,17 +2261,17 @@ int gf_w32_split_init(gf_t *gf)
2261 2261 */
2262 2262  
2263 2263 if (h->arg1 == 8 && h->arg2 == 8) {
2264   - gf->multiply.w32 = gf_w32_split_8_8_multiply;
  2264 + SET_FUNCTION(gf,multiply,w32,gf_w32_split_8_8_multiply)
2265 2265 } else if (ispclmul) {
2266 2266 if ((0xfffe0000 & h->prim_poly) == 0){
2267   - gf->multiply.w32 = gf_w32_clm_multiply_2;
  2267 + SET_FUNCTION(gf,multiply,w32,gf_w32_clm_multiply_2)
2268 2268 } else if ((0xffc00000 & h->prim_poly) == 0){
2269   - gf->multiply.w32 = gf_w32_clm_multiply_3;
  2269 + SET_FUNCTION(gf,multiply,w32,gf_w32_clm_multiply_3)
2270 2270 } else if ((0xfe000000 & h->prim_poly) == 0){
2271   - gf->multiply.w32 = gf_w32_clm_multiply_4;
  2271 + SET_FUNCTION(gf,multiply,w32,gf_w32_clm_multiply_4)
2272 2272 }
2273 2273 } else {
2274   - gf->multiply.w32 = gf_w32_bytwo_p_multiply;
  2274 + SET_FUNCTION(gf,multiply,w32,gf_w32_bytwo_p_multiply)
2275 2275 }
2276 2276  
2277 2277 /* Easy cases: 16/32 and 2/32 */
... ... @@ -2279,7 +2279,7 @@ int gf_w32_split_init(gf_t *gf)
2279 2279 if ((h->arg1 == 16 && h->arg2 == 32) || (h->arg1 == 32 && h->arg2 == 16)) {
2280 2280 d16 = (struct gf_split_16_32_lazy_data *) h->private;
2281 2281 d16->last_value = 0;
2282   - gf->multiply_region.w32 = gf_w32_split_16_32_lazy_multiply_region;
  2282 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_16_32_lazy_multiply_region)
2283 2283 return 1;
2284 2284 }
2285 2285  
... ... @@ -2288,11 +2288,11 @@ int gf_w32_split_init(gf_t *gf)
2288 2288 ld2->last_value = 0;
2289 2289 #ifdef INTEL_SSSE3
2290 2290 if (!(h->region_type & GF_REGION_NOSIMD))
2291   - gf->multiply_region.w32 = gf_w32_split_2_32_lazy_sse_multiply_region;
  2291 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_2_32_lazy_sse_multiply_region)
2292 2292 else
2293   - gf->multiply_region.w32 = gf_w32_split_2_32_lazy_multiply_region;
  2293 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_2_32_lazy_multiply_region)
2294 2294 #else
2295   - gf->multiply_region.w32 = gf_w32_split_2_32_lazy_multiply_region;
  2295 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_2_32_lazy_multiply_region)
2296 2296 if(h->region_type & GF_REGION_SIMD) return 0;
2297 2297 #endif
2298 2298 return 1;
... ... @@ -2305,15 +2305,15 @@ int gf_w32_split_init(gf_t *gf)
2305 2305 ld4 = (struct gf_split_4_32_lazy_data *) h->private;
2306 2306 ld4->last_value = 0;
2307 2307 if ((h->region_type & GF_REGION_NOSIMD) || !(issse3 || isneon)) {
2308   - gf->multiply_region.w32 = gf_w32_split_4_32_lazy_multiply_region;
  2308 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_4_32_lazy_multiply_region)
2309 2309 } else if (isneon) {
2310 2310 #ifdef ARM_NEON
2311 2311 gf_w32_neon_split_init(gf);
2312 2312 #endif
2313 2313 } else if (h->region_type & GF_REGION_ALTMAP) {
2314   - gf->multiply_region.w32 = gf_w32_split_4_32_lazy_sse_altmap_multiply_region;
  2314 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_4_32_lazy_sse_altmap_multiply_region)
2315 2315 } else {
2316   - gf->multiply_region.w32 = gf_w32_split_4_32_lazy_sse_multiply_region;
  2316 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_4_32_lazy_sse_multiply_region)
2317 2317 }
2318 2318 return 1;
2319 2319 }
... ... @@ -2324,7 +2324,7 @@ int gf_w32_split_init(gf_t *gf)
2324 2324 h->mult_type == GF_MULT_DEFAULT) {
2325 2325 d32 = (struct gf_split_8_32_lazy_data *) h->private;
2326 2326 d32->last_value = 0;
2327   - gf->multiply_region.w32 = gf_w32_split_8_32_lazy_multiply_region;
  2327 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_8_32_lazy_multiply_region)
2328 2328 return 1;
2329 2329 }
2330 2330  
... ... @@ -2333,8 +2333,8 @@ int gf_w32_split_init(gf_t *gf)
2333 2333 if (h->arg1 == 8 && h->arg2 == 8) {
2334 2334 d8 = (struct gf_w32_split_8_8_data *) h->private;
2335 2335 d8->last_value = 0;
2336   - gf->multiply.w32 = gf_w32_split_8_8_multiply;
2337   - gf->multiply_region.w32 = gf_w32_split_8_32_lazy_multiply_region;
  2336 + SET_FUNCTION(gf,multiply,w32,gf_w32_split_8_8_multiply)
  2337 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_8_32_lazy_multiply_region)
2338 2338 basep = 1;
2339 2339 for (exp = 0; exp < 7; exp++) {
2340 2340 for (j = 0; j < 256; j++) d8->tables[exp][0][j] = 0;
... ... @@ -2407,14 +2407,14 @@ int gf_w32_group_init(gf_t *gf)
2407 2407 }
2408 2408  
2409 2409 if (g_s == g_r) {
2410   - gf->multiply.w32 = gf_w32_group_s_equals_r_multiply;
2411   - gf->multiply_region.w32 = gf_w32_group_s_equals_r_multiply_region;
  2410 + SET_FUNCTION(gf,multiply,w32,gf_w32_group_s_equals_r_multiply)
  2411 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_group_s_equals_r_multiply_region)
2412 2412 } else {
2413   - gf->multiply.w32 = gf_w32_group_multiply;
2414   - gf->multiply_region.w32 = gf_w32_group_multiply_region;
  2413 + SET_FUNCTION(gf,multiply,w32,gf_w32_group_multiply)
  2414 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_group_multiply_region)
2415 2415 }
2416   - gf->divide.w32 = NULL;
2417   - gf->inverse.w32 = gf_w32_euclid;
  2416 + SET_FUNCTION(gf,divide,w32,NULL)
  2417 + SET_FUNCTION(gf,inverse,w32,gf_w32_euclid)
2418 2418  
2419 2419 return 1;
2420 2420 }
... ... @@ -2666,18 +2666,18 @@ int gf_w32_composite_init(gf_t *gf)
2666 2666 cd->alog = gf_w16_get_mult_alog_table(h->base_gf);
2667 2667  
2668 2668 if (h->region_type & GF_REGION_ALTMAP) {
2669   - gf->multiply_region.w32 = gf_w32_composite_multiply_region_alt;
  2669 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_composite_multiply_region_alt)
2670 2670 } else {
2671   - gf->multiply_region.w32 = gf_w32_composite_multiply_region;
  2671 + SET_FUNCTION(gf,multiply_region,w32,gf_w32_composite_multiply_region)
2672 2672 }
2673 2673  
2674 2674 if (cd->log == NULL) {
2675   - gf->multiply.w32 = gf_w32_composite_multiply_recursive;
  2675 + SET_FUNCTION(gf,multiply,w32,gf_w32_composite_multiply_recursive)
2676 2676 } else {
2677   - gf->multiply.w32 = gf_w32_composite_multiply_inline;
  2677 + SET_FUNCTION(gf,multiply,w32,gf_w32_composite_multiply_inline)
2678 2678 }
2679   - gf->divide.w32 = NULL;
2680   - gf->inverse.w32 = gf_w32_composite_inverse;
  2679 + SET_FUNCTION(gf,divide,w32,NULL)
  2680 + SET_FUNCTION(gf,inverse,w32,gf_w32_composite_inverse)
2681 2681  
2682 2682 return 1;
2683 2683 }
... ... @@ -2776,10 +2776,10 @@ int gf_w32_init(gf_t *gf)
2776 2776  
2777 2777 if(h->mult_type != GF_MULT_COMPOSITE) h->prim_poly &= 0xffffffff;
2778 2778  
2779   - gf->multiply.w32 = NULL;
2780   - gf->divide.w32 = NULL;
2781   - gf->inverse.w32 = NULL;
2782   - gf->multiply_region.w32 = NULL;
  2779 + SET_FUNCTION(gf,multiply,w32,NULL)
  2780 + SET_FUNCTION(gf,divide,w32,NULL)
  2781 + SET_FUNCTION(gf,inverse,w32,NULL)
  2782 + SET_FUNCTION(gf,multiply_region,w32,NULL)
2783 2783  
2784 2784 switch(h->mult_type) {
2785 2785 case GF_MULT_CARRY_FREE: if (gf_w32_cfm_init(gf) == 0) return 0; break;
... ... @@ -2794,30 +2794,30 @@ int gf_w32_init(gf_t *gf)
2794 2794 default: return 0;
2795 2795 }
2796 2796 if (h->divide_type == GF_DIVIDE_EUCLID) {
2797   - gf->divide.w32 = gf_w32_divide_from_inverse;
2798   - gf->inverse.w32 = gf_w32_euclid;
  2797 + SET_FUNCTION(gf,divide,w32,gf_w32_divide_from_inverse)
  2798 + SET_FUNCTION(gf,inverse,w32,gf_w32_euclid)
2799 2799 } else if (h->divide_type == GF_DIVIDE_MATRIX) {
2800   - gf->divide.w32 = gf_w32_divide_from_inverse;
2801   - gf->inverse.w32 = gf_w32_matrix;
  2800 + SET_FUNCTION(gf,divide,w32,gf_w32_divide_from_inverse)
  2801 + SET_FUNCTION(gf,inverse,w32,gf_w32_matrix)
2802 2802 }
2803 2803  
2804 2804 if (gf->inverse.w32 != NULL && gf->divide.w32 == NULL) {
2805   - gf->divide.w32 = gf_w32_divide_from_inverse;
  2805 + SET_FUNCTION(gf,divide,w32,gf_w32_divide_from_inverse)
2806 2806 }
2807 2807 if (gf->inverse.w32 == NULL && gf->divide.w32 != NULL) {
2808   - gf->inverse.w32 = gf_w32_inverse_from_divide;
  2808 + SET_FUNCTION(gf,inverse,w32,gf_w32_inverse_from_divide)
2809 2809 }
2810 2810 if (h->region_type == GF_REGION_CAUCHY) {
2811   - gf->extract_word.w32 = gf_wgen_extract_word;
2812   - gf->multiply_region.w32 = gf_wgen_cauchy_region;
  2811 + SET_FUNCTION(gf,extract_word,w32,gf_wgen_extract_word)
  2812 + SET_FUNCTION(gf,multiply_region,w32,gf_wgen_cauchy_region)
2813 2813 } else if (h->region_type & GF_REGION_ALTMAP) {
2814 2814 if (h->mult_type == GF_MULT_COMPOSITE) {
2815   - gf->extract_word.w32 = gf_w32_composite_extract_word;
  2815 + SET_FUNCTION(gf,extract_word,w32,gf_w32_composite_extract_word)
2816 2816 } else {
2817   - gf->extract_word.w32 = gf_w32_split_extract_word;
  2817 + SET_FUNCTION(gf,extract_word,w32,gf_w32_split_extract_word)
2818 2818 }
2819 2819 } else {
2820   - gf->extract_word.w32 = gf_w32_extract_word;
  2820 + SET_FUNCTION(gf,extract_word,w32,gf_w32_extract_word)
2821 2821 }
2822 2822 return 1;
2823 2823 }
... ...
src/gf_w4.c
... ... @@ -311,10 +311,10 @@ int gf_w4_log_init(gf_t *gf)
311 311 return 0;
312 312 }
313 313  
314   - gf->inverse.w32 = gf_w4_inverse_from_divide;
315   - gf->divide.w32 = gf_w4_log_divide;
316   - gf->multiply.w32 = gf_w4_log_multiply;
317   - gf->multiply_region.w32 = gf_w4_log_multiply_region;
  314 + SET_FUNCTION(gf,inverse,w32,gf_w4_inverse_from_divide)
  315 + SET_FUNCTION(gf,divide,w32,gf_w4_log_divide)
  316 + SET_FUNCTION(gf,multiply,w32,gf_w4_log_multiply)
  317 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_log_multiply_region)
318 318 return 1;
319 319 }
320 320  
... ... @@ -444,20 +444,20 @@ int gf_w4_single_table_init(gf_t *gf)
444 444 }
445 445 }
446 446  
447   - gf->inverse.w32 = NULL;
448   - gf->divide.w32 = gf_w4_single_table_divide;
449   - gf->multiply.w32 = gf_w4_single_table_multiply;
  447 + SET_FUNCTION(gf,inverse,w32,NULL)
  448 + SET_FUNCTION(gf,divide,w32,gf_w4_single_table_divide)
  449 + SET_FUNCTION(gf,multiply,w32,gf_w4_single_table_multiply)
450 450 #if defined(INTEL_SSSE3) || defined(ARM_NEON)
451 451 if(h->region_type & (GF_REGION_NOSIMD | GF_REGION_CAUCHY))
452   - gf->multiply_region.w32 = gf_w4_single_table_multiply_region;
  452 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_single_table_multiply_region)
453 453 else
454 454 #if defined(INTEL_SSSE3)
455   - gf->multiply_region.w32 = gf_w4_single_table_sse_multiply_region;
  455 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_single_table_sse_multiply_region)
456 456 #elif defined(ARM_NEON)
457 457 gf_w4_neon_single_table_init(gf);
458 458 #endif
459 459 #else
460   - gf->multiply_region.w32 = gf_w4_single_table_multiply_region;
  460 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_single_table_multiply_region)
461 461 if (h->region_type & GF_REGION_SIMD) return 0;
462 462 #endif
463 463  
... ... @@ -548,10 +548,10 @@ int gf_w4_double_table_init(gf_t *gf)
548 548 }
549 549 }
550 550  
551   - gf->inverse.w32 = NULL;
552   - gf->divide.w32 = gf_w4_double_table_divide;
553   - gf->multiply.w32 = gf_w4_double_table_multiply;
554   - gf->multiply_region.w32 = gf_w4_double_table_multiply_region;
  551 + SET_FUNCTION(gf,inverse,w32,NULL)
  552 + SET_FUNCTION(gf,divide,w32,gf_w4_double_table_divide)
  553 + SET_FUNCTION(gf,multiply,w32,gf_w4_double_table_multiply)
  554 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_double_table_multiply_region)
555 555 return 1;
556 556 }
557 557  
... ... @@ -682,10 +682,10 @@ int gf_w4_quad_table_init(gf_t *gf)
682 682 }
683 683 }
684 684  
685   - gf->inverse.w32 = NULL;
686   - gf->divide.w32 = gf_w4_quad_table_divide;
687   - gf->multiply.w32 = gf_w4_quad_table_multiply;
688   - gf->multiply_region.w32 = gf_w4_quad_table_multiply_region;
  685 + SET_FUNCTION(gf,inverse,w32,NULL)
  686 + SET_FUNCTION(gf,divide,w32,gf_w4_quad_table_divide)
  687 + SET_FUNCTION(gf,multiply,w32,gf_w4_quad_table_multiply)
  688 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_quad_table_multiply_region)
689 689 return 1;
690 690 }
691 691 static
... ... @@ -724,10 +724,10 @@ int gf_w4_quad_table_lazy_init(gf_t *gf)
724 724 }
725 725 }
726 726  
727   - gf->inverse.w32 = NULL;
728   - gf->divide.w32 = gf_w4_quad_table_lazy_divide;
729   - gf->multiply.w32 = gf_w4_quad_table_lazy_multiply;
730   - gf->multiply_region.w32 = gf_w4_quad_table_multiply_region;
  727 + SET_FUNCTION(gf,inverse,w32,NULL)
  728 + SET_FUNCTION(gf,divide,w32,gf_w4_quad_table_lazy_divide)
  729 + SET_FUNCTION(gf,multiply,w32,gf_w4_quad_table_lazy_multiply)
  730 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_quad_table_multiply_region)
731 731 return 1;
732 732 }
733 733  
... ... @@ -1865,26 +1865,26 @@ int gf_w4_bytwo_init(gf_t *gf)
1865 1865 }
1866 1866  
1867 1867 if (h->mult_type == GF_MULT_BYTWO_p) {
1868   - gf->multiply.w32 = gf_w4_bytwo_p_multiply;
  1868 + SET_FUNCTION(gf,multiply,w32,gf_w4_bytwo_p_multiply)
1869 1869 #ifdef INTEL_SSE2
1870 1870 if (h->region_type & GF_REGION_NOSIMD)
1871   - gf->multiply_region.w32 = gf_w4_bytwo_p_nosse_multiply_region;
  1871 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_bytwo_p_nosse_multiply_region)
1872 1872 else
1873   - gf->multiply_region.w32 = gf_w4_bytwo_p_sse_multiply_region;
  1873 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_bytwo_p_sse_multiply_region)
1874 1874 #else
1875   - gf->multiply_region.w32 = gf_w4_bytwo_p_nosse_multiply_region;
  1875 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_bytwo_p_nosse_multiply_region)
1876 1876 if (h->region_type & GF_REGION_SIMD)
1877 1877 return 0;
1878 1878 #endif
1879 1879 } else {
1880   - gf->multiply.w32 = gf_w4_bytwo_b_multiply;
  1880 + SET_FUNCTION(gf,multiply,w32,gf_w4_bytwo_b_multiply)
1881 1881 #ifdef INTEL_SSE2
1882 1882 if (h->region_type & GF_REGION_NOSIMD)
1883   - gf->multiply_region.w32 = gf_w4_bytwo_b_nosse_multiply_region;
  1883 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_bytwo_b_nosse_multiply_region)
1884 1884 else
1885   - gf->multiply_region.w32 = gf_w4_bytwo_b_sse_multiply_region;
  1885 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_bytwo_b_sse_multiply_region)
1886 1886 #else
1887   - gf->multiply_region.w32 = gf_w4_bytwo_b_nosse_multiply_region;
  1887 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_bytwo_b_nosse_multiply_region)
1888 1888 if (h->region_type & GF_REGION_SIMD)
1889 1889 return 0;
1890 1890 #endif
... ... @@ -1897,7 +1897,7 @@ static
1897 1897 int gf_w4_cfm_init(gf_t *gf)
1898 1898 {
1899 1899 #if defined(INTEL_SSE4_PCLMUL)
1900   - gf->multiply.w32 = gf_w4_clm_multiply;
  1900 + SET_FUNCTION(gf,multiply,w32,gf_w4_clm_multiply)
1901 1901 return 1;
1902 1902 #elif defined(ARM_NEON)
1903 1903 return gf_w4_neon_cfm_init(gf);
... ... @@ -1908,7 +1908,7 @@ int gf_w4_cfm_init(gf_t *gf)
1908 1908 static
1909 1909 int gf_w4_shift_init(gf_t *gf)
1910 1910 {
1911   - gf->multiply.w32 = gf_w4_shift_multiply;
  1911 + SET_FUNCTION(gf,multiply,w32,gf_w4_shift_multiply)
1912 1912 return 1;
1913 1913 }
1914 1914  
... ... @@ -1977,11 +1977,11 @@ gf_w4_init (gf_t *gf)
1977 1977 h = (gf_internal_t *) gf->scratch;
1978 1978 if (h->prim_poly == 0) h->prim_poly = 0x13;
1979 1979 h->prim_poly |= 0x10;
1980   - gf->multiply.w32 = NULL;
1981   - gf->divide.w32 = NULL;
1982   - gf->inverse.w32 = NULL;
1983   - gf->multiply_region.w32 = NULL;
1984   - gf->extract_word.w32 = gf_w4_extract_word;
  1980 + SET_FUNCTION(gf,multiply,w32,NULL)
  1981 + SET_FUNCTION(gf,divide,w32,NULL)
  1982 + SET_FUNCTION(gf,inverse,w32,NULL)
  1983 + SET_FUNCTION(gf,multiply_region,w32,NULL)
  1984 + SET_FUNCTION(gf,extract_word,w32,gf_w4_extract_word)
1985 1985  
1986 1986 switch(h->mult_type) {
1987 1987 case GF_MULT_CARRY_FREE: if (gf_w4_cfm_init(gf) == 0) return 0; break;
... ... @@ -1995,27 +1995,27 @@ gf_w4_init (gf_t *gf)
1995 1995 }
1996 1996  
1997 1997 if (h->divide_type == GF_DIVIDE_EUCLID) {
1998   - gf->divide.w32 = gf_w4_divide_from_inverse;
1999   - gf->inverse.w32 = gf_w4_euclid;
  1998 + SET_FUNCTION(gf,divide,w32,gf_w4_divide_from_inverse)
  1999 + SET_FUNCTION(gf,inverse,w32,gf_w4_euclid)
2000 2000 } else if (h->divide_type == GF_DIVIDE_MATRIX) {
2001   - gf->divide.w32 = gf_w4_divide_from_inverse;
2002   - gf->inverse.w32 = gf_w4_matrix;
  2001 + SET_FUNCTION(gf,divide,w32,gf_w4_divide_from_inverse)
  2002 + SET_FUNCTION(gf,inverse,w32,gf_w4_matrix)
2003 2003 }
2004 2004  
2005 2005 if (gf->divide.w32 == NULL) {
2006   - gf->divide.w32 = gf_w4_divide_from_inverse;
2007   - if (gf->inverse.w32 == NULL) gf->inverse.w32 = gf_w4_euclid;
  2006 + SET_FUNCTION(gf,divide,w32,gf_w4_divide_from_inverse)
  2007 + if (gf->inverse.w32 == NULL) SET_FUNCTION(gf,inverse,w32,gf_w4_euclid)
2008 2008 }
2009 2009  
2010   - if (gf->inverse.w32 == NULL) gf->inverse.w32 = gf_w4_inverse_from_divide;
  2010 + if (gf->inverse.w32 == NULL) SET_FUNCTION(gf,inverse,w32,gf_w4_inverse_from_divide)
2011 2011  
2012 2012 if (h->region_type == GF_REGION_CAUCHY) {
2013   - gf->multiply_region.w32 = gf_wgen_cauchy_region;
2014   - gf->extract_word.w32 = gf_wgen_extract_word;
  2013 + SET_FUNCTION(gf,multiply_region,w32,gf_wgen_cauchy_region)
  2014 + SET_FUNCTION(gf,extract_word,w32,gf_wgen_extract_word)
2015 2015 }
2016 2016  
2017 2017 if (gf->multiply_region.w32 == NULL) {
2018   - gf->multiply_region.w32 = gf_w4_multiply_region_from_single;
  2018 + SET_FUNCTION(gf,multiply_region,w32,gf_w4_multiply_region_from_single)
2019 2019 }
2020 2020  
2021 2021 return 1;
... ...
src/gf_w64.c
... ... @@ -697,17 +697,17 @@ gf_w64_split_16_64_lazy_multiply_region(gf_t *gf, void *src, void *dest, uint64_
697 697 static
698 698 int gf_w64_shift_init(gf_t *gf)
699 699 {
700   - gf->multiply.w64 = gf_w64_shift_multiply;
701   - gf->inverse.w64 = gf_w64_euclid;
702   - gf->multiply_region.w64 = gf_w64_multiply_region_from_single;
  700 + SET_FUNCTION(gf,multiply,w64,gf_w64_shift_multiply)
  701 + SET_FUNCTION(gf,inverse,w64,gf_w64_euclid)
  702 + SET_FUNCTION(gf,multiply_region,w64,gf_w64_multiply_region_from_single)
703 703 return 1;
704 704 }
705 705  
706 706 static
707 707 int gf_w64_cfm_init(gf_t *gf)
708 708 {
709   - gf->inverse.w64 = gf_w64_euclid;
710   - gf->multiply_region.w64 = gf_w64_multiply_region_from_single;
  709 + SET_FUNCTION(gf,inverse,w64,gf_w64_euclid)
  710 + SET_FUNCTION(gf,multiply_region,w64,gf_w64_multiply_region_from_single)
711 711  
712 712 #if defined(INTEL_SSE4_PCLMUL)
713 713 gf_internal_t *h;
... ... @@ -715,11 +715,11 @@ int gf_w64_cfm_init(gf_t *gf)
715 715 h = (gf_internal_t *) gf->scratch;
716 716  
717 717 if ((0xfffffffe00000000ULL & h->prim_poly) == 0){
718   - gf->multiply.w64 = gf_w64_clm_multiply_2;
719   - gf->multiply_region.w64 = gf_w64_clm_multiply_region_from_single_2;
  718 + SET_FUNCTION(gf,multiply,w64,gf_w64_clm_multiply_2)
  719 + SET_FUNCTION(gf,multiply_region,w64,gf_w64_clm_multiply_region_from_single_2)
720 720 }else if((0xfffe000000000000ULL & h->prim_poly) == 0){
721   - gf->multiply.w64 = gf_w64_clm_multiply_4;
722   - gf->multiply_region.w64 = gf_w64_clm_multiply_region_from_single_4;
  721 + SET_FUNCTION(gf,multiply,w64,gf_w64_clm_multiply_4)
  722 + SET_FUNCTION(gf,multiply_region,w64,gf_w64_clm_multiply_region_from_single_4)
723 723 } else {
724 724 return 0;
725 725 }
... ... @@ -1008,14 +1008,14 @@ int gf_w64_group_init(gf_t *gf)