Commit fc54fcb
committed
ctypes: use the correct ABI for variadic functions
On arm64 the calling convention for variardic functions is different
than the convention for fixed-arg functions of the same arg types.
ctypes needs to use ffi_prep_cif_var to tell libffi which calling
convention to use.
This patch adds a new attribute "f.variadic" for ctypes function
pointers, so users can specify which functions are variadic.
It will also auto-detect varargs when a function is called with more
arguments than f.argtypes specifies. Since this is a new option
and it only matters on arm64 on apple platforms, lots of existing code
will not set f.variadic. This will do the right thing in most
situations.1 parent 1648c99 commit fc54fcb
File tree
7 files changed
+86
-12
lines changed- Doc/library
- Lib/test
- Misc/NEWS.d/next/Core and Builtins
- Modules/_ctypes
7 files changed
+86
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1579 | 1579 | | |
1580 | 1580 | | |
1581 | 1581 | | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
1582 | 1589 | | |
1583 | 1590 | | |
1584 | 1591 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1034 | 1034 | | |
1035 | 1035 | | |
1036 | 1036 | | |
| 1037 | + | |
| 1038 | + | |
1037 | 1039 | | |
1038 | 1040 | | |
1039 | 1041 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2509 | 2509 | | |
2510 | 2510 | | |
2511 | 2511 | | |
| 2512 | + | |
2512 | 2513 | | |
2513 | 2514 | | |
2514 | 2515 | | |
2515 | 2516 | | |
2516 | 2517 | | |
| 2518 | + | |
| 2519 | + | |
2517 | 2520 | | |
2518 | 2521 | | |
2519 | 2522 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3320 | 3320 | | |
3321 | 3321 | | |
3322 | 3322 | | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
3323 | 3352 | | |
3324 | 3353 | | |
3325 | 3354 | | |
| |||
3365 | 3394 | | |
3366 | 3395 | | |
3367 | 3396 | | |
| 3397 | + | |
| 3398 | + | |
3368 | 3399 | | |
3369 | 3400 | | |
3370 | 3401 | | |
| |||
5839 | 5870 | | |
5840 | 5871 | | |
5841 | 5872 | | |
| 5873 | + | |
5842 | 5874 | | |
5843 | 5875 | | |
5844 | 5876 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
| |||
812 | 816 | | |
813 | 817 | | |
814 | 818 | | |
815 | | - | |
| 819 | + | |
| 820 | + | |
816 | 821 | | |
817 | 822 | | |
818 | 823 | | |
| |||
835 | 840 | | |
836 | 841 | | |
837 | 842 | | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
846 | 874 | | |
| 875 | + | |
847 | 876 | | |
848 | 877 | | |
849 | 878 | | |
| |||
1212 | 1241 | | |
1213 | 1242 | | |
1214 | 1243 | | |
1215 | | - | |
1216 | | - | |
1217 | | - | |
| 1244 | + | |
| 1245 | + | |
1218 | 1246 | | |
1219 | 1247 | | |
1220 | 1248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
| |||
0 commit comments