Index: Lib/ctypes/test/test_callbacks.py =================================================================== --- Lib/ctypes/test/test_callbacks.py (revision 88199) +++ Lib/ctypes/test/test_callbacks.py (working copy) @@ -207,6 +207,37 @@ windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) self.assertFalse(windowCount == 0) + def test_callback_register_int(self): + dll = CDLL(_ctypes_test.__file__) + CALLBACK = CFUNCTYPE(c_int, c_int, c_int, c_int, c_int, c_int) + func = dll._testfunc_cbk_reg_int + func.argtypes = (c_int, c_int, c_int, c_int, c_int, CALLBACK) + func.restype = c_int + + def callback(a, b, c, d, e): + return a+b+c+d+e + + result = func(1, 2, 3, 4, 5, CALLBACK(callback)) + self.assertEqual(result, callback(1*1, 2*2, 3*3, 4*4, 5*5)) + + + def test_callback_register_double(self): + dll = CDLL(_ctypes_test.__file__) + + CALLBACK = CFUNCTYPE(c_double, c_double, c_double, c_double, + c_double, c_double) + func = dll._testfunc_cbk_reg_double + func.argtypes = (c_double, c_double, c_double, + c_double, c_double, CALLBACK) + func.restype = c_double + + def callback(a, b, c, d, e): + return a+b+c+d+e + + result = func(1.1, 2.2, 3.3, 4.4, 5.5, CALLBACK(callback)) + self.assertEqual(result, callback(1.1*1.1, 2.2*2.2, 3.3*3.3 + , 4.4*4.4, 5.5*5.5)) + ################################################################ if __name__ == '__main__': Index: Modules/_ctypes/libffi_msvc/ffi.c =================================================================== --- Modules/_ctypes/libffi_msvc/ffi.c (revision 88199) +++ Modules/_ctypes/libffi_msvc/ffi.c (working copy) @@ -379,7 +379,7 @@ short bytes; char *tramp; #ifdef _WIN64 - int mask; + int mask = 0; #endif FFI_ASSERT (cif->abi == FFI_SYSV); Index: Modules/_ctypes/_ctypes_test.c =================================================================== --- Modules/_ctypes/_ctypes_test.c (revision 88199) +++ Modules/_ctypes/_ctypes_test.c (working copy) @@ -25,6 +25,19 @@ /* some functions handy for testing */ +EXPORT(int) +_testfunc_cbk_reg_int(int a, int b, int c, int d, int e, + int (*func)(int, int, int, int, int)) +{ + return func(a*a, b*b, c*c, d*d, e*e); +} + +EXPORT(double) +_testfunc_cbk_reg_double(double a, double b, double c, double d, double e, + double (*func)(double, double, double, double, double)) +{ + return func(a*a, b*b, c*c, d*d, e*e); +} EXPORT(void)testfunc_array(int values[4]) { printf("testfunc_array %d %d %d %d\n",