Skip to content

Commit 0c21214

Browse files
committed
replace usage of Py_VA_COPY with the (C99) standard va_copy
1 parent ec2319c commit 0c21214

File tree

8 files changed

+11
-71
lines changed

8 files changed

+11
-71
lines changed

Include/pyport.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -723,15 +723,7 @@ extern pid_t forkpty(int *, char *, struct termios *, struct winsize *);
723723
#define Py_ULL(x) Py_LL(x##U)
724724
#endif
725725

726-
#ifdef VA_LIST_IS_ARRAY
727-
#define Py_VA_COPY(x, y) memcpy((x), (y), sizeof(va_list))
728-
#else
729-
#ifdef __va_copy
730-
#define Py_VA_COPY __va_copy
731-
#else
732-
#define Py_VA_COPY(x, y) (x) = (y)
733-
#endif
734-
#endif
726+
#define Py_VA_COPY va_copy
735727

736728
/*
737729
* Convenient macros to deal with endianness of the platform. WORDS_BIGENDIAN is

Objects/abstract.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,7 @@ objargs_mkstack(PyObject **small_stack, Py_ssize_t small_stack_size,
26832683
PyObject **stack;
26842684

26852685
/* Count the number of arguments */
2686-
Py_VA_COPY(countva, va);
2686+
va_copy(countva, va);
26872687

26882688
n = 0;
26892689
while (1) {

Objects/unicodeobject.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,9 +2874,8 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
28742874
writer.min_length = strlen(format) + 100;
28752875
writer.overallocate = 1;
28762876

2877-
/* va_list may be an array (of 1 item) on some platforms (ex: AMD64).
2878-
Copy it to be able to pass a reference to a subfunction. */
2879-
Py_VA_COPY(vargs2, vargs);
2877+
// Copy varags to be able to pass a reference to a subfunction.
2878+
va_copy(vargs2, vargs);
28802879

28812880
for (f = format; *f; ) {
28822881
if (*f == '%') {

Python/getargs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ PyArg_VaParse(PyObject *args, const char *format, va_list va)
142142
{
143143
va_list lva;
144144

145-
Py_VA_COPY(lva, va);
145+
va_copy(lva, va);
146146

147147
return vgetargs1(args, format, &lva, 0);
148148
}
@@ -152,7 +152,7 @@ _PyArg_VaParse_SizeT(PyObject *args, const char *format, va_list va)
152152
{
153153
va_list lva;
154154

155-
Py_VA_COPY(lva, va);
155+
va_copy(lva, va);
156156

157157
return vgetargs1(args, format, &lva, FLAG_SIZE_T);
158158
}
@@ -1402,7 +1402,7 @@ PyArg_VaParseTupleAndKeywords(PyObject *args,
14021402
return 0;
14031403
}
14041404

1405-
Py_VA_COPY(lva, va);
1405+
va_copy(lva, va);
14061406

14071407
retval = vgetargskeywords(args, keywords, format, kwlist, &lva, 0);
14081408
return retval;
@@ -1426,7 +1426,7 @@ _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *args,
14261426
return 0;
14271427
}
14281428

1429-
Py_VA_COPY(lva, va);
1429+
va_copy(lva, va);
14301430

14311431
retval = vgetargskeywords(args, keywords, format,
14321432
kwlist, &lva, FLAG_SIZE_T);
@@ -1531,7 +1531,7 @@ _PyArg_VaParseTupleAndKeywordsFast(PyObject *args, PyObject *keywords,
15311531
return 0;
15321532
}
15331533

1534-
Py_VA_COPY(lva, va);
1534+
va_copy(lva, va);
15351535

15361536
retval = vgetargskeywordsfast(args, keywords, parser, &lva, 0);
15371537
return retval;
@@ -1552,7 +1552,7 @@ _PyArg_VaParseTupleAndKeywordsFast_SizeT(PyObject *args, PyObject *keywords,
15521552
return 0;
15531553
}
15541554

1555-
Py_VA_COPY(lva, va);
1555+
va_copy(lva, va);
15561556

15571557
retval = vgetargskeywordsfast(args, keywords, parser, &lva, FLAG_SIZE_T);
15581558
return retval;

Python/modsupport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ va_build_value(const char *format, va_list va, int flags)
468468
int n = countformat(f, '\0');
469469
va_list lva;
470470

471-
Py_VA_COPY(lva, va);
471+
va_copy(lva, va);
472472

473473
if (n < 0)
474474
return NULL;

configure

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13539,40 +13539,6 @@ $as_echo "no" >&6; }
1353913539
fi
1354013540
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1354113541

13542-
va_list_is_array=no
13543-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether va_list is an array" >&5
13544-
$as_echo_n "checking whether va_list is an array... " >&6; }
13545-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13546-
/* end confdefs.h. */
13547-
13548-
#ifdef HAVE_STDARG_PROTOTYPES
13549-
#include <stdarg.h>
13550-
#else
13551-
#include <varargs.h>
13552-
#endif
13553-
13554-
int
13555-
main ()
13556-
{
13557-
va_list list1, list2; list1 = list2;
13558-
;
13559-
return 0;
13560-
}
13561-
_ACEOF
13562-
if ac_fn_c_try_compile "$LINENO"; then :
13563-
13564-
else
13565-
13566-
13567-
$as_echo "#define VA_LIST_IS_ARRAY 1" >>confdefs.h
13568-
13569-
va_list_is_array=yes
13570-
13571-
fi
13572-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13573-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $va_list_is_array" >&5
13574-
$as_echo "$va_list_is_array" >&6; }
13575-
1357613542
# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1357713543

1357813544

configure.ac

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4038,20 +4038,6 @@ x.sa_len = 0;]])],
40384038
[AC_MSG_RESULT(no)]
40394039
)
40404040

4041-
va_list_is_array=no
4042-
AC_MSG_CHECKING(whether va_list is an array)
4043-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4044-
#ifdef HAVE_STDARG_PROTOTYPES
4045-
#include <stdarg.h>
4046-
#else
4047-
#include <varargs.h>
4048-
#endif
4049-
]], [[va_list list1, list2; list1 = list2;]])],[],[
4050-
AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
4051-
va_list_is_array=yes
4052-
])
4053-
AC_MSG_RESULT($va_list_is_array)
4054-
40554041
# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
40564042
AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
40574043
[Define this if you have some version of gethostbyname_r()])

pyconfig.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,9 +1361,6 @@
13611361
#endif
13621362

13631363

1364-
/* Define if a va_list is an array of some kind */
1365-
#undef VA_LIST_IS_ARRAY
1366-
13671364
/* Define if you want SIGFPE handled (see Include/pyfpe.h). */
13681365
#undef WANT_SIGFPE_HANDLER
13691366

0 commit comments

Comments
 (0)