├── .gitignore
├── HowItsDone
├── Python-iOS-app.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── fancyzero.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── fancyzero.xcuserdatad
│ └── xcschemes
│ ├── Python-iOS-app.xcscheme
│ └── xcschememanagement.plist
├── Python-iOS-app
├── AppDelegate.h
├── AppDelegate.m
├── Default-568h@2x.png
├── Default.png
├── Default@2x.png
├── Python-iOS-app-Info.plist
├── Python-iOS-app-Prefix.pch
├── ViewController.h
├── ViewController.m
├── en.lproj
│ ├── InfoPlist.strings
│ ├── ViewController_iPad.xib
│ └── ViewController_iPhone.xib
├── main.m
└── python
│ └── lib
│ ├── python2.7
│ └── site-packages
│ │ └── README
│ └── python27.zip
├── README.md
├── libPython.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── fancyzero.xcuserdatad
│ │ ├── UserInterfaceState.xcuserstate
│ │ └── WorkspaceSettings.xcsettings
└── xcuserdata
│ └── fancyzero.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints.xcbkptlist
│ └── xcschemes
│ ├── libPython Mac.xcscheme
│ ├── libPython.xcscheme
│ └── xcschememanagement.plist
├── libPython
├── AppDelegate.h
├── AppDelegate.m
├── Include
│ ├── Python-ast.h
│ ├── Python.h
│ ├── abstract.h
│ ├── asdl.h
│ ├── ast.h
│ ├── bitset.h
│ ├── boolobject.h
│ ├── bufferobject.h
│ ├── bytearrayobject.h
│ ├── bytes_methods.h
│ ├── bytesobject.h
│ ├── cStringIO.h
│ ├── cellobject.h
│ ├── ceval.h
│ ├── classobject.h
│ ├── cobject.h
│ ├── code.h
│ ├── codecs.h
│ ├── compile.h
│ ├── complexobject.h
│ ├── datetime.h
│ ├── descrobject.h
│ ├── dictobject.h
│ ├── dtoa.h
│ ├── enumobject.h
│ ├── errcode.h
│ ├── eval.h
│ ├── fileobject.h
│ ├── floatobject.h
│ ├── frameobject.h
│ ├── funcobject.h
│ ├── genobject.h
│ ├── graminit.h
│ ├── grammar.h
│ ├── import.h
│ ├── intobject.h
│ ├── intrcheck.h
│ ├── iterobject.h
│ ├── listobject.h
│ ├── longintrepr.h
│ ├── longobject.h
│ ├── marshal.h
│ ├── memoryobject.h
│ ├── metagrammar.h
│ ├── methodobject.h
│ ├── modsupport.h
│ ├── moduleobject.h
│ ├── node.h
│ ├── object.h
│ ├── objimpl.h
│ ├── opcode.h
│ ├── osdefs.h
│ ├── parsetok.h
│ ├── patchlevel.h
│ ├── pgen.h
│ ├── pgenheaders.h
│ ├── py_curses.h
│ ├── pyarena.h
│ ├── pycapsule.h
│ ├── pyctype.h
│ ├── pydebug.h
│ ├── pyerrors.h
│ ├── pyexpat.h
│ ├── pyfpe.h
│ ├── pygetopt.h
│ ├── pymacconfig.h
│ ├── pymath.h
│ ├── pymem.h
│ ├── pyport.h
│ ├── pystate.h
│ ├── pystrcmp.h
│ ├── pystrtod.h
│ ├── pythonrun.h
│ ├── pythread.h
│ ├── rangeobject.h
│ ├── setobject.h
│ ├── sliceobject.h
│ ├── stringobject.h
│ ├── structmember.h
│ ├── structseq.h
│ ├── symtable.h
│ ├── sysmodule.h
│ ├── timefuncs.h
│ ├── token.h
│ ├── traceback.h
│ ├── tupleobject.h
│ ├── ucnhash.h
│ ├── unicodeobject.h
│ ├── warnings.h
│ └── weakrefobject.h
├── Modules
│ ├── _bisectmodule.c
│ ├── _codecsmodule.c
│ ├── _collectionsmodule.c
│ ├── _csv.c
│ ├── _ctypes
│ │ ├── _ctypes.c
│ │ ├── _ctypes_test.c
│ │ ├── _ctypes_test.h
│ │ ├── callbacks.c
│ │ ├── callproc.c
│ │ ├── cfield.c
│ │ ├── ctypes.h
│ │ ├── ctypes_dlfcn.h
│ │ ├── darwin
│ │ │ ├── LICENSE
│ │ │ ├── README
│ │ │ ├── README.ctypes
│ │ │ ├── dlfcn.h
│ │ │ └── dlfcn_simple.c
│ │ ├── libffi
│ │ │ ├── include
│ │ │ │ ├── Makefile.am
│ │ │ │ ├── Makefile.in
│ │ │ │ ├── ffi.h.in
│ │ │ │ └── ffi_common.h
│ │ │ ├── install-sh
│ │ │ ├── libffi.pc.in
│ │ │ ├── libffi.xcodeproj
│ │ │ │ ├── project.pbxproj
│ │ │ │ └── xcuserdata
│ │ │ │ │ └── fancyzero.xcuserdatad
│ │ │ │ │ └── xcschemes
│ │ │ │ │ ├── libffi OS X.xcscheme
│ │ │ │ │ ├── libffi iOS.xcscheme
│ │ │ │ │ └── xcschememanagement.plist
│ │ │ ├── libtool-ldflags
│ │ │ ├── libtool-version
│ │ │ ├── ltmain.sh
│ │ │ ├── m4
│ │ │ │ ├── asmcfi.m4
│ │ │ │ ├── ax_append_flag.m4
│ │ │ │ ├── ax_cc_maxopt.m4
│ │ │ │ ├── ax_cflags_warn_all.m4
│ │ │ │ ├── ax_check_compile_flag.m4
│ │ │ │ ├── ax_compiler_vendor.m4
│ │ │ │ ├── ax_configure_args.m4
│ │ │ │ ├── ax_enable_builddir.m4
│ │ │ │ ├── ax_gcc_archflag.m4
│ │ │ │ ├── ax_gcc_x86_cpuid.m4
│ │ │ │ ├── libtool.m4
│ │ │ │ ├── ltoptions.m4
│ │ │ │ ├── ltsugar.m4
│ │ │ │ ├── ltversion.m4
│ │ │ │ └── lt~obsolete.m4
│ │ │ ├── man
│ │ │ │ ├── Makefile.am
│ │ │ │ ├── Makefile.in
│ │ │ │ ├── ffi.3
│ │ │ │ ├── ffi_call.3
│ │ │ │ ├── ffi_prep_cif.3
│ │ │ │ └── ffi_prep_cif_var.3
│ │ │ ├── mdate-sh
│ │ │ ├── missing
│ │ │ ├── msvcc.sh
│ │ │ ├── src
│ │ │ │ ├── aarch64
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── alpha
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── osf.S
│ │ │ │ ├── arm
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ ├── gentramp.sh
│ │ │ │ │ ├── sysv.S
│ │ │ │ │ └── trampoline.S
│ │ │ │ ├── avr32
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── bfin
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── closures.c
│ │ │ │ ├── cris
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── debug.c
│ │ │ │ ├── dlmalloc.c
│ │ │ │ ├── frv
│ │ │ │ │ ├── eabi.S
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ └── ffitarget.h
│ │ │ │ ├── ia64
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ ├── ia64_flags.h
│ │ │ │ │ └── unix.S
│ │ │ │ ├── java_raw_api.c
│ │ │ │ ├── m32r
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── m68k
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── metag
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── microblaze
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── mips
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ ├── n32.S
│ │ │ │ │ └── o32.S
│ │ │ │ ├── moxie
│ │ │ │ │ ├── eabi.S
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ └── ffitarget.h
│ │ │ │ ├── pa
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ ├── hpux32.S
│ │ │ │ │ └── linux.S
│ │ │ │ ├── powerpc
│ │ │ │ │ ├── aix.S
│ │ │ │ │ ├── aix_closure.S
│ │ │ │ │ ├── asm.h
│ │ │ │ │ ├── darwin.S
│ │ │ │ │ ├── darwin_closure.S
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffi_darwin.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ ├── linux64.S
│ │ │ │ │ ├── linux64_closure.S
│ │ │ │ │ ├── ppc_closure.S
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── prep_cif.c
│ │ │ │ ├── raw_api.c
│ │ │ │ ├── s390
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── sh
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── sh64
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ │ ├── sparc
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ ├── v8.S
│ │ │ │ │ └── v9.S
│ │ │ │ ├── tile
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── tile.S
│ │ │ │ ├── types.c
│ │ │ │ ├── x86
│ │ │ │ │ ├── darwin.S
│ │ │ │ │ ├── darwin64.S
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffi64.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ ├── freebsd.S
│ │ │ │ │ ├── sysv.S
│ │ │ │ │ ├── unix64.S
│ │ │ │ │ ├── win32.S
│ │ │ │ │ └── win64.S
│ │ │ │ └── xtensa
│ │ │ │ │ ├── ffi.c
│ │ │ │ │ ├── ffitarget.h
│ │ │ │ │ └── sysv.S
│ │ │ ├── stamp-h.in
│ │ │ ├── testsuite
│ │ │ │ ├── Makefile.am
│ │ │ │ ├── Makefile.in
│ │ │ │ ├── config
│ │ │ │ │ └── default.exp
│ │ │ │ ├── lib
│ │ │ │ │ ├── libffi.exp
│ │ │ │ │ ├── target-libpath.exp
│ │ │ │ │ └── wrapper.exp
│ │ │ │ ├── libffi.call
│ │ │ │ │ ├── call.exp
│ │ │ │ │ ├── closure_fn0.c
│ │ │ │ │ ├── closure_fn1.c
│ │ │ │ │ ├── closure_fn2.c
│ │ │ │ │ ├── closure_fn3.c
│ │ │ │ │ ├── closure_fn4.c
│ │ │ │ │ ├── closure_fn5.c
│ │ │ │ │ ├── closure_fn6.c
│ │ │ │ │ ├── closure_loc_fn0.c
│ │ │ │ │ ├── closure_stdcall.c
│ │ │ │ │ ├── closure_thiscall.c
│ │ │ │ │ ├── cls_12byte.c
│ │ │ │ │ ├── cls_16byte.c
│ │ │ │ │ ├── cls_18byte.c
│ │ │ │ │ ├── cls_19byte.c
│ │ │ │ │ ├── cls_1_1byte.c
│ │ │ │ │ ├── cls_20byte.c
│ │ │ │ │ ├── cls_20byte1.c
│ │ │ │ │ ├── cls_24byte.c
│ │ │ │ │ ├── cls_2byte.c
│ │ │ │ │ ├── cls_3_1byte.c
│ │ │ │ │ ├── cls_3byte1.c
│ │ │ │ │ ├── cls_3byte2.c
│ │ │ │ │ ├── cls_4_1byte.c
│ │ │ │ │ ├── cls_4byte.c
│ │ │ │ │ ├── cls_5_1_byte.c
│ │ │ │ │ ├── cls_5byte.c
│ │ │ │ │ ├── cls_64byte.c
│ │ │ │ │ ├── cls_6_1_byte.c
│ │ │ │ │ ├── cls_6byte.c
│ │ │ │ │ ├── cls_7_1_byte.c
│ │ │ │ │ ├── cls_7byte.c
│ │ │ │ │ ├── cls_8byte.c
│ │ │ │ │ ├── cls_9byte1.c
│ │ │ │ │ ├── cls_9byte2.c
│ │ │ │ │ ├── cls_align_double.c
│ │ │ │ │ ├── cls_align_float.c
│ │ │ │ │ ├── cls_align_longdouble.c
│ │ │ │ │ ├── cls_align_longdouble_split.c
│ │ │ │ │ ├── cls_align_longdouble_split2.c
│ │ │ │ │ ├── cls_align_pointer.c
│ │ │ │ │ ├── cls_align_sint16.c
│ │ │ │ │ ├── cls_align_sint32.c
│ │ │ │ │ ├── cls_align_sint64.c
│ │ │ │ │ ├── cls_align_uint16.c
│ │ │ │ │ ├── cls_align_uint32.c
│ │ │ │ │ ├── cls_align_uint64.c
│ │ │ │ │ ├── cls_dbls_struct.c
│ │ │ │ │ ├── cls_double.c
│ │ │ │ │ ├── cls_double_va.c
│ │ │ │ │ ├── cls_float.c
│ │ │ │ │ ├── cls_longdouble.c
│ │ │ │ │ ├── cls_longdouble_va.c
│ │ │ │ │ ├── cls_multi_schar.c
│ │ │ │ │ ├── cls_multi_sshort.c
│ │ │ │ │ ├── cls_multi_sshortchar.c
│ │ │ │ │ ├── cls_multi_uchar.c
│ │ │ │ │ ├── cls_multi_ushort.c
│ │ │ │ │ ├── cls_multi_ushortchar.c
│ │ │ │ │ ├── cls_pointer.c
│ │ │ │ │ ├── cls_pointer_stack.c
│ │ │ │ │ ├── cls_schar.c
│ │ │ │ │ ├── cls_sint.c
│ │ │ │ │ ├── cls_sshort.c
│ │ │ │ │ ├── cls_struct_va1.c
│ │ │ │ │ ├── cls_uchar.c
│ │ │ │ │ ├── cls_uchar_va.c
│ │ │ │ │ ├── cls_uint.c
│ │ │ │ │ ├── cls_uint_va.c
│ │ │ │ │ ├── cls_ulong_va.c
│ │ │ │ │ ├── cls_ulonglong.c
│ │ │ │ │ ├── cls_ushort.c
│ │ │ │ │ ├── cls_ushort_va.c
│ │ │ │ │ ├── err_bad_abi.c
│ │ │ │ │ ├── err_bad_typedef.c
│ │ │ │ │ ├── fastthis1_win32.c
│ │ │ │ │ ├── fastthis2_win32.c
│ │ │ │ │ ├── fastthis3_win32.c
│ │ │ │ │ ├── ffitest.h
│ │ │ │ │ ├── float.c
│ │ │ │ │ ├── float1.c
│ │ │ │ │ ├── float2.c
│ │ │ │ │ ├── float3.c
│ │ │ │ │ ├── float4.c
│ │ │ │ │ ├── float_va.c
│ │ │ │ │ ├── huge_struct.c
│ │ │ │ │ ├── many.c
│ │ │ │ │ ├── many2.c
│ │ │ │ │ ├── many2_win32.c
│ │ │ │ │ ├── many_win32.c
│ │ │ │ │ ├── negint.c
│ │ │ │ │ ├── nested_struct.c
│ │ │ │ │ ├── nested_struct1.c
│ │ │ │ │ ├── nested_struct10.c
│ │ │ │ │ ├── nested_struct11.c
│ │ │ │ │ ├── nested_struct2.c
│ │ │ │ │ ├── nested_struct3.c
│ │ │ │ │ ├── nested_struct4.c
│ │ │ │ │ ├── nested_struct5.c
│ │ │ │ │ ├── nested_struct6.c
│ │ │ │ │ ├── nested_struct7.c
│ │ │ │ │ ├── nested_struct8.c
│ │ │ │ │ ├── nested_struct9.c
│ │ │ │ │ ├── problem1.c
│ │ │ │ │ ├── promotion.c
│ │ │ │ │ ├── pyobjc-tc.c
│ │ │ │ │ ├── return_dbl.c
│ │ │ │ │ ├── return_dbl1.c
│ │ │ │ │ ├── return_dbl2.c
│ │ │ │ │ ├── return_fl.c
│ │ │ │ │ ├── return_fl1.c
│ │ │ │ │ ├── return_fl2.c
│ │ │ │ │ ├── return_fl3.c
│ │ │ │ │ ├── return_ldl.c
│ │ │ │ │ ├── return_ll.c
│ │ │ │ │ ├── return_ll1.c
│ │ │ │ │ ├── return_sc.c
│ │ │ │ │ ├── return_sl.c
│ │ │ │ │ ├── return_uc.c
│ │ │ │ │ ├── return_ul.c
│ │ │ │ │ ├── stret_large.c
│ │ │ │ │ ├── stret_large2.c
│ │ │ │ │ ├── stret_medium.c
│ │ │ │ │ ├── stret_medium2.c
│ │ │ │ │ ├── strlen.c
│ │ │ │ │ ├── strlen2_win32.c
│ │ │ │ │ ├── strlen_win32.c
│ │ │ │ │ ├── struct1.c
│ │ │ │ │ ├── struct1_win32.c
│ │ │ │ │ ├── struct2.c
│ │ │ │ │ ├── struct2_win32.c
│ │ │ │ │ ├── struct3.c
│ │ │ │ │ ├── struct4.c
│ │ │ │ │ ├── struct5.c
│ │ │ │ │ ├── struct6.c
│ │ │ │ │ ├── struct7.c
│ │ │ │ │ ├── struct8.c
│ │ │ │ │ ├── struct9.c
│ │ │ │ │ ├── testclosure.c
│ │ │ │ │ ├── uninitialized.c
│ │ │ │ │ ├── va_1.c
│ │ │ │ │ ├── va_struct1.c
│ │ │ │ │ ├── va_struct2.c
│ │ │ │ │ └── va_struct3.c
│ │ │ │ └── libffi.special
│ │ │ │ │ ├── ffitestcxx.h
│ │ │ │ │ ├── special.exp
│ │ │ │ │ ├── unwindtest.cc
│ │ │ │ │ └── unwindtest_ffi_call.cc
│ │ │ └── texinfo.tex
│ │ ├── malloc_closure.c
│ │ └── stgdict.c
│ ├── _elementtree.c
│ ├── _functoolsmodule.c
│ ├── _hashopenssl.c
│ ├── _heapqmodule.c
│ ├── _hotshot.c
│ ├── _io
│ │ ├── _iomodule.c
│ │ ├── _iomodule.h
│ │ ├── bufferedio.c
│ │ ├── bytesio.c
│ │ ├── fileio.c
│ │ ├── iobase.c
│ │ ├── stringio.c
│ │ └── textio.c
│ ├── _json.c
│ ├── _localemodule.c
│ ├── _lsprof.c
│ ├── _math.c
│ ├── _math.h
│ ├── _multiprocessing
│ │ ├── connection.h
│ │ ├── multiprocessing.c
│ │ ├── multiprocessing.h
│ │ ├── pipe_connection.c
│ │ ├── semaphore.c
│ │ ├── socket_connection.c
│ │ └── win32_functions.c
│ ├── _randommodule.c
│ ├── _sre.c
│ ├── _ssl.c
│ ├── _struct.c
│ ├── _testcapimodule.c
│ ├── _tkinter.c
│ ├── _weakref.c
│ ├── addrinfo.h
│ ├── almodule.c
│ ├── arraymodule.c
│ ├── audioop.c
│ ├── binascii.c
│ ├── bz2module.c
│ ├── cPickle.c
│ ├── cStringIO.c
│ ├── cdmodule.c
│ ├── cgen.py
│ ├── cgensupport.c
│ ├── cgensupport.h
│ ├── cjkcodecs
│ │ ├── README
│ │ ├── _codecs_cn.c
│ │ ├── _codecs_hk.c
│ │ ├── _codecs_iso2022.c
│ │ ├── _codecs_jp.c
│ │ ├── _codecs_kr.c
│ │ ├── _codecs_tw.c
│ │ ├── alg_jisx0201.h
│ │ ├── cjkcodecs.h
│ │ ├── emu_jisx0213_2000.h
│ │ ├── mappings_cn.h
│ │ ├── mappings_hk.h
│ │ ├── mappings_jisx0213_pair.h
│ │ ├── mappings_jp.h
│ │ ├── mappings_kr.h
│ │ ├── mappings_tw.h
│ │ ├── multibytecodec.c
│ │ └── multibytecodec.h
│ ├── clmodule.c
│ ├── cmathmodule.c
│ ├── config.c
│ ├── config.c.in
│ ├── cryptmodule.c
│ ├── cstubs
│ ├── datetimemodule.c
│ ├── dbmmodule.c
│ ├── dlmodule.c
│ ├── errnomodule.c
│ ├── fcntlmodule.c
│ ├── flmodule.c
│ ├── fmmodule.c
│ ├── fpectlmodule.c
│ ├── fpetestmodule.c
│ ├── future_builtins.c
│ ├── gc_weakref.txt
│ ├── gcmodule.c
│ ├── gdbmmodule.c
│ ├── getaddrinfo.c
│ ├── getbuildinfo.c
│ ├── getnameinfo.c
│ ├── getpath.c
│ ├── grpmodule.c
│ ├── imageop.c
│ ├── imgfile.c
│ ├── itertoolsmodule.c
│ ├── linuxaudiodev.c
│ ├── main.c
│ ├── makesetup
│ ├── makexp_aix
│ ├── mathmodule.c
│ ├── md5.c
│ ├── md5.h
│ ├── md5module.c
│ ├── mmapmodule.c
│ ├── nismodule.c
│ ├── operator.c
│ ├── parsermodule.c
│ ├── posixmodule.c
│ ├── posixmodule.h
│ ├── puremodule.c
│ ├── pwdmodule.c
│ ├── python.c
│ ├── readline.c
│ ├── resource.c
│ ├── rotatingtree.c
│ ├── rotatingtree.h
│ ├── selectmodule.c
│ ├── sgimodule.c
│ ├── sha256module.c
│ ├── sha512module.c
│ ├── shamodule.c
│ ├── signalmodule.c
│ ├── socketmodule.c
│ ├── socketmodule.h
│ ├── spwdmodule.c
│ ├── sre.h
│ ├── sre_constants.h
│ ├── stropmodule.c
│ ├── svmodule.c
│ ├── symtablemodule.c
│ ├── syslogmodule.c
│ ├── termios.c
│ ├── testcapi_long.h
│ ├── threadmodule.c
│ ├── timemodule.c
│ ├── timing.h
│ ├── timingmodule.c
│ ├── tkinter.h
│ ├── unicodedata.c
│ ├── unicodedata_db.h
│ ├── unicodename_db.h
│ ├── xxmodule.c
│ ├── xxsubtype.c
│ ├── yuv.h
│ ├── yuvconvert.c
│ ├── zipimport.c
│ ├── zlib
│ │ ├── ChangeLog
│ │ ├── FAQ
│ │ ├── INDEX
│ │ ├── Makefile
│ │ ├── Makefile.in
│ │ ├── README
│ │ ├── adler32.c
│ │ ├── algorithm.txt
│ │ ├── compress.c
│ │ ├── configure
│ │ ├── crc32.c
│ │ ├── crc32.h
│ │ ├── deflate.c
│ │ ├── deflate.h
│ │ ├── example.c
│ │ ├── gzio.c
│ │ ├── infback.c
│ │ ├── inffast.c
│ │ ├── inffast.h
│ │ ├── inffixed.h
│ │ ├── inflate.c
│ │ ├── inflate.h
│ │ ├── inftrees.c
│ │ ├── inftrees.h
│ │ ├── make_vms.com
│ │ ├── minigzip.c
│ │ ├── trees.c
│ │ ├── trees.h
│ │ ├── uncompr.c
│ │ ├── zconf.h
│ │ ├── zconf.in.h
│ │ ├── zlib.3
│ │ ├── zlib.h
│ │ ├── zutil.c
│ │ └── zutil.h
│ └── zlibmodule.c
├── Objects
│ ├── abstract.c
│ ├── boolobject.c
│ ├── bufferobject.c
│ ├── bytearrayobject.c
│ ├── bytes_methods.c
│ ├── capsule.c
│ ├── cellobject.c
│ ├── classobject.c
│ ├── cobject.c
│ ├── codeobject.c
│ ├── complexobject.c
│ ├── descrobject.c
│ ├── dictnotes.txt
│ ├── dictobject.c
│ ├── enumobject.c
│ ├── exceptions.c
│ ├── fileobject.c
│ ├── floatobject.c
│ ├── frameobject.c
│ ├── funcobject.c
│ ├── genobject.c
│ ├── intobject.c
│ ├── iterobject.c
│ ├── listobject.c
│ ├── listsort.txt
│ ├── lnotab_notes.txt
│ ├── longobject.c
│ ├── memoryobject.c
│ ├── methodobject.c
│ ├── moduleobject.c
│ ├── object.c
│ ├── obmalloc.c
│ ├── rangeobject.c
│ ├── setobject.c
│ ├── sliceobject.c
│ ├── stringlib
│ │ ├── README.txt
│ │ ├── count.h
│ │ ├── ctype.h
│ │ ├── fastsearch.h
│ │ ├── find.h
│ │ ├── formatter.h
│ │ ├── localeutil.h
│ │ ├── partition.h
│ │ ├── split.h
│ │ ├── string_format.h
│ │ ├── stringdefs.h
│ │ ├── transmogrify.h
│ │ └── unicodedefs.h
│ ├── stringobject.c
│ ├── structseq.c
│ ├── tupleobject.c
│ ├── typeobject.c
│ ├── unicodectype.c
│ ├── unicodeobject.c
│ ├── unicodetype_db.h
│ └── weakrefobject.c
├── Parser
│ ├── Python.asdl
│ ├── acceler.c
│ ├── asdl.py
│ ├── asdl_c.py
│ ├── bitset.c
│ ├── firstsets.c
│ ├── grammar.c
│ ├── grammar1.c
│ ├── intrcheck.c
│ ├── listnode.c
│ ├── metagrammar.c
│ ├── myreadline.c
│ ├── node.c
│ ├── parser.c
│ ├── parser.h
│ ├── parsetok.c
│ ├── pgen.c
│ ├── pgenmain.c
│ ├── printgrammar.c
│ ├── spark.py
│ ├── tokenizer.c
│ ├── tokenizer.h
│ └── tokenizer_pgen.c
├── Python
│ ├── Python-ast.c
│ ├── _warnings.c
│ ├── asdl.c
│ ├── ast.c
│ ├── atof.c
│ ├── bltinmodule.c
│ ├── ceval.c
│ ├── codecs.c
│ ├── compile.c
│ ├── dtoa.c
│ ├── dup2.c
│ ├── errors.c
│ ├── formatter_string.c
│ ├── formatter_unicode.c
│ ├── frozen.c
│ ├── frozenmain.c
│ ├── future.c
│ ├── getargs.c
│ ├── getcompiler.c
│ ├── getcopyright.c
│ ├── getcwd.c
│ ├── getopt.c
│ ├── getplatform.c
│ ├── getversion.c
│ ├── graminit.c
│ ├── import.c
│ ├── importdl.c
│ ├── importdl.h
│ ├── marshal.c
│ ├── modsupport.c
│ ├── mysnprintf.c
│ ├── mystrtoul.c
│ ├── peephole.c
│ ├── pyarena.c
│ ├── pyctype.c
│ ├── pyfpe.c
│ ├── pymath.c
│ ├── pystate.c
│ ├── pystrcmp.c
│ ├── pystrtod.c
│ ├── pythonrun.c
│ ├── random.c
│ ├── sigcheck.c
│ ├── strdup.c
│ ├── strtod.c
│ ├── structmember.c
│ ├── symtable.c
│ ├── sysmodule.c
│ ├── thread.c
│ ├── thread_atheos.h
│ ├── thread_beos.h
│ ├── thread_cthread.h
│ ├── thread_foobar.h
│ ├── thread_lwp.h
│ ├── thread_nt.h
│ ├── thread_os2.h
│ ├── thread_pth.h
│ ├── thread_pthread.h
│ ├── thread_sgi.h
│ ├── thread_solaris.h
│ ├── thread_wince.h
│ └── traceback.c
├── main.mm
└── pyconfig.h
└── python-ios.xcworkspace
└── contents.xcworkspacedata
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | .DS_Store
3 |
4 | *.xcuserstate
5 |
6 | python-ios.xcworkspace/xcuserdata/fancyzero.xcuserdatad/UserInterfaceState.xcuserstate
7 |
8 | *.xcbkptlist
9 |
10 | python-ios.xcworkspace/xcuserdata/fancyzero.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
11 |
--------------------------------------------------------------------------------
/HowItsDone:
--------------------------------------------------------------------------------
1 | Goto Python-2.7.5, and "./configure" this will config for mac OSX plaform, but still can make next of your steps easier.
2 |
3 | Create a static library project, then add all python file into project with directory structure.
4 |
5 | while( build_not_successed )
6 | {
7 | Try to build it, and you will found some source file are not for iOS platform, remove these files, and some other files
8 | failed to compile because missing other 3rd party libs, remove it from the project , or provide the libs.
9 | }
10 |
11 | you will get a python interpet with some useful builtin modules.
12 |
13 | manually edit the Modules/config.c to register built-in modules, you see how, when you open the config.c it's easy to understand
14 | module "zlib" must be registered in order to import for a zip file.
15 |
16 | and in python/libs/site.py there comment line "known_paths = addusersitepackages(known_paths)" , that depends a module called "_sysconfigdata", this module is generated when you make python in commandline, so this funciton call should be disabled
17 |
18 | that's all I remember...
19 |
20 |
--------------------------------------------------------------------------------
/Python-iOS-app.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Python-iOS-app.xcodeproj/project.xcworkspace/xcuserdata/fancyzero.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancyzero/Python-iOS/b9cd21ddb9cfa977e46140062c6bf620b8e0205b/Python-iOS-app.xcodeproj/project.xcworkspace/xcuserdata/fancyzero.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/Python-iOS-app.xcodeproj/xcuserdata/fancyzero.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Python-iOS-app.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 04A1DE2817C4FE4E00B87DED
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Python-iOS-app/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // Python-iOS-app
4 | //
5 | // Created by Fancyzero on 13-8-21.
6 | // Copyright (c) 2013年 Fancyzero. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class ViewController;
12 |
13 | @interface AppDelegate : UIResponder
14 |
15 | @property (strong, nonatomic) UIWindow *window;
16 |
17 | @property (strong, nonatomic) ViewController *viewController;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/Python-iOS-app/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancyzero/Python-iOS/b9cd21ddb9cfa977e46140062c6bf620b8e0205b/Python-iOS-app/Default-568h@2x.png
--------------------------------------------------------------------------------
/Python-iOS-app/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancyzero/Python-iOS/b9cd21ddb9cfa977e46140062c6bf620b8e0205b/Python-iOS-app/Default.png
--------------------------------------------------------------------------------
/Python-iOS-app/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancyzero/Python-iOS/b9cd21ddb9cfa977e46140062c6bf620b8e0205b/Python-iOS-app/Default@2x.png
--------------------------------------------------------------------------------
/Python-iOS-app/Python-iOS-app-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | com.fancylab.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Python-iOS-app/Python-iOS-app-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'Python-iOS-app' target in the 'Python-iOS-app' project
3 | //
4 |
5 | #import
6 |
7 | #ifndef __IPHONE_4_0
8 | #warning "This project uses features only available in iOS SDK 4.0 and later."
9 | #endif
10 |
11 | #ifdef __OBJC__
12 | #import
13 | #import
14 | #endif
15 |
--------------------------------------------------------------------------------
/Python-iOS-app/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // Python-iOS-app
4 | //
5 | // Created by Fancyzero on 13-8-21.
6 | // Copyright (c) 2013年 Fancyzero. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Python-iOS-app/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // Python-iOS-app
4 | //
5 | // Created by Fancyzero on 13-8-21.
6 | // Copyright (c) 2013年 Fancyzero. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | - (void)viewDidLoad
18 | {
19 | [super viewDidLoad];
20 | // Do any additional setup after loading the view, typically from a nib.
21 | }
22 |
23 | - (void)didReceiveMemoryWarning
24 | {
25 | [super didReceiveMemoryWarning];
26 | // Dispose of any resources that can be recreated.
27 | }
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/Python-iOS-app/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/Python-iOS-app/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // Python-iOS-app
4 | //
5 | // Created by Fancyzero on 13-8-21.
6 | // Copyright (c) 2013年 Fancyzero. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char *argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Python-iOS-app/python/lib/python2.7/site-packages/README:
--------------------------------------------------------------------------------
1 | This directory exists so that 3rd party packages can be installed
2 | here. Read the source for site.py for more details.
3 |
--------------------------------------------------------------------------------
/Python-iOS-app/python/lib/python27.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancyzero/Python-iOS/b9cd21ddb9cfa977e46140062c6bf620b8e0205b/Python-iOS-app/python/lib/python27.zip
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Python-iOS
2 | =========
3 |
4 | Python static library XCode project with built-in modules
5 | based on Python-2.7.5
6 |
7 | Run Python on iOS
8 |
9 |
10 | 2013-8-21
11 | Added a iOS App project to demostrate how to use it
12 |
13 |
14 |
--------------------------------------------------------------------------------
/libPython.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/libPython.xcodeproj/project.xcworkspace/xcuserdata/fancyzero.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancyzero/Python-iOS/b9cd21ddb9cfa977e46140062c6bf620b8e0205b/libPython.xcodeproj/project.xcworkspace/xcuserdata/fancyzero.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/libPython.xcodeproj/project.xcworkspace/xcuserdata/fancyzero.xcuserdatad/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges
6 |
7 | SnapshotAutomaticallyBeforeSignificantChanges
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/libPython.xcodeproj/xcuserdata/fancyzero.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | libPython Mac.xcscheme
8 |
9 | orderHint
10 | 2
11 |
12 | libPython.xcscheme
13 |
14 | orderHint
15 | 1
16 |
17 |
18 | SuppressBuildableAutocreation
19 |
20 | 04442B4E17BF75BD00D3E3D1
21 |
22 | primary
23 |
24 |
25 | 04442C1F17BF765A00D3E3D1
26 |
27 | primary
28 |
29 |
30 | 0449BA381787C60900022D0E
31 |
32 | primary
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/libPython/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // pythonpythonios
4 | //
5 | // Created by Fancyzero on 13-7-6.
6 | // Copyright (c) 2013年 Fancyzero. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/libPython/Include/asdl.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_ASDL_H
2 | #define Py_ASDL_H
3 |
4 | typedef PyObject * identifier;
5 | typedef PyObject * string;
6 | typedef PyObject * object;
7 |
8 | #ifndef __cplusplus
9 | typedef enum {false, true} bool;
10 | #endif
11 |
12 | /* It would be nice if the code generated by asdl_c.py was completely
13 | independent of Python, but it is a goal the requires too much work
14 | at this stage. So, for example, I'll represent identifiers as
15 | interned Python strings.
16 | */
17 |
18 | /* XXX A sequence should be typed so that its use can be typechecked. */
19 |
20 | typedef struct {
21 | int size;
22 | void *elements[1];
23 | } asdl_seq;
24 |
25 | typedef struct {
26 | int size;
27 | int elements[1];
28 | } asdl_int_seq;
29 |
30 | asdl_seq *asdl_seq_new(int size, PyArena *arena);
31 | asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
32 |
33 | #define asdl_seq_GET(S, I) (S)->elements[(I)]
34 | #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
35 | #ifdef Py_DEBUG
36 | #define asdl_seq_SET(S, I, V) { \
37 | int _asdl_i = (I); \
38 | assert((S) && _asdl_i < (S)->size); \
39 | (S)->elements[_asdl_i] = (V); \
40 | }
41 | #else
42 | #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
43 | #endif
44 |
45 | #endif /* !Py_ASDL_H */
46 |
--------------------------------------------------------------------------------
/libPython/Include/ast.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_AST_H
2 | #define Py_AST_H
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags,
8 | const char *, PyArena *);
9 |
10 | #ifdef __cplusplus
11 | }
12 | #endif
13 | #endif /* !Py_AST_H */
14 |
--------------------------------------------------------------------------------
/libPython/Include/bitset.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef Py_BITSET_H
3 | #define Py_BITSET_H
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | /* Bitset interface */
9 |
10 | #define BYTE char
11 |
12 | typedef BYTE *bitset;
13 |
14 | bitset newbitset(int nbits);
15 | void delbitset(bitset bs);
16 | #define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0)
17 | int addbit(bitset bs, int ibit); /* Returns 0 if already set */
18 | int samebitset(bitset bs1, bitset bs2, int nbits);
19 | void mergebitset(bitset bs1, bitset bs2, int nbits);
20 |
21 | #define BITSPERBYTE (8*sizeof(BYTE))
22 | #define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)
23 |
24 | #define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE)
25 | #define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE)
26 | #define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit))
27 | #define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE)
28 |
29 | #ifdef __cplusplus
30 | }
31 | #endif
32 | #endif /* !Py_BITSET_H */
33 |
--------------------------------------------------------------------------------
/libPython/Include/boolobject.h:
--------------------------------------------------------------------------------
1 | /* Boolean object interface */
2 |
3 | #ifndef Py_BOOLOBJECT_H
4 | #define Py_BOOLOBJECT_H
5 | #ifdef __cplusplus
6 | extern "C" {
7 | #endif
8 |
9 |
10 | typedef PyIntObject PyBoolObject;
11 |
12 | PyAPI_DATA(PyTypeObject) PyBool_Type;
13 |
14 | #define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)
15 |
16 | /* Py_False and Py_True are the only two bools in existence.
17 | Don't forget to apply Py_INCREF() when returning either!!! */
18 |
19 | /* Don't use these directly */
20 | PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct;
21 |
22 | /* Use these macros */
23 | #define Py_False ((PyObject *) &_Py_ZeroStruct)
24 | #define Py_True ((PyObject *) &_Py_TrueStruct)
25 |
26 | /* Macros for returning Py_True or Py_False, respectively */
27 | #define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
28 | #define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
29 |
30 | /* Function to return a bool from a C long */
31 | PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
32 |
33 | #ifdef __cplusplus
34 | }
35 | #endif
36 | #endif /* !Py_BOOLOBJECT_H */
37 |
--------------------------------------------------------------------------------
/libPython/Include/bufferobject.h:
--------------------------------------------------------------------------------
1 |
2 | /* Buffer object interface */
3 |
4 | /* Note: the object's structure is private */
5 |
6 | #ifndef Py_BUFFEROBJECT_H
7 | #define Py_BUFFEROBJECT_H
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 |
13 | PyAPI_DATA(PyTypeObject) PyBuffer_Type;
14 |
15 | #define PyBuffer_Check(op) (Py_TYPE(op) == &PyBuffer_Type)
16 |
17 | #define Py_END_OF_BUFFER (-1)
18 |
19 | PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base,
20 | Py_ssize_t offset, Py_ssize_t size);
21 | PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base,
22 | Py_ssize_t offset,
23 | Py_ssize_t size);
24 |
25 | PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size);
26 | PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size);
27 |
28 | PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size);
29 |
30 | #ifdef __cplusplus
31 | }
32 | #endif
33 | #endif /* !Py_BUFFEROBJECT_H */
34 |
--------------------------------------------------------------------------------
/libPython/Include/bytesobject.h:
--------------------------------------------------------------------------------
1 | #define PyBytesObject PyStringObject
2 | #define PyBytes_Type PyString_Type
3 |
4 | #define PyBytes_Check PyString_Check
5 | #define PyBytes_CheckExact PyString_CheckExact
6 | #define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED
7 | #define PyBytes_AS_STRING PyString_AS_STRING
8 | #define PyBytes_GET_SIZE PyString_GET_SIZE
9 | #define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS
10 |
11 | #define PyBytes_FromStringAndSize PyString_FromStringAndSize
12 | #define PyBytes_FromString PyString_FromString
13 | #define PyBytes_FromFormatV PyString_FromFormatV
14 | #define PyBytes_FromFormat PyString_FromFormat
15 | #define PyBytes_Size PyString_Size
16 | #define PyBytes_AsString PyString_AsString
17 | #define PyBytes_Repr PyString_Repr
18 | #define PyBytes_Concat PyString_Concat
19 | #define PyBytes_ConcatAndDel PyString_ConcatAndDel
20 | #define _PyBytes_Resize _PyString_Resize
21 | #define _PyBytes_Eq _PyString_Eq
22 | #define PyBytes_Format PyString_Format
23 | #define _PyBytes_FormatLong _PyString_FormatLong
24 | #define PyBytes_DecodeEscape PyString_DecodeEscape
25 | #define _PyBytes_Join _PyString_Join
26 | #define PyBytes_AsStringAndSize PyString_AsStringAndSize
27 | #define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping
28 |
--------------------------------------------------------------------------------
/libPython/Include/cellobject.h:
--------------------------------------------------------------------------------
1 | /* Cell object interface */
2 |
3 | #ifndef Py_CELLOBJECT_H
4 | #define Py_CELLOBJECT_H
5 | #ifdef __cplusplus
6 | extern "C" {
7 | #endif
8 |
9 | typedef struct {
10 | PyObject_HEAD
11 | PyObject *ob_ref; /* Content of the cell or NULL when empty */
12 | } PyCellObject;
13 |
14 | PyAPI_DATA(PyTypeObject) PyCell_Type;
15 |
16 | #define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type)
17 |
18 | PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
19 | PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
20 | PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
21 |
22 | #define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref)
23 | #define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v)
24 |
25 | #ifdef __cplusplus
26 | }
27 | #endif
28 | #endif /* !Py_TUPLEOBJECT_H */
29 |
--------------------------------------------------------------------------------
/libPython/Include/compile.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef Py_COMPILE_H
3 | #define Py_COMPILE_H
4 |
5 | #include "code.h"
6 |
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 |
11 | /* Public interface */
12 | struct _node; /* Declare the existence of this type */
13 | PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
14 |
15 | /* Future feature support */
16 |
17 | typedef struct {
18 | int ff_features; /* flags set by future statements */
19 | int ff_lineno; /* line number of last future statement */
20 | } PyFutureFeatures;
21 |
22 | #define FUTURE_NESTED_SCOPES "nested_scopes"
23 | #define FUTURE_GENERATORS "generators"
24 | #define FUTURE_DIVISION "division"
25 | #define FUTURE_ABSOLUTE_IMPORT "absolute_import"
26 | #define FUTURE_WITH_STATEMENT "with_statement"
27 | #define FUTURE_PRINT_FUNCTION "print_function"
28 | #define FUTURE_UNICODE_LITERALS "unicode_literals"
29 |
30 |
31 | struct _mod; /* Declare the existence of this type */
32 | PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *,
33 | PyCompilerFlags *, PyArena *);
34 | PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);
35 |
36 |
37 | #ifdef __cplusplus
38 | }
39 | #endif
40 | #endif /* !Py_COMPILE_H */
41 |
--------------------------------------------------------------------------------
/libPython/Include/dtoa.h:
--------------------------------------------------------------------------------
1 | #ifndef PY_NO_SHORT_FLOAT_REPR
2 | #ifdef __cplusplus
3 | extern "C" {
4 | #endif
5 |
6 | PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
7 | PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
8 | int *decpt, int *sign, char **rve);
9 | PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
10 |
11 |
12 | #ifdef __cplusplus
13 | }
14 | #endif
15 | #endif
16 |
--------------------------------------------------------------------------------
/libPython/Include/enumobject.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_ENUMOBJECT_H
2 | #define Py_ENUMOBJECT_H
3 |
4 | /* Enumerate Object */
5 |
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | PyAPI_DATA(PyTypeObject) PyEnum_Type;
11 | PyAPI_DATA(PyTypeObject) PyReversed_Type;
12 |
13 | #ifdef __cplusplus
14 | }
15 | #endif
16 |
17 | #endif /* !Py_ENUMOBJECT_H */
18 |
--------------------------------------------------------------------------------
/libPython/Include/errcode.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_ERRCODE_H
2 | #define Py_ERRCODE_H
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 |
8 | /* Error codes passed around between file input, tokenizer, parser and
9 | interpreter. This is necessary so we can turn them into Python
10 | exceptions at a higher level. Note that some errors have a
11 | slightly different meaning when passed from the tokenizer to the
12 | parser than when passed from the parser to the interpreter; e.g.
13 | the parser only returns E_EOF when it hits EOF immediately, and it
14 | never returns E_OK. */
15 |
16 | #define E_OK 10 /* No error */
17 | #define E_EOF 11 /* End Of File */
18 | #define E_INTR 12 /* Interrupted */
19 | #define E_TOKEN 13 /* Bad token */
20 | #define E_SYNTAX 14 /* Syntax error */
21 | #define E_NOMEM 15 /* Ran out of memory */
22 | #define E_DONE 16 /* Parsing complete */
23 | #define E_ERROR 17 /* Execution error */
24 | #define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */
25 | #define E_OVERFLOW 19 /* Node had too many children */
26 | #define E_TOODEEP 20 /* Too many indentation levels */
27 | #define E_DEDENT 21 /* No matching outer block for dedent */
28 | #define E_DECODE 22 /* Error in decoding into Unicode */
29 | #define E_EOFS 23 /* EOF in triple-quoted string */
30 | #define E_EOLS 24 /* EOL in single-quoted string */
31 | #define E_LINECONT 25 /* Unexpected characters after a line continuation */
32 |
33 | #ifdef __cplusplus
34 | }
35 | #endif
36 | #endif /* !Py_ERRCODE_H */
37 |
--------------------------------------------------------------------------------
/libPython/Include/eval.h:
--------------------------------------------------------------------------------
1 |
2 | /* Interface to execute compiled code */
3 |
4 | #ifndef Py_EVAL_H
5 | #define Py_EVAL_H
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *);
11 |
12 | PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co,
13 | PyObject *globals,
14 | PyObject *locals,
15 | PyObject **args, int argc,
16 | PyObject **kwds, int kwdc,
17 | PyObject **defs, int defc,
18 | PyObject *closure);
19 |
20 | PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
21 |
22 | #ifdef __cplusplus
23 | }
24 | #endif
25 | #endif /* !Py_EVAL_H */
26 |
--------------------------------------------------------------------------------
/libPython/Include/genobject.h:
--------------------------------------------------------------------------------
1 |
2 | /* Generator object interface */
3 |
4 | #ifndef Py_GENOBJECT_H
5 | #define Py_GENOBJECT_H
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | struct _frame; /* Avoid including frameobject.h */
11 |
12 | typedef struct {
13 | PyObject_HEAD
14 | /* The gi_ prefix is intended to remind of generator-iterator. */
15 |
16 | /* Note: gi_frame can be NULL if the generator is "finished" */
17 | struct _frame *gi_frame;
18 |
19 | /* True if generator is being executed. */
20 | int gi_running;
21 |
22 | /* The code object backing the generator */
23 | PyObject *gi_code;
24 |
25 | /* List of weak reference. */
26 | PyObject *gi_weakreflist;
27 | } PyGenObject;
28 |
29 | PyAPI_DATA(PyTypeObject) PyGen_Type;
30 |
31 | #define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
32 | #define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)
33 |
34 | PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
35 | PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
36 |
37 | #ifdef __cplusplus
38 | }
39 | #endif
40 | #endif /* !Py_GENOBJECT_H */
41 |
--------------------------------------------------------------------------------
/libPython/Include/intrcheck.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef Py_INTRCHECK_H
3 | #define Py_INTRCHECK_H
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | PyAPI_FUNC(int) PyOS_InterruptOccurred(void);
9 | PyAPI_FUNC(void) PyOS_InitInterrupts(void);
10 | PyAPI_FUNC(void) PyOS_AfterFork(void);
11 |
12 | #ifdef __cplusplus
13 | }
14 | #endif
15 | #endif /* !Py_INTRCHECK_H */
16 |
--------------------------------------------------------------------------------
/libPython/Include/iterobject.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_ITEROBJECT_H
2 | #define Py_ITEROBJECT_H
3 | /* Iterators (the basic kind, over a sequence) */
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | PyAPI_DATA(PyTypeObject) PySeqIter_Type;
9 |
10 | #define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type)
11 |
12 | PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
13 |
14 | PyAPI_DATA(PyTypeObject) PyCallIter_Type;
15 |
16 | #define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type)
17 |
18 | PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
19 | #ifdef __cplusplus
20 | }
21 | #endif
22 | #endif /* !Py_ITEROBJECT_H */
23 |
24 |
--------------------------------------------------------------------------------
/libPython/Include/marshal.h:
--------------------------------------------------------------------------------
1 |
2 | /* Interface for marshal.c */
3 |
4 | #ifndef Py_MARSHAL_H
5 | #define Py_MARSHAL_H
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | #define Py_MARSHAL_VERSION 2
11 |
12 | PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int);
13 | PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
14 | PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);
15 |
16 | PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
17 | PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
18 | PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
19 | PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
20 | PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
21 |
22 | #ifdef __cplusplus
23 | }
24 | #endif
25 | #endif /* !Py_MARSHAL_H */
26 |
--------------------------------------------------------------------------------
/libPython/Include/metagrammar.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_METAGRAMMAR_H
2 | #define Py_METAGRAMMAR_H
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 |
8 | #define MSTART 256
9 | #define RULE 257
10 | #define RHS 258
11 | #define ALT 259
12 | #define ITEM 260
13 | #define ATOM 261
14 |
15 | #ifdef __cplusplus
16 | }
17 | #endif
18 | #endif /* !Py_METAGRAMMAR_H */
19 |
--------------------------------------------------------------------------------
/libPython/Include/moduleobject.h:
--------------------------------------------------------------------------------
1 |
2 | /* Module object interface */
3 |
4 | #ifndef Py_MODULEOBJECT_H
5 | #define Py_MODULEOBJECT_H
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | PyAPI_DATA(PyTypeObject) PyModule_Type;
11 |
12 | #define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type)
13 | #define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type)
14 |
15 | PyAPI_FUNC(PyObject *) PyModule_New(const char *);
16 | PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
17 | PyAPI_FUNC(char *) PyModule_GetName(PyObject *);
18 | PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *);
19 | PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
20 |
21 | #ifdef __cplusplus
22 | }
23 | #endif
24 | #endif /* !Py_MODULEOBJECT_H */
25 |
--------------------------------------------------------------------------------
/libPython/Include/node.h:
--------------------------------------------------------------------------------
1 |
2 | /* Parse tree node interface */
3 |
4 | #ifndef Py_NODE_H
5 | #define Py_NODE_H
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | typedef struct _node {
11 | short n_type;
12 | char *n_str;
13 | int n_lineno;
14 | int n_col_offset;
15 | int n_nchildren;
16 | struct _node *n_child;
17 | } node;
18 |
19 | PyAPI_FUNC(node *) PyNode_New(int type);
20 | PyAPI_FUNC(int) PyNode_AddChild(node *n, int type,
21 | char *str, int lineno, int col_offset);
22 | PyAPI_FUNC(void) PyNode_Free(node *n);
23 | #ifndef Py_LIMITED_API
24 | Py_ssize_t _PyNode_SizeOf(node *n);
25 | #endif
26 |
27 | /* Node access functions */
28 | #define NCH(n) ((n)->n_nchildren)
29 |
30 | #define CHILD(n, i) (&(n)->n_child[i])
31 | #define RCHILD(n, i) (CHILD(n, NCH(n) + i))
32 | #define TYPE(n) ((n)->n_type)
33 | #define STR(n) ((n)->n_str)
34 |
35 | /* Assert that the type of a node is what we expect */
36 | #define REQ(n, type) assert(TYPE(n) == (type))
37 |
38 | PyAPI_FUNC(void) PyNode_ListTree(node *);
39 |
40 | #ifdef __cplusplus
41 | }
42 | #endif
43 | #endif /* !Py_NODE_H */
44 |
--------------------------------------------------------------------------------
/libPython/Include/osdefs.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_OSDEFS_H
2 | #define Py_OSDEFS_H
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 |
8 | /* Operating system dependencies */
9 |
10 | /* Mod by chrish: QNX has WATCOM, but isn't DOS */
11 | #if !defined(__QNX__)
12 | #if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2)
13 | #if defined(PYOS_OS2) && defined(PYCC_GCC)
14 | #define MAXPATHLEN 260
15 | #define SEP '/'
16 | #define ALTSEP '\\'
17 | #else
18 | #define SEP '\\'
19 | #define ALTSEP '/'
20 | #define MAXPATHLEN 256
21 | #endif
22 | #define DELIM ';'
23 | #endif
24 | #endif
25 |
26 | #ifdef RISCOS
27 | #define SEP '.'
28 | #define MAXPATHLEN 256
29 | #define DELIM ','
30 | #endif
31 |
32 |
33 | /* Filename separator */
34 | #ifndef SEP
35 | #define SEP '/'
36 | #endif
37 |
38 | /* Max pathname length */
39 | #ifdef __hpux
40 | #include
41 | #include
42 | #ifndef PATH_MAX
43 | #define PATH_MAX MAXPATHLEN
44 | #endif
45 | #endif
46 |
47 | #ifndef MAXPATHLEN
48 | #if defined(PATH_MAX) && PATH_MAX > 1024
49 | #define MAXPATHLEN PATH_MAX
50 | #else
51 | #define MAXPATHLEN 1024
52 | #endif
53 | #endif
54 |
55 | /* Search path entry delimiter */
56 | #ifndef DELIM
57 | #define DELIM ':'
58 | #endif
59 |
60 | #ifdef __cplusplus
61 | }
62 | #endif
63 | #endif /* !Py_OSDEFS_H */
64 |
--------------------------------------------------------------------------------
/libPython/Include/parsetok.h:
--------------------------------------------------------------------------------
1 |
2 | /* Parser-tokenizer link interface */
3 |
4 | #ifndef Py_PARSETOK_H
5 | #define Py_PARSETOK_H
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | typedef struct {
11 | int error;
12 | const char *filename;
13 | int lineno;
14 | int offset;
15 | char *text;
16 | int token;
17 | int expected;
18 | } perrdetail;
19 |
20 | #if 0
21 | #define PyPARSE_YIELD_IS_KEYWORD 0x0001
22 | #endif
23 |
24 | #define PyPARSE_DONT_IMPLY_DEDENT 0x0002
25 |
26 | #if 0
27 | #define PyPARSE_WITH_IS_KEYWORD 0x0003
28 | #endif
29 |
30 | #define PyPARSE_PRINT_IS_FUNCTION 0x0004
31 | #define PyPARSE_UNICODE_LITERALS 0x0008
32 |
33 |
34 |
35 | PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
36 | perrdetail *);
37 | PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
38 | char *, char *, perrdetail *);
39 |
40 | PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
41 | perrdetail *, int);
42 | PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *, grammar *,
43 | int, char *, char *,
44 | perrdetail *, int);
45 | PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(FILE *, const char *, grammar *,
46 | int, char *, char *,
47 | perrdetail *, int *);
48 |
49 | PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *,
50 | const char *,
51 | grammar *, int,
52 | perrdetail *, int);
53 | PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(const char *,
54 | const char *,
55 | grammar *, int,
56 | perrdetail *, int *);
57 |
58 | /* Note that he following function is defined in pythonrun.c not parsetok.c. */
59 | PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
60 |
61 | #ifdef __cplusplus
62 | }
63 | #endif
64 | #endif /* !Py_PARSETOK_H */
65 |
--------------------------------------------------------------------------------
/libPython/Include/patchlevel.h:
--------------------------------------------------------------------------------
1 |
2 | /* Newfangled version identification scheme.
3 |
4 | This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL
5 | was available. To test for presence of the scheme, test for
6 | defined(PY_MAJOR_VERSION).
7 |
8 | When the major or minor version changes, the VERSION variable in
9 | configure.ac must also be changed.
10 |
11 | There is also (independent) API version information in modsupport.h.
12 | */
13 |
14 | /* Values for PY_RELEASE_LEVEL */
15 | #define PY_RELEASE_LEVEL_ALPHA 0xA
16 | #define PY_RELEASE_LEVEL_BETA 0xB
17 | #define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */
18 | #define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */
19 | /* Higher for patch releases */
20 |
21 | /* Version parsed out into numeric values */
22 | /*--start constants--*/
23 | #define PY_MAJOR_VERSION 2
24 | #define PY_MINOR_VERSION 7
25 | #define PY_MICRO_VERSION 5
26 | #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
27 | #define PY_RELEASE_SERIAL 0
28 |
29 | /* Version as a string */
30 | #define PY_VERSION "2.7.5"
31 | /*--end constants--*/
32 |
33 | /* Subversion Revision number of this file (not of the repository). Empty
34 | since Mercurial migration. */
35 | #define PY_PATCHLEVEL_REVISION ""
36 |
37 | /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
38 | Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */
39 | #define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \
40 | (PY_MINOR_VERSION << 16) | \
41 | (PY_MICRO_VERSION << 8) | \
42 | (PY_RELEASE_LEVEL << 4) | \
43 | (PY_RELEASE_SERIAL << 0))
44 |
--------------------------------------------------------------------------------
/libPython/Include/pgen.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_PGEN_H
2 | #define Py_PGEN_H
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 |
8 | /* Parser generator interface */
9 |
10 | extern grammar *meta_grammar(void);
11 |
12 | struct _node;
13 | extern grammar *pgen(struct _node *);
14 |
15 | #ifdef __cplusplus
16 | }
17 | #endif
18 | #endif /* !Py_PGEN_H */
19 |
--------------------------------------------------------------------------------
/libPython/Include/pgenheaders.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_PGENHEADERS_H
2 | #define Py_PGENHEADERS_H
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 |
8 | /* Include files and extern declarations used by most of the parser. */
9 |
10 | #include "Python.h"
11 |
12 | PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
13 | Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
14 | PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...)
15 | Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
16 |
17 | #define addarc _Py_addarc
18 | #define addbit _Py_addbit
19 | #define adddfa _Py_adddfa
20 | #define addfirstsets _Py_addfirstsets
21 | #define addlabel _Py_addlabel
22 | #define addstate _Py_addstate
23 | #define delbitset _Py_delbitset
24 | #define dumptree _Py_dumptree
25 | #define findlabel _Py_findlabel
26 | #define mergebitset _Py_mergebitset
27 | #define meta_grammar _Py_meta_grammar
28 | #define newbitset _Py_newbitset
29 | #define newgrammar _Py_newgrammar
30 | #define pgen _Py_pgen
31 | #define printgrammar _Py_printgrammar
32 | #define printnonterminals _Py_printnonterminals
33 | #define printtree _Py_printtree
34 | #define samebitset _Py_samebitset
35 | #define showtree _Py_showtree
36 | #define tok_dump _Py_tok_dump
37 | #define translatelabels _Py_translatelabels
38 |
39 | #ifdef __cplusplus
40 | }
41 | #endif
42 | #endif /* !Py_PGENHEADERS_H */
43 |
--------------------------------------------------------------------------------
/libPython/Include/pycapsule.h:
--------------------------------------------------------------------------------
1 |
2 | /* Capsule objects let you wrap a C "void *" pointer in a Python
3 | object. They're a way of passing data through the Python interpreter
4 | without creating your own custom type.
5 |
6 | Capsules are used for communication between extension modules.
7 | They provide a way for an extension module to export a C interface
8 | to other extension modules, so that extension modules can use the
9 | Python import mechanism to link to one another.
10 |
11 | For more information, please see "c-api/capsule.html" in the
12 | documentation.
13 | */
14 |
15 | #ifndef Py_CAPSULE_H
16 | #define Py_CAPSULE_H
17 | #ifdef __cplusplus
18 | extern "C" {
19 | #endif
20 |
21 | PyAPI_DATA(PyTypeObject) PyCapsule_Type;
22 |
23 | typedef void (*PyCapsule_Destructor)(PyObject *);
24 |
25 | #define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type)
26 |
27 |
28 | PyAPI_FUNC(PyObject *) PyCapsule_New(
29 | void *pointer,
30 | const char *name,
31 | PyCapsule_Destructor destructor);
32 |
33 | PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name);
34 |
35 | PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule);
36 |
37 | PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule);
38 |
39 | PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule);
40 |
41 | PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name);
42 |
43 | PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer);
44 |
45 | PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor);
46 |
47 | PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name);
48 |
49 | PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context);
50 |
51 | PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block);
52 |
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 | #endif /* !Py_CAPSULE_H */
57 |
--------------------------------------------------------------------------------
/libPython/Include/pyctype.h:
--------------------------------------------------------------------------------
1 | #ifndef PYCTYPE_H
2 | #define PYCTYPE_H
3 |
4 | #define PY_CTF_LOWER 0x01
5 | #define PY_CTF_UPPER 0x02
6 | #define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER)
7 | #define PY_CTF_DIGIT 0x04
8 | #define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT)
9 | #define PY_CTF_SPACE 0x08
10 | #define PY_CTF_XDIGIT 0x10
11 |
12 | PyAPI_DATA(const unsigned int) _Py_ctype_table[256];
13 |
14 | /* Unlike their C counterparts, the following macros are not meant to
15 | * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument
16 | * must be a signed/unsigned char. */
17 | #define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER)
18 | #define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER)
19 | #define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA)
20 | #define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT)
21 | #define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT)
22 | #define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM)
23 | #define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE)
24 |
25 | PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256];
26 | PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256];
27 |
28 | #define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)])
29 | #define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
30 |
31 | #endif /* !PYCTYPE_H */
32 |
--------------------------------------------------------------------------------
/libPython/Include/pydebug.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef Py_PYDEBUG_H
3 | #define Py_PYDEBUG_H
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | PyAPI_DATA(int) Py_DebugFlag;
9 | PyAPI_DATA(int) Py_VerboseFlag;
10 | PyAPI_DATA(int) Py_InteractiveFlag;
11 | PyAPI_DATA(int) Py_InspectFlag;
12 | PyAPI_DATA(int) Py_OptimizeFlag;
13 | PyAPI_DATA(int) Py_NoSiteFlag;
14 | PyAPI_DATA(int) Py_BytesWarningFlag;
15 | PyAPI_DATA(int) Py_UseClassExceptionsFlag;
16 | PyAPI_DATA(int) Py_FrozenFlag;
17 | PyAPI_DATA(int) Py_TabcheckFlag;
18 | PyAPI_DATA(int) Py_UnicodeFlag;
19 | PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
20 | PyAPI_DATA(int) Py_DivisionWarningFlag;
21 | PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
22 | PyAPI_DATA(int) Py_NoUserSiteDirectory;
23 | /* _XXX Py_QnewFlag should go away in 3.0. It's true iff -Qnew is passed,
24 | on the command line, and is used in 2.2 by ceval.c to make all "/" divisions
25 | true divisions (which they will be in 3.0). */
26 | PyAPI_DATA(int) _Py_QnewFlag;
27 | /* Warn about 3.x issues */
28 | PyAPI_DATA(int) Py_Py3kWarningFlag;
29 | PyAPI_DATA(int) Py_HashRandomizationFlag;
30 |
31 | /* this is a wrapper around getenv() that pays attention to
32 | Py_IgnoreEnvironmentFlag. It should be used for getting variables like
33 | PYTHONPATH and PYTHONHOME from the environment */
34 | #define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s))
35 |
36 | PyAPI_FUNC(void) Py_FatalError(const char *message);
37 |
38 | #ifdef __cplusplus
39 | }
40 | #endif
41 | #endif /* !Py_PYDEBUG_H */
42 |
--------------------------------------------------------------------------------
/libPython/Include/pygetopt.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef Py_PYGETOPT_H
3 | #define Py_PYGETOPT_H
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | PyAPI_DATA(int) _PyOS_opterr;
9 | PyAPI_DATA(int) _PyOS_optind;
10 | PyAPI_DATA(char *) _PyOS_optarg;
11 |
12 | PyAPI_FUNC(void) _PyOS_ResetGetOpt(void);
13 | PyAPI_FUNC(int) _PyOS_GetOpt(int argc, char **argv, char *optstring);
14 |
15 | #ifdef __cplusplus
16 | }
17 | #endif
18 | #endif /* !Py_PYGETOPT_H */
19 |
--------------------------------------------------------------------------------
/libPython/Include/pystrcmp.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_STRCMP_H
2 | #define Py_STRCMP_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | PyAPI_FUNC(int) PyOS_mystrnicmp(const char *, const char *, Py_ssize_t);
9 | PyAPI_FUNC(int) PyOS_mystricmp(const char *, const char *);
10 |
11 | #if defined(MS_WINDOWS) || defined(PYOS_OS2)
12 | #define PyOS_strnicmp strnicmp
13 | #define PyOS_stricmp stricmp
14 | #else
15 | #define PyOS_strnicmp PyOS_mystrnicmp
16 | #define PyOS_stricmp PyOS_mystricmp
17 | #endif
18 |
19 | #ifdef __cplusplus
20 | }
21 | #endif
22 |
23 | #endif /* !Py_STRCMP_H */
24 |
--------------------------------------------------------------------------------
/libPython/Include/pystrtod.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_STRTOD_H
2 | #define Py_STRTOD_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr);
10 | PyAPI_FUNC(double) PyOS_ascii_atof(const char *str);
11 |
12 | /* Deprecated in 2.7 and 3.1. Will disappear in 2.8 (if it exists) and 3.2 */
13 | PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len,
14 | const char *format, double d);
15 | PyAPI_FUNC(double) PyOS_string_to_double(const char *str,
16 | char **endptr,
17 | PyObject *overflow_exception);
18 |
19 | /* The caller is responsible for calling PyMem_Free to free the buffer
20 | that's is returned. */
21 | PyAPI_FUNC(char *) PyOS_double_to_string(double val,
22 | char format_code,
23 | int precision,
24 | int flags,
25 | int *type);
26 |
27 | PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr);
28 |
29 |
30 | /* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */
31 | #define Py_DTSF_SIGN 0x01 /* always add the sign */
32 | #define Py_DTSF_ADD_DOT_0 0x02 /* if the result is an integer add ".0" */
33 | #define Py_DTSF_ALT 0x04 /* "alternate" formatting. it's format_code
34 | specific */
35 |
36 | /* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */
37 | #define Py_DTST_FINITE 0
38 | #define Py_DTST_INFINITE 1
39 | #define Py_DTST_NAN 2
40 |
41 | #ifdef __cplusplus
42 | }
43 | #endif
44 |
45 | #endif /* !Py_STRTOD_H */
46 |
--------------------------------------------------------------------------------
/libPython/Include/pythread.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef Py_PYTHREAD_H
3 | #define Py_PYTHREAD_H
4 |
5 | typedef void *PyThread_type_lock;
6 | typedef void *PyThread_type_sema;
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | PyAPI_FUNC(void) PyThread_init_thread(void);
13 | PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *);
14 | PyAPI_FUNC(void) PyThread_exit_thread(void);
15 | PyAPI_FUNC(long) PyThread_get_thread_ident(void);
16 |
17 | PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void);
18 | PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock);
19 | PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int);
20 | #define WAIT_LOCK 1
21 | #define NOWAIT_LOCK 0
22 | PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock);
23 |
24 | PyAPI_FUNC(size_t) PyThread_get_stacksize(void);
25 | PyAPI_FUNC(int) PyThread_set_stacksize(size_t);
26 |
27 | /* Thread Local Storage (TLS) API */
28 | PyAPI_FUNC(int) PyThread_create_key(void);
29 | PyAPI_FUNC(void) PyThread_delete_key(int);
30 | PyAPI_FUNC(int) PyThread_set_key_value(int, void *);
31 | PyAPI_FUNC(void *) PyThread_get_key_value(int);
32 | PyAPI_FUNC(void) PyThread_delete_key_value(int key);
33 |
34 | /* Cleanup after a fork */
35 | PyAPI_FUNC(void) PyThread_ReInitTLS(void);
36 |
37 | #ifdef __cplusplus
38 | }
39 | #endif
40 |
41 | #endif /* !Py_PYTHREAD_H */
42 |
--------------------------------------------------------------------------------
/libPython/Include/rangeobject.h:
--------------------------------------------------------------------------------
1 |
2 | /* Range object interface */
3 |
4 | #ifndef Py_RANGEOBJECT_H
5 | #define Py_RANGEOBJECT_H
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | /* This is about the type 'xrange', not the built-in function range(), which
11 | returns regular lists. */
12 |
13 | /*
14 | A range object represents an integer range. This is an immutable object;
15 | a range cannot change its value after creation.
16 |
17 | Range objects behave like the corresponding tuple objects except that
18 | they are represented by a start, stop, and step datamembers.
19 | */
20 |
21 | PyAPI_DATA(PyTypeObject) PyRange_Type;
22 |
23 | #define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type)
24 |
25 | #ifdef __cplusplus
26 | }
27 | #endif
28 | #endif /* !Py_RANGEOBJECT_H */
29 |
--------------------------------------------------------------------------------
/libPython/Include/sliceobject.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_SLICEOBJECT_H
2 | #define Py_SLICEOBJECT_H
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | /* The unique ellipsis object "..." */
8 |
9 | PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */
10 |
11 | #define Py_Ellipsis (&_Py_EllipsisObject)
12 |
13 | /* Slice object interface */
14 |
15 | /*
16 |
17 | A slice object containing start, stop, and step data members (the
18 | names are from range). After much talk with Guido, it was decided to
19 | let these be any arbitrary python type. Py_None stands for omitted values.
20 | */
21 |
22 | typedef struct {
23 | PyObject_HEAD
24 | PyObject *start, *stop, *step; /* not NULL */
25 | } PySliceObject;
26 |
27 | PyAPI_DATA(PyTypeObject) PySlice_Type;
28 | PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
29 |
30 | #define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type)
31 |
32 | PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
33 | PyObject* step);
34 | PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
35 | PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, Py_ssize_t length,
36 | Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
37 | PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length,
38 | Py_ssize_t *start, Py_ssize_t *stop,
39 | Py_ssize_t *step, Py_ssize_t *slicelength);
40 |
41 | #ifdef __cplusplus
42 | }
43 | #endif
44 | #endif /* !Py_SLICEOBJECT_H */
45 |
--------------------------------------------------------------------------------
/libPython/Include/structseq.h:
--------------------------------------------------------------------------------
1 |
2 | /* Tuple object interface */
3 |
4 | #ifndef Py_STRUCTSEQ_H
5 | #define Py_STRUCTSEQ_H
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | typedef struct PyStructSequence_Field {
11 | char *name;
12 | char *doc;
13 | } PyStructSequence_Field;
14 |
15 | typedef struct PyStructSequence_Desc {
16 | char *name;
17 | char *doc;
18 | struct PyStructSequence_Field *fields;
19 | int n_in_sequence;
20 | } PyStructSequence_Desc;
21 |
22 | extern char* PyStructSequence_UnnamedField;
23 |
24 | PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
25 | PyStructSequence_Desc *desc);
26 |
27 | PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
28 |
29 | typedef struct {
30 | PyObject_VAR_HEAD
31 | PyObject *ob_item[1];
32 | } PyStructSequence;
33 |
34 | /* Macro, *only* to be used to fill in brand new objects */
35 | #define PyStructSequence_SET_ITEM(op, i, v) \
36 | (((PyStructSequence *)(op))->ob_item[i] = v)
37 |
38 | #ifdef __cplusplus
39 | }
40 | #endif
41 | #endif /* !Py_STRUCTSEQ_H */
42 |
--------------------------------------------------------------------------------
/libPython/Include/sysmodule.h:
--------------------------------------------------------------------------------
1 |
2 | /* System module interface */
3 |
4 | #ifndef Py_SYSMODULE_H
5 | #define Py_SYSMODULE_H
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | PyAPI_FUNC(PyObject *) PySys_GetObject(char *);
11 | PyAPI_FUNC(int) PySys_SetObject(char *, PyObject *);
12 | PyAPI_FUNC(FILE *) PySys_GetFile(char *, FILE *);
13 | PyAPI_FUNC(void) PySys_SetArgv(int, char **);
14 | PyAPI_FUNC(void) PySys_SetArgvEx(int, char **, int);
15 | PyAPI_FUNC(void) PySys_SetPath(char *);
16 |
17 | PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
18 | Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
19 | PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...)
20 | Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
21 |
22 | PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
23 | PyAPI_FUNC(void) PySys_AddWarnOption(char *);
24 | PyAPI_FUNC(int) PySys_HasWarnOptions(void);
25 |
26 | #ifdef __cplusplus
27 | }
28 | #endif
29 | #endif /* !Py_SYSMODULE_H */
30 |
--------------------------------------------------------------------------------
/libPython/Include/timefuncs.h:
--------------------------------------------------------------------------------
1 | /* timefuncs.h
2 | */
3 |
4 | /* Utility function related to timemodule.c. */
5 |
6 | #ifndef TIMEFUNCS_H
7 | #define TIMEFUNCS_H
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 |
13 | /* Cast double x to time_t, but raise ValueError if x is too large
14 | * to fit in a time_t. ValueError is set on return iff the return
15 | * value is (time_t)-1 and PyErr_Occurred().
16 | */
17 | PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x);
18 |
19 | /* Get the current time since the epoch in seconds */
20 | PyAPI_FUNC(double) _PyTime_FloatTime(void);
21 |
22 |
23 | #ifdef __cplusplus
24 | }
25 | #endif
26 | #endif /* TIMEFUNCS_H */
27 |
--------------------------------------------------------------------------------
/libPython/Include/traceback.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef Py_TRACEBACK_H
3 | #define Py_TRACEBACK_H
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | struct _frame;
9 |
10 | /* Traceback interface */
11 |
12 | typedef struct _traceback {
13 | PyObject_HEAD
14 | struct _traceback *tb_next;
15 | struct _frame *tb_frame;
16 | int tb_lasti;
17 | int tb_lineno;
18 | } PyTracebackObject;
19 |
20 | PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *);
21 | PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
22 | PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, const char *, int, int);
23 |
24 | /* Reveal traceback type so we can typecheck traceback objects */
25 | PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
26 | #define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type)
27 |
28 | #ifdef __cplusplus
29 | }
30 | #endif
31 | #endif /* !Py_TRACEBACK_H */
32 |
--------------------------------------------------------------------------------
/libPython/Include/ucnhash.h:
--------------------------------------------------------------------------------
1 | /* Unicode name database interface */
2 |
3 | #ifndef Py_UCNHASH_H
4 | #define Py_UCNHASH_H
5 | #ifdef __cplusplus
6 | extern "C" {
7 | #endif
8 |
9 | /* revised ucnhash CAPI interface (exported through a "wrapper") */
10 |
11 | #define PyUnicodeData_CAPSULE_NAME "unicodedata.ucnhash_CAPI"
12 |
13 | typedef struct {
14 |
15 | /* Size of this struct */
16 | int size;
17 |
18 | /* Get name for a given character code. Returns non-zero if
19 | success, zero if not. Does not set Python exceptions.
20 | If self is NULL, data come from the default version of the database.
21 | If it is not NULL, it should be a unicodedata.ucd_X_Y_Z object */
22 | int (*getname)(PyObject *self, Py_UCS4 code, char* buffer, int buflen);
23 |
24 | /* Get character code for a given name. Same error handling
25 | as for getname. */
26 | int (*getcode)(PyObject *self, const char* name, int namelen, Py_UCS4* code);
27 |
28 | } _PyUnicode_Name_CAPI;
29 |
30 | #ifdef __cplusplus
31 | }
32 | #endif
33 | #endif /* !Py_UCNHASH_H */
34 |
--------------------------------------------------------------------------------
/libPython/Include/warnings.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_WARNINGS_H
2 | #define Py_WARNINGS_H
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | PyAPI_FUNC(void) _PyWarnings_Init(void);
8 |
9 | PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t);
10 | PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int,
11 | const char *, PyObject *);
12 |
13 | #define PyErr_WarnPy3k(msg, stacklevel) \
14 | (Py_Py3kWarningFlag ? PyErr_WarnEx(PyExc_DeprecationWarning, msg, stacklevel) : 0)
15 |
16 | /* DEPRECATED: Use PyErr_WarnEx() instead. */
17 | #define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
18 |
19 | #ifdef __cplusplus
20 | }
21 | #endif
22 | #endif /* !Py_WARNINGS_H */
23 |
24 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/_ctypes_test.h:
--------------------------------------------------------------------------------
1 | extern int _testfunc_i_bhilfd(char b, short h, int i, long l, float f, double d);
2 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/ctypes_dlfcn.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | This file should be kept compatible with Python 2.3, see PEP 291.
3 | *****************************************************************/
4 |
5 | #ifndef _CTYPES_DLFCN_H_
6 | #define _CTYPES_DLFCN_H_
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif /* __cplusplus */
11 |
12 | #ifndef MS_WIN32
13 |
14 | #include
15 |
16 | #ifndef CTYPES_DARWIN_DLFCN
17 |
18 | #define ctypes_dlsym dlsym
19 | #define ctypes_dlerror dlerror
20 | #define ctypes_dlopen dlopen
21 | #define ctypes_dlclose dlclose
22 | #define ctypes_dladdr dladdr
23 |
24 | #endif /* !CTYPES_DARWIN_DLFCN */
25 |
26 | #endif /* !MS_WIN32 */
27 |
28 | #ifdef __cplusplus
29 | }
30 | #endif /* __cplusplus */
31 | #endif /* _CTYPES_DLFCN_H_ */
32 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/darwin/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2002 Jorge Acereda &
2 | Peter O'Gorman
3 |
4 | Portions may be copyright others, see the AUTHORS file included with this
5 | distribution.
6 |
7 | Maintained by Peter O'Gorman
8 |
9 | Bug Reports and other queries should go to
10 |
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining
13 | a copy of this software and associated documentation files (the
14 | "Software"), to deal in the Software without restriction, including
15 | without limitation the rights to use, copy, modify, merge, publish,
16 | distribute, sublicense, and/or sell copies of the Software, and to
17 | permit persons to whom the Software is furnished to do so, subject to
18 | the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be
21 | included in all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
31 |
32 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/darwin/README.ctypes:
--------------------------------------------------------------------------------
1 | The files in this directory are taken from
2 | http://www.opendarwin.org/cgi-bin/cvsweb.cgi/~checkout~/proj/dlcompat/
3 |
4 | The LICENSE in this directory applies to these files.
5 |
6 | Thomas Heller, Jan 2003
7 |
8 | These files have been modified so they fall back to the system
9 | dlfcn calls if available in libSystem.
10 |
11 | Bob Ippolito, Feb 2006
12 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/include/Makefile.am:
--------------------------------------------------------------------------------
1 | ## Process this with automake to create Makefile.in
2 |
3 | AUTOMAKE_OPTIONS=foreign
4 |
5 | DISTCLEANFILES=ffitarget.h
6 | EXTRA_DIST=ffi.h.in ffi_common.h
7 |
8 | includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
9 | nodist_includes_HEADERS = ffi.h ffitarget.h
10 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/libffi.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@prefix@
2 | exec_prefix=@exec_prefix@
3 | libdir=@libdir@
4 | includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
5 |
6 | Name: @PACKAGE_NAME@
7 | Description: Library supporting Foreign Function Interfaces
8 | Version: @PACKAGE_VERSION@
9 | Libs: -L${libdir} -lffi
10 | Cflags: -I${includedir}
11 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/libffi.xcodeproj/xcuserdata/fancyzero.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | libffi OS X.xcscheme
8 |
9 | orderHint
10 | 2
11 |
12 | libffi iOS.xcscheme
13 |
14 | orderHint
15 | 1
16 |
17 |
18 | SuppressBuildableAutocreation
19 |
20 | 6C43CB3C1534E9D100162364
21 |
22 | primary
23 |
24 |
25 | F6F980B9147386130008F121
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/libtool-version:
--------------------------------------------------------------------------------
1 | # This file is used to maintain libtool version info for libffi. See
2 | # the libtool manual to understand the meaning of the fields. This is
3 | # a separate file so that version updates don't involve re-running
4 | # automake.
5 | #
6 | # Here are a set of rules to help you update your library version
7 | # information:
8 | #
9 | # 1. Start with version information of `0:0:0' for each libtool library.
10 | #
11 | # 2. Update the version information only immediately before a public
12 | # release of your software. More frequent updates are unnecessary,
13 | # and only guarantee that the current interface number gets larger
14 | # faster.
15 | #
16 | # 3. If the library source code has changed at all since the last
17 | # update, then increment revision (`c:r:a' becomes `c:r+1:a').
18 | #
19 | # 4. If any interfaces have been added, removed, or changed since the
20 | # last update, increment current, and set revision to 0.
21 | #
22 | # 5. If any interfaces have been added since the last public release,
23 | # then increment age.
24 | #
25 | # 6. If any interfaces have been removed since the last public
26 | # release, then set age to 0.
27 | #
28 | # CURRENT:REVISION:AGE
29 | 6:1:0
30 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/m4/asmcfi.m4:
--------------------------------------------------------------------------------
1 | AC_DEFUN([GCC_AS_CFI_PSEUDO_OP],
2 | [AC_CACHE_CHECK([assembler .cfi pseudo-op support],
3 | gcc_cv_as_cfi_pseudo_op, [
4 | gcc_cv_as_cfi_pseudo_op=unknown
5 | AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],,
6 | [gcc_cv_as_cfi_pseudo_op=yes],
7 | [gcc_cv_as_cfi_pseudo_op=no])
8 | ])
9 | if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then
10 | AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1,
11 | [Define if your assembler supports .cfi_* directives.])
12 | fi
13 | ])
14 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/m4/ltversion.m4:
--------------------------------------------------------------------------------
1 | # ltversion.m4 -- version numbers -*- Autoconf -*-
2 | #
3 | # Copyright (C) 2004 Free Software Foundation, Inc.
4 | # Written by Scott James Remnant, 2004
5 | #
6 | # This file is free software; the Free Software Foundation gives
7 | # unlimited permission to copy and/or distribute it, with or without
8 | # modifications, as long as this notice is preserved.
9 |
10 | # @configure_input@
11 |
12 | # serial 3337 ltversion.m4
13 | # This file is part of GNU Libtool
14 |
15 | m4_define([LT_PACKAGE_VERSION], [2.4.2])
16 | m4_define([LT_PACKAGE_REVISION], [1.3337])
17 |
18 | AC_DEFUN([LTVERSION_VERSION],
19 | [macro_version='2.4.2'
20 | macro_revision='1.3337'
21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
22 | _LT_DECL(, macro_revision, 0)
23 | ])
24 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/man/Makefile.am:
--------------------------------------------------------------------------------
1 | ## Process this with automake to create Makefile.in
2 |
3 | AUTOMAKE_OPTIONS=foreign
4 |
5 | EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3
6 |
7 | man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3
8 |
9 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/man/ffi.3:
--------------------------------------------------------------------------------
1 | .Dd February 15, 2008
2 | .Dt FFI 3
3 | .Sh NAME
4 | .Nm FFI
5 | .Nd Foreign Function Interface
6 | .Sh LIBRARY
7 | libffi, -lffi
8 | .Sh SYNOPSIS
9 | .In ffi.h
10 | .Ft ffi_status
11 | .Fo ffi_prep_cif
12 | .Fa "ffi_cif *cif"
13 | .Fa "ffi_abi abi"
14 | .Fa "unsigned int nargs"
15 | .Fa "ffi_type *rtype"
16 | .Fa "ffi_type **atypes"
17 | .Fc
18 | .Ft void
19 | .Fo ffi_prep_cif_var
20 | .Fa "ffi_cif *cif"
21 | .Fa "ffi_abi abi"
22 | .Fa "unsigned int nfixedargs"
23 | .Fa "unsigned int ntotalargs"
24 | .Fa "ffi_type *rtype"
25 | .Fa "ffi_type **atypes"
26 | .Fc
27 | .Ft void
28 | .Fo ffi_call
29 | .Fa "ffi_cif *cif"
30 | .Fa "void (*fn)(void)"
31 | .Fa "void *rvalue"
32 | .Fa "void **avalue"
33 | .Fc
34 | .Sh DESCRIPTION
35 | The foreign function interface provides a mechanism by which a function can
36 | generate a call to another function at runtime without requiring knowledge of
37 | the called function's interface at compile time.
38 | .Sh SEE ALSO
39 | .Xr ffi_prep_cif 3 ,
40 | .Xr ffi_prep_cif_var 3 ,
41 | .Xr ffi_call 3
42 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/man/ffi_prep_cif.3:
--------------------------------------------------------------------------------
1 | .Dd February 15, 2008
2 | .Dt ffi_prep_cif 3
3 | .Sh NAME
4 | .Nm ffi_prep_cif
5 | .Nd Prepare a
6 | .Nm ffi_cif
7 | structure for use with
8 | .Nm ffi_call
9 | .
10 | .Sh SYNOPSIS
11 | .In ffi.h
12 | .Ft ffi_status
13 | .Fo ffi_prep_cif
14 | .Fa "ffi_cif *cif"
15 | .Fa "ffi_abi abi"
16 | .Fa "unsigned int nargs"
17 | .Fa "ffi_type *rtype"
18 | .Fa "ffi_type **atypes"
19 | .Fc
20 | .Sh DESCRIPTION
21 | The
22 | .Nm ffi_prep_cif
23 | function prepares a
24 | .Nm ffi_cif
25 | structure for use with
26 | .Nm ffi_call
27 | .
28 | .Fa abi
29 | specifies a set of calling conventions to use.
30 | .Fa atypes
31 | is an array of
32 | .Fa nargs
33 | pointers to
34 | .Nm ffi_type
35 | structs that describe the data type, size and alignment of each argument.
36 | .Fa rtype
37 | points to an
38 | .Nm ffi_type
39 | that describes the data type, size and alignment of the
40 | return value. Note that to call a variadic function
41 | .Nm ffi_prep_cif_var
42 | must be used instead.
43 | .Sh RETURN VALUES
44 | Upon successful completion,
45 | .Nm ffi_prep_cif
46 | returns
47 | .Nm FFI_OK .
48 | It will return
49 | .Nm FFI_BAD_TYPEDEF
50 | if
51 | .Fa cif
52 | is
53 | .Nm NULL
54 | or
55 | .Fa atypes
56 | or
57 | .Fa rtype
58 | is malformed. If
59 | .Fa abi
60 | does not refer to a valid ABI,
61 | .Nm FFI_BAD_ABI
62 | will be returned. Available ABIs are
63 | defined in
64 | .Nm .
65 | .Sh SEE ALSO
66 | .Xr ffi 3 ,
67 | .Xr ffi_call 3 ,
68 | .Xr ffi_prep_cif_var 3
69 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/man/ffi_prep_cif_var.3:
--------------------------------------------------------------------------------
1 | .Dd January 25, 2011
2 | .Dt ffi_prep_cif_var 3
3 | .Sh NAME
4 | .Nm ffi_prep_cif_var
5 | .Nd Prepare a
6 | .Nm ffi_cif
7 | structure for use with
8 | .Nm ffi_call
9 | for variadic functions.
10 | .Sh SYNOPSIS
11 | .In ffi.h
12 | .Ft ffi_status
13 | .Fo ffi_prep_cif_var
14 | .Fa "ffi_cif *cif"
15 | .Fa "ffi_abi abi"
16 | .Fa "unsigned int nfixedargs"
17 | .Fa "unsigned int ntotalargs"
18 | .Fa "ffi_type *rtype"
19 | .Fa "ffi_type **atypes"
20 | .Fc
21 | .Sh DESCRIPTION
22 | The
23 | .Nm ffi_prep_cif_var
24 | function prepares a
25 | .Nm ffi_cif
26 | structure for use with
27 | .Nm ffi_call
28 | for variadic functions.
29 | .Fa abi
30 | specifies a set of calling conventions to use.
31 | .Fa atypes
32 | is an array of
33 | .Fa ntotalargs
34 | pointers to
35 | .Nm ffi_type
36 | structs that describe the data type, size and alignment of each argument.
37 | .Fa rtype
38 | points to an
39 | .Nm ffi_type
40 | that describes the data type, size and alignment of the
41 | return value.
42 | .Fa nfixedargs
43 | must contain the number of fixed (non-variadic) arguments.
44 | Note that to call a non-variadic function
45 | .Nm ffi_prep_cif
46 | must be used.
47 | .Sh RETURN VALUES
48 | Upon successful completion,
49 | .Nm ffi_prep_cif_var
50 | returns
51 | .Nm FFI_OK .
52 | It will return
53 | .Nm FFI_BAD_TYPEDEF
54 | if
55 | .Fa cif
56 | is
57 | .Nm NULL
58 | or
59 | .Fa atypes
60 | or
61 | .Fa rtype
62 | is malformed. If
63 | .Fa abi
64 | does not refer to a valid ABI,
65 | .Nm FFI_BAD_ABI
66 | will be returned. Available ABIs are
67 | defined in
68 | .Nm
69 | .
70 | .Sh SEE ALSO
71 | .Xr ffi 3 ,
72 | .Xr ffi_call 3 ,
73 | .Xr ffi_prep_cif 3
74 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/src/bfin/ffitarget.h:
--------------------------------------------------------------------------------
1 | /* -----------------------------------------------------------------------
2 | ffitarget.h - Copyright (c) 2012 Alexandre K. I. de Mendonca
3 |
4 | Blackfin Foreign Function Interface
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining
7 | a copy of this software and associated documentation files (the
8 | ``Software''), to deal in the Software without restriction, including
9 | without limitation the rights to use, copy, modify, merge, publish,
10 | distribute, sublicense, and/or sell copies of the Software, and to
11 | permit persons to whom the Software is furnished to do so, subject to
12 | the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included
15 | in all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 | DEALINGS IN THE SOFTWARE.
25 | ----------------------------------------------------------------------- */
26 |
27 | #ifndef LIBFFI_TARGET_H
28 | #define LIBFFI_TARGET_H
29 |
30 | #ifndef LIBFFI_ASM
31 | typedef unsigned long ffi_arg;
32 | typedef signed long ffi_sarg;
33 |
34 | typedef enum ffi_abi {
35 | FFI_FIRST_ABI = 0,
36 | FFI_SYSV,
37 | FFI_LAST_ABI,
38 | FFI_DEFAULT_ABI = FFI_SYSV
39 | } ffi_abi;
40 | #endif
41 |
42 | #endif
43 |
44 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/src/microblaze/ffitarget.h:
--------------------------------------------------------------------------------
1 | /* -----------------------------------------------------------------------
2 | ffitarget.h - Copyright (c) 2012, 2013 Xilinx, Inc
3 |
4 | Target configuration macros for MicroBlaze.
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining
7 | a copy of this software and associated documentation files (the
8 | ``Software''), to deal in the Software without restriction, including
9 | without limitation the rights to use, copy, modify, merge, publish,
10 | distribute, sublicense, and/or sell copies of the Software, and to
11 | permit persons to whom the Software is furnished to do so, subject to
12 | the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included
15 | in all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 | DEALINGS IN THE SOFTWARE.
25 | ----------------------------------------------------------------------- */
26 |
27 | #ifndef LIBFFI_TARGET_H
28 | #define LIBFFI_TARGET_H
29 |
30 | #ifndef LIBFFI_H
31 | #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
32 | #endif
33 |
34 | #ifndef LIBFFI_ASM
35 | typedef unsigned long ffi_arg;
36 | typedef signed long ffi_sarg;
37 |
38 | typedef enum ffi_abi {
39 | FFI_FIRST_ABI = 0,
40 | FFI_SYSV,
41 | FFI_LAST_ABI,
42 | FFI_DEFAULT_ABI = FFI_SYSV
43 | } ffi_abi;
44 | #endif
45 |
46 | /* Definitions for closures */
47 |
48 | #define FFI_CLOSURES 1
49 | #define FFI_NATIVE_RAW_API 0
50 |
51 | #define FFI_TRAMPOLINE_SIZE (4*8)
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/stamp-h.in:
--------------------------------------------------------------------------------
1 | timestamp
2 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/config/default.exp:
--------------------------------------------------------------------------------
1 | load_lib "standard.exp"
2 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/call.exp:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003, 2006, 2009, 2010 Free Software Foundation, Inc.
2 |
3 | # This program is free software; you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation; either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program; see the file COPYING3. If not see
15 | # .
16 |
17 | dg-init
18 | libffi-init
19 |
20 | global srcdir subdir
21 |
22 | if { [string match $using_gcc "yes"] } {
23 |
24 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O0 -W -Wall" ""
25 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2" ""
26 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O3" ""
27 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-Os" ""
28 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2 -fomit-frame-pointer" ""
29 |
30 | } else {
31 |
32 | # Assume we are using the vendor compiler.
33 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" ""
34 |
35 | }
36 |
37 | dg-finish
38 |
39 | # Local Variables:
40 | # tcl-indent-level:4
41 | # End:
42 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_dbls_struct.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call, closure_call
2 | Purpose: Check double arguments in structs.
3 | Limitations: none.
4 | PR: none.
5 | Originator: Blake Chaffin 6/23/2007 */
6 |
7 | /* { dg-do run } */
8 |
9 | #include "ffitest.h"
10 |
11 | typedef struct Dbls {
12 | double x;
13 | double y;
14 | } Dbls;
15 |
16 | void
17 | closure_test_fn(Dbls p)
18 | {
19 | printf("%.1f %.1f\n", p.x, p.y);
20 | }
21 |
22 | void
23 | closure_test_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
24 | void** args, void* userdata __UNUSED__)
25 | {
26 | closure_test_fn(*(Dbls*)args[0]);
27 | }
28 |
29 | int main(int argc __UNUSED__, char** argv __UNUSED__)
30 | {
31 | ffi_cif cif;
32 |
33 | void *code;
34 | ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
35 | ffi_type* cl_arg_types[1];
36 |
37 | ffi_type ts1_type;
38 | ffi_type* ts1_type_elements[4];
39 |
40 | Dbls arg = { 1.0, 2.0 };
41 |
42 | ts1_type.size = 0;
43 | ts1_type.alignment = 0;
44 | ts1_type.type = FFI_TYPE_STRUCT;
45 | ts1_type.elements = ts1_type_elements;
46 |
47 | ts1_type_elements[0] = &ffi_type_double;
48 | ts1_type_elements[1] = &ffi_type_double;
49 | ts1_type_elements[2] = NULL;
50 |
51 | cl_arg_types[0] = &ts1_type;
52 |
53 | /* Initialize the cif */
54 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
55 | &ffi_type_void, cl_arg_types) == FFI_OK);
56 |
57 | CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_gn, NULL, code) == FFI_OK);
58 |
59 | ((void*(*)(Dbls))(code))(arg);
60 | /* { dg-output "1.0 2.0\n" } */
61 |
62 | closure_test_fn(arg);
63 | /* { dg-output "1.0 2.0\n" } */
64 |
65 | return 0;
66 | }
67 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_double.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Check return value double.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20030828 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static void cls_ret_double_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
11 | void* userdata __UNUSED__)
12 | {
13 | *(double *)resp = *(double *)args[0];
14 |
15 | printf("%f: %f\n",*(double *)args[0],
16 | *(double *)resp);
17 | }
18 | typedef double (*cls_ret_double)(double);
19 |
20 | int main (void)
21 | {
22 | ffi_cif cif;
23 | void *code;
24 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
25 | ffi_type * cl_arg_types[2];
26 | double res;
27 |
28 | cl_arg_types[0] = &ffi_type_double;
29 | cl_arg_types[1] = NULL;
30 |
31 | /* Initialize the cif */
32 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
33 | &ffi_type_double, cl_arg_types) == FFI_OK);
34 |
35 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_double_fn, NULL, code) == FFI_OK);
36 |
37 | res = (*((cls_ret_double)code))(21474.789);
38 | /* { dg-output "21474.789000: 21474.789000" } */
39 | printf("res: %.6f\n", res);
40 | /* { dg-output "\nres: 21474.789000" } */
41 |
42 | exit(0);
43 | }
44 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_double_va.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call, closure_call
2 | Purpose: Test doubles passed in variable argument lists.
3 | Limitations: none.
4 | PR: none.
5 | Originator: Blake Chaffin 6/6/2007 */
6 |
7 | /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
8 | /* { dg-output "" { xfail avr32*-*-* } } */
9 | /* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */
10 |
11 | #include "ffitest.h"
12 |
13 | static void
14 | cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp,
15 | void** args, void* userdata __UNUSED__)
16 | {
17 | char* format = *(char**)args[0];
18 | double doubleValue = *(double*)args[1];
19 |
20 | *(ffi_arg*)resp = printf(format, doubleValue);
21 | }
22 |
23 | int main (void)
24 | {
25 | ffi_cif cif;
26 | void *code;
27 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
28 | void* args[3];
29 | ffi_type* arg_types[3];
30 |
31 | char* format = "%.1f\n";
32 | double doubleArg = 7;
33 | ffi_arg res = 0;
34 |
35 | arg_types[0] = &ffi_type_pointer;
36 | arg_types[1] = &ffi_type_double;
37 | arg_types[2] = NULL;
38 |
39 | /* This printf call is variadic */
40 | CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint,
41 | arg_types) == FFI_OK);
42 |
43 | args[0] = &format;
44 | args[1] = &doubleArg;
45 | args[2] = NULL;
46 |
47 | ffi_call(&cif, FFI_FN(printf), &res, args);
48 | /* { dg-output "7.0" } */
49 | printf("res: %d\n", (int) res);
50 | /* { dg-output "\nres: 4" } */
51 |
52 | /* The call to cls_double_va_fn is static, so have to use a normal prep_cif */
53 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint, arg_types) == FFI_OK);
54 |
55 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL, code) == FFI_OK);
56 |
57 | res = ((int(*)(char*, double))(code))(format, doubleArg);
58 | /* { dg-output "\n7.0" } */
59 | printf("res: %d\n", (int) res);
60 | /* { dg-output "\nres: 4" } */
61 |
62 | exit(0);
63 | }
64 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_float.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Check return value float.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20030828 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static void cls_ret_float_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
11 | void* userdata __UNUSED__)
12 | {
13 | *(float *)resp = *(float *)args[0];
14 |
15 | printf("%g: %g\n",*(float *)args[0],
16 | *(float *)resp);
17 | }
18 |
19 | typedef float (*cls_ret_float)(float);
20 |
21 | int main (void)
22 | {
23 | ffi_cif cif;
24 | void *code;
25 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
26 | ffi_type * cl_arg_types[2];
27 | float res;
28 |
29 | cl_arg_types[0] = &ffi_type_float;
30 | cl_arg_types[1] = NULL;
31 |
32 | /* Initialize the cif */
33 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
34 | &ffi_type_float, cl_arg_types) == FFI_OK);
35 |
36 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_float_fn, NULL, code) == FFI_OK);
37 | res = ((((cls_ret_float)code)(-2122.12)));
38 | /* { dg-output "\\-2122.12: \\-2122.12" } */
39 | printf("res: %.6f\n", res);
40 | /* { dg-output "\nres: \-2122.120117" } */
41 | exit(0);
42 | }
43 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_longdouble_va.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call, closure_call
2 | Purpose: Test long doubles passed in variable argument lists.
3 | Limitations: none.
4 | PR: none.
5 | Originator: Blake Chaffin 6/6/2007 */
6 |
7 | /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
8 | /* { dg-output "" { xfail avr32*-*-* x86_64-*-mingw* } } */
9 | /* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */
10 |
11 | #include "ffitest.h"
12 |
13 | static void
14 | cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp,
15 | void** args, void* userdata __UNUSED__)
16 | {
17 | char* format = *(char**)args[0];
18 | long double ldValue = *(long double*)args[1];
19 |
20 | *(ffi_arg*)resp = printf(format, ldValue);
21 | }
22 |
23 | int main (void)
24 | {
25 | ffi_cif cif;
26 | void *code;
27 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
28 | void* args[3];
29 | ffi_type* arg_types[3];
30 |
31 | char* format = "%.1Lf\n";
32 | long double ldArg = 7;
33 | ffi_arg res = 0;
34 |
35 | arg_types[0] = &ffi_type_pointer;
36 | arg_types[1] = &ffi_type_longdouble;
37 | arg_types[2] = NULL;
38 |
39 | /* This printf call is variadic */
40 | CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint,
41 | arg_types) == FFI_OK);
42 |
43 | args[0] = &format;
44 | args[1] = &ldArg;
45 | args[2] = NULL;
46 |
47 | ffi_call(&cif, FFI_FN(printf), &res, args);
48 | /* { dg-output "7.0" } */
49 | printf("res: %d\n", (int) res);
50 | /* { dg-output "\nres: 4" } */
51 |
52 | /* The call to cls_longdouble_va_fn is static, so have to use a normal prep_cif */
53 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint,
54 | arg_types) == FFI_OK);
55 |
56 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL, code) == FFI_OK);
57 |
58 | res = ((int(*)(char*, long double))(code))(format, ldArg);
59 | /* { dg-output "\n7.0" } */
60 | printf("res: %d\n", (int) res);
61 | /* { dg-output "\nres: 4" } */
62 |
63 | exit(0);
64 | }
65 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_multi_schar.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call, closure_call
2 | Purpose: Check passing of multiple signed char values.
3 | Limitations: none.
4 | PR: PR13221.
5 | Originator: 20031129 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | signed char test_func_fn(signed char a1, signed char a2)
11 | {
12 | signed char result;
13 |
14 | result = a1 + a2;
15 |
16 | printf("%d %d: %d\n", a1, a2, result);
17 |
18 | return result;
19 |
20 | }
21 |
22 | static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
23 | void *data __UNUSED__)
24 | {
25 | signed char a1, a2;
26 |
27 | a1 = *(signed char *)avals[0];
28 | a2 = *(signed char *)avals[1];
29 |
30 | *(ffi_arg *)rval = test_func_fn(a1, a2);
31 |
32 | }
33 |
34 | typedef signed char (*test_type)(signed char, signed char);
35 |
36 | int main (void)
37 | {
38 | ffi_cif cif;
39 | void *code;
40 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
41 | void * args_dbl[3];
42 | ffi_type * cl_arg_types[3];
43 | ffi_arg res_call;
44 | signed char a, b, res_closure;
45 |
46 | a = 2;
47 | b = 125;
48 |
49 | args_dbl[0] = &a;
50 | args_dbl[1] = &b;
51 | args_dbl[2] = NULL;
52 |
53 | cl_arg_types[0] = &ffi_type_schar;
54 | cl_arg_types[1] = &ffi_type_schar;
55 | cl_arg_types[2] = NULL;
56 |
57 | /* Initialize the cif */
58 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
59 | &ffi_type_schar, cl_arg_types) == FFI_OK);
60 |
61 | ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
62 | /* { dg-output "2 125: 127" } */
63 | printf("res: %d\n", (signed char)res_call);
64 | /* { dg-output "\nres: 127" } */
65 |
66 | CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
67 |
68 | res_closure = (*((test_type)code))(2, 125);
69 | /* { dg-output "\n2 125: 127" } */
70 | printf("res: %d\n", res_closure);
71 | /* { dg-output "\nres: 127" } */
72 |
73 | exit(0);
74 | }
75 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_multi_sshort.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call, closure_call
2 | Purpose: Check passing of multiple signed short values.
3 | Limitations: none.
4 | PR: PR13221.
5 | Originator: 20031129 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | signed short test_func_fn(signed short a1, signed short a2)
11 | {
12 | signed short result;
13 |
14 | result = a1 + a2;
15 |
16 | printf("%d %d: %d\n", a1, a2, result);
17 |
18 | return result;
19 |
20 | }
21 |
22 | static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
23 | void *data __UNUSED__)
24 | {
25 | signed short a1, a2;
26 |
27 | a1 = *(signed short *)avals[0];
28 | a2 = *(signed short *)avals[1];
29 |
30 | *(ffi_arg *)rval = test_func_fn(a1, a2);
31 |
32 | }
33 |
34 | typedef signed short (*test_type)(signed short, signed short);
35 |
36 | int main (void)
37 | {
38 | ffi_cif cif;
39 | void *code;
40 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
41 | void * args_dbl[3];
42 | ffi_type * cl_arg_types[3];
43 | ffi_arg res_call;
44 | unsigned short a, b, res_closure;
45 |
46 | a = 2;
47 | b = 32765;
48 |
49 | args_dbl[0] = &a;
50 | args_dbl[1] = &b;
51 | args_dbl[2] = NULL;
52 |
53 | cl_arg_types[0] = &ffi_type_sshort;
54 | cl_arg_types[1] = &ffi_type_sshort;
55 | cl_arg_types[2] = NULL;
56 |
57 | /* Initialize the cif */
58 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
59 | &ffi_type_sshort, cl_arg_types) == FFI_OK);
60 |
61 | ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
62 | /* { dg-output "2 32765: 32767" } */
63 | printf("res: %d\n", (unsigned short)res_call);
64 | /* { dg-output "\nres: 32767" } */
65 |
66 | CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
67 |
68 | res_closure = (*((test_type)code))(2, 32765);
69 | /* { dg-output "\n2 32765: 32767" } */
70 | printf("res: %d\n", res_closure);
71 | /* { dg-output "\nres: 32767" } */
72 |
73 | exit(0);
74 | }
75 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_schar.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Check return value schar.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20031108 */
6 |
7 |
8 |
9 | /* { dg-do run } */
10 | #include "ffitest.h"
11 |
12 | static void cls_ret_schar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
13 | void* userdata __UNUSED__)
14 | {
15 | *(ffi_arg*)resp = *(signed char *)args[0];
16 | printf("%d: %d\n",*(signed char *)args[0],
17 | (int)*(ffi_arg *)(resp));
18 | }
19 | typedef signed char (*cls_ret_schar)(signed char);
20 |
21 | int main (void)
22 | {
23 | ffi_cif cif;
24 | void *code;
25 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
26 | ffi_type * cl_arg_types[2];
27 | signed char res;
28 |
29 | cl_arg_types[0] = &ffi_type_schar;
30 | cl_arg_types[1] = NULL;
31 |
32 | /* Initialize the cif */
33 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
34 | &ffi_type_schar, cl_arg_types) == FFI_OK);
35 |
36 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_schar_fn, NULL, code) == FFI_OK);
37 |
38 | res = (*((cls_ret_schar)code))(127);
39 | /* { dg-output "127: 127" } */
40 | printf("res: %d\n", res);
41 | /* { dg-output "\nres: 127" } */
42 |
43 | exit(0);
44 | }
45 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_sint.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Check return value sint32.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20031108 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static void cls_ret_sint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
11 | void* userdata __UNUSED__)
12 | {
13 | *(ffi_arg*)resp = *(signed int *)args[0];
14 | printf("%d: %d\n",*(signed int *)args[0],
15 | (int)*(ffi_arg *)(resp));
16 | }
17 | typedef signed int (*cls_ret_sint)(signed int);
18 |
19 | int main (void)
20 | {
21 | ffi_cif cif;
22 | void *code;
23 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
24 | ffi_type * cl_arg_types[2];
25 | signed int res;
26 |
27 | cl_arg_types[0] = &ffi_type_sint;
28 | cl_arg_types[1] = NULL;
29 |
30 | /* Initialize the cif */
31 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
32 | &ffi_type_sint, cl_arg_types) == FFI_OK);
33 |
34 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sint_fn, NULL, code) == FFI_OK);
35 |
36 | res = (*((cls_ret_sint)code))(65534);
37 | /* { dg-output "65534: 65534" } */
38 | printf("res: %d\n",res);
39 | /* { dg-output "\nres: 65534" } */
40 |
41 | exit(0);
42 | }
43 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_sshort.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Check return value sshort.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20031108 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static void cls_ret_sshort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
11 | void* userdata __UNUSED__)
12 | {
13 | *(ffi_arg*)resp = *(signed short *)args[0];
14 | printf("%d: %d\n",*(signed short *)args[0],
15 | (int)*(ffi_arg *)(resp));
16 | }
17 | typedef signed short (*cls_ret_sshort)(signed short);
18 |
19 | int main (void)
20 | {
21 | ffi_cif cif;
22 | void *code;
23 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
24 | ffi_type * cl_arg_types[2];
25 | signed short res;
26 |
27 | cl_arg_types[0] = &ffi_type_sshort;
28 | cl_arg_types[1] = NULL;
29 |
30 | /* Initialize the cif */
31 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
32 | &ffi_type_sshort, cl_arg_types) == FFI_OK);
33 |
34 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sshort_fn, NULL, code) == FFI_OK);
35 |
36 | res = (*((cls_ret_sshort)code))(255);
37 | /* { dg-output "255: 255" } */
38 | printf("res: %d\n",res);
39 | /* { dg-output "\nres: 255" } */
40 |
41 | exit(0);
42 | }
43 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_uchar.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Check return value uchar.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20030828 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static void cls_ret_uchar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
11 | void* userdata __UNUSED__)
12 | {
13 | *(ffi_arg*)resp = *(unsigned char *)args[0];
14 | printf("%d: %d\n",*(unsigned char *)args[0],
15 | (int)*(ffi_arg *)(resp));
16 | }
17 | typedef unsigned char (*cls_ret_uchar)(unsigned char);
18 |
19 | int main (void)
20 | {
21 | ffi_cif cif;
22 | void *code;
23 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
24 | ffi_type * cl_arg_types[2];
25 | unsigned char res;
26 |
27 | cl_arg_types[0] = &ffi_type_uchar;
28 | cl_arg_types[1] = NULL;
29 |
30 | /* Initialize the cif */
31 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
32 | &ffi_type_uchar, cl_arg_types) == FFI_OK);
33 |
34 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uchar_fn, NULL, code) == FFI_OK);
35 |
36 | res = (*((cls_ret_uchar)code))(127);
37 | /* { dg-output "127: 127" } */
38 | printf("res: %d\n",res);
39 | /* { dg-output "\nres: 127" } */
40 |
41 | exit(0);
42 | }
43 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_uchar_va.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Test anonymous unsigned char argument.
3 | Limitations: none.
4 | PR: none.
5 | Originator: ARM Ltd. */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | typedef unsigned char T;
11 |
12 | static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
13 | void* userdata __UNUSED__)
14 | {
15 | *(ffi_arg *)resp = *(T *)args[0];
16 |
17 | printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]);
18 | }
19 |
20 | typedef T (*cls_ret_T)(T, ...);
21 |
22 | int main (void)
23 | {
24 | ffi_cif cif;
25 | void *code;
26 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
27 | ffi_type * cl_arg_types[3];
28 | T res;
29 |
30 | cl_arg_types[0] = &ffi_type_uchar;
31 | cl_arg_types[1] = &ffi_type_uchar;
32 | cl_arg_types[2] = NULL;
33 |
34 | /* Initialize the cif */
35 | CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2,
36 | &ffi_type_uchar, cl_arg_types) == FFI_OK);
37 |
38 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
39 | res = ((((cls_ret_T)code)(67, 4)));
40 | /* { dg-output "67: 67 4" } */
41 | printf("res: %d\n", res);
42 | /* { dg-output "\nres: 67" } */
43 | exit(0);
44 | }
45 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_uint.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Check return value uint.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20030828 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static void cls_ret_uint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
11 | void* userdata __UNUSED__)
12 | {
13 | *(ffi_arg *)resp = *(unsigned int *)args[0];
14 |
15 | printf("%d: %d\n",*(unsigned int *)args[0],
16 | (int)*(ffi_arg *)(resp));
17 | }
18 | typedef unsigned int (*cls_ret_uint)(unsigned int);
19 |
20 | int main (void)
21 | {
22 | ffi_cif cif;
23 | void *code;
24 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
25 | ffi_type * cl_arg_types[2];
26 | unsigned int res;
27 |
28 | cl_arg_types[0] = &ffi_type_uint;
29 | cl_arg_types[1] = NULL;
30 |
31 | /* Initialize the cif */
32 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
33 | &ffi_type_uint, cl_arg_types) == FFI_OK);
34 |
35 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uint_fn, NULL, code) == FFI_OK);
36 |
37 | res = (*((cls_ret_uint)code))(2147483647);
38 | /* { dg-output "2147483647: 2147483647" } */
39 | printf("res: %d\n",res);
40 | /* { dg-output "\nres: 2147483647" } */
41 |
42 | exit(0);
43 | }
44 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_uint_va.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Test anonymous unsigned int argument.
3 | Limitations: none.
4 | PR: none.
5 | Originator: ARM Ltd. */
6 |
7 | /* { dg-do run } */
8 |
9 | #include "ffitest.h"
10 |
11 | typedef unsigned int T;
12 |
13 | static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
14 | void* userdata __UNUSED__)
15 | {
16 | *(T *)resp = *(T *)args[0];
17 |
18 | printf("%d: %d %d\n", *(T *)resp, *(T *)args[0], *(T *)args[1]);
19 | }
20 |
21 | typedef T (*cls_ret_T)(T, ...);
22 |
23 | int main (void)
24 | {
25 | ffi_cif cif;
26 | void *code;
27 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
28 | ffi_type * cl_arg_types[3];
29 | T res;
30 |
31 | cl_arg_types[0] = &ffi_type_uint;
32 | cl_arg_types[1] = &ffi_type_uint;
33 | cl_arg_types[2] = NULL;
34 |
35 | /* Initialize the cif */
36 | CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2,
37 | &ffi_type_uint, cl_arg_types) == FFI_OK);
38 |
39 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
40 | res = ((((cls_ret_T)code)(67, 4)));
41 | /* { dg-output "67: 67 4" } */
42 | printf("res: %d\n", res);
43 | /* { dg-output "\nres: 67" } */
44 | exit(0);
45 | }
46 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_ulong_va.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Test anonymous unsigned long argument.
3 | Limitations: none.
4 | PR: none.
5 | Originator: ARM Ltd. */
6 |
7 | /* { dg-do run } */
8 |
9 | #include "ffitest.h"
10 |
11 | typedef unsigned long T;
12 |
13 | static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
14 | void* userdata __UNUSED__)
15 | {
16 | *(T *)resp = *(T *)args[0];
17 |
18 | printf("%ld: %ld %ld\n", *(T *)resp, *(T *)args[0], *(T *)args[1]);
19 | }
20 |
21 | typedef T (*cls_ret_T)(T, ...);
22 |
23 | int main (void)
24 | {
25 | ffi_cif cif;
26 | void *code;
27 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
28 | ffi_type * cl_arg_types[3];
29 | T res;
30 |
31 | cl_arg_types[0] = &ffi_type_ulong;
32 | cl_arg_types[1] = &ffi_type_ulong;
33 | cl_arg_types[2] = NULL;
34 |
35 | /* Initialize the cif */
36 | CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2,
37 | &ffi_type_ulong, cl_arg_types) == FFI_OK);
38 |
39 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
40 | res = ((((cls_ret_T)code)(67, 4)));
41 | /* { dg-output "67: 67 4" } */
42 | printf("res: %ld\n", res);
43 | /* { dg-output "\nres: 67" } */
44 | exit(0);
45 | }
46 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_ulonglong.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Check return value long long.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20030828 */
6 |
7 | /* { dg-do run } */
8 | /* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */
9 | #include "ffitest.h"
10 |
11 | static void cls_ret_ulonglong_fn(ffi_cif* cif __UNUSED__, void* resp,
12 | void** args, void* userdata __UNUSED__)
13 | {
14 | *(unsigned long long *)resp= 0xfffffffffffffffLL ^ *(unsigned long long *)args[0];
15 |
16 | printf("%" PRIuLL ": %" PRIuLL "\n",*(unsigned long long *)args[0],
17 | *(unsigned long long *)(resp));
18 | }
19 | typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long);
20 |
21 | int main (void)
22 | {
23 | ffi_cif cif;
24 | void *code;
25 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
26 | ffi_type * cl_arg_types[2];
27 | unsigned long long res;
28 |
29 | cl_arg_types[0] = &ffi_type_uint64;
30 | cl_arg_types[1] = NULL;
31 |
32 | /* Initialize the cif */
33 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
34 | &ffi_type_uint64, cl_arg_types) == FFI_OK);
35 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ulonglong_fn, NULL, code) == FFI_OK);
36 | res = (*((cls_ret_ulonglong)code))(214LL);
37 | /* { dg-output "214: 1152921504606846761" } */
38 | printf("res: %" PRIdLL "\n", res);
39 | /* { dg-output "\nres: 1152921504606846761" } */
40 |
41 | res = (*((cls_ret_ulonglong)code))(9223372035854775808LL);
42 | /* { dg-output "\n9223372035854775808: 8070450533247928831" } */
43 | printf("res: %" PRIdLL "\n", res);
44 | /* { dg-output "\nres: 8070450533247928831" } */
45 |
46 | exit(0);
47 | }
48 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_ushort.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Check return value ushort.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20030828 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static void cls_ret_ushort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
11 | void* userdata __UNUSED__)
12 | {
13 | *(ffi_arg*)resp = *(unsigned short *)args[0];
14 |
15 | printf("%d: %d\n",*(unsigned short *)args[0],
16 | (int)*(ffi_arg *)(resp));
17 | }
18 | typedef unsigned short (*cls_ret_ushort)(unsigned short);
19 |
20 | int main (void)
21 | {
22 | ffi_cif cif;
23 | void *code;
24 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
25 | ffi_type * cl_arg_types[2];
26 | unsigned short res;
27 |
28 | cl_arg_types[0] = &ffi_type_ushort;
29 | cl_arg_types[1] = NULL;
30 |
31 | /* Initialize the cif */
32 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
33 | &ffi_type_ushort, cl_arg_types) == FFI_OK);
34 |
35 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ushort_fn, NULL, code) == FFI_OK);
36 |
37 | res = (*((cls_ret_ushort)code))(65535);
38 | /* { dg-output "65535: 65535" } */
39 | printf("res: %d\n",res);
40 | /* { dg-output "\nres: 65535" } */
41 |
42 | exit(0);
43 | }
44 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/cls_ushort_va.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Test anonymous unsigned short argument.
3 | Limitations: none.
4 | PR: none.
5 | Originator: ARM Ltd. */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | typedef unsigned short T;
11 |
12 | static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
13 | void* userdata __UNUSED__)
14 | {
15 | *(ffi_arg *)resp = *(T *)args[0];
16 |
17 | printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]);
18 | }
19 |
20 | typedef T (*cls_ret_T)(T, ...);
21 |
22 | int main (void)
23 | {
24 | ffi_cif cif;
25 | void *code;
26 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
27 | ffi_type * cl_arg_types[3];
28 | T res;
29 |
30 | cl_arg_types[0] = &ffi_type_ushort;
31 | cl_arg_types[1] = &ffi_type_ushort;
32 | cl_arg_types[2] = NULL;
33 |
34 | /* Initialize the cif */
35 | CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2,
36 | &ffi_type_ushort, cl_arg_types) == FFI_OK);
37 |
38 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
39 | res = ((((cls_ret_T)code)(67, 4)));
40 | /* { dg-output "67: 67 4" } */
41 | printf("res: %d\n", res);
42 | /* { dg-output "\nres: 67" } */
43 | exit(0);
44 | }
45 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/err_bad_abi.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_prep_cif, ffi_prep_closure
2 | Purpose: Test error return for bad ABIs.
3 | Limitations: none.
4 | PR: none.
5 | Originator: Blake Chaffin 6/6/2007 */
6 |
7 | /* { dg-do run } */
8 |
9 | #include "ffitest.h"
10 |
11 | static void
12 | dummy_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
13 | void** args __UNUSED__, void* userdata __UNUSED__)
14 | {}
15 |
16 | int main (void)
17 | {
18 | ffi_cif cif;
19 | void *code;
20 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
21 | ffi_type* arg_types[1];
22 |
23 | arg_types[0] = NULL;
24 |
25 | CHECK(ffi_prep_cif(&cif, 255, 0, &ffi_type_void,
26 | arg_types) == FFI_BAD_ABI);
27 |
28 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &ffi_type_void,
29 | arg_types) == FFI_OK);
30 |
31 | cif.abi= 255;
32 |
33 | CHECK(ffi_prep_closure_loc(pcl, &cif, dummy_fn, NULL, code) == FFI_BAD_ABI);
34 |
35 | exit(0);
36 | }
37 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/err_bad_typedef.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_prep_cif
2 | Purpose: Test error return for bad typedefs.
3 | Limitations: none.
4 | PR: none.
5 | Originator: Blake Chaffin 6/6/2007 */
6 |
7 | /* { dg-do run } */
8 |
9 | #include "ffitest.h"
10 |
11 | int main (void)
12 | {
13 | ffi_cif cif;
14 | ffi_type* arg_types[1];
15 |
16 | ffi_type badType = ffi_type_void;
17 |
18 | arg_types[0] = NULL;
19 |
20 | badType.size = 0;
21 |
22 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &badType,
23 | arg_types) == FFI_BAD_TYPEDEF);
24 |
25 | exit(0);
26 | }
27 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/fastthis1_win32.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check fastcall fct call on X86_WIN32 systems.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8 |
9 | #include "ffitest.h"
10 |
11 | static size_t __FASTCALL__ my_fastcall_f(char *s, float a)
12 | {
13 | return (size_t) ((int) strlen(s) + (int) a);
14 | }
15 |
16 | int main (void)
17 | {
18 | ffi_cif cif;
19 | ffi_type *args[MAX_ARGS];
20 | void *values[MAX_ARGS];
21 | ffi_arg rint;
22 | char *s;
23 | float v2;
24 | args[0] = &ffi_type_pointer;
25 | args[1] = &ffi_type_float;
26 | values[0] = (void*) &s;
27 | values[1] = (void*) &v2;
28 |
29 | /* Initialize the cif */
30 | CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 2,
31 | &ffi_type_sint, args) == FFI_OK);
32 |
33 | s = "a";
34 | v2 = 0.0;
35 | ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values);
36 | CHECK(rint == 1);
37 |
38 | s = "1234567";
39 | v2 = -1.0;
40 | ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values);
41 | CHECK(rint == 6);
42 |
43 | s = "1234567890123456789012345";
44 | v2 = 1.0;
45 | ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values);
46 | CHECK(rint == 26);
47 |
48 | printf("fastcall fct1 tests passed\n");
49 | exit(0);
50 | }
51 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/fastthis2_win32.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check fastcall fct call on X86_WIN32 systems.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8 |
9 | #include "ffitest.h"
10 |
11 | static size_t __FASTCALL__ my_fastcall_f(float a, char *s)
12 | {
13 | return (size_t) ((int) strlen(s) + (int) a);
14 | }
15 |
16 | int main (void)
17 | {
18 | ffi_cif cif;
19 | ffi_type *args[MAX_ARGS];
20 | void *values[MAX_ARGS];
21 | ffi_arg rint;
22 | char *s;
23 | float v2;
24 | args[1] = &ffi_type_pointer;
25 | args[0] = &ffi_type_float;
26 | values[1] = (void*) &s;
27 | values[0] = (void*) &v2;
28 |
29 | /* Initialize the cif */
30 | CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 2,
31 | &ffi_type_sint, args) == FFI_OK);
32 |
33 | s = "a";
34 | v2 = 0.0;
35 | ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values);
36 | CHECK(rint == 1);
37 |
38 | s = "1234567";
39 | v2 = -1.0;
40 | ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values);
41 | CHECK(rint == 6);
42 |
43 | s = "1234567890123456789012345";
44 | v2 = 1.0;
45 | ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values);
46 | CHECK(rint == 26);
47 |
48 | printf("fastcall fct2 tests passed\n");
49 | exit(0);
50 | }
51 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/fastthis3_win32.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check fastcall f call on X86_WIN32 systems.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8 |
9 | #include "ffitest.h"
10 |
11 | static size_t __FASTCALL__ my_fastcall_f(float a, char *s, int i)
12 | {
13 | return (size_t) ((int) strlen(s) + (int) a + i);
14 | }
15 |
16 | int main (void)
17 | {
18 | ffi_cif cif;
19 | ffi_type *args[MAX_ARGS];
20 | void *values[MAX_ARGS];
21 | ffi_arg rint;
22 | char *s;
23 | int v1;
24 | float v2;
25 | args[2] = &ffi_type_sint;
26 | args[1] = &ffi_type_pointer;
27 | args[0] = &ffi_type_float;
28 | values[2] = (void*) &v1;
29 | values[1] = (void*) &s;
30 | values[0] = (void*) &v2;
31 |
32 | /* Initialize the cif */
33 | CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 3,
34 | &ffi_type_sint, args) == FFI_OK);
35 |
36 | s = "a";
37 | v1 = 1;
38 | v2 = 0.0;
39 | ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values);
40 | CHECK(rint == 2);
41 |
42 | s = "1234567";
43 | v2 = -1.0;
44 | v1 = -2;
45 | ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values);
46 | CHECK(rint == 4);
47 |
48 | s = "1234567890123456789012345";
49 | v2 = 1.0;
50 | v1 = 2;
51 | ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values);
52 | CHECK(rint == 28);
53 |
54 | printf("fastcall fct3 tests passed\n");
55 | exit(0);
56 | }
57 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/float.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value float.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 |
9 | #include "ffitest.h"
10 |
11 | static int floating(int a, float b, double c, long double d)
12 | {
13 | int i;
14 |
15 | i = (int) ((float)a/b + ((float)c/(float)d));
16 |
17 | return i;
18 | }
19 |
20 | int main (void)
21 | {
22 | ffi_cif cif;
23 | ffi_type *args[MAX_ARGS];
24 | void *values[MAX_ARGS];
25 | ffi_arg rint;
26 |
27 | float f;
28 | signed int si1;
29 | double d;
30 | long double ld;
31 |
32 | args[0] = &ffi_type_sint;
33 | values[0] = &si1;
34 | args[1] = &ffi_type_float;
35 | values[1] = &f;
36 | args[2] = &ffi_type_double;
37 | values[2] = &d;
38 | args[3] = &ffi_type_longdouble;
39 | values[3] = &ld;
40 |
41 | /* Initialize the cif */
42 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
43 | &ffi_type_sint, args) == FFI_OK);
44 |
45 | si1 = 6;
46 | f = 3.14159;
47 | d = (double)1.0/(double)3.0;
48 | ld = 2.71828182846L;
49 |
50 | floating (si1, f, d, ld);
51 |
52 | ffi_call(&cif, FFI_FN(floating), &rint, values);
53 |
54 | printf ("%d vs %d\n", (int)rint, floating (si1, f, d, ld));
55 |
56 | CHECK((int)rint == floating(si1, f, d, ld));
57 |
58 | exit (0);
59 | }
60 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/float1.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value double.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 | #include "float.h"
10 |
11 | typedef union
12 | {
13 | double d;
14 | unsigned char c[sizeof (double)];
15 | } value_type;
16 |
17 | #define CANARY 0xba
18 |
19 | static double dblit(float f)
20 | {
21 | return f/3.0;
22 | }
23 |
24 | int main (void)
25 | {
26 | ffi_cif cif;
27 | ffi_type *args[MAX_ARGS];
28 | void *values[MAX_ARGS];
29 | float f;
30 | value_type result[2];
31 | unsigned int i;
32 |
33 | args[0] = &ffi_type_float;
34 | values[0] = &f;
35 |
36 | /* Initialize the cif */
37 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
38 | &ffi_type_double, args) == FFI_OK);
39 |
40 | f = 3.14159;
41 |
42 | /* Put a canary in the return array. This is a regression test for
43 | a buffer overrun. */
44 | memset(result[1].c, CANARY, sizeof (double));
45 |
46 | ffi_call(&cif, FFI_FN(dblit), &result[0].d, values);
47 |
48 | /* These are not always the same!! Check for a reasonable delta */
49 |
50 | CHECK(result[0].d - dblit(f) < DBL_EPSILON);
51 |
52 | /* Check the canary. */
53 | for (i = 0; i < sizeof (double); ++i)
54 | CHECK(result[1].c[i] == CANARY);
55 |
56 | exit(0);
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/float2.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value long double.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-excess-errors "fails" { target x86_64-*-mingw* x86_64-*-cygwin* } } */
8 | /* { dg-do run { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
9 |
10 | #include "ffitest.h"
11 | #include "float.h"
12 |
13 | static long double ldblit(float f)
14 | {
15 | return (long double) (((long double) f)/ (long double) 3.0);
16 | }
17 |
18 | int main (void)
19 | {
20 | ffi_cif cif;
21 | ffi_type *args[MAX_ARGS];
22 | void *values[MAX_ARGS];
23 | float f;
24 | long double ld;
25 |
26 | args[0] = &ffi_type_float;
27 | values[0] = &f;
28 |
29 | /* Initialize the cif */
30 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
31 | &ffi_type_longdouble, args) == FFI_OK);
32 |
33 | f = 3.14159;
34 |
35 | #if 1
36 | /* This is ifdef'd out for now. long double support under SunOS/gcc
37 | is pretty much non-existent. You'll get the odd bus error in library
38 | routines like printf(). */
39 | printf ("%Lf\n", ldblit(f));
40 | #endif
41 | ld = 666;
42 | ffi_call(&cif, FFI_FN(ldblit), &ld, values);
43 |
44 | #if 1
45 | /* This is ifdef'd out for now. long double support under SunOS/gcc
46 | is pretty much non-existent. You'll get the odd bus error in library
47 | routines like printf(). */
48 | printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON);
49 | #endif
50 |
51 | /* These are not always the same!! Check for a reasonable delta */
52 | if (ld - ldblit(f) < LDBL_EPSILON)
53 | puts("long double return value tests ok!");
54 | else
55 | CHECK(0);
56 |
57 | exit(0);
58 | }
59 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/float3.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check float arguments with different orders.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 |
9 | #include "ffitest.h"
10 | #include "float.h"
11 |
12 | static double floating_1(float a, double b, long double c)
13 | {
14 | return (double) a + b + (double) c;
15 | }
16 |
17 | static double floating_2(long double a, double b, float c)
18 | {
19 | return (double) a + b + (double) c;
20 | }
21 |
22 | int main (void)
23 | {
24 | ffi_cif cif;
25 | ffi_type *args[MAX_ARGS];
26 | void *values[MAX_ARGS];
27 | double rd;
28 |
29 | float f;
30 | double d;
31 | long double ld;
32 |
33 | args[0] = &ffi_type_float;
34 | values[0] = &f;
35 | args[1] = &ffi_type_double;
36 | values[1] = &d;
37 | args[2] = &ffi_type_longdouble;
38 | values[2] = &ld;
39 |
40 | /* Initialize the cif */
41 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
42 | &ffi_type_double, args) == FFI_OK);
43 |
44 | f = 3.14159;
45 | d = (double)1.0/(double)3.0;
46 | ld = 2.71828182846L;
47 |
48 | floating_1 (f, d, ld);
49 |
50 | ffi_call(&cif, FFI_FN(floating_1), &rd, values);
51 |
52 | CHECK(rd - floating_1(f, d, ld) < DBL_EPSILON);
53 |
54 | args[0] = &ffi_type_longdouble;
55 | values[0] = &ld;
56 | args[1] = &ffi_type_double;
57 | values[1] = &d;
58 | args[2] = &ffi_type_float;
59 | values[2] = &f;
60 |
61 | /* Initialize the cif */
62 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
63 | &ffi_type_double, args) == FFI_OK);
64 |
65 | floating_2 (ld, d, f);
66 |
67 | ffi_call(&cif, FFI_FN(floating_2), &rd, values);
68 |
69 | CHECK(rd - floating_2(ld, d, f) < DBL_EPSILON);
70 |
71 | exit (0);
72 | }
73 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/float4.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check denorm double value.
3 | Limitations: none.
4 | PR: PR26483.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | /* { dg-options "-mieee" { target alpha*-*-* } } */
9 |
10 | #include "ffitest.h"
11 | #include "float.h"
12 |
13 | typedef union
14 | {
15 | double d;
16 | unsigned char c[sizeof (double)];
17 | } value_type;
18 |
19 | #define CANARY 0xba
20 |
21 | static double dblit(double d)
22 | {
23 | return d;
24 | }
25 |
26 | int main (void)
27 | {
28 | ffi_cif cif;
29 | ffi_type *args[MAX_ARGS];
30 | void *values[MAX_ARGS];
31 | double d;
32 | value_type result[2];
33 | unsigned int i;
34 |
35 | args[0] = &ffi_type_double;
36 | values[0] = &d;
37 |
38 | /* Initialize the cif */
39 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
40 | &ffi_type_double, args) == FFI_OK);
41 |
42 | d = DBL_MIN / 2;
43 |
44 | /* Put a canary in the return array. This is a regression test for
45 | a buffer overrun. */
46 | memset(result[1].c, CANARY, sizeof (double));
47 |
48 | ffi_call(&cif, FFI_FN(dblit), &result[0].d, values);
49 |
50 | /* The standard delta check doesn't work for denorms. Since we didn't do
51 | any arithmetic, we should get the original result back, and hence an
52 | exact check should be OK here. */
53 |
54 | CHECK(result[0].d == dblit(d));
55 |
56 | /* Check the canary. */
57 | for (i = 0; i < sizeof (double); ++i)
58 | CHECK(result[1].c[i] == CANARY);
59 |
60 | exit(0);
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/many.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value float, with many arguments
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | #include
11 |
12 | static float many(float f1,
13 | float f2,
14 | float f3,
15 | float f4,
16 | float f5,
17 | float f6,
18 | float f7,
19 | float f8,
20 | float f9,
21 | float f10,
22 | float f11,
23 | float f12,
24 | float f13)
25 | {
26 | #if 0
27 | printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n",
28 | (double) f1, (double) f2, (double) f3, (double) f4, (double) f5,
29 | (double) f6, (double) f7, (double) f8, (double) f9, (double) f10,
30 | (double) f11, (double) f12, (double) f13);
31 | #endif
32 |
33 | return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13);
34 | }
35 |
36 | int main (void)
37 | {
38 | ffi_cif cif;
39 | ffi_type *args[13];
40 | void *values[13];
41 | float fa[13];
42 | float f, ff;
43 | int i;
44 |
45 | for (i = 0; i < 13; i++)
46 | {
47 | args[i] = &ffi_type_float;
48 | values[i] = &fa[i];
49 | fa[i] = (float) i;
50 | }
51 |
52 | /* Initialize the cif */
53 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13,
54 | &ffi_type_float, args) == FFI_OK);
55 |
56 | ffi_call(&cif, FFI_FN(many), &f, values);
57 |
58 | ff = many(fa[0], fa[1],
59 | fa[2], fa[3],
60 | fa[4], fa[5],
61 | fa[6], fa[7],
62 | fa[8], fa[9],
63 | fa[10],fa[11],fa[12]);
64 |
65 | if (f - ff < FLT_EPSILON)
66 | exit(0);
67 | else
68 | abort();
69 | }
70 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/many2.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check uint8_t arguments.
3 | Limitations: none.
4 | PR: PR45677.
5 | Originator: Dan Witte 20100916 */
6 |
7 | /* { dg-do run } */
8 |
9 | #include "ffitest.h"
10 |
11 | #define NARGS 7
12 |
13 | typedef unsigned char u8;
14 |
15 | #ifdef __GNUC__
16 | __attribute__((noinline))
17 | #endif
18 | uint8_t
19 | foo (uint8_t a, uint8_t b, uint8_t c, uint8_t d,
20 | uint8_t e, uint8_t f, uint8_t g)
21 | {
22 | return a + b + c + d + e + f + g;
23 | }
24 |
25 | uint8_t
26 | bar (uint8_t a, uint8_t b, uint8_t c, uint8_t d,
27 | uint8_t e, uint8_t f, uint8_t g)
28 | {
29 | return foo (a, b, c, d, e, f, g);
30 | }
31 |
32 | int
33 | main (void)
34 | {
35 | ffi_type *ffitypes[NARGS];
36 | int i;
37 | ffi_cif cif;
38 | ffi_arg result = 0;
39 | uint8_t args[NARGS];
40 | void *argptrs[NARGS];
41 |
42 | for (i = 0; i < NARGS; ++i)
43 | ffitypes[i] = &ffi_type_uint8;
44 |
45 | CHECK (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, NARGS,
46 | &ffi_type_uint8, ffitypes) == FFI_OK);
47 |
48 | for (i = 0; i < NARGS; ++i)
49 | {
50 | args[i] = i;
51 | argptrs[i] = &args[i];
52 | }
53 | ffi_call (&cif, FFI_FN (bar), &result, argptrs);
54 |
55 | CHECK (result == 21);
56 | return 0;
57 | }
58 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/many2_win32.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check stdcall many call on X86_WIN32 systems.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8 |
9 | #include "ffitest.h"
10 | #include
11 |
12 | static float __attribute__((fastcall)) fastcall_many(float f1,
13 | float f2,
14 | float f3,
15 | float f4,
16 | float f5,
17 | float f6,
18 | float f7,
19 | float f8,
20 | float f9,
21 | float f10,
22 | float f11,
23 | float f12,
24 | float f13)
25 | {
26 | return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13);
27 | }
28 |
29 | int main (void)
30 | {
31 | ffi_cif cif;
32 | ffi_type *args[13];
33 | void *values[13];
34 | float fa[13];
35 | float f, ff;
36 | unsigned long ul;
37 |
38 | for (ul = 0; ul < 13; ul++)
39 | {
40 | args[ul] = &ffi_type_float;
41 | values[ul] = &fa[ul];
42 | fa[ul] = (float) ul;
43 | }
44 |
45 | /* Initialize the cif */
46 | CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 13,
47 | &ffi_type_float, args) == FFI_OK);
48 |
49 | ff = fastcall_many(fa[0], fa[1],
50 | fa[2], fa[3],
51 | fa[4], fa[5],
52 | fa[6], fa[7],
53 | fa[8], fa[9],
54 | fa[10], fa[11], fa[12]);
55 |
56 | ffi_call(&cif, FFI_FN(fastcall_many), &f, values);
57 |
58 | if (f - ff < FLT_EPSILON)
59 | printf("fastcall many arg tests ok!\n");
60 | else
61 | CHECK(0);
62 | exit(0);
63 | }
64 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/many_win32.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check stdcall many call on X86_WIN32 systems.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8 |
9 | #include "ffitest.h"
10 | #include
11 |
12 | static float __attribute__((stdcall)) stdcall_many(float f1,
13 | float f2,
14 | float f3,
15 | float f4,
16 | float f5,
17 | float f6,
18 | float f7,
19 | float f8,
20 | float f9,
21 | float f10,
22 | float f11,
23 | float f12,
24 | float f13)
25 | {
26 | return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13);
27 | }
28 |
29 | int main (void)
30 | {
31 | ffi_cif cif;
32 | ffi_type *args[13];
33 | void *values[13];
34 | float fa[13];
35 | float f, ff;
36 | unsigned long ul;
37 |
38 | for (ul = 0; ul < 13; ul++)
39 | {
40 | args[ul] = &ffi_type_float;
41 | values[ul] = &fa[ul];
42 | fa[ul] = (float) ul;
43 | }
44 |
45 | /* Initialize the cif */
46 | CHECK(ffi_prep_cif(&cif, FFI_STDCALL, 13,
47 | &ffi_type_float, args) == FFI_OK);
48 |
49 | ff = stdcall_many(fa[0], fa[1],
50 | fa[2], fa[3],
51 | fa[4], fa[5],
52 | fa[6], fa[7],
53 | fa[8], fa[9],
54 | fa[10], fa[11], fa[12]);
55 |
56 | ffi_call(&cif, FFI_FN(stdcall_many), &f, values);
57 |
58 | if (f - ff < FLT_EPSILON)
59 | printf("stdcall many arg tests ok!\n");
60 | else
61 | CHECK(0);
62 | exit(0);
63 | }
64 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/negint.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check that negative integers are passed correctly.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 |
9 | #include "ffitest.h"
10 |
11 | static int checking(int a, short b, signed char c)
12 | {
13 |
14 | return (a < 0 && b < 0 && c < 0);
15 | }
16 |
17 | int main (void)
18 | {
19 | ffi_cif cif;
20 | ffi_type *args[MAX_ARGS];
21 | void *values[MAX_ARGS];
22 | ffi_arg rint;
23 |
24 | signed int si;
25 | signed short ss;
26 | signed char sc;
27 |
28 | args[0] = &ffi_type_sint;
29 | values[0] = &si;
30 | args[1] = &ffi_type_sshort;
31 | values[1] = &ss;
32 | args[2] = &ffi_type_schar;
33 | values[2] = ≻
34 |
35 | /* Initialize the cif */
36 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
37 | &ffi_type_sint, args) == FFI_OK);
38 |
39 | si = -6;
40 | ss = -12;
41 | sc = -1;
42 |
43 | checking (si, ss, sc);
44 |
45 | ffi_call(&cif, FFI_FN(checking), &rint, values);
46 |
47 | printf ("%d vs %d\n", (int)rint, checking (si, ss, sc));
48 |
49 | CHECK(rint != 0);
50 |
51 | exit (0);
52 | }
53 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/promotion.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Promotion test.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 | static int promotion(signed char sc, signed short ss,
10 | unsigned char uc, unsigned short us)
11 | {
12 | int r = (int) sc + (int) ss + (int) uc + (int) us;
13 |
14 | return r;
15 | }
16 |
17 | int main (void)
18 | {
19 | ffi_cif cif;
20 | ffi_type *args[MAX_ARGS];
21 | void *values[MAX_ARGS];
22 | ffi_arg rint;
23 | signed char sc;
24 | unsigned char uc;
25 | signed short ss;
26 | unsigned short us;
27 | unsigned long ul;
28 |
29 | args[0] = &ffi_type_schar;
30 | args[1] = &ffi_type_sshort;
31 | args[2] = &ffi_type_uchar;
32 | args[3] = &ffi_type_ushort;
33 | values[0] = ≻
34 | values[1] = &ss;
35 | values[2] = &uc;
36 | values[3] = &us;
37 |
38 | /* Initialize the cif */
39 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
40 | &ffi_type_sint, args) == FFI_OK);
41 |
42 | us = 0;
43 | ul = 0;
44 |
45 | for (sc = (signed char) -127;
46 | sc <= (signed char) 120; sc += 1)
47 | for (ss = -30000; ss <= 30000; ss += 10000)
48 | for (uc = (unsigned char) 0;
49 | uc <= (unsigned char) 200; uc += 20)
50 | for (us = 0; us <= 60000; us += 10000)
51 | {
52 | ul++;
53 | ffi_call(&cif, FFI_FN(promotion), &rint, values);
54 | CHECK((int)rint == (signed char) sc + (signed short) ss +
55 | (unsigned char) uc + (unsigned short) us);
56 | }
57 | printf("%lu promotion tests run\n", ul);
58 | exit(0);
59 | }
60 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_dbl.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value double.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20050212 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static double return_dbl(double dbl)
11 | {
12 | printf ("%f\n", dbl);
13 | return 2 * dbl;
14 | }
15 | int main (void)
16 | {
17 | ffi_cif cif;
18 | ffi_type *args[MAX_ARGS];
19 | void *values[MAX_ARGS];
20 | double dbl, rdbl;
21 |
22 | args[0] = &ffi_type_double;
23 | values[0] = &dbl;
24 |
25 | /* Initialize the cif */
26 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
27 | &ffi_type_double, args) == FFI_OK);
28 |
29 | for (dbl = -127.3; dbl < 127; dbl++)
30 | {
31 | ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values);
32 | printf ("%f vs %f\n", rdbl, return_dbl(dbl));
33 | CHECK(rdbl == 2 * dbl);
34 | }
35 | exit(0);
36 | }
37 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_dbl1.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value double.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20050212 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static double return_dbl(double dbl1, float fl2, unsigned int in3, double dbl4)
11 | {
12 | return dbl1 + fl2 + in3 + dbl4;
13 | }
14 | int main (void)
15 | {
16 | ffi_cif cif;
17 | ffi_type *args[MAX_ARGS];
18 | void *values[MAX_ARGS];
19 | double dbl1, dbl4, rdbl;
20 | float fl2;
21 | unsigned int in3;
22 | args[0] = &ffi_type_double;
23 | args[1] = &ffi_type_float;
24 | args[2] = &ffi_type_uint;
25 | args[3] = &ffi_type_double;
26 | values[0] = &dbl1;
27 | values[1] = &fl2;
28 | values[2] = &in3;
29 | values[3] = &dbl4;
30 |
31 | /* Initialize the cif */
32 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
33 | &ffi_type_double, args) == FFI_OK);
34 | dbl1 = 127.0;
35 | fl2 = 128.0;
36 | in3 = 255;
37 | dbl4 = 512.7;
38 |
39 | ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values);
40 | printf ("%f vs %f\n", rdbl, return_dbl(dbl1, fl2, in3, dbl4));
41 | CHECK(rdbl == dbl1 + fl2 + in3 + dbl4);
42 | exit(0);
43 | }
44 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_dbl2.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value double.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20050212 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static double return_dbl(double dbl1, double dbl2, unsigned int in3, double dbl4)
11 | {
12 | return dbl1 + dbl2 + in3 + dbl4;
13 | }
14 | int main (void)
15 | {
16 | ffi_cif cif;
17 | ffi_type *args[MAX_ARGS];
18 | void *values[MAX_ARGS];
19 | double dbl1, dbl2, dbl4, rdbl;
20 | unsigned int in3;
21 | args[0] = &ffi_type_double;
22 | args[1] = &ffi_type_double;
23 | args[2] = &ffi_type_uint;
24 | args[3] = &ffi_type_double;
25 | values[0] = &dbl1;
26 | values[1] = &dbl2;
27 | values[2] = &in3;
28 | values[3] = &dbl4;
29 |
30 | /* Initialize the cif */
31 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
32 | &ffi_type_double, args) == FFI_OK);
33 | dbl1 = 127.0;
34 | dbl2 = 128.0;
35 | in3 = 255;
36 | dbl4 = 512.7;
37 |
38 | ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values);
39 | printf ("%f vs %f\n", rdbl, return_dbl(dbl1, dbl2, in3, dbl4));
40 | CHECK(rdbl == dbl1 + dbl2 + in3 + dbl4);
41 | exit(0);
42 | }
43 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_fl.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value float.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20050212 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static float return_fl(float fl)
11 | {
12 | return 2 * fl;
13 | }
14 | int main (void)
15 | {
16 | ffi_cif cif;
17 | ffi_type *args[MAX_ARGS];
18 | void *values[MAX_ARGS];
19 | float fl, rfl;
20 |
21 | args[0] = &ffi_type_float;
22 | values[0] = &fl;
23 |
24 | /* Initialize the cif */
25 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
26 | &ffi_type_float, args) == FFI_OK);
27 |
28 | for (fl = -127.0; fl < 127; fl++)
29 | {
30 | ffi_call(&cif, FFI_FN(return_fl), &rfl, values);
31 | printf ("%f vs %f\n", rfl, return_fl(fl));
32 | CHECK(rfl == 2 * fl);
33 | }
34 | exit(0);
35 | }
36 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_fl1.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value float.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20050212 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static float return_fl(float fl1, float fl2)
11 | {
12 | return fl1 + fl2;
13 | }
14 | int main (void)
15 | {
16 | ffi_cif cif;
17 | ffi_type *args[MAX_ARGS];
18 | void *values[MAX_ARGS];
19 | float fl1, fl2, rfl;
20 |
21 | args[0] = &ffi_type_float;
22 | args[1] = &ffi_type_float;
23 | values[0] = &fl1;
24 | values[1] = &fl2;
25 |
26 | /* Initialize the cif */
27 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
28 | &ffi_type_float, args) == FFI_OK);
29 | fl1 = 127.0;
30 | fl2 = 128.0;
31 |
32 | ffi_call(&cif, FFI_FN(return_fl), &rfl, values);
33 | printf ("%f vs %f\n", rfl, return_fl(fl1, fl2));
34 | CHECK(rfl == fl1 + fl2);
35 | exit(0);
36 | }
37 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_fl2.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value float.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20050212 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | /* Use volatile float to avoid false negative on ix86. See PR target/323. */
11 | static float return_fl(float fl1, float fl2, float fl3, float fl4)
12 | {
13 | volatile float sum;
14 |
15 | sum = fl1 + fl2 + fl3 + fl4;
16 | return sum;
17 | }
18 | int main (void)
19 | {
20 | ffi_cif cif;
21 | ffi_type *args[MAX_ARGS];
22 | void *values[MAX_ARGS];
23 | float fl1, fl2, fl3, fl4, rfl;
24 | volatile float sum;
25 |
26 | args[0] = &ffi_type_float;
27 | args[1] = &ffi_type_float;
28 | args[2] = &ffi_type_float;
29 | args[3] = &ffi_type_float;
30 | values[0] = &fl1;
31 | values[1] = &fl2;
32 | values[2] = &fl3;
33 | values[3] = &fl4;
34 |
35 | /* Initialize the cif */
36 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
37 | &ffi_type_float, args) == FFI_OK);
38 | fl1 = 127.0;
39 | fl2 = 128.0;
40 | fl3 = 255.1;
41 | fl4 = 512.7;
42 |
43 | ffi_call(&cif, FFI_FN(return_fl), &rfl, values);
44 | printf ("%f vs %f\n", rfl, return_fl(fl1, fl2, fl3, fl4));
45 |
46 | sum = fl1 + fl2 + fl3 + fl4;
47 | CHECK(rfl == sum);
48 | exit(0);
49 | }
50 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_fl3.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value float.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20050212 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static float return_fl(float fl1, float fl2, unsigned int in3, float fl4)
11 | {
12 | return fl1 + fl2 + in3 + fl4;
13 | }
14 | int main (void)
15 | {
16 | ffi_cif cif;
17 | ffi_type *args[MAX_ARGS];
18 | void *values[MAX_ARGS];
19 | float fl1, fl2, fl4, rfl;
20 | unsigned int in3;
21 | args[0] = &ffi_type_float;
22 | args[1] = &ffi_type_float;
23 | args[2] = &ffi_type_uint;
24 | args[3] = &ffi_type_float;
25 | values[0] = &fl1;
26 | values[1] = &fl2;
27 | values[2] = &in3;
28 | values[3] = &fl4;
29 |
30 | /* Initialize the cif */
31 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
32 | &ffi_type_float, args) == FFI_OK);
33 | fl1 = 127.0;
34 | fl2 = 128.0;
35 | in3 = 255;
36 | fl4 = 512.7;
37 |
38 | ffi_call(&cif, FFI_FN(return_fl), &rfl, values);
39 | printf ("%f vs %f\n", rfl, return_fl(fl1, fl2, in3, fl4));
40 | CHECK(rfl == fl1 + fl2 + in3 + fl4);
41 | exit(0);
42 | }
43 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_ldl.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value long double.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20071113 */
6 |
7 | /* { dg-do run { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
8 | #include "ffitest.h"
9 |
10 | static long double return_ldl(long double ldl)
11 | {
12 | return 2*ldl;
13 | }
14 | int main (void)
15 | {
16 | ffi_cif cif;
17 | ffi_type *args[MAX_ARGS];
18 | void *values[MAX_ARGS];
19 | long double ldl, rldl;
20 |
21 | args[0] = &ffi_type_longdouble;
22 | values[0] = &ldl;
23 |
24 | /* Initialize the cif */
25 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
26 | &ffi_type_longdouble, args) == FFI_OK);
27 |
28 | for (ldl = -127.0; ldl < 127.0; ldl++)
29 | {
30 | ffi_call(&cif, FFI_FN(return_ldl), &rldl, values);
31 | CHECK(rldl == 2 * ldl);
32 | }
33 | exit(0);
34 | }
35 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_ll.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value long long.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 | static long long return_ll(long long ll)
10 | {
11 | return ll;
12 | }
13 |
14 | int main (void)
15 | {
16 | ffi_cif cif;
17 | ffi_type *args[MAX_ARGS];
18 | void *values[MAX_ARGS];
19 | long long rlonglong;
20 | long long ll;
21 |
22 | args[0] = &ffi_type_sint64;
23 | values[0] = ≪
24 |
25 | /* Initialize the cif */
26 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
27 | &ffi_type_sint64, args) == FFI_OK);
28 |
29 | for (ll = 0LL; ll < 100LL; ll++)
30 | {
31 | ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values);
32 | CHECK(rlonglong == ll);
33 | }
34 |
35 | for (ll = 55555555555000LL; ll < 55555555555100LL; ll++)
36 | {
37 | ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values);
38 | CHECK(rlonglong == ll);
39 | }
40 | exit(0);
41 | }
42 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_ll1.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check if long long are passed in the corresponding regs on ppc.
3 | Limitations: none.
4 | PR: 20104.
5 | Originator: 20050222 */
6 |
7 | /* { dg-do run } */
8 | /* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */
9 | #include "ffitest.h"
10 | static long long return_ll(int ll0, long long ll1, int ll2)
11 | {
12 | return ll0 + ll1 + ll2;
13 | }
14 |
15 | int main (void)
16 | {
17 | ffi_cif cif;
18 | ffi_type *args[MAX_ARGS];
19 | void *values[MAX_ARGS];
20 | long long rlonglong;
21 | long long ll1;
22 | unsigned ll0, ll2;
23 |
24 | args[0] = &ffi_type_sint;
25 | args[1] = &ffi_type_sint64;
26 | args[2] = &ffi_type_sint;
27 | values[0] = &ll0;
28 | values[1] = &ll1;
29 | values[2] = &ll2;
30 |
31 | /* Initialize the cif */
32 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
33 | &ffi_type_sint64, args) == FFI_OK);
34 |
35 | ll0 = 11111111;
36 | ll1 = 11111111111000LL;
37 | ll2 = 11111111;
38 |
39 | ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values);
40 | printf("res: %" PRIdLL ", %" PRIdLL "\n", rlonglong, ll0 + ll1 + ll2);
41 | /* { dg-output "res: 11111133333222, 11111133333222" } */
42 | exit(0);
43 | }
44 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_sc.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value signed char.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static signed char return_sc(signed char sc)
11 | {
12 | return sc;
13 | }
14 | int main (void)
15 | {
16 | ffi_cif cif;
17 | ffi_type *args[MAX_ARGS];
18 | void *values[MAX_ARGS];
19 | ffi_arg rint;
20 | signed char sc;
21 |
22 | args[0] = &ffi_type_schar;
23 | values[0] = ≻
24 |
25 | /* Initialize the cif */
26 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
27 | &ffi_type_schar, args) == FFI_OK);
28 |
29 | for (sc = (signed char) -127;
30 | sc < (signed char) 127; sc++)
31 | {
32 | ffi_call(&cif, FFI_FN(return_sc), &rint, values);
33 | CHECK((signed char)rint == sc);
34 | }
35 | exit(0);
36 | }
37 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_sl.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check if long as return type is handled correctly.
3 | Limitations: none.
4 | PR: none.
5 | */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 | static long return_sl(long l1, long l2)
10 | {
11 | return l1 - l2;
12 | }
13 |
14 | int main (void)
15 | {
16 | ffi_cif cif;
17 | ffi_type *args[MAX_ARGS];
18 | void *values[MAX_ARGS];
19 | ffi_arg res;
20 | unsigned long l1, l2;
21 |
22 | args[0] = &ffi_type_slong;
23 | args[1] = &ffi_type_slong;
24 | values[0] = &l1;
25 | values[1] = &l2;
26 |
27 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
28 | &ffi_type_slong, args) == FFI_OK);
29 |
30 | l1 = 1073741823L;
31 | l2 = 1073741824L;
32 |
33 | ffi_call(&cif, FFI_FN(return_sl), &res, values);
34 | printf("res: %ld, %ld\n", (long)res, l1 - l2);
35 | /* { dg-output "res: -1, -1" } */
36 |
37 | exit(0);
38 | }
39 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_uc.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check return value unsigned char.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static unsigned char return_uc(unsigned char uc)
11 | {
12 | return uc;
13 | }
14 |
15 | int main (void)
16 | {
17 | ffi_cif cif;
18 | ffi_type *args[MAX_ARGS];
19 | void *values[MAX_ARGS];
20 | ffi_arg rint;
21 |
22 | unsigned char uc;
23 |
24 | args[0] = &ffi_type_uchar;
25 | values[0] = &uc;
26 |
27 | /* Initialize the cif */
28 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
29 | &ffi_type_uchar, args) == FFI_OK);
30 |
31 | for (uc = (unsigned char) '\x00';
32 | uc < (unsigned char) '\xff'; uc++)
33 | {
34 | ffi_call(&cif, FFI_FN(return_uc), &rint, values);
35 | CHECK((unsigned char)rint == uc);
36 | }
37 | exit(0);
38 | }
39 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/return_ul.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check if unsigned long as return type is handled correctly.
3 | Limitations: none.
4 | PR: none.
5 | Originator: 20060724 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 | static unsigned long return_ul(unsigned long ul1, unsigned long ul2)
10 | {
11 | return ul1 + ul2;
12 | }
13 |
14 | int main (void)
15 | {
16 | ffi_cif cif;
17 | ffi_type *args[MAX_ARGS];
18 | void *values[MAX_ARGS];
19 | ffi_arg res;
20 | unsigned long ul1, ul2;
21 |
22 | args[0] = &ffi_type_ulong;
23 | args[1] = &ffi_type_ulong;
24 | values[0] = &ul1;
25 | values[1] = &ul2;
26 |
27 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
28 | &ffi_type_ulong, args) == FFI_OK);
29 |
30 | ul1 = 1073741823L;
31 | ul2 = 1073741824L;
32 |
33 | ffi_call(&cif, FFI_FN(return_ul), &res, values);
34 | printf("res: %lu, %lu\n", (unsigned long)res, ul1 + ul2);
35 | /* { dg-output "res: 2147483647, 2147483647" } */
36 |
37 | exit(0);
38 | }
39 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/strlen.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check strlen function call.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | static size_t my_strlen(char *s)
11 | {
12 | return (strlen(s));
13 | }
14 |
15 | int main (void)
16 | {
17 | ffi_cif cif;
18 | ffi_type *args[MAX_ARGS];
19 | void *values[MAX_ARGS];
20 | ffi_arg rint;
21 | char *s;
22 |
23 | args[0] = &ffi_type_pointer;
24 | values[0] = (void*) &s;
25 |
26 | /* Initialize the cif */
27 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
28 | &ffi_type_sint, args) == FFI_OK);
29 |
30 | s = "a";
31 | ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
32 | CHECK(rint == 1);
33 |
34 | s = "1234567";
35 | ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
36 | CHECK(rint == 7);
37 |
38 | s = "1234567890123456789012345";
39 | ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
40 | CHECK(rint == 25);
41 |
42 | exit (0);
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/strlen2_win32.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check fastcall strlen call on X86_WIN32 systems.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8 |
9 | #include "ffitest.h"
10 |
11 | static size_t __FASTCALL__ my_fastcall_strlen(char *s)
12 | {
13 | return (strlen(s));
14 | }
15 |
16 | int main (void)
17 | {
18 | ffi_cif cif;
19 | ffi_type *args[MAX_ARGS];
20 | void *values[MAX_ARGS];
21 | ffi_arg rint;
22 | char *s;
23 | args[0] = &ffi_type_pointer;
24 | values[0] = (void*) &s;
25 |
26 | /* Initialize the cif */
27 | CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1,
28 | &ffi_type_sint, args) == FFI_OK);
29 |
30 | s = "a";
31 | ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
32 | CHECK(rint == 1);
33 |
34 | s = "1234567";
35 | ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
36 | CHECK(rint == 7);
37 |
38 | s = "1234567890123456789012345";
39 | ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
40 | CHECK(rint == 25);
41 |
42 | printf("fastcall strlen tests passed\n");
43 | exit(0);
44 | }
45 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/strlen_win32.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check stdcall strlen call on X86_WIN32 systems.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8 |
9 | #include "ffitest.h"
10 |
11 | static size_t __attribute__((stdcall)) my_stdcall_strlen(char *s)
12 | {
13 | return (strlen(s));
14 | }
15 |
16 | int main (void)
17 | {
18 | ffi_cif cif;
19 | ffi_type *args[MAX_ARGS];
20 | void *values[MAX_ARGS];
21 | ffi_arg rint;
22 | char *s;
23 | args[0] = &ffi_type_pointer;
24 | values[0] = (void*) &s;
25 |
26 | /* Initialize the cif */
27 | CHECK(ffi_prep_cif(&cif, FFI_STDCALL, 1,
28 | &ffi_type_sint, args) == FFI_OK);
29 |
30 | s = "a";
31 | ffi_call(&cif, FFI_FN(my_stdcall_strlen), &rint, values);
32 | CHECK(rint == 1);
33 |
34 | s = "1234567";
35 | ffi_call(&cif, FFI_FN(my_stdcall_strlen), &rint, values);
36 | CHECK(rint == 7);
37 |
38 | s = "1234567890123456789012345";
39 | ffi_call(&cif, FFI_FN(my_stdcall_strlen), &rint, values);
40 | CHECK(rint == 25);
41 |
42 | printf("stdcall strlen tests passed\n");
43 | exit(0);
44 | }
45 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/struct1.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check structures.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | typedef struct
11 | {
12 | unsigned char uc;
13 | double d;
14 | unsigned int ui;
15 | } test_structure_1;
16 |
17 | static test_structure_1 struct1(test_structure_1 ts)
18 | {
19 | ts.uc++;
20 | ts.d--;
21 | ts.ui++;
22 |
23 | return ts;
24 | }
25 |
26 | int main (void)
27 | {
28 | ffi_cif cif;
29 | ffi_type *args[MAX_ARGS];
30 | void *values[MAX_ARGS];
31 | ffi_type ts1_type;
32 | ffi_type *ts1_type_elements[4];
33 |
34 | test_structure_1 ts1_arg;
35 |
36 | /* This is a hack to get a properly aligned result buffer */
37 | test_structure_1 *ts1_result =
38 | (test_structure_1 *) malloc (sizeof(test_structure_1));
39 |
40 | ts1_type.size = 0;
41 | ts1_type.alignment = 0;
42 | ts1_type.type = FFI_TYPE_STRUCT;
43 | ts1_type.elements = ts1_type_elements;
44 | ts1_type_elements[0] = &ffi_type_uchar;
45 | ts1_type_elements[1] = &ffi_type_double;
46 | ts1_type_elements[2] = &ffi_type_uint;
47 | ts1_type_elements[3] = NULL;
48 |
49 | args[0] = &ts1_type;
50 | values[0] = &ts1_arg;
51 |
52 | /* Initialize the cif */
53 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
54 | &ts1_type, args) == FFI_OK);
55 |
56 | ts1_arg.uc = '\x01';
57 | ts1_arg.d = 3.14159;
58 | ts1_arg.ui = 555;
59 |
60 | ffi_call(&cif, FFI_FN(struct1), ts1_result, values);
61 |
62 | CHECK(ts1_result->ui == 556);
63 | CHECK(ts1_result->d == 3.14159 - 1);
64 |
65 | free (ts1_result);
66 | exit(0);
67 | }
68 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/struct1_win32.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check structures with fastcall/thiscall convention.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8 | #include "ffitest.h"
9 |
10 | typedef struct
11 | {
12 | unsigned char uc;
13 | double d;
14 | unsigned int ui;
15 | } test_structure_1;
16 |
17 | static test_structure_1 __FASTCALL__ struct1(test_structure_1 ts)
18 | {
19 | ts.uc++;
20 | ts.d--;
21 | ts.ui++;
22 |
23 | return ts;
24 | }
25 |
26 | int main (void)
27 | {
28 | ffi_cif cif;
29 | ffi_type *args[MAX_ARGS];
30 | void *values[MAX_ARGS];
31 | ffi_type ts1_type;
32 | ffi_type *ts1_type_elements[4];
33 |
34 | test_structure_1 ts1_arg;
35 |
36 | /* This is a hack to get a properly aligned result buffer */
37 | test_structure_1 *ts1_result =
38 | (test_structure_1 *) malloc (sizeof(test_structure_1));
39 |
40 | ts1_type.size = 0;
41 | ts1_type.alignment = 0;
42 | ts1_type.type = FFI_TYPE_STRUCT;
43 | ts1_type.elements = ts1_type_elements;
44 | ts1_type_elements[0] = &ffi_type_uchar;
45 | ts1_type_elements[1] = &ffi_type_double;
46 | ts1_type_elements[2] = &ffi_type_uint;
47 | ts1_type_elements[3] = NULL;
48 |
49 | args[0] = &ts1_type;
50 | values[0] = &ts1_arg;
51 |
52 | /* Initialize the cif */
53 | CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1,
54 | &ts1_type, args) == FFI_OK);
55 |
56 | ts1_arg.uc = '\x01';
57 | ts1_arg.d = 3.14159;
58 | ts1_arg.ui = 555;
59 |
60 | ffi_call(&cif, FFI_FN(struct1), ts1_result, values);
61 |
62 | CHECK(ts1_result->ui == 556);
63 | CHECK(ts1_result->d == 3.14159 - 1);
64 |
65 | free (ts1_result);
66 | exit(0);
67 | }
68 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/struct2.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check structures.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | typedef struct
11 | {
12 | double d1;
13 | double d2;
14 | } test_structure_2;
15 |
16 | static test_structure_2 struct2(test_structure_2 ts)
17 | {
18 | ts.d1--;
19 | ts.d2--;
20 |
21 | return ts;
22 | }
23 |
24 | int main (void)
25 | {
26 | ffi_cif cif;
27 | ffi_type *args[MAX_ARGS];
28 | void *values[MAX_ARGS];
29 | test_structure_2 ts2_arg;
30 | ffi_type ts2_type;
31 | ffi_type *ts2_type_elements[3];
32 |
33 | /* This is a hack to get a properly aligned result buffer */
34 | test_structure_2 *ts2_result =
35 | (test_structure_2 *) malloc (sizeof(test_structure_2));
36 |
37 | ts2_type.size = 0;
38 | ts2_type.alignment = 0;
39 | ts2_type.type = FFI_TYPE_STRUCT;
40 | ts2_type.elements = ts2_type_elements;
41 | ts2_type_elements[0] = &ffi_type_double;
42 | ts2_type_elements[1] = &ffi_type_double;
43 | ts2_type_elements[2] = NULL;
44 |
45 | args[0] = &ts2_type;
46 | values[0] = &ts2_arg;
47 |
48 | /* Initialize the cif */
49 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts2_type, args) == FFI_OK);
50 |
51 | ts2_arg.d1 = 5.55;
52 | ts2_arg.d2 = 6.66;
53 |
54 | printf ("%g\n", ts2_arg.d1);
55 | printf ("%g\n", ts2_arg.d2);
56 |
57 | ffi_call(&cif, FFI_FN(struct2), ts2_result, values);
58 |
59 | printf ("%g\n", ts2_result->d1);
60 | printf ("%g\n", ts2_result->d2);
61 |
62 | CHECK(ts2_result->d1 == 5.55 - 1);
63 | CHECK(ts2_result->d2 == 6.66 - 1);
64 |
65 | free (ts2_result);
66 | exit(0);
67 | }
68 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/struct2_win32.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check structures in fastcall/stdcall function
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8 | #include "ffitest.h"
9 |
10 | typedef struct
11 | {
12 | double d1;
13 | double d2;
14 | } test_structure_2;
15 |
16 | static test_structure_2 __FASTCALL__ struct2(test_structure_2 ts)
17 | {
18 | ts.d1--;
19 | ts.d2--;
20 |
21 | return ts;
22 | }
23 |
24 | int main (void)
25 | {
26 | ffi_cif cif;
27 | ffi_type *args[MAX_ARGS];
28 | void *values[MAX_ARGS];
29 | test_structure_2 ts2_arg;
30 | ffi_type ts2_type;
31 | ffi_type *ts2_type_elements[3];
32 |
33 | /* This is a hack to get a properly aligned result buffer */
34 | test_structure_2 *ts2_result =
35 | (test_structure_2 *) malloc (sizeof(test_structure_2));
36 |
37 | ts2_type.size = 0;
38 | ts2_type.alignment = 0;
39 | ts2_type.type = FFI_TYPE_STRUCT;
40 | ts2_type.elements = ts2_type_elements;
41 | ts2_type_elements[0] = &ffi_type_double;
42 | ts2_type_elements[1] = &ffi_type_double;
43 | ts2_type_elements[2] = NULL;
44 |
45 | args[0] = &ts2_type;
46 | values[0] = &ts2_arg;
47 |
48 | /* Initialize the cif */
49 | CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1, &ts2_type, args) == FFI_OK);
50 |
51 | ts2_arg.d1 = 5.55;
52 | ts2_arg.d2 = 6.66;
53 |
54 | printf ("%g\n", ts2_arg.d1);
55 | printf ("%g\n", ts2_arg.d2);
56 |
57 | ffi_call(&cif, FFI_FN(struct2), ts2_result, values);
58 |
59 | printf ("%g\n", ts2_result->d1);
60 | printf ("%g\n", ts2_result->d2);
61 |
62 | CHECK(ts2_result->d1 == 5.55 - 1);
63 | CHECK(ts2_result->d2 == 6.66 - 1);
64 |
65 | free (ts2_result);
66 | exit(0);
67 | }
68 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/struct3.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check structures.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | typedef struct
11 | {
12 | int si;
13 | } test_structure_3;
14 |
15 | static test_structure_3 struct3(test_structure_3 ts)
16 | {
17 | ts.si = -(ts.si*2);
18 |
19 | return ts;
20 | }
21 |
22 | int main (void)
23 | {
24 | ffi_cif cif;
25 | ffi_type *args[MAX_ARGS];
26 | void *values[MAX_ARGS];
27 | int compare_value;
28 | ffi_type ts3_type;
29 | ffi_type *ts3_type_elements[2];
30 |
31 | test_structure_3 ts3_arg;
32 | test_structure_3 *ts3_result =
33 | (test_structure_3 *) malloc (sizeof(test_structure_3));
34 |
35 | ts3_type.size = 0;
36 | ts3_type.alignment = 0;
37 | ts3_type.type = FFI_TYPE_STRUCT;
38 | ts3_type.elements = ts3_type_elements;
39 | ts3_type_elements[0] = &ffi_type_sint;
40 | ts3_type_elements[1] = NULL;
41 |
42 | args[0] = &ts3_type;
43 | values[0] = &ts3_arg;
44 |
45 | /* Initialize the cif */
46 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
47 | &ts3_type, args) == FFI_OK);
48 |
49 | ts3_arg.si = -123;
50 | compare_value = ts3_arg.si;
51 |
52 | ffi_call(&cif, FFI_FN(struct3), ts3_result, values);
53 |
54 | printf ("%d %d\n", ts3_result->si, -(compare_value*2));
55 |
56 | CHECK(ts3_result->si == -(compare_value*2));
57 |
58 | free (ts3_result);
59 | exit(0);
60 | }
61 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/struct4.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check structures.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | typedef struct
11 | {
12 | unsigned ui1;
13 | unsigned ui2;
14 | unsigned ui3;
15 | } test_structure_4;
16 |
17 | static test_structure_4 struct4(test_structure_4 ts)
18 | {
19 | ts.ui3 = ts.ui1 * ts.ui2 * ts.ui3;
20 |
21 | return ts;
22 | }
23 |
24 | int main (void)
25 | {
26 | ffi_cif cif;
27 | ffi_type *args[MAX_ARGS];
28 | void *values[MAX_ARGS];
29 | ffi_type ts4_type;
30 | ffi_type *ts4_type_elements[4];
31 |
32 | test_structure_4 ts4_arg;
33 |
34 | /* This is a hack to get a properly aligned result buffer */
35 | test_structure_4 *ts4_result =
36 | (test_structure_4 *) malloc (sizeof(test_structure_4));
37 |
38 | ts4_type.size = 0;
39 | ts4_type.alignment = 0;
40 | ts4_type.type = FFI_TYPE_STRUCT;
41 | ts4_type.elements = ts4_type_elements;
42 | ts4_type_elements[0] = &ffi_type_uint;
43 | ts4_type_elements[1] = &ffi_type_uint;
44 | ts4_type_elements[2] = &ffi_type_uint;
45 | ts4_type_elements[3] = NULL;
46 |
47 | args[0] = &ts4_type;
48 | values[0] = &ts4_arg;
49 |
50 | /* Initialize the cif */
51 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts4_type, args) == FFI_OK);
52 |
53 | ts4_arg.ui1 = 2;
54 | ts4_arg.ui2 = 3;
55 | ts4_arg.ui3 = 4;
56 |
57 | ffi_call (&cif, FFI_FN(struct4), ts4_result, values);
58 |
59 | CHECK(ts4_result->ui3 == 2U * 3U * 4U);
60 |
61 |
62 | free (ts4_result);
63 | exit(0);
64 | }
65 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/struct5.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check structures.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 | typedef struct
10 | {
11 | char c1;
12 | char c2;
13 | } test_structure_5;
14 |
15 | static test_structure_5 struct5(test_structure_5 ts1, test_structure_5 ts2)
16 | {
17 | ts1.c1 += ts2.c1;
18 | ts1.c2 -= ts2.c2;
19 |
20 | return ts1;
21 | }
22 |
23 | int main (void)
24 | {
25 | ffi_cif cif;
26 | ffi_type *args[MAX_ARGS];
27 | void *values[MAX_ARGS];
28 | ffi_type ts5_type;
29 | ffi_type *ts5_type_elements[3];
30 |
31 | test_structure_5 ts5_arg1, ts5_arg2;
32 |
33 | /* This is a hack to get a properly aligned result buffer */
34 | test_structure_5 *ts5_result =
35 | (test_structure_5 *) malloc (sizeof(test_structure_5));
36 |
37 | ts5_type.size = 0;
38 | ts5_type.alignment = 0;
39 | ts5_type.type = FFI_TYPE_STRUCT;
40 | ts5_type.elements = ts5_type_elements;
41 | ts5_type_elements[0] = &ffi_type_schar;
42 | ts5_type_elements[1] = &ffi_type_schar;
43 | ts5_type_elements[2] = NULL;
44 |
45 | args[0] = &ts5_type;
46 | args[1] = &ts5_type;
47 | values[0] = &ts5_arg1;
48 | values[1] = &ts5_arg2;
49 |
50 | /* Initialize the cif */
51 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ts5_type, args) == FFI_OK);
52 |
53 | ts5_arg1.c1 = 2;
54 | ts5_arg1.c2 = 6;
55 | ts5_arg2.c1 = 5;
56 | ts5_arg2.c2 = 3;
57 |
58 | ffi_call (&cif, FFI_FN(struct5), ts5_result, values);
59 |
60 | CHECK(ts5_result->c1 == 7);
61 | CHECK(ts5_result->c2 == 3);
62 |
63 |
64 | free (ts5_result);
65 | exit(0);
66 | }
67 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/struct6.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check structures.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 | typedef struct
10 | {
11 | float f;
12 | double d;
13 | } test_structure_6;
14 |
15 | static test_structure_6 struct6 (test_structure_6 ts)
16 | {
17 | ts.f += 1;
18 | ts.d += 1;
19 |
20 | return ts;
21 | }
22 |
23 | int main (void)
24 | {
25 | ffi_cif cif;
26 | ffi_type *args[MAX_ARGS];
27 | void *values[MAX_ARGS];
28 | ffi_type ts6_type;
29 | ffi_type *ts6_type_elements[3];
30 |
31 | test_structure_6 ts6_arg;
32 |
33 | /* This is a hack to get a properly aligned result buffer */
34 | test_structure_6 *ts6_result =
35 | (test_structure_6 *) malloc (sizeof(test_structure_6));
36 |
37 | ts6_type.size = 0;
38 | ts6_type.alignment = 0;
39 | ts6_type.type = FFI_TYPE_STRUCT;
40 | ts6_type.elements = ts6_type_elements;
41 | ts6_type_elements[0] = &ffi_type_float;
42 | ts6_type_elements[1] = &ffi_type_double;
43 | ts6_type_elements[2] = NULL;
44 |
45 | args[0] = &ts6_type;
46 | values[0] = &ts6_arg;
47 |
48 | /* Initialize the cif */
49 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts6_type, args) == FFI_OK);
50 |
51 | ts6_arg.f = 5.55f;
52 | ts6_arg.d = 6.66;
53 |
54 | printf ("%g\n", ts6_arg.f);
55 | printf ("%g\n", ts6_arg.d);
56 |
57 | ffi_call(&cif, FFI_FN(struct6), ts6_result, values);
58 |
59 | CHECK(ts6_result->f == 5.55f + 1);
60 | CHECK(ts6_result->d == 6.66 + 1);
61 |
62 | free (ts6_result);
63 | exit(0);
64 | }
65 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/struct7.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check structures.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 | typedef struct
10 | {
11 | float f1;
12 | float f2;
13 | double d;
14 | } test_structure_7;
15 |
16 | static test_structure_7 struct7 (test_structure_7 ts)
17 | {
18 | ts.f1 += 1;
19 | ts.f2 += 1;
20 | ts.d += 1;
21 |
22 | return ts;
23 | }
24 |
25 | int main (void)
26 | {
27 | ffi_cif cif;
28 | ffi_type *args[MAX_ARGS];
29 | void *values[MAX_ARGS];
30 | ffi_type ts7_type;
31 | ffi_type *ts7_type_elements[4];
32 |
33 | test_structure_7 ts7_arg;
34 |
35 | /* This is a hack to get a properly aligned result buffer */
36 | test_structure_7 *ts7_result =
37 | (test_structure_7 *) malloc (sizeof(test_structure_7));
38 |
39 | ts7_type.size = 0;
40 | ts7_type.alignment = 0;
41 | ts7_type.type = FFI_TYPE_STRUCT;
42 | ts7_type.elements = ts7_type_elements;
43 | ts7_type_elements[0] = &ffi_type_float;
44 | ts7_type_elements[1] = &ffi_type_float;
45 | ts7_type_elements[2] = &ffi_type_double;
46 | ts7_type_elements[3] = NULL;
47 |
48 | args[0] = &ts7_type;
49 | values[0] = &ts7_arg;
50 |
51 | /* Initialize the cif */
52 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts7_type, args) == FFI_OK);
53 |
54 | ts7_arg.f1 = 5.55f;
55 | ts7_arg.f2 = 55.5f;
56 | ts7_arg.d = 6.66;
57 |
58 | printf ("%g\n", ts7_arg.f1);
59 | printf ("%g\n", ts7_arg.f2);
60 | printf ("%g\n", ts7_arg.d);
61 |
62 | ffi_call(&cif, FFI_FN(struct7), ts7_result, values);
63 |
64 | printf ("%g\n", ts7_result->f1);
65 | printf ("%g\n", ts7_result->f2);
66 | printf ("%g\n", ts7_result->d);
67 |
68 | CHECK(ts7_result->f1 == 5.55f + 1);
69 | CHECK(ts7_result->f2 == 55.5f + 1);
70 | CHECK(ts7_result->d == 6.66 + 1);
71 |
72 | free (ts7_result);
73 | exit(0);
74 | }
75 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/struct9.c:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call
2 | Purpose: Check structures.
3 | Limitations: none.
4 | PR: none.
5 | Originator: From the original ffitest.c */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | typedef struct
11 | {
12 | float f;
13 | int i;
14 | } test_structure_9;
15 |
16 | static test_structure_9 struct9 (test_structure_9 ts)
17 | {
18 | ts.f += 1;
19 | ts.i += 1;
20 |
21 | return ts;
22 | }
23 |
24 | int main (void)
25 | {
26 | ffi_cif cif;
27 | ffi_type *args[MAX_ARGS];
28 | void *values[MAX_ARGS];
29 | ffi_type ts9_type;
30 | ffi_type *ts9_type_elements[3];
31 |
32 | test_structure_9 ts9_arg;
33 |
34 | /* This is a hack to get a properly aligned result buffer */
35 | test_structure_9 *ts9_result =
36 | (test_structure_9 *) malloc (sizeof(test_structure_9));
37 |
38 | ts9_type.size = 0;
39 | ts9_type.alignment = 0;
40 | ts9_type.type = FFI_TYPE_STRUCT;
41 | ts9_type.elements = ts9_type_elements;
42 | ts9_type_elements[0] = &ffi_type_float;
43 | ts9_type_elements[1] = &ffi_type_sint;
44 | ts9_type_elements[2] = NULL;
45 |
46 | args[0] = &ts9_type;
47 | values[0] = &ts9_arg;
48 |
49 | /* Initialize the cif */
50 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts9_type, args) == FFI_OK);
51 |
52 | ts9_arg.f = 5.55f;
53 | ts9_arg.i = 5;
54 |
55 | printf ("%g\n", ts9_arg.f);
56 | printf ("%d\n", ts9_arg.i);
57 |
58 | ffi_call(&cif, FFI_FN(struct9), ts9_result, values);
59 |
60 | printf ("%g\n", ts9_result->f);
61 | printf ("%d\n", ts9_result->i);
62 |
63 | CHECK(ts9_result->f == 5.55f + 1);
64 | CHECK(ts9_result->i == 5 + 1);
65 |
66 | free (ts9_result);
67 | exit(0);
68 | }
69 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/testclosure.c:
--------------------------------------------------------------------------------
1 | /* Area: closure_call
2 | Purpose: Check return value float.
3 | Limitations: none.
4 | PR: 41908.
5 | Originator: 20091102 */
6 |
7 | /* { dg-do run } */
8 | #include "ffitest.h"
9 |
10 | typedef struct cls_struct_combined {
11 | float a;
12 | float b;
13 | float c;
14 | float d;
15 | } cls_struct_combined;
16 |
17 | void cls_struct_combined_fn(struct cls_struct_combined arg)
18 | {
19 | printf("%g %g %g %g\n",
20 | arg.a, arg.b,
21 | arg.c, arg.d);
22 | fflush(stdout);
23 | }
24 |
25 | static void
26 | cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
27 | void** args, void* userdata __UNUSED__)
28 | {
29 | struct cls_struct_combined a0;
30 |
31 | a0 = *(struct cls_struct_combined*)(args[0]);
32 |
33 | cls_struct_combined_fn(a0);
34 | }
35 |
36 |
37 | int main (void)
38 | {
39 | ffi_cif cif;
40 | void *code;
41 | ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
42 | ffi_type* cls_struct_fields0[5];
43 | ffi_type cls_struct_type0;
44 | ffi_type* dbl_arg_types[5];
45 |
46 | struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0};
47 |
48 | cls_struct_type0.size = 0;
49 | cls_struct_type0.alignment = 0;
50 | cls_struct_type0.type = FFI_TYPE_STRUCT;
51 | cls_struct_type0.elements = cls_struct_fields0;
52 |
53 | cls_struct_fields0[0] = &ffi_type_float;
54 | cls_struct_fields0[1] = &ffi_type_float;
55 | cls_struct_fields0[2] = &ffi_type_float;
56 | cls_struct_fields0[3] = &ffi_type_float;
57 | cls_struct_fields0[4] = NULL;
58 |
59 | dbl_arg_types[0] = &cls_struct_type0;
60 | dbl_arg_types[1] = NULL;
61 |
62 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_void,
63 | dbl_arg_types) == FFI_OK);
64 |
65 | CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK);
66 |
67 | ((void(*)(cls_struct_combined)) (code))(g_dbl);
68 | /* { dg-output "4 5 1 8" } */
69 | exit(0);
70 | }
71 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.call/uninitialized.c:
--------------------------------------------------------------------------------
1 | /* { dg-do run } */
2 | #include "ffitest.h"
3 |
4 | typedef struct
5 | {
6 | unsigned char uc;
7 | double d;
8 | unsigned int ui;
9 | } test_structure_1;
10 |
11 | static test_structure_1 struct1(test_structure_1 ts)
12 | {
13 | ts.uc++;
14 | ts.d--;
15 | ts.ui++;
16 |
17 | return ts;
18 | }
19 |
20 | int main (void)
21 | {
22 | ffi_cif cif;
23 | ffi_type *args[MAX_ARGS];
24 | void *values[MAX_ARGS];
25 | ffi_type ts1_type;
26 | ffi_type *ts1_type_elements[4];
27 |
28 | memset(&cif, 1, sizeof(cif));
29 | ts1_type.size = 0;
30 | ts1_type.alignment = 0;
31 | ts1_type.type = FFI_TYPE_STRUCT;
32 | ts1_type.elements = ts1_type_elements;
33 | ts1_type_elements[0] = &ffi_type_uchar;
34 | ts1_type_elements[1] = &ffi_type_double;
35 | ts1_type_elements[2] = &ffi_type_uint;
36 | ts1_type_elements[3] = NULL;
37 |
38 | test_structure_1 ts1_arg;
39 | /* This is a hack to get a properly aligned result buffer */
40 | test_structure_1 *ts1_result =
41 | (test_structure_1 *) malloc (sizeof(test_structure_1));
42 |
43 | args[0] = &ts1_type;
44 | values[0] = &ts1_arg;
45 |
46 | /* Initialize the cif */
47 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
48 | &ts1_type, args) == FFI_OK);
49 |
50 | ts1_arg.uc = '\x01';
51 | ts1_arg.d = 3.14159;
52 | ts1_arg.ui = 555;
53 |
54 | ffi_call(&cif, FFI_FN(struct1), ts1_result, values);
55 |
56 | CHECK(ts1_result->ui == 556);
57 | CHECK(ts1_result->d == 3.14159 - 1);
58 |
59 | free (ts1_result);
60 | exit(0);
61 | }
62 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.special/ffitestcxx.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include "fficonfig.h"
6 |
7 | #define MAX_ARGS 256
8 |
9 |
10 | /* Define __UNUSED__ that also other compilers than gcc can run the tests. */
11 | #undef __UNUSED__
12 | #if defined(__GNUC__)
13 | #define __UNUSED__ __attribute__((__unused__))
14 | #else
15 | #define __UNUSED__
16 | #endif
17 |
18 | #define CHECK(x) (!(x) ? abort() : (void)0)
19 |
20 | /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
21 | file open. */
22 | #ifdef HAVE_MMAP_ANON
23 | # undef HAVE_MMAP_DEV_ZERO
24 |
25 | # include
26 | # ifndef MAP_FAILED
27 | # define MAP_FAILED -1
28 | # endif
29 | # if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
30 | # define MAP_ANONYMOUS MAP_ANON
31 | # endif
32 | # define USING_MMAP
33 |
34 | #endif
35 |
36 | #ifdef HAVE_MMAP_DEV_ZERO
37 |
38 | # include
39 | # ifndef MAP_FAILED
40 | # define MAP_FAILED -1
41 | # endif
42 | # define USING_MMAP
43 |
44 | #endif
45 |
46 |
47 | /* MinGW kludge. */
48 | #ifdef _WIN64
49 | #define PRIdLL "I64d"
50 | #define PRIuLL "I64u"
51 | #else
52 | #define PRIdLL "lld"
53 | #define PRIuLL "llu"
54 | #endif
55 |
56 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.special/special.exp:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003, 2006, 2009, 2010 Free Software Foundation, Inc.
2 |
3 | # This program is free software; you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation; either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program; see the file COPYING3. If not see
15 | # .
16 |
17 | dg-init
18 | libffi-init
19 |
20 | global srcdir subdir
21 |
22 | global cxx_options
23 |
24 | set cxx_options " -shared-libgcc -lstdc++"
25 |
26 | if { [string match $using_gcc "yes"] } {
27 |
28 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O0 -W -Wall"
29 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O2"
30 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O3"
31 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-Os"
32 |
33 | }
34 |
35 | dg-finish
36 |
37 | # Local Variables:
38 | # tcl-indent-level:4
39 | # End:
40 |
--------------------------------------------------------------------------------
/libPython/Modules/_ctypes/libffi/testsuite/libffi.special/unwindtest_ffi_call.cc:
--------------------------------------------------------------------------------
1 | /* Area: ffi_call, unwind info
2 | Purpose: Check if the unwind information is passed correctly.
3 | Limitations: none.
4 | PR: none.
5 | Originator: Andreas Tobler 20061213 */
6 |
7 | /* { dg-do run } */
8 |
9 | #include "ffitestcxx.h"
10 |
11 | static int checking(int a __UNUSED__, short b __UNUSED__,
12 | signed char c __UNUSED__)
13 | {
14 | throw 9;
15 | }
16 |
17 | int main (void)
18 | {
19 | ffi_cif cif;
20 | ffi_type *args[MAX_ARGS];
21 | void *values[MAX_ARGS];
22 | ffi_arg rint;
23 |
24 | signed int si;
25 | signed short ss;
26 | signed char sc;
27 |
28 | args[0] = &ffi_type_sint;
29 | values[0] = &si;
30 | args[1] = &ffi_type_sshort;
31 | values[1] = &ss;
32 | args[2] = &ffi_type_schar;
33 | values[2] = ≻
34 |
35 | /* Initialize the cif */
36 | CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
37 | &ffi_type_sint, args) == FFI_OK);
38 |
39 | si = -6;
40 | ss = -12;
41 | sc = -1;
42 | {
43 | try
44 | {
45 | ffi_call(&cif, FFI_FN(checking), &rint, values);
46 | } catch (int exception_code)
47 | {
48 | CHECK(exception_code == 9);
49 | }
50 | printf("part one OK\n");
51 | /* { dg-output "part one OK" } */
52 | }
53 | exit(0);
54 | }
55 |
--------------------------------------------------------------------------------
/libPython/Modules/_heapqmodule.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancyzero/Python-iOS/b9cd21ddb9cfa977e46140062c6bf620b8e0205b/libPython/Modules/_heapqmodule.c
--------------------------------------------------------------------------------
/libPython/Modules/_math.h:
--------------------------------------------------------------------------------
1 | double _Py_acosh(double x);
2 | double _Py_asinh(double x);
3 | double _Py_atanh(double x);
4 | double _Py_expm1(double x);
5 | double _Py_log1p(double x);
6 |
7 | #ifdef HAVE_ACOSH
8 | #define m_acosh acosh
9 | #else
10 | /* if the system doesn't have acosh, use the substitute
11 | function defined in Modules/_math.c. */
12 | #define m_acosh _Py_acosh
13 | #endif
14 |
15 | #ifdef HAVE_ASINH
16 | #define m_asinh asinh
17 | #else
18 | /* if the system doesn't have asinh, use the substitute
19 | function defined in Modules/_math.c. */
20 | #define m_asinh _Py_asinh
21 | #endif
22 |
23 | #ifdef HAVE_ATANH
24 | #define m_atanh atanh
25 | #else
26 | /* if the system doesn't have atanh, use the substitute
27 | function defined in Modules/_math.c. */
28 | #define m_atanh _Py_atanh
29 | #endif
30 |
31 | #ifdef HAVE_EXPM1
32 | #define m_expm1 expm1
33 | #else
34 | /* if the system doesn't have expm1, use the substitute
35 | function defined in Modules/_math.c. */
36 | #define m_expm1 _Py_expm1
37 | #endif
38 |
39 | /* Use the substitute from _math.c on all platforms:
40 | it includes workarounds for buggy handling of zeros. */
41 | #define m_log1p _Py_log1p
42 |
--------------------------------------------------------------------------------
/libPython/Modules/cjkcodecs/alg_jisx0201.h:
--------------------------------------------------------------------------------
1 | #define JISX0201_R_ENCODE(c, assi) \
2 | if ((c) < 0x80 && (c) != 0x5c && (c) != 0x7e) \
3 | (assi) = (c); \
4 | else if ((c) == 0x00a5) (assi) = 0x5c; \
5 | else if ((c) == 0x203e) (assi) = 0x7e;
6 | #define JISX0201_K_ENCODE(c, assi) \
7 | if ((c) >= 0xff61 && (c) <= 0xff9f) \
8 | (assi) = (c) - 0xfec0;
9 | #define JISX0201_ENCODE(c, assi) \
10 | JISX0201_R_ENCODE(c, assi) \
11 | else JISX0201_K_ENCODE(c, assi)
12 |
13 | #define JISX0201_R_DECODE(c, assi) \
14 | if ((c) < 0x5c) (assi) = (c); \
15 | else if ((c) == 0x5c) (assi) = 0x00a5; \
16 | else if ((c) < 0x7e) (assi) = (c); \
17 | else if ((c) == 0x7e) (assi) = 0x203e; \
18 | else if ((c) == 0x7f) (assi) = 0x7f;
19 | #define JISX0201_K_DECODE(c, assi) \
20 | if ((c) >= 0xa1 && (c) <= 0xdf) \
21 | (assi) = 0xfec0 + (c);
22 | #define JISX0201_DECODE(c, assi) \
23 | JISX0201_R_DECODE(c, assi) \
24 | else JISX0201_K_DECODE(c, assi)
25 |
--------------------------------------------------------------------------------
/libPython/Modules/config.c.in:
--------------------------------------------------------------------------------
1 | /* -*- C -*- ***********************************************
2 | Copyright (c) 2000, BeOpen.com.
3 | Copyright (c) 1995-2000, Corporation for National Research Initiatives.
4 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
5 | All rights reserved.
6 |
7 | See the file "Misc/COPYRIGHT" for information on usage and
8 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9 | ******************************************************************/
10 |
11 | /* Module configuration */
12 |
13 | /* !!! !!! !!! This file is edited by the makesetup script !!! !!! !!! */
14 |
15 | /* This file contains the table of built-in modules.
16 | See init_builtin() in import.c. */
17 |
18 | #include "Python.h"
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 |
25 | /* -- ADDMODULE MARKER 1 -- */
26 |
27 | extern void PyMarshal_Init(void);
28 | extern void initimp(void);
29 | extern void initgc(void);
30 | extern void init_ast(void);
31 | extern void _PyWarnings_Init(void);
32 |
33 | struct _inittab _PyImport_Inittab[] = {
34 |
35 | /* -- ADDMODULE MARKER 2 -- */
36 |
37 | /* This module lives in marshal.c */
38 | {"marshal", PyMarshal_Init},
39 |
40 | /* This lives in import.c */
41 | {"imp", initimp},
42 |
43 | /* This lives in Python/Python-ast.c */
44 | {"_ast", init_ast},
45 |
46 | /* These entries are here for sys.builtin_module_names */
47 | {"__main__", NULL},
48 | {"__builtin__", NULL},
49 | {"sys", NULL},
50 | {"exceptions", NULL},
51 |
52 | /* This lives in gcmodule.c */
53 | {"gc", initgc},
54 |
55 | /* This lives in _warnings.c */
56 | {"_warnings", _PyWarnings_Init},
57 |
58 | /* Sentinel */
59 | {0, 0}
60 | };
61 |
62 |
63 | #ifdef __cplusplus
64 | }
65 | #endif
66 |
--------------------------------------------------------------------------------
/libPython/Modules/cryptmodule.c:
--------------------------------------------------------------------------------
1 | /* cryptmodule.c - by Steve Majewski
2 | */
3 |
4 | #include "Python.h"
5 |
6 | #include
7 |
8 | #ifdef __VMS
9 | #include
10 | #endif
11 |
12 | /* Module crypt */
13 |
14 |
15 | static PyObject *crypt_crypt(PyObject *self, PyObject *args)
16 | {
17 | char *word, *salt;
18 | #ifndef __VMS
19 | extern char * crypt(const char *, const char *);
20 | #endif
21 |
22 | if (!PyArg_ParseTuple(args, "ss:crypt", &word, &salt)) {
23 | return NULL;
24 | }
25 | /* On some platforms (AtheOS) crypt returns NULL for an invalid
26 | salt. Return None in that case. XXX Maybe raise an exception? */
27 | return Py_BuildValue("s", crypt(word, salt));
28 |
29 | }
30 |
31 | PyDoc_STRVAR(crypt_crypt__doc__,
32 | "crypt(word, salt) -> string\n\
33 | word will usually be a user's password. salt is a 2-character string\n\
34 | which will be used to select one of 4096 variations of DES. The characters\n\
35 | in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\
36 | the hashed password as a string, which will be composed of characters from\n\
37 | the same alphabet as the salt.");
38 |
39 |
40 | static PyMethodDef crypt_methods[] = {
41 | {"crypt", crypt_crypt, METH_VARARGS, crypt_crypt__doc__},
42 | {NULL, NULL} /* sentinel */
43 | };
44 |
45 | PyMODINIT_FUNC
46 | initcrypt(void)
47 | {
48 | Py_InitModule("crypt", crypt_methods);
49 | }
50 |
--------------------------------------------------------------------------------
/libPython/Modules/posixmodule.h:
--------------------------------------------------------------------------------
1 | /* Declarations shared between the different POSIX-related modules */
2 |
3 | #ifndef Py_POSIXMODULE_H
4 | #define Py_POSIXMODULE_H
5 | #ifdef __cplusplus
6 | extern "C" {
7 | #endif
8 |
9 | #ifdef HAVE_SYS_TYPES_H
10 | #include
11 | #endif
12 |
13 | #ifndef Py_LIMITED_API
14 | #ifndef MS_WINDOWS
15 | PyAPI_FUNC(PyObject *) _PyInt_FromUid(uid_t);
16 | PyAPI_FUNC(PyObject *) _PyInt_FromGid(gid_t);
17 | PyAPI_FUNC(int) _Py_Uid_Converter(PyObject *, void *);
18 | PyAPI_FUNC(int) _Py_Gid_Converter(PyObject *, void *);
19 | #endif /* MS_WINDOWS */
20 | #endif
21 |
22 | #ifdef __cplusplus
23 | }
24 | #endif
25 | #endif /* !Py_POSIXMODULE_H */
26 |
--------------------------------------------------------------------------------
/libPython/Modules/python.c:
--------------------------------------------------------------------------------
1 | /* Minimal main program -- everything is loaded from the library */
2 |
3 | #include "Python.h"
4 |
5 | #ifdef __FreeBSD__
6 | #include
7 | #endif
8 |
9 | int
10 | main(int argc, char **argv)
11 | {
12 | /* 754 requires that FP exceptions run in "no stop" mode by default,
13 | * and until C vendors implement C99's ways to control FP exceptions,
14 | * Python requires non-stop mode. Alas, some platforms enable FP
15 | * exceptions by default. Here we disable them.
16 | */
17 | #ifdef __FreeBSD__
18 | fp_except_t m;
19 |
20 | m = fpgetmask();
21 | fpsetmask(m & ~FP_X_OFL);
22 | #endif
23 | return Py_Main(argc, argv);
24 | }
25 |
--------------------------------------------------------------------------------
/libPython/Modules/rotatingtree.h:
--------------------------------------------------------------------------------
1 | /* "Rotating trees" (Armin Rigo)
2 | *
3 | * Google "splay trees" for the general idea.
4 | *
5 | * It's a dict-like data structure that works best when accesses are not
6 | * random, but follow a strong pattern. The one implemented here is for
7 | * access patterns where the same small set of keys is looked up over
8 | * and over again, and this set of keys evolves slowly over time.
9 | */
10 |
11 | #include
12 |
13 | #define EMPTY_ROTATING_TREE ((rotating_node_t *)NULL)
14 |
15 | typedef struct rotating_node_s rotating_node_t;
16 | typedef int (*rotating_tree_enum_fn) (rotating_node_t *node, void *arg);
17 |
18 | struct rotating_node_s {
19 | void *key;
20 | rotating_node_t *left;
21 | rotating_node_t *right;
22 | };
23 |
24 | void RotatingTree_Add(rotating_node_t **root, rotating_node_t *node);
25 | rotating_node_t* RotatingTree_Get(rotating_node_t **root, void *key);
26 | int RotatingTree_Enum(rotating_node_t *root, rotating_tree_enum_fn enumfn,
27 | void *arg);
28 |
--------------------------------------------------------------------------------
/libPython/Modules/sgimodule.c:
--------------------------------------------------------------------------------
1 |
2 | /* SGI module -- random SGI-specific things */
3 |
4 | #include "Python.h"
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | static PyObject *
11 | sgi_nap(PyObject *self, PyObject *args)
12 | {
13 | long ticks;
14 | if (!PyArg_ParseTuple(args, "l:nap", &ticks))
15 | return NULL;
16 | Py_BEGIN_ALLOW_THREADS
17 | sginap(ticks);
18 | Py_END_ALLOW_THREADS
19 | Py_INCREF(Py_None);
20 | return Py_None;
21 | }
22 |
23 | extern char *_getpty(int *, int, mode_t, int);
24 |
25 | static PyObject *
26 | sgi__getpty(PyObject *self, PyObject *args)
27 | {
28 | int oflag;
29 | int mode;
30 | int nofork;
31 | char *name;
32 | int fildes;
33 | if (!PyArg_ParseTuple(args, "iii:_getpty", &oflag, &mode, &nofork))
34 | return NULL;
35 | errno = 0;
36 | name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
37 | if (name == NULL) {
38 | PyErr_SetFromErrno(PyExc_IOError);
39 | return NULL;
40 | }
41 | return Py_BuildValue("(si)", name, fildes);
42 | }
43 |
44 | static PyMethodDef sgi_methods[] = {
45 | {"nap", sgi_nap, METH_VARARGS},
46 | {"_getpty", sgi__getpty, METH_VARARGS},
47 | {NULL, NULL} /* sentinel */
48 | };
49 |
50 |
51 | void
52 | initsgi(void)
53 | {
54 | Py_InitModule("sgi", sgi_methods);
55 | }
56 |
--------------------------------------------------------------------------------
/libPython/Modules/timingmodule.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Author: George V. Neville-Neil
3 | */
4 |
5 | #include "Python.h"
6 |
7 | /* Our stuff... */
8 | #include "timing.h"
9 |
10 | static PyObject *
11 | start_timing(PyObject *self)
12 | {
13 | Py_INCREF(Py_None);
14 | BEGINTIMING;
15 | return Py_None;
16 | }
17 |
18 | static PyObject *
19 | finish_timing(PyObject *self)
20 | {
21 | ENDTIMING
22 | Py_INCREF(Py_None);
23 | return Py_None;
24 | }
25 |
26 | static PyObject *
27 | seconds(PyObject *self)
28 | {
29 | return PyInt_FromLong(TIMINGS);
30 | }
31 |
32 | static PyObject *
33 | milli(PyObject *self)
34 | {
35 | return PyInt_FromLong(TIMINGMS);
36 | }
37 |
38 | static PyObject *
39 | micro(PyObject *self)
40 | {
41 | return PyInt_FromLong(TIMINGUS);
42 | }
43 |
44 |
45 | static PyMethodDef timing_methods[] = {
46 | {"start", (PyCFunction)start_timing, METH_NOARGS},
47 | {"finish", (PyCFunction)finish_timing, METH_NOARGS},
48 | {"seconds", (PyCFunction)seconds, METH_NOARGS},
49 | {"milli", (PyCFunction)milli, METH_NOARGS},
50 | {"micro", (PyCFunction)micro, METH_NOARGS},
51 | {NULL, NULL}
52 | };
53 |
54 |
55 | PyMODINIT_FUNC inittiming(void)
56 | {
57 | if (PyErr_WarnPy3k("the timing module has been removed in "
58 | "Python 3.0; use time.clock() instead", 2) < 0)
59 | return;
60 |
61 | (void)Py_InitModule("timing", timing_methods);
62 | }
63 |
--------------------------------------------------------------------------------
/libPython/Modules/tkinter.h:
--------------------------------------------------------------------------------
1 | #ifndef TKINTER_H
2 | #define TKINTER_H
3 |
4 | /* This header is used to share some macros between _tkinter.c and
5 | * tkappinit.c.
6 | * Be sure to include tk.h before including this header so
7 | * TK_VERSION_HEX is properly defined. */
8 |
9 | /* TK_RELEASE_LEVEL is always one of the following:
10 | * TCL_ALPHA_RELEASE 0
11 | * TCL_BETA_RELEASE 1
12 | * TCL_FINAL_RELEASE 2
13 | */
14 | #define TK_VERSION_HEX ((TK_MAJOR_VERSION << 24) | \
15 | (TK_MINOR_VERSION << 16) | \
16 | (TK_RELEASE_SERIAL << 8) | \
17 | (TK_RELEASE_LEVEL << 0))
18 |
19 | /* Protect Tk 8.4.13 and older from a deadlock that happens when trying
20 | * to load tk after a failed attempt. */
21 | #if TK_VERSION_HEX < 0x08040e02
22 | #define TKINTER_PROTECT_LOADTK
23 | #define TKINTER_LOADTK_ERRMSG \
24 | "Calling Tk_Init again after a previous call failed might deadlock"
25 | #endif
26 |
27 | #endif /* !TKINTER_H */
28 |
--------------------------------------------------------------------------------
/libPython/Modules/unicodedata.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancyzero/Python-iOS/b9cd21ddb9cfa977e46140062c6bf620b8e0205b/libPython/Modules/unicodedata.c
--------------------------------------------------------------------------------
/libPython/Modules/zlib/ChangeLog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancyzero/Python-iOS/b9cd21ddb9cfa977e46140062c6bf620b8e0205b/libPython/Modules/zlib/ChangeLog
--------------------------------------------------------------------------------
/libPython/Modules/zlib/INDEX:
--------------------------------------------------------------------------------
1 | ChangeLog history of changes
2 | FAQ Frequently Asked Questions about zlib
3 | INDEX this file
4 | Makefile makefile for Unix (generated by configure)
5 | Makefile.in makefile for Unix (template for configure)
6 | README guess what
7 | algorithm.txt description of the (de)compression algorithm
8 | configure configure script for Unix
9 | zconf.in.h template for zconf.h (used by configure)
10 |
11 | amiga/ makefiles for Amiga SAS C
12 | as400/ makefiles for IBM AS/400
13 | msdos/ makefiles for MSDOS
14 | old/ makefiles for various architectures and zlib documentation
15 | files that have not yet been updated for zlib 1.2.x
16 | projects/ projects for various Integrated Development Environments
17 | qnx/ makefiles for QNX
18 | win32/ makefiles for Windows
19 |
20 | zlib public header files (must be kept):
21 | zconf.h
22 | zlib.h
23 |
24 | private source files used to build the zlib library:
25 | adler32.c
26 | compress.c
27 | crc32.c
28 | crc32.h
29 | deflate.c
30 | deflate.h
31 | gzio.c
32 | infback.c
33 | inffast.c
34 | inffast.h
35 | inffixed.h
36 | inflate.c
37 | inflate.h
38 | inftrees.c
39 | inftrees.h
40 | trees.c
41 | trees.h
42 | uncompr.c
43 | zutil.c
44 | zutil.h
45 |
46 | source files for sample programs:
47 | example.c
48 | minigzip.c
49 |
50 | unsupported contribution by third parties
51 | See contrib/README.contrib
52 |
--------------------------------------------------------------------------------
/libPython/Modules/zlib/inffast.h:
--------------------------------------------------------------------------------
1 | /* inffast.h -- header to use inffast.c
2 | * Copyright (C) 1995-2003 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /* WARNING: this file should *not* be used by applications. It is
7 | part of the implementation of the compression library and is
8 | subject to change. Applications should only use zlib.h.
9 | */
10 |
11 | void inflate_fast OF((z_streamp strm, unsigned start));
12 |
--------------------------------------------------------------------------------
/libPython/Objects/listsort.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fancyzero/Python-iOS/b9cd21ddb9cfa977e46140062c6bf620b8e0205b/libPython/Objects/listsort.txt
--------------------------------------------------------------------------------
/libPython/Objects/stringlib/README.txt:
--------------------------------------------------------------------------------
1 | bits shared by the stringobject and unicodeobject implementations (and
2 | possibly other modules, in a not too distant future).
3 |
4 | the stuff in here is included into relevant places; see the individual
5 | source files for details.
6 |
7 | --------------------------------------------------------------------
8 | the following defines used by the different modules:
9 |
10 | STRINGLIB_CHAR
11 |
12 | the type used to hold a character (char or Py_UNICODE)
13 |
14 | STRINGLIB_EMPTY
15 |
16 | a PyObject representing the empty string, only to be used if
17 | STRINGLIB_MUTABLE is 0
18 |
19 | Py_ssize_t STRINGLIB_LEN(PyObject*)
20 |
21 | returns the length of the given string object (which must be of the
22 | right type)
23 |
24 | PyObject* STRINGLIB_NEW(STRINGLIB_CHAR*, Py_ssize_t)
25 |
26 | creates a new string object
27 |
28 | STRINGLIB_CHAR* STRINGLIB_STR(PyObject*)
29 |
30 | returns the pointer to the character data for the given string
31 | object (which must be of the right type)
32 |
33 | int STRINGLIB_CHECK_EXACT(PyObject *)
34 |
35 | returns true if the object is an instance of our type, not a subclass
36 |
37 | STRINGLIB_MUTABLE
38 |
39 | must be 0 or 1 to tell the cpp macros in stringlib code if the object
40 | being operated on is mutable or not
41 |
--------------------------------------------------------------------------------
/libPython/Objects/stringlib/count.h:
--------------------------------------------------------------------------------
1 | /* stringlib: count implementation */
2 |
3 | #ifndef STRINGLIB_COUNT_H
4 | #define STRINGLIB_COUNT_H
5 |
6 | #ifndef STRINGLIB_FASTSEARCH_H
7 | #error must include "stringlib/fastsearch.h" before including this module
8 | #endif
9 |
10 | Py_LOCAL_INLINE(Py_ssize_t)
11 | stringlib_count(const STRINGLIB_CHAR* str, Py_ssize_t str_len,
12 | const STRINGLIB_CHAR* sub, Py_ssize_t sub_len,
13 | Py_ssize_t maxcount)
14 | {
15 | Py_ssize_t count;
16 |
17 | if (str_len < 0)
18 | return 0; /* start > len(str) */
19 | if (sub_len == 0)
20 | return (str_len < maxcount) ? str_len + 1 : maxcount;
21 |
22 | count = fastsearch(str, str_len, sub, sub_len, maxcount, FAST_COUNT);
23 |
24 | if (count < 0)
25 | return 0; /* no match */
26 |
27 | return count;
28 | }
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/libPython/Objects/stringlib/stringdefs.h:
--------------------------------------------------------------------------------
1 | #ifndef STRINGLIB_STRINGDEFS_H
2 | #define STRINGLIB_STRINGDEFS_H
3 |
4 | /* this is sort of a hack. there's at least one place (formatting
5 | floats) where some stringlib code takes a different path if it's
6 | compiled as unicode. */
7 | #define STRINGLIB_IS_UNICODE 0
8 |
9 | #define STRINGLIB_OBJECT PyStringObject
10 | #define STRINGLIB_CHAR char
11 | #define STRINGLIB_TYPE_NAME "string"
12 | #define STRINGLIB_PARSE_CODE "S"
13 | #define STRINGLIB_EMPTY nullstring
14 | #define STRINGLIB_ISSPACE Py_ISSPACE
15 | #define STRINGLIB_ISLINEBREAK(x) ((x == '\n') || (x == '\r'))
16 | #define STRINGLIB_ISDECIMAL(x) ((x >= '0') && (x <= '9'))
17 | #define STRINGLIB_TODECIMAL(x) (STRINGLIB_ISDECIMAL(x) ? (x - '0') : -1)
18 | #define STRINGLIB_TOUPPER Py_TOUPPER
19 | #define STRINGLIB_TOLOWER Py_TOLOWER
20 | #define STRINGLIB_FILL memset
21 | #define STRINGLIB_STR PyString_AS_STRING
22 | #define STRINGLIB_LEN PyString_GET_SIZE
23 | #define STRINGLIB_NEW PyString_FromStringAndSize
24 | #define STRINGLIB_RESIZE _PyString_Resize
25 | #define STRINGLIB_CHECK PyString_Check
26 | #define STRINGLIB_CHECK_EXACT PyString_CheckExact
27 | #define STRINGLIB_TOSTR PyObject_Str
28 | #define STRINGLIB_GROUPING _PyString_InsertThousandsGrouping
29 | #define STRINGLIB_GROUPING_LOCALE _PyString_InsertThousandsGroupingLocale
30 |
31 | #define STRINGLIB_WANT_CONTAINS_OBJ 1
32 |
33 | #endif /* !STRINGLIB_STRINGDEFS_H */
34 |
--------------------------------------------------------------------------------
/libPython/Objects/stringlib/unicodedefs.h:
--------------------------------------------------------------------------------
1 | #ifndef STRINGLIB_UNICODEDEFS_H
2 | #define STRINGLIB_UNICODEDEFS_H
3 |
4 | /* this is sort of a hack. there's at least one place (formatting
5 | floats) where some stringlib code takes a different path if it's
6 | compiled as unicode. */
7 | #define STRINGLIB_IS_UNICODE 1
8 |
9 | #define STRINGLIB_OBJECT PyUnicodeObject
10 | #define STRINGLIB_CHAR Py_UNICODE
11 | #define STRINGLIB_TYPE_NAME "unicode"
12 | #define STRINGLIB_PARSE_CODE "U"
13 | #define STRINGLIB_EMPTY unicode_empty
14 | #define STRINGLIB_ISSPACE Py_UNICODE_ISSPACE
15 | #define STRINGLIB_ISLINEBREAK BLOOM_LINEBREAK
16 | #define STRINGLIB_ISDECIMAL Py_UNICODE_ISDECIMAL
17 | #define STRINGLIB_TODECIMAL Py_UNICODE_TODECIMAL
18 | #define STRINGLIB_TOUPPER Py_UNICODE_TOUPPER
19 | #define STRINGLIB_TOLOWER Py_UNICODE_TOLOWER
20 | #define STRINGLIB_FILL Py_UNICODE_FILL
21 | #define STRINGLIB_STR PyUnicode_AS_UNICODE
22 | #define STRINGLIB_LEN PyUnicode_GET_SIZE
23 | #define STRINGLIB_NEW PyUnicode_FromUnicode
24 | #define STRINGLIB_RESIZE PyUnicode_Resize
25 | #define STRINGLIB_CHECK PyUnicode_Check
26 | #define STRINGLIB_CHECK_EXACT PyUnicode_CheckExact
27 | #define STRINGLIB_GROUPING _PyUnicode_InsertThousandsGrouping
28 |
29 | #if PY_VERSION_HEX < 0x03000000
30 | #define STRINGLIB_TOSTR PyObject_Unicode
31 | #else
32 | #define STRINGLIB_TOSTR PyObject_Str
33 | #endif
34 |
35 | #define STRINGLIB_WANT_CONTAINS_OBJ 1
36 |
37 | #endif /* !STRINGLIB_UNICODEDEFS_H */
38 |
--------------------------------------------------------------------------------
/libPython/Parser/bitset.c:
--------------------------------------------------------------------------------
1 |
2 | /* Bitset primitives used by the parser generator */
3 |
4 | #include "pgenheaders.h"
5 | #include "bitset.h"
6 |
7 | bitset
8 | newbitset(int nbits)
9 | {
10 | int nbytes = NBYTES(nbits);
11 | bitset ss = (char *)PyObject_MALLOC(sizeof(BYTE) * nbytes);
12 |
13 | if (ss == NULL)
14 | Py_FatalError("no mem for bitset");
15 |
16 | ss += nbytes;
17 | while (--nbytes >= 0)
18 | *--ss = 0;
19 | return ss;
20 | }
21 |
22 | void
23 | delbitset(bitset ss)
24 | {
25 | PyObject_FREE(ss);
26 | }
27 |
28 | int
29 | addbit(bitset ss, int ibit)
30 | {
31 | int ibyte = BIT2BYTE(ibit);
32 | BYTE mask = BIT2MASK(ibit);
33 |
34 | if (ss[ibyte] & mask)
35 | return 0; /* Bit already set */
36 | ss[ibyte] |= mask;
37 | return 1;
38 | }
39 |
40 | #if 0 /* Now a macro */
41 | int
42 | testbit(bitset ss, int ibit)
43 | {
44 | return (ss[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0;
45 | }
46 | #endif
47 |
48 | int
49 | samebitset(bitset ss1, bitset ss2, int nbits)
50 | {
51 | int i;
52 |
53 | for (i = NBYTES(nbits); --i >= 0; )
54 | if (*ss1++ != *ss2++)
55 | return 0;
56 | return 1;
57 | }
58 |
59 | void
60 | mergebitset(bitset ss1, bitset ss2, int nbits)
61 | {
62 | int i;
63 |
64 | for (i = NBYTES(nbits); --i >= 0; )
65 | *ss1++ |= *ss2++;
66 | }
67 |
--------------------------------------------------------------------------------
/libPython/Parser/grammar1.c:
--------------------------------------------------------------------------------
1 |
2 | /* Grammar subroutines needed by parser */
3 |
4 | #include "Python.h"
5 | #include "pgenheaders.h"
6 | #include "grammar.h"
7 | #include "token.h"
8 |
9 | /* Return the DFA for the given type */
10 |
11 | dfa *
12 | PyGrammar_FindDFA(grammar *g, register int type)
13 | {
14 | register dfa *d;
15 | #if 1
16 | /* Massive speed-up */
17 | d = &g->g_dfa[type - NT_OFFSET];
18 | assert(d->d_type == type);
19 | return d;
20 | #else
21 | /* Old, slow version */
22 | register int i;
23 |
24 | for (i = g->g_ndfas, d = g->g_dfa; --i >= 0; d++) {
25 | if (d->d_type == type)
26 | return d;
27 | }
28 | assert(0);
29 | /* NOTREACHED */
30 | #endif
31 | }
32 |
33 | char *
34 | PyGrammar_LabelRepr(label *lb)
35 | {
36 | static char buf[100];
37 |
38 | if (lb->lb_type == ENDMARKER)
39 | return "EMPTY";
40 | else if (ISNONTERMINAL(lb->lb_type)) {
41 | if (lb->lb_str == NULL) {
42 | PyOS_snprintf(buf, sizeof(buf), "NT%d", lb->lb_type);
43 | return buf;
44 | }
45 | else
46 | return lb->lb_str;
47 | }
48 | else {
49 | if (lb->lb_str == NULL)
50 | return _PyParser_TokenNames[lb->lb_type];
51 | else {
52 | PyOS_snprintf(buf, sizeof(buf), "%.32s(%.32s)",
53 | _PyParser_TokenNames[lb->lb_type], lb->lb_str);
54 | return buf;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/libPython/Parser/listnode.c:
--------------------------------------------------------------------------------
1 |
2 | /* List a node on a file */
3 |
4 | #include "pgenheaders.h"
5 | #include "token.h"
6 | #include "node.h"
7 |
8 | /* Forward */
9 | static void list1node(FILE *, node *);
10 | static void listnode(FILE *, node *);
11 |
12 | void
13 | PyNode_ListTree(node *n)
14 | {
15 | listnode(stdout, n);
16 | }
17 |
18 | static int level, atbol;
19 |
20 | static void
21 | listnode(FILE *fp, node *n)
22 | {
23 | level = 0;
24 | atbol = 1;
25 | list1node(fp, n);
26 | }
27 |
28 | static void
29 | list1node(FILE *fp, node *n)
30 | {
31 | if (n == 0)
32 | return;
33 | if (ISNONTERMINAL(TYPE(n))) {
34 | int i;
35 | for (i = 0; i < NCH(n); i++)
36 | list1node(fp, CHILD(n, i));
37 | }
38 | else if (ISTERMINAL(TYPE(n))) {
39 | switch (TYPE(n)) {
40 | case INDENT:
41 | ++level;
42 | break;
43 | case DEDENT:
44 | --level;
45 | break;
46 | default:
47 | if (atbol) {
48 | int i;
49 | for (i = 0; i < level; ++i)
50 | fprintf(fp, "\t");
51 | atbol = 0;
52 | }
53 | if (TYPE(n) == NEWLINE) {
54 | if (STR(n) != NULL)
55 | fprintf(fp, "%s", STR(n));
56 | fprintf(fp, "\n");
57 | atbol = 1;
58 | }
59 | else
60 | fprintf(fp, "%s ", STR(n));
61 | break;
62 | }
63 | }
64 | else
65 | fprintf(fp, "? ");
66 | }
67 |
--------------------------------------------------------------------------------
/libPython/Parser/parser.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_PARSER_H
2 | #define Py_PARSER_H
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 |
8 | /* Parser interface */
9 |
10 | #define MAXSTACK 1500
11 |
12 | typedef struct {
13 | int s_state; /* State in current DFA */
14 | dfa *s_dfa; /* Current DFA */
15 | struct _node *s_parent; /* Where to add next node */
16 | } stackentry;
17 |
18 | typedef struct {
19 | stackentry *s_top; /* Top entry */
20 | stackentry s_base[MAXSTACK];/* Array of stack entries */
21 | /* NB The stack grows down */
22 | } stack;
23 |
24 | typedef struct {
25 | stack p_stack; /* Stack of parser states */
26 | grammar *p_grammar; /* Grammar to use */
27 | node *p_tree; /* Top of parse tree */
28 | #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
29 | unsigned long p_flags; /* see co_flags in Include/code.h */
30 | #endif
31 | } parser_state;
32 |
33 | parser_state *PyParser_New(grammar *g, int start);
34 | void PyParser_Delete(parser_state *ps);
35 | int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno, int col_offset,
36 | int *expected_ret);
37 | void PyGrammar_AddAccelerators(grammar *g);
38 |
39 | #ifdef __cplusplus
40 | }
41 | #endif
42 | #endif /* !Py_PARSER_H */
43 |
--------------------------------------------------------------------------------
/libPython/Parser/tokenizer_pgen.c:
--------------------------------------------------------------------------------
1 | #define PGEN
2 | #include "tokenizer.c"
3 |
--------------------------------------------------------------------------------
/libPython/Python/asdl.c:
--------------------------------------------------------------------------------
1 | #include "Python.h"
2 | #include "asdl.h"
3 |
4 | asdl_seq *
5 | asdl_seq_new(int size, PyArena *arena)
6 | {
7 | asdl_seq *seq = NULL;
8 | size_t n = (size ? (sizeof(void *) * (size - 1)) : 0);
9 |
10 | /* check size is sane */
11 | if (size < 0 || size == INT_MIN ||
12 | (size && ((size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
13 | PyErr_NoMemory();
14 | return NULL;
15 | }
16 |
17 | /* check if size can be added safely */
18 | if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
19 | PyErr_NoMemory();
20 | return NULL;
21 | }
22 |
23 | n += sizeof(asdl_seq);
24 |
25 | seq = (asdl_seq *)PyArena_Malloc(arena, n);
26 | if (!seq) {
27 | PyErr_NoMemory();
28 | return NULL;
29 | }
30 | memset(seq, 0, n);
31 | seq->size = size;
32 | return seq;
33 | }
34 |
35 | asdl_int_seq *
36 | asdl_int_seq_new(int size, PyArena *arena)
37 | {
38 | asdl_int_seq *seq = NULL;
39 | size_t n = (size ? (sizeof(void *) * (size - 1)) : 0);
40 |
41 | /* check size is sane */
42 | if (size < 0 || size == INT_MIN ||
43 | (size && ((size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
44 | PyErr_NoMemory();
45 | return NULL;
46 | }
47 |
48 | /* check if size can be added safely */
49 | if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
50 | PyErr_NoMemory();
51 | return NULL;
52 | }
53 |
54 | n += sizeof(asdl_seq);
55 |
56 | seq = (asdl_int_seq *)PyArena_Malloc(arena, n);
57 | if (!seq) {
58 | PyErr_NoMemory();
59 | return NULL;
60 | }
61 | memset(seq, 0, n);
62 | seq->size = size;
63 | return seq;
64 | }
65 |
--------------------------------------------------------------------------------
/libPython/Python/atof.c:
--------------------------------------------------------------------------------
1 |
2 | /* Just in case you haven't got an atof() around...
3 | This one doesn't check for bad syntax or overflow,
4 | and is slow and inaccurate.
5 | But it's good enough for the occasional string literal... */
6 |
7 | #include "pyconfig.h"
8 |
9 | #include
10 |
11 | double atof(char *s)
12 | {
13 | double a = 0.0;
14 | int e = 0;
15 | int c;
16 | while ((c = *s++) != '\0' && isdigit(c)) {
17 | a = a*10.0 + (c - '0');
18 | }
19 | if (c == '.') {
20 | while ((c = *s++) != '\0' && isdigit(c)) {
21 | a = a*10.0 + (c - '0');
22 | e = e-1;
23 | }
24 | }
25 | if (c == 'e' || c == 'E') {
26 | int sign = 1;
27 | int i = 0;
28 | c = *s++;
29 | if (c == '+')
30 | c = *s++;
31 | else if (c == '-') {
32 | c = *s++;
33 | sign = -1;
34 | }
35 | while (isdigit(c)) {
36 | i = i*10 + (c - '0');
37 | c = *s++;
38 | }
39 | e += i*sign;
40 | }
41 | while (e > 0) {
42 | a *= 10.0;
43 | e--;
44 | }
45 | while (e < 0) {
46 | a *= 0.1;
47 | e++;
48 | }
49 | return a;
50 | }
51 |
--------------------------------------------------------------------------------
/libPython/Python/dup2.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Public domain dup2() lookalike
3 | * by Curtis Jackson @ AT&T Technologies, Burlington, NC
4 | * electronic address: burl!rcj
5 | *
6 | * dup2 performs the following functions:
7 | *
8 | * Check to make sure that fd1 is a valid open file descriptor.
9 | * Check to see if fd2 is already open; if so, close it.
10 | * Duplicate fd1 onto fd2; checking to make sure fd2 is a valid fd.
11 | * Return fd2 if all went well; return BADEXIT otherwise.
12 | */
13 |
14 | #include
15 | #include
16 |
17 | #define BADEXIT -1
18 |
19 | int
20 | dup2(int fd1, int fd2)
21 | {
22 | if (fd1 != fd2) {
23 | if (fcntl(fd1, F_GETFL) < 0)
24 | return BADEXIT;
25 | if (fcntl(fd2, F_GETFL) >= 0)
26 | close(fd2);
27 | if (fcntl(fd1, F_DUPFD, fd2) < 0)
28 | return BADEXIT;
29 | }
30 | return fd2;
31 | }
32 |
--------------------------------------------------------------------------------
/libPython/Python/formatter_string.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* Implements the string (as opposed to unicode) version of the
3 | built-in formatters for string, int, float. That is, the versions
4 | of int.__format__, etc., that take and return string objects */
5 |
6 | #include "Python.h"
7 | #include "../Objects/stringlib/stringdefs.h"
8 |
9 | #define FORMAT_STRING _PyBytes_FormatAdvanced
10 | #define FORMAT_LONG _PyLong_FormatAdvanced
11 | #define FORMAT_INT _PyInt_FormatAdvanced
12 | #define FORMAT_FLOAT _PyFloat_FormatAdvanced
13 | #ifndef WITHOUT_COMPLEX
14 | #define FORMAT_COMPLEX _PyComplex_FormatAdvanced
15 | #endif
16 |
17 | #include "../Objects/stringlib/formatter.h"
18 |
--------------------------------------------------------------------------------
/libPython/Python/formatter_unicode.c:
--------------------------------------------------------------------------------
1 | /* Implements the unicode (as opposed to string) version of the
2 | built-in formatter for unicode. That is, unicode.__format__(). */
3 |
4 | #include "Python.h"
5 |
6 | #ifdef Py_USING_UNICODE
7 |
8 | #include "../Objects/stringlib/unicodedefs.h"
9 |
10 | #define FORMAT_STRING _PyUnicode_FormatAdvanced
11 |
12 | /* don't define FORMAT_LONG, FORMAT_FLOAT, and FORMAT_COMPLEX, since
13 | we can live with only the string versions of those. The builtin
14 | format() will convert them to unicode. */
15 |
16 | #include "../Objects/stringlib/formatter.h"
17 |
18 | #endif
19 |
--------------------------------------------------------------------------------
/libPython/Python/frozen.c:
--------------------------------------------------------------------------------
1 |
2 | /* Dummy frozen modules initializer */
3 |
4 | #include "Python.h"
5 |
6 | /* In order to test the support for frozen modules, by default we
7 | define a single frozen module, __hello__. Loading it will print
8 | some famous words... */
9 |
10 | /* To regenerate this data after the bytecode or marshal format has changed,
11 | go to ../Tools/freeze/ and freeze the hello.py file; then copy and paste
12 | the appropriate bytes from M___main__.c. */
13 |
14 | static unsigned char M___hello__[] = {
15 | 99,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,
16 | 0,115,9,0,0,0,100,0,0,71,72,100,1,0,83,40,
17 | 2,0,0,0,115,14,0,0,0,72,101,108,108,111,32,119,
18 | 111,114,108,100,46,46,46,78,40,0,0,0,0,40,0,0,
19 | 0,0,40,0,0,0,0,40,0,0,0,0,115,8,0,0,
20 | 0,104,101,108,108,111,46,112,121,115,1,0,0,0,63,1,
21 | 0,0,0,115,0,0,0,0,
22 | };
23 |
24 | #define SIZE (int)sizeof(M___hello__)
25 |
26 | static struct _frozen _PyImport_FrozenModules[] = {
27 | /* Test module */
28 | {"__hello__", M___hello__, SIZE},
29 | /* Test package (negative size indicates package-ness) */
30 | {"__phello__", M___hello__, -SIZE},
31 | {"__phello__.spam", M___hello__, SIZE},
32 | {0, 0, 0} /* sentinel */
33 | };
34 |
35 | /* Embedding apps may change this pointer to point to their favorite
36 | collection of frozen modules: */
37 |
38 | struct _frozen *PyImport_FrozenModules = _PyImport_FrozenModules;
39 |
--------------------------------------------------------------------------------
/libPython/Python/frozenmain.c:
--------------------------------------------------------------------------------
1 |
2 | /* Python interpreter main program for frozen scripts */
3 |
4 | #include "Python.h"
5 |
6 | #ifdef MS_WINDOWS
7 | extern void PyWinFreeze_ExeInit(void);
8 | extern void PyWinFreeze_ExeTerm(void);
9 | extern int PyInitFrozenExtensions(void);
10 | #endif
11 |
12 | /* Main program */
13 |
14 | int
15 | Py_FrozenMain(int argc, char **argv)
16 | {
17 | char *p;
18 | int n, sts;
19 | int inspect = 0;
20 | int unbuffered = 0;
21 |
22 | Py_FrozenFlag = 1; /* Suppress errors from getpath.c */
23 |
24 | if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
25 | inspect = 1;
26 | if ((p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
27 | unbuffered = 1;
28 |
29 | if (unbuffered) {
30 | setbuf(stdin, (char *)NULL);
31 | setbuf(stdout, (char *)NULL);
32 | setbuf(stderr, (char *)NULL);
33 | }
34 |
35 | #ifdef MS_WINDOWS
36 | PyInitFrozenExtensions();
37 | #endif /* MS_WINDOWS */
38 | Py_SetProgramName(argv[0]);
39 | Py_Initialize();
40 | #ifdef MS_WINDOWS
41 | PyWinFreeze_ExeInit();
42 | #endif
43 |
44 | if (Py_VerboseFlag)
45 | fprintf(stderr, "Python %s\n%s\n",
46 | Py_GetVersion(), Py_GetCopyright());
47 |
48 | PySys_SetArgv(argc, argv);
49 |
50 | n = PyImport_ImportFrozenModule("__main__");
51 | if (n == 0)
52 | Py_FatalError("__main__ not frozen");
53 | if (n < 0) {
54 | PyErr_Print();
55 | sts = 1;
56 | }
57 | else
58 | sts = 0;
59 |
60 | if (inspect && isatty((int)fileno(stdin)))
61 | sts = PyRun_AnyFile(stdin, "") != 0;
62 |
63 | #ifdef MS_WINDOWS
64 | PyWinFreeze_ExeTerm();
65 | #endif
66 | Py_Finalize();
67 | return sts;
68 | }
69 |
--------------------------------------------------------------------------------
/libPython/Python/getcompiler.c:
--------------------------------------------------------------------------------
1 |
2 | /* Return the compiler identification, if possible. */
3 |
4 | #include "Python.h"
5 |
6 | #ifndef COMPILER
7 |
8 | #ifdef __GNUC__
9 | #define COMPILER "\n[GCC " __VERSION__ "]"
10 | #endif
11 |
12 | #endif /* !COMPILER */
13 |
14 | #ifndef COMPILER
15 |
16 | #ifdef __cplusplus
17 | #define COMPILER "[C++]"
18 | #else
19 | #define COMPILER "[C]"
20 | #endif
21 |
22 | #endif /* !COMPILER */
23 |
24 | const char *
25 | Py_GetCompiler(void)
26 | {
27 | return COMPILER;
28 | }
29 |
--------------------------------------------------------------------------------
/libPython/Python/getcopyright.c:
--------------------------------------------------------------------------------
1 | /* Return the copyright string. This is updated manually. */
2 |
3 | #include "Python.h"
4 |
5 | static char cprt[] =
6 | "\
7 | Copyright (c) 2001-2013 Python Software Foundation.\n\
8 | All Rights Reserved.\n\
9 | \n\
10 | Copyright (c) 2000 BeOpen.com.\n\
11 | All Rights Reserved.\n\
12 | \n\
13 | Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n\
14 | All Rights Reserved.\n\
15 | \n\
16 | Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n\
17 | All Rights Reserved.";
18 |
19 | const char *
20 | Py_GetCopyright(void)
21 | {
22 | return cprt;
23 | }
24 |
--------------------------------------------------------------------------------
/libPython/Python/getcwd.c:
--------------------------------------------------------------------------------
1 |
2 | /* Two PD getcwd() implementations.
3 | Author: Guido van Rossum, CWI Amsterdam, Jan 1991, . */
4 |
5 | #include
6 | #include
7 |
8 | #ifdef HAVE_GETWD
9 |
10 | /* Version for BSD systems -- use getwd() */
11 |
12 | #ifdef HAVE_SYS_PARAM_H
13 | #include
14 | #endif
15 |
16 | #ifndef MAXPATHLEN
17 | #if defined(PATH_MAX) && PATH_MAX > 1024
18 | #define MAXPATHLEN PATH_MAX
19 | #else
20 | #define MAXPATHLEN 1024
21 | #endif
22 | #endif
23 |
24 | extern char *getwd(char *);
25 |
26 | char *
27 | getcwd(char *buf, int size)
28 | {
29 | char localbuf[MAXPATHLEN+1];
30 | char *ret;
31 |
32 | if (size <= 0) {
33 | errno = EINVAL;
34 | return NULL;
35 | }
36 | ret = getwd(localbuf);
37 | if (ret != NULL && strlen(localbuf) >= (size_t)size) {
38 | errno = ERANGE;
39 | return NULL;
40 | }
41 | if (ret == NULL) {
42 | errno = EACCES; /* Most likely error */
43 | return NULL;
44 | }
45 | strncpy(buf, localbuf, size);
46 | return buf;
47 | }
48 |
49 | #else /* !HAVE_GETWD */
50 |
51 | /* Version for really old UNIX systems -- use pipe from pwd */
52 |
53 | #ifndef PWD_CMD
54 | #define PWD_CMD "/bin/pwd"
55 | #endif
56 |
57 | char *
58 | getcwd(char *buf, int size)
59 | {
60 | FILE *fp;
61 | char *p;
62 | if (size <= 0) {
63 | errno = EINVAL;
64 | return NULL;
65 | }
66 | if ((fp = popen(PWD_CMD, "r")) == NULL)
67 | return NULL;
68 | if (fgets(buf, size, fp) == NULL || pclose(fp) != 0) {
69 | errno = EACCES; /* Most likely error */
70 | return NULL;
71 | }
72 | for (p = buf; *p != '\n'; p++) {
73 | if (*p == '\0') {
74 | errno = ERANGE;
75 | return NULL;
76 | }
77 | }
78 | *p = '\0';
79 | return buf;
80 | }
81 |
82 | #endif /* !HAVE_GETWD */
83 |
--------------------------------------------------------------------------------
/libPython/Python/getplatform.c:
--------------------------------------------------------------------------------
1 |
2 | #include "Python.h"
3 |
4 | #ifndef PLATFORM
5 | #define PLATFORM "unknown"
6 | #endif
7 |
8 | const char *
9 | Py_GetPlatform(void)
10 | {
11 | return PLATFORM;
12 | }
13 |
--------------------------------------------------------------------------------
/libPython/Python/getversion.c:
--------------------------------------------------------------------------------
1 |
2 | /* Return the full version string. */
3 |
4 | #include "Python.h"
5 |
6 | #include "patchlevel.h"
7 |
8 | const char *
9 | Py_GetVersion(void)
10 | {
11 | static char version[250];
12 | PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s",
13 | PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());
14 | return version;
15 | }
16 |
--------------------------------------------------------------------------------
/libPython/Python/importdl.h:
--------------------------------------------------------------------------------
1 | #ifndef Py_IMPORTDL_H
2 | #define Py_IMPORTDL_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /* Definitions for dynamic loading of extension modules */
10 | enum filetype {
11 | SEARCH_ERROR,
12 | PY_SOURCE,
13 | PY_COMPILED,
14 | C_EXTENSION,
15 | PY_RESOURCE, /* Mac only */
16 | PKG_DIRECTORY,
17 | C_BUILTIN,
18 | PY_FROZEN,
19 | PY_CODERESOURCE, /* Mac only */
20 | IMP_HOOK
21 | };
22 |
23 | struct filedescr {
24 | char *suffix;
25 | char *mode;
26 | enum filetype type;
27 | };
28 | extern struct filedescr * _PyImport_Filetab;
29 | extern const struct filedescr _PyImport_DynLoadFiletab[];
30 |
31 | extern PyObject *_PyImport_LoadDynamicModule(char *name, char *pathname,
32 | FILE *);
33 |
34 | /* Max length of module suffix searched for -- accommodates "module.slb" */
35 | #define MAXSUFFIXSIZE 12
36 |
37 | #ifdef MS_WINDOWS
38 | #include
39 | typedef FARPROC dl_funcptr;
40 | #else
41 | #if defined(PYOS_OS2) && !defined(PYCC_GCC)
42 | #include
43 | typedef int (* APIENTRY dl_funcptr)();
44 | #else
45 | typedef void (*dl_funcptr)(void);
46 | #endif
47 | #endif
48 |
49 |
50 | #ifdef __cplusplus
51 | }
52 | #endif
53 | #endif /* !Py_IMPORTDL_H */
54 |
--------------------------------------------------------------------------------
/libPython/Python/pyfpe.c:
--------------------------------------------------------------------------------
1 | #include "pyconfig.h"
2 | #include "pyfpe.h"
3 | /*
4 | * The signal handler for SIGFPE is actually declared in an external
5 | * module fpectl, or as preferred by the user. These variable
6 | * definitions are required in order to compile Python without
7 | * getting missing externals, but to actually handle SIGFPE requires
8 | * defining a handler and enabling generation of SIGFPE.
9 | */
10 |
11 | #ifdef WANT_SIGFPE_HANDLER
12 | jmp_buf PyFPE_jbuf;
13 | int PyFPE_counter = 0;
14 | #endif
15 |
16 | /* Have this outside the above #ifdef, since some picky ANSI compilers issue a
17 | warning when compiling an empty file. */
18 |
19 | double
20 | PyFPE_dummy(void *dummy)
21 | {
22 | return 1.0;
23 | }
24 |
--------------------------------------------------------------------------------
/libPython/Python/pymath.c:
--------------------------------------------------------------------------------
1 | #include "Python.h"
2 |
3 | #ifdef X87_DOUBLE_ROUNDING
4 | /* On x86 platforms using an x87 FPU, this function is called from the
5 | Py_FORCE_DOUBLE macro (defined in pymath.h) to force a floating-point
6 | number out of an 80-bit x87 FPU register and into a 64-bit memory location,
7 | thus rounding from extended precision to double precision. */
8 | double _Py_force_double(double x)
9 | {
10 | volatile double y;
11 | y = x;
12 | return y;
13 | }
14 | #endif
15 |
16 | #ifdef HAVE_GCC_ASM_FOR_X87
17 |
18 | /* inline assembly for getting and setting the 387 FPU control word on
19 | gcc/x86 */
20 |
21 | unsigned short _Py_get_387controlword(void) {
22 | unsigned short cw;
23 | __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
24 | return cw;
25 | }
26 |
27 | void _Py_set_387controlword(unsigned short cw) {
28 | __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
29 | }
30 |
31 | #endif
32 |
33 |
34 | #ifndef HAVE_HYPOT
35 | double hypot(double x, double y)
36 | {
37 | double yx;
38 |
39 | x = fabs(x);
40 | y = fabs(y);
41 | if (x < y) {
42 | double temp = x;
43 | x = y;
44 | y = temp;
45 | }
46 | if (x == 0.)
47 | return 0.;
48 | else {
49 | yx = y/x;
50 | return x*sqrt(1.+yx*yx);
51 | }
52 | }
53 | #endif /* HAVE_HYPOT */
54 |
55 | #ifndef HAVE_COPYSIGN
56 | double
57 | copysign(double x, double y)
58 | {
59 | /* use atan2 to distinguish -0. from 0. */
60 | if (y > 0. || (y == 0. && atan2(y, -1.) > 0.)) {
61 | return fabs(x);
62 | } else {
63 | return -fabs(x);
64 | }
65 | }
66 | #endif /* HAVE_COPYSIGN */
67 |
68 | #ifndef HAVE_ROUND
69 | double
70 | round(double x)
71 | {
72 | double absx, y;
73 | absx = fabs(x);
74 | y = floor(absx);
75 | if (absx - y >= 0.5)
76 | y += 1.0;
77 | return copysign(y, x);
78 | }
79 | #endif /* HAVE_ROUND */
80 |
--------------------------------------------------------------------------------
/libPython/Python/pystrcmp.c:
--------------------------------------------------------------------------------
1 | /* Cross platform case insensitive string compare functions
2 | */
3 |
4 | #include "Python.h"
5 |
6 | int
7 | PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size)
8 | {
9 | if (size == 0)
10 | return 0;
11 | while ((--size > 0) &&
12 | (tolower((unsigned)*s1) == tolower((unsigned)*s2))) {
13 | if (!*s1++ || !*s2++)
14 | break;
15 | }
16 | return tolower((unsigned)*s1) - tolower((unsigned)*s2);
17 | }
18 |
19 | int
20 | PyOS_mystricmp(const char *s1, const char *s2)
21 | {
22 | while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) {
23 | ;
24 | }
25 | return (tolower((unsigned)*s1) - tolower((unsigned)*s2));
26 | }
27 |
--------------------------------------------------------------------------------
/libPython/Python/sigcheck.c:
--------------------------------------------------------------------------------
1 |
2 | /* Sigcheck is similar to intrcheck() but sets an exception when an
3 | interrupt occurs. It can't be in the intrcheck.c file since that
4 | file (and the whole directory it is in) doesn't know about objects
5 | or exceptions. It can't be in errors.c because it can be
6 | overridden (at link time) by a more powerful version implemented in
7 | signalmodule.c. */
8 |
9 | #include "Python.h"
10 |
11 | /* ARGSUSED */
12 | int
13 | PyErr_CheckSignals(void)
14 | {
15 | if (!PyOS_InterruptOccurred())
16 | return 0;
17 | PyErr_SetNone(PyExc_KeyboardInterrupt);
18 | return -1;
19 | }
20 |
--------------------------------------------------------------------------------
/libPython/Python/strdup.c:
--------------------------------------------------------------------------------
1 | /* strdup() replacement (from stdwin, if you must know) */
2 |
3 | #include "pgenheaders.h"
4 |
5 | char *
6 | strdup(const char *str)
7 | {
8 | if (str != NULL) {
9 | register char *copy = malloc(strlen(str) + 1);
10 | if (copy != NULL)
11 | return strcpy(copy, str);
12 | }
13 | return NULL;
14 | }
15 |
--------------------------------------------------------------------------------
/libPython/Python/thread_foobar.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Initialization.
4 | */
5 | static void
6 | PyThread__init_thread(void)
7 | {
8 | }
9 |
10 | /*
11 | * Thread support.
12 | */
13 | long
14 | PyThread_start_new_thread(void (*func)(void *), void *arg)
15 | {
16 | int success = 0; /* init not needed when SOLARIS_THREADS and */
17 | /* C_THREADS implemented properly */
18 |
19 | dprintf(("PyThread_start_new_thread called\n"));
20 | if (!initialized)
21 | PyThread_init_thread();
22 | return success < 0 ? -1 : 0;
23 | }
24 |
25 | long
26 | PyThread_get_thread_ident(void)
27 | {
28 | if (!initialized)
29 | PyThread_init_thread();
30 | }
31 |
32 | void
33 | PyThread_exit_thread(void)
34 | {
35 | dprintf(("PyThread_exit_thread called\n"));
36 | if (!initialized)
37 | exit(0);
38 | }
39 |
40 | /*
41 | * Lock support.
42 | */
43 | PyThread_type_lock
44 | PyThread_allocate_lock(void)
45 | {
46 |
47 | dprintf(("PyThread_allocate_lock called\n"));
48 | if (!initialized)
49 | PyThread_init_thread();
50 |
51 | dprintf(("PyThread_allocate_lock() -> %p\n", lock));
52 | return (PyThread_type_lock) lock;
53 | }
54 |
55 | void
56 | PyThread_free_lock(PyThread_type_lock lock)
57 | {
58 | dprintf(("PyThread_free_lock(%p) called\n", lock));
59 | }
60 |
61 | int
62 | PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
63 | {
64 | int success;
65 |
66 | dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
67 | dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
68 | return success;
69 | }
70 |
71 | void
72 | PyThread_release_lock(PyThread_type_lock lock)
73 | {
74 | dprintf(("PyThread_release_lock(%p) called\n", lock));
75 | }
76 |
--------------------------------------------------------------------------------
/libPython/main.mm:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // pythonpythonios
4 | //
5 | // Created by Fancyzero on 13-7-6.
6 | // Copyright (c) 2013年 Fancyzero. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 | #include "Python.h"
13 | #include
14 | extern "C" void initzlib(void);
15 | int main(int argc, char *argv[])
16 | {
17 |
18 | NSString *path = [[NSBundle mainBundle] pathForResource:@"python" ofType:nil inDirectory:@""];
19 | std::string str = [path UTF8String];
20 | str += "/";
21 | char ppp[10240];
22 | strcpy( ppp, str.c_str());
23 | Py_SetPythonHome(ppp);
24 | Py_Initialize();
25 | initzlib();
26 | PyRun_SimpleString("from encodings import ascii");
27 | PyRun_SimpleString("from encodings import hex_codec");
28 | PyRun_SimpleString("import json");
29 | PyRun_SimpleString("import socket");
30 | @autoreleasepool {
31 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/python-ios.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------