mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-25 06:42:27 +00:00
python-3.6.zip added from Github
README.cosmo contains the necessary links.
This commit is contained in:
parent
75fc601ff5
commit
0c4c56ff39
4219 changed files with 1968626 additions and 0 deletions
2
third_party/python/Modules/README
vendored
Normal file
2
third_party/python/Modules/README
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
Source files for standard library extension modules,
|
||||
and former extension modules that are now builtin modules.
|
10
third_party/python/Modules/Setup.config.in
vendored
Normal file
10
third_party/python/Modules/Setup.config.in
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# This file is transmogrified into Setup.config by config.status.
|
||||
|
||||
# The purpose of this file is to conditionally enable certain modules
|
||||
# based on configure-time options.
|
||||
|
||||
# Threading
|
||||
@USE_THREAD_MODULE@_thread _threadmodule.c
|
||||
|
||||
# The rest of the modules previously listed in this file are built
|
||||
# by the setup.py script in Python 2.1 and later.
|
389
third_party/python/Modules/Setup.dist
vendored
Normal file
389
third_party/python/Modules/Setup.dist
vendored
Normal file
|
@ -0,0 +1,389 @@
|
|||
# -*- makefile -*-
|
||||
# The file Setup is used by the makesetup script to construct the files
|
||||
# Makefile and config.c, from Makefile.pre and config.c.in,
|
||||
# respectively. The file Setup itself is initially copied from
|
||||
# Setup.dist; once it exists it will not be overwritten, so you can edit
|
||||
# Setup to your heart's content. Note that Makefile.pre is created
|
||||
# from Makefile.pre.in by the toplevel configure script.
|
||||
|
||||
# (VPATH notes: Setup and Makefile.pre are in the build directory, as
|
||||
# are Makefile and config.c; the *.in and *.dist files are in the source
|
||||
# directory.)
|
||||
|
||||
# Each line in this file describes one or more optional modules.
|
||||
# Modules enabled here will not be compiled by the setup.py script,
|
||||
# so the file can be used to override setup.py's behavior.
|
||||
|
||||
# Lines have the following structure:
|
||||
#
|
||||
# <module> ... [<sourcefile> ...] [<cpparg> ...] [<library> ...]
|
||||
#
|
||||
# <sourcefile> is anything ending in .c (.C, .cc, .c++ are C++ files)
|
||||
# <cpparg> is anything starting with -I, -D, -U or -C
|
||||
# <library> is anything ending in .a or beginning with -l or -L
|
||||
# <module> is anything else but should be a valid Python
|
||||
# identifier (letters, digits, underscores, beginning with non-digit)
|
||||
#
|
||||
# (As the makesetup script changes, it may recognize some other
|
||||
# arguments as well, e.g. *.so and *.sl as libraries. See the big
|
||||
# case statement in the makesetup script.)
|
||||
#
|
||||
# Lines can also have the form
|
||||
#
|
||||
# <name> = <value>
|
||||
#
|
||||
# which defines a Make variable definition inserted into Makefile.in
|
||||
#
|
||||
# Finally, if a line contains just the word "*shared*" (without the
|
||||
# quotes but with the stars), then the following modules will not be
|
||||
# built statically. The build process works like this:
|
||||
#
|
||||
# 1. Build all modules that are declared as static in Modules/Setup,
|
||||
# combine them into libpythonxy.a, combine that into python.
|
||||
# 2. Build all modules that are listed as shared in Modules/Setup.
|
||||
# 3. Invoke setup.py. That builds all modules that
|
||||
# a) are not builtin, and
|
||||
# b) are not listed in Modules/Setup, and
|
||||
# c) can be build on the target
|
||||
#
|
||||
# Therefore, modules declared to be shared will not be
|
||||
# included in the config.c file, nor in the list of objects to be
|
||||
# added to the library archive, and their linker options won't be
|
||||
# added to the linker options. Rules to create their .o files and
|
||||
# their shared libraries will still be added to the Makefile, and
|
||||
# their names will be collected in the Make variable SHAREDMODS. This
|
||||
# is used to build modules as shared libraries. (They can be
|
||||
# installed using "make sharedinstall", which is implied by the
|
||||
# toplevel "make install" target.) (For compatibility,
|
||||
# *noconfig* has the same effect as *shared*.)
|
||||
#
|
||||
# In addition, *static* explicitly declares the following modules to
|
||||
# be static. Lines containing "*static*" and "*shared*" may thus
|
||||
# alternate throughout this file.
|
||||
|
||||
# NOTE: As a standard policy, as many modules as can be supported by a
|
||||
# platform should be present. The distribution comes with all modules
|
||||
# enabled that are supported by most platforms and don't require you
|
||||
# to ftp sources from elsewhere.
|
||||
|
||||
|
||||
# Some special rules to define PYTHONPATH.
|
||||
# Edit the definitions below to indicate which options you are using.
|
||||
# Don't add any whitespace or comments!
|
||||
|
||||
# Directories where library files get installed.
|
||||
# DESTLIB is for Python modules; MACHDESTLIB for shared libraries.
|
||||
DESTLIB=$(LIBDEST)
|
||||
MACHDESTLIB=$(BINLIBDEST)
|
||||
|
||||
# NOTE: all the paths are now relative to the prefix that is computed
|
||||
# at run time!
|
||||
|
||||
# Standard path -- don't edit.
|
||||
# No leading colon since this is the first entry.
|
||||
# Empty since this is now just the runtime prefix.
|
||||
DESTPATH=
|
||||
|
||||
# Site specific path components -- should begin with : if non-empty
|
||||
SITEPATH=
|
||||
|
||||
# Standard path components for test modules
|
||||
TESTPATH=
|
||||
|
||||
# Path components for machine- or system-dependent modules and shared libraries
|
||||
MACHDEPPATH=:$(PLATDIR)
|
||||
EXTRAMACHDEPPATH=
|
||||
|
||||
COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)
|
||||
PYTHONPATH=$(COREPYTHONPATH)
|
||||
|
||||
|
||||
# The modules listed here can't be built as shared libraries for
|
||||
# various reasons; therefore they are listed here instead of in the
|
||||
# normal order.
|
||||
|
||||
# This only contains the minimal set of modules required to run the
|
||||
# setup.py script in the root of the Python source tree.
|
||||
|
||||
posix posixmodule.c # posix (UNIX) system calls
|
||||
errno errnomodule.c # posix (UNIX) errno values
|
||||
pwd pwdmodule.c # this is needed to find out the user's home dir
|
||||
# if $HOME is not set
|
||||
_sre _sre.c # Fredrik Lundh's new regular expressions
|
||||
_codecs _codecsmodule.c # access to the builtin codecs and codec registry
|
||||
_weakref _weakref.c # weak references
|
||||
_functools _functoolsmodule.c # Tools for working with functions and callable objects
|
||||
_operator _operator.c # operator.add() and similar goodies
|
||||
_collections _collectionsmodule.c # Container types
|
||||
itertools itertoolsmodule.c # Functions creating iterators for efficient looping
|
||||
atexit atexitmodule.c # Register functions to be run at interpreter-shutdown
|
||||
_signal signalmodule.c
|
||||
_stat _stat.c # stat.h interface
|
||||
time timemodule.c # -lm # time operations and variables
|
||||
|
||||
# access to ISO C locale support
|
||||
_locale _localemodule.c # -lintl
|
||||
|
||||
# Standard I/O baseline
|
||||
_io -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c
|
||||
|
||||
# The zipimport module is always imported at startup. Having it as a
|
||||
# builtin module avoids some bootstrapping problems and reduces overhead.
|
||||
zipimport zipimport.c
|
||||
|
||||
# faulthandler module
|
||||
faulthandler faulthandler.c
|
||||
|
||||
# debug tool to trace memory blocks allocated by Python
|
||||
_tracemalloc _tracemalloc.c hashtable.c
|
||||
|
||||
# The rest of the modules listed in this file are all commented out by
|
||||
# default. Usually they can be detected and built as dynamically
|
||||
# loaded modules by the new setup.py script added in Python 2.1. If
|
||||
# you're on a platform that doesn't support dynamic loading, want to
|
||||
# compile modules statically into the Python binary, or need to
|
||||
# specify some odd set of compiler switches, you can uncomment the
|
||||
# appropriate lines below.
|
||||
|
||||
# ======================================================================
|
||||
|
||||
# The Python symtable module depends on .h files that setup.py doesn't track
|
||||
_symtable symtablemodule.c
|
||||
|
||||
# Uncommenting the following line tells makesetup that all following
|
||||
# modules are to be built as shared libraries (see above for more
|
||||
# detail; also note that *static* reverses this effect):
|
||||
|
||||
#*shared*
|
||||
|
||||
# GNU readline. Unlike previous Python incarnations, GNU readline is
|
||||
# now incorporated in an optional module, configured in the Setup file
|
||||
# instead of by a configure script switch. You may have to insert a
|
||||
# -L option pointing to the directory where libreadline.* lives,
|
||||
# and you may have to change -ltermcap to -ltermlib or perhaps remove
|
||||
# it, depending on your system -- see the GNU readline instructions.
|
||||
# It's okay for this to be a shared library, too.
|
||||
|
||||
#readline readline.c -lreadline -ltermcap
|
||||
|
||||
|
||||
# Modules that should always be present (non UNIX dependent):
|
||||
|
||||
#array arraymodule.c # array objects
|
||||
#cmath cmathmodule.c _math.c # -lm # complex math library functions
|
||||
#math mathmodule.c _math.c # -lm # math library functions, e.g. sin()
|
||||
#_struct _struct.c # binary structure packing/unpacking
|
||||
#_weakref _weakref.c # basic weak reference support
|
||||
#_testcapi _testcapimodule.c # Python C API test module
|
||||
#_random _randommodule.c # Random number generator
|
||||
#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
|
||||
#_pickle _pickle.c # pickle accelerator
|
||||
#_datetime _datetimemodule.c # datetime accelerator
|
||||
#_bisect _bisectmodule.c # Bisection algorithms
|
||||
#_heapq _heapqmodule.c # Heap queue algorithm
|
||||
#_asyncio _asynciomodule.c # Fast asyncio Future
|
||||
|
||||
#unicodedata unicodedata.c # static Unicode character database
|
||||
|
||||
|
||||
# Modules with some UNIX dependencies -- on by default:
|
||||
# (If you have a really backward UNIX, select and socket may not be
|
||||
# supported...)
|
||||
|
||||
#fcntl fcntlmodule.c # fcntl(2) and ioctl(2)
|
||||
#spwd spwdmodule.c # spwd(3)
|
||||
#grp grpmodule.c # grp(3)
|
||||
#select selectmodule.c # select(2); not on ancient System V
|
||||
|
||||
# Memory-mapped files (also works on Win32).
|
||||
#mmap mmapmodule.c
|
||||
|
||||
# CSV file helper
|
||||
#_csv _csv.c
|
||||
|
||||
# Socket module helper for socket(2)
|
||||
#_socket socketmodule.c
|
||||
|
||||
# Socket module helper for SSL support; you must comment out the other
|
||||
# socket line above, and possibly edit the SSL variable:
|
||||
#SSL=/usr/local/ssl
|
||||
#_ssl _ssl.c \
|
||||
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
|
||||
# -L$(SSL)/lib -lssl -lcrypto
|
||||
|
||||
# The crypt module is now disabled by default because it breaks builds
|
||||
# on many systems (where -lcrypt is needed), e.g. Linux (I believe).
|
||||
#
|
||||
# First, look at Setup.config; configure may have set this for you.
|
||||
|
||||
#_crypt _cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems
|
||||
|
||||
|
||||
# Some more UNIX dependent modules -- off by default, since these
|
||||
# are not supported by all UNIX systems:
|
||||
|
||||
#nis nismodule.c -lnsl # Sun yellow pages -- not everywhere
|
||||
#termios termios.c # Steen Lumholt's termios module
|
||||
#resource resource.c # Jeremy Hylton's rlimit interface
|
||||
|
||||
#_posixsubprocess _posixsubprocess.c # POSIX subprocess module helper
|
||||
|
||||
# Multimedia modules -- off by default.
|
||||
# These don't work for 64-bit platforms!!!
|
||||
# #993173 says audioop works on 64-bit platforms, though.
|
||||
# These represent audio samples or images as strings:
|
||||
|
||||
#audioop audioop.c # Operations on audio samples
|
||||
|
||||
|
||||
# Note that the _md5 and _sha modules are normally only built if the
|
||||
# system does not have the OpenSSL libs containing an optimized version.
|
||||
|
||||
# The _md5 module implements the RSA Data Security, Inc. MD5
|
||||
# Message-Digest Algorithm, described in RFC 1321.
|
||||
|
||||
#_md5 md5module.c
|
||||
|
||||
|
||||
# The _sha module implements the SHA checksum algorithms.
|
||||
# (NIST's Secure Hash Algorithms.)
|
||||
#_sha1 sha1module.c
|
||||
#_sha256 sha256module.c
|
||||
#_sha512 sha512module.c
|
||||
#_sha3 _sha3/sha3module.c
|
||||
|
||||
# _blake module
|
||||
#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
|
||||
|
||||
# The _tkinter module.
|
||||
#
|
||||
# The command for _tkinter is long and site specific. Please
|
||||
# uncomment and/or edit those parts as indicated. If you don't have a
|
||||
# specific extension (e.g. Tix or BLT), leave the corresponding line
|
||||
# commented out. (Leave the trailing backslashes in! If you
|
||||
# experience strange errors, you may want to join all uncommented
|
||||
# lines and remove the backslashes -- the backslash interpretation is
|
||||
# done by the shell's "read" command and it may not be implemented on
|
||||
# every system.
|
||||
|
||||
# *** Always uncomment this (leave the leading underscore in!):
|
||||
# _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \
|
||||
# *** Uncomment and edit to reflect where your Tcl/Tk libraries are:
|
||||
# -L/usr/local/lib \
|
||||
# *** Uncomment and edit to reflect where your Tcl/Tk headers are:
|
||||
# -I/usr/local/include \
|
||||
# *** Uncomment and edit to reflect where your X11 header files are:
|
||||
# -I/usr/X11R6/include \
|
||||
# *** Or uncomment this for Solaris:
|
||||
# -I/usr/openwin/include \
|
||||
# *** Uncomment and edit for Tix extension only:
|
||||
# -DWITH_TIX -ltix8.1.8.2 \
|
||||
# *** Uncomment and edit for BLT extension only:
|
||||
# -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \
|
||||
# *** Uncomment and edit for PIL (TkImaging) extension only:
|
||||
# (See http://www.pythonware.com/products/pil/ for more info)
|
||||
# -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
|
||||
# *** Uncomment and edit for TOGL extension only:
|
||||
# -DWITH_TOGL togl.c \
|
||||
# *** Uncomment and edit to reflect your Tcl/Tk versions:
|
||||
# -ltk8.2 -ltcl8.2 \
|
||||
# *** Uncomment and edit to reflect where your X11 libraries are:
|
||||
# -L/usr/X11R6/lib \
|
||||
# *** Or uncomment this for Solaris:
|
||||
# -L/usr/openwin/lib \
|
||||
# *** Uncomment these for TOGL extension only:
|
||||
# -lGL -lGLU -lXext -lXmu \
|
||||
# *** Uncomment for AIX:
|
||||
# -lld \
|
||||
# *** Always uncomment this; X11 libraries to link with:
|
||||
# -lX11
|
||||
|
||||
# Lance Ellinghaus's syslog module
|
||||
#syslog syslogmodule.c # syslog daemon interface
|
||||
|
||||
|
||||
# Curses support, requiring the System V version of curses, often
|
||||
# provided by the ncurses library. e.g. on Linux, link with -lncurses
|
||||
# instead of -lcurses).
|
||||
#
|
||||
# First, look at Setup.config; configure may have set this for you.
|
||||
|
||||
#_curses _cursesmodule.c -lcurses -ltermcap
|
||||
# Wrapper for the panel library that's part of ncurses and SYSV curses.
|
||||
#_curses_panel _curses_panel.c -lpanel -lncurses
|
||||
|
||||
|
||||
# Modules that provide persistent dictionary-like semantics. You will
|
||||
# probably want to arrange for at least one of them to be available on
|
||||
# your machine, though none are defined by default because of library
|
||||
# dependencies. The Python module dbm/__init__.py provides an
|
||||
# implementation independent wrapper for these; dbm/dumb.py provides
|
||||
# similar functionality (but slower of course) implemented in Python.
|
||||
|
||||
# The standard Unix dbm module has been moved to Setup.config so that
|
||||
# it will be compiled as a shared library by default. Compiling it as
|
||||
# a built-in module causes conflicts with the pybsddb3 module since it
|
||||
# creates a static dependency on an out-of-date version of db.so.
|
||||
#
|
||||
# First, look at Setup.config; configure may have set this for you.
|
||||
|
||||
#_dbm _dbmmodule.c # dbm(3) may require -lndbm or similar
|
||||
|
||||
# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
|
||||
#
|
||||
# First, look at Setup.config; configure may have set this for you.
|
||||
|
||||
#_gdbm _gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm
|
||||
|
||||
|
||||
# Helper module for various ascii-encoders
|
||||
#binascii binascii.c
|
||||
|
||||
# Fred Drake's interface to the Python parser
|
||||
#parser parsermodule.c
|
||||
|
||||
|
||||
# Lee Busby's SIGFPE modules.
|
||||
# The library to link fpectl with is platform specific.
|
||||
# Choose *one* of the options below for fpectl:
|
||||
|
||||
# For SGI IRIX (tested on 5.3):
|
||||
#fpectl fpectlmodule.c -lfpe
|
||||
|
||||
# For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2):
|
||||
# (Without the compiler you don't have -lsunmath.)
|
||||
#fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm
|
||||
|
||||
# For other systems: see instructions in fpectlmodule.c.
|
||||
#fpectl fpectlmodule.c ...
|
||||
|
||||
# Test module for fpectl. No extra libraries needed.
|
||||
#fpetest fpetestmodule.c
|
||||
|
||||
# Andrew Kuchling's zlib module.
|
||||
# This require zlib 1.1.3 (or later).
|
||||
# See http://www.gzip.org/zlib/
|
||||
#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
|
||||
|
||||
# Interface to the Expat XML parser
|
||||
# More information on Expat can be found at www.libexpat.org.
|
||||
#
|
||||
#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI
|
||||
|
||||
# Hye-Shik Chang's CJKCodecs
|
||||
|
||||
# multibytecodec is required for all the other CJK codec modules
|
||||
#_multibytecodec cjkcodecs/multibytecodec.c
|
||||
|
||||
#_codecs_cn cjkcodecs/_codecs_cn.c
|
||||
#_codecs_hk cjkcodecs/_codecs_hk.c
|
||||
#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
|
||||
#_codecs_jp cjkcodecs/_codecs_jp.c
|
||||
#_codecs_kr cjkcodecs/_codecs_kr.c
|
||||
#_codecs_tw cjkcodecs/_codecs_tw.c
|
||||
|
||||
# Example -- included for reference only:
|
||||
# xx xxmodule.c
|
||||
|
||||
# Another example -- the 'xxsubtype' module shows C-level subtyping in action
|
||||
xxsubtype xxsubtype.c
|
2525
third_party/python/Modules/_asynciomodule.c
vendored
Normal file
2525
third_party/python/Modules/_asynciomodule.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
263
third_party/python/Modules/_bisectmodule.c
vendored
Normal file
263
third_party/python/Modules/_bisectmodule.c
vendored
Normal file
|
@ -0,0 +1,263 @@
|
|||
/* Bisection algorithms. Drop in replacement for bisect.py
|
||||
|
||||
Converted to C by Dmitry Vasiliev (dima at hlabs.spb.ru).
|
||||
*/
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
|
||||
_Py_IDENTIFIER(insert);
|
||||
|
||||
static Py_ssize_t
|
||||
internal_bisect_right(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t hi)
|
||||
{
|
||||
PyObject *litem;
|
||||
Py_ssize_t mid;
|
||||
int res;
|
||||
|
||||
if (lo < 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "lo must be non-negative");
|
||||
return -1;
|
||||
}
|
||||
if (hi == -1) {
|
||||
hi = PySequence_Size(list);
|
||||
if (hi < 0)
|
||||
return -1;
|
||||
}
|
||||
while (lo < hi) {
|
||||
/* The (size_t)cast ensures that the addition and subsequent division
|
||||
are performed as unsigned operations, avoiding difficulties from
|
||||
signed overflow. (See issue 13496.) */
|
||||
mid = ((size_t)lo + hi) / 2;
|
||||
litem = PySequence_GetItem(list, mid);
|
||||
if (litem == NULL)
|
||||
return -1;
|
||||
res = PyObject_RichCompareBool(item, litem, Py_LT);
|
||||
Py_DECREF(litem);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
if (res)
|
||||
hi = mid;
|
||||
else
|
||||
lo = mid + 1;
|
||||
}
|
||||
return lo;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
bisect_right(PyObject *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
PyObject *list, *item;
|
||||
Py_ssize_t lo = 0;
|
||||
Py_ssize_t hi = -1;
|
||||
Py_ssize_t index;
|
||||
static char *keywords[] = {"a", "x", "lo", "hi", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|nn:bisect_right",
|
||||
keywords, &list, &item, &lo, &hi))
|
||||
return NULL;
|
||||
index = internal_bisect_right(list, item, lo, hi);
|
||||
if (index < 0)
|
||||
return NULL;
|
||||
return PyLong_FromSsize_t(index);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bisect_right_doc,
|
||||
"bisect_right(a, x[, lo[, hi]]) -> index\n\
|
||||
\n\
|
||||
Return the index where to insert item x in list a, assuming a is sorted.\n\
|
||||
\n\
|
||||
The return value i is such that all e in a[:i] have e <= x, and all e in\n\
|
||||
a[i:] have e > x. So if x already appears in the list, i points just\n\
|
||||
beyond the rightmost x already there\n\
|
||||
\n\
|
||||
Optional args lo (default 0) and hi (default len(a)) bound the\n\
|
||||
slice of a to be searched.\n");
|
||||
|
||||
static PyObject *
|
||||
insort_right(PyObject *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
PyObject *list, *item, *result;
|
||||
Py_ssize_t lo = 0;
|
||||
Py_ssize_t hi = -1;
|
||||
Py_ssize_t index;
|
||||
static char *keywords[] = {"a", "x", "lo", "hi", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|nn:insort_right",
|
||||
keywords, &list, &item, &lo, &hi))
|
||||
return NULL;
|
||||
index = internal_bisect_right(list, item, lo, hi);
|
||||
if (index < 0)
|
||||
return NULL;
|
||||
if (PyList_CheckExact(list)) {
|
||||
if (PyList_Insert(list, index, item) < 0)
|
||||
return NULL;
|
||||
} else {
|
||||
result = _PyObject_CallMethodId(list, &PyId_insert, "nO", index, item);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
Py_DECREF(result);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(insort_right_doc,
|
||||
"insort_right(a, x[, lo[, hi]])\n\
|
||||
\n\
|
||||
Insert item x in list a, and keep it sorted assuming a is sorted.\n\
|
||||
\n\
|
||||
If x is already in a, insert it to the right of the rightmost x.\n\
|
||||
\n\
|
||||
Optional args lo (default 0) and hi (default len(a)) bound the\n\
|
||||
slice of a to be searched.\n");
|
||||
|
||||
static Py_ssize_t
|
||||
internal_bisect_left(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t hi)
|
||||
{
|
||||
PyObject *litem;
|
||||
Py_ssize_t mid;
|
||||
int res;
|
||||
|
||||
if (lo < 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "lo must be non-negative");
|
||||
return -1;
|
||||
}
|
||||
if (hi == -1) {
|
||||
hi = PySequence_Size(list);
|
||||
if (hi < 0)
|
||||
return -1;
|
||||
}
|
||||
while (lo < hi) {
|
||||
/* The (size_t)cast ensures that the addition and subsequent division
|
||||
are performed as unsigned operations, avoiding difficulties from
|
||||
signed overflow. (See issue 13496.) */
|
||||
mid = ((size_t)lo + hi) / 2;
|
||||
litem = PySequence_GetItem(list, mid);
|
||||
if (litem == NULL)
|
||||
return -1;
|
||||
res = PyObject_RichCompareBool(litem, item, Py_LT);
|
||||
Py_DECREF(litem);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
if (res)
|
||||
lo = mid + 1;
|
||||
else
|
||||
hi = mid;
|
||||
}
|
||||
return lo;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
bisect_left(PyObject *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
PyObject *list, *item;
|
||||
Py_ssize_t lo = 0;
|
||||
Py_ssize_t hi = -1;
|
||||
Py_ssize_t index;
|
||||
static char *keywords[] = {"a", "x", "lo", "hi", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|nn:bisect_left",
|
||||
keywords, &list, &item, &lo, &hi))
|
||||
return NULL;
|
||||
index = internal_bisect_left(list, item, lo, hi);
|
||||
if (index < 0)
|
||||
return NULL;
|
||||
return PyLong_FromSsize_t(index);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bisect_left_doc,
|
||||
"bisect_left(a, x[, lo[, hi]]) -> index\n\
|
||||
\n\
|
||||
Return the index where to insert item x in list a, assuming a is sorted.\n\
|
||||
\n\
|
||||
The return value i is such that all e in a[:i] have e < x, and all e in\n\
|
||||
a[i:] have e >= x. So if x already appears in the list, i points just\n\
|
||||
before the leftmost x already there.\n\
|
||||
\n\
|
||||
Optional args lo (default 0) and hi (default len(a)) bound the\n\
|
||||
slice of a to be searched.\n");
|
||||
|
||||
static PyObject *
|
||||
insort_left(PyObject *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
PyObject *list, *item, *result;
|
||||
Py_ssize_t lo = 0;
|
||||
Py_ssize_t hi = -1;
|
||||
Py_ssize_t index;
|
||||
static char *keywords[] = {"a", "x", "lo", "hi", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|nn:insort_left",
|
||||
keywords, &list, &item, &lo, &hi))
|
||||
return NULL;
|
||||
index = internal_bisect_left(list, item, lo, hi);
|
||||
if (index < 0)
|
||||
return NULL;
|
||||
if (PyList_CheckExact(list)) {
|
||||
if (PyList_Insert(list, index, item) < 0)
|
||||
return NULL;
|
||||
} else {
|
||||
result = _PyObject_CallMethodId(list, &PyId_insert, "nO", index, item);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
Py_DECREF(result);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(insort_left_doc,
|
||||
"insort_left(a, x[, lo[, hi]])\n\
|
||||
\n\
|
||||
Insert item x in list a, and keep it sorted assuming a is sorted.\n\
|
||||
\n\
|
||||
If x is already in a, insert it to the left of the leftmost x.\n\
|
||||
\n\
|
||||
Optional args lo (default 0) and hi (default len(a)) bound the\n\
|
||||
slice of a to be searched.\n");
|
||||
|
||||
PyDoc_STRVAR(bisect_doc, "Alias for bisect_right().\n");
|
||||
PyDoc_STRVAR(insort_doc, "Alias for insort_right().\n");
|
||||
|
||||
static PyMethodDef bisect_methods[] = {
|
||||
{"bisect_right", (PyCFunction)bisect_right,
|
||||
METH_VARARGS|METH_KEYWORDS, bisect_right_doc},
|
||||
{"bisect", (PyCFunction)bisect_right,
|
||||
METH_VARARGS|METH_KEYWORDS, bisect_doc},
|
||||
{"insort_right", (PyCFunction)insort_right,
|
||||
METH_VARARGS|METH_KEYWORDS, insort_right_doc},
|
||||
{"insort", (PyCFunction)insort_right,
|
||||
METH_VARARGS|METH_KEYWORDS, insort_doc},
|
||||
{"bisect_left", (PyCFunction)bisect_left,
|
||||
METH_VARARGS|METH_KEYWORDS, bisect_left_doc},
|
||||
{"insort_left", (PyCFunction)insort_left,
|
||||
METH_VARARGS|METH_KEYWORDS, insort_left_doc},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(module_doc,
|
||||
"Bisection algorithms.\n\
|
||||
\n\
|
||||
This module provides support for maintaining a list in sorted order without\n\
|
||||
having to sort the list after each insertion. For long lists of items with\n\
|
||||
expensive comparison operations, this can be an improvement over the more\n\
|
||||
common approach.\n");
|
||||
|
||||
|
||||
static struct PyModuleDef _bisectmodule = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"_bisect",
|
||||
module_doc,
|
||||
-1,
|
||||
bisect_methods,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC
|
||||
PyInit__bisect(void)
|
||||
{
|
||||
return PyModule_Create(&_bisectmodule);
|
||||
}
|
49
third_party/python/Modules/_blake2/blake2b2s.py
vendored
Executable file
49
third_party/python/Modules/_blake2/blake2b2s.py
vendored
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
BLAKE2 = os.path.join(HERE, 'impl')
|
||||
|
||||
PUBLIC_SEARCH = re.compile(r'\ int (blake2[bs]p?[a-z_]*)\(')
|
||||
|
||||
|
||||
def getfiles():
|
||||
for name in os.listdir(BLAKE2):
|
||||
name = os.path.join(BLAKE2, name)
|
||||
if os.path.isfile(name):
|
||||
yield name
|
||||
|
||||
|
||||
def find_public():
|
||||
public_funcs = set()
|
||||
for name in getfiles():
|
||||
with open(name) as f:
|
||||
for line in f:
|
||||
# find public functions
|
||||
mo = PUBLIC_SEARCH.search(line)
|
||||
if mo:
|
||||
public_funcs.add(mo.group(1))
|
||||
|
||||
for f in sorted(public_funcs):
|
||||
print('#define {0:<18} PyBlake2_{0}'.format(f))
|
||||
|
||||
return public_funcs
|
||||
|
||||
|
||||
def main():
|
||||
lines = []
|
||||
with open(os.path.join(HERE, 'blake2b_impl.c')) as f:
|
||||
for line in f:
|
||||
line = line.replace('blake2b', 'blake2s')
|
||||
line = line.replace('BLAKE2b', 'BLAKE2s')
|
||||
line = line.replace('BLAKE2B', 'BLAKE2S')
|
||||
lines.append(line)
|
||||
with open(os.path.join(HERE, 'blake2s_impl.c'), 'w') as f:
|
||||
f.write(''.join(lines))
|
||||
# find_public()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
463
third_party/python/Modules/_blake2/blake2b_impl.c
vendored
Normal file
463
third_party/python/Modules/_blake2/blake2b_impl.c
vendored
Normal file
|
@ -0,0 +1,463 @@
|
|||
/*
|
||||
* Written in 2013 by Dmitry Chestnykh <dmitry@codingrobots.com>
|
||||
* Modified for CPython by Christian Heimes <christian@python.org>
|
||||
*
|
||||
* To the extent possible under law, the author have dedicated all
|
||||
* copyright and related and neighboring rights to this software to
|
||||
* the public domain worldwide. This software is distributed without
|
||||
* any warranty. http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
/* WARNING: autogenerated file!
|
||||
*
|
||||
* The blake2s_impl.c is autogenerated from blake2b_impl.c.
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
#include "pystrhex.h"
|
||||
#ifdef WITH_THREAD
|
||||
#include "pythread.h"
|
||||
#endif
|
||||
|
||||
#include "../hashlib.h"
|
||||
#include "blake2ns.h"
|
||||
|
||||
#define HAVE_BLAKE2B 1
|
||||
#define BLAKE2_LOCAL_INLINE(type) Py_LOCAL_INLINE(type)
|
||||
|
||||
#include "impl/blake2.h"
|
||||
#include "impl/blake2-impl.h" /* for secure_zero_memory() and store48() */
|
||||
|
||||
#ifdef BLAKE2_USE_SSE
|
||||
#include "impl/blake2b.c"
|
||||
#else
|
||||
#include "impl/blake2b-ref.c"
|
||||
#endif
|
||||
|
||||
|
||||
extern PyTypeObject PyBlake2_BLAKE2bType;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
blake2b_param param;
|
||||
blake2b_state state;
|
||||
#ifdef WITH_THREAD
|
||||
PyThread_type_lock lock;
|
||||
#endif
|
||||
} BLAKE2bObject;
|
||||
|
||||
#include "clinic/blake2b_impl.c.h"
|
||||
|
||||
/*[clinic input]
|
||||
module _blake2
|
||||
class _blake2.blake2b "BLAKE2bObject *" "&PyBlake2_BLAKE2bType"
|
||||
[clinic start generated code]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=d47b0527b39c673f]*/
|
||||
|
||||
|
||||
static BLAKE2bObject *
|
||||
new_BLAKE2bObject(PyTypeObject *type)
|
||||
{
|
||||
BLAKE2bObject *self;
|
||||
self = (BLAKE2bObject *)type->tp_alloc(type, 0);
|
||||
#ifdef WITH_THREAD
|
||||
if (self != NULL) {
|
||||
self->lock = NULL;
|
||||
}
|
||||
#endif
|
||||
return self;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
@classmethod
|
||||
_blake2.blake2b.__new__ as py_blake2b_new
|
||||
data: object(c_default="NULL") = b''
|
||||
/
|
||||
*
|
||||
digest_size: int(c_default="BLAKE2B_OUTBYTES") = _blake2.blake2b.MAX_DIGEST_SIZE
|
||||
key: Py_buffer(c_default="NULL", py_default="b''") = None
|
||||
salt: Py_buffer(c_default="NULL", py_default="b''") = None
|
||||
person: Py_buffer(c_default="NULL", py_default="b''") = None
|
||||
fanout: int = 1
|
||||
depth: int = 1
|
||||
leaf_size as leaf_size_obj: object(c_default="NULL") = 0
|
||||
node_offset as node_offset_obj: object(c_default="NULL") = 0
|
||||
node_depth: int = 0
|
||||
inner_size: int = 0
|
||||
last_node: bool = False
|
||||
|
||||
Return a new BLAKE2b hash object.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
|
||||
Py_buffer *key, Py_buffer *salt, Py_buffer *person,
|
||||
int fanout, int depth, PyObject *leaf_size_obj,
|
||||
PyObject *node_offset_obj, int node_depth,
|
||||
int inner_size, int last_node)
|
||||
/*[clinic end generated code: output=7506d8d890e5f13b input=aca35b33c5612b4b]*/
|
||||
{
|
||||
BLAKE2bObject *self = NULL;
|
||||
Py_buffer buf;
|
||||
|
||||
unsigned long leaf_size = 0;
|
||||
unsigned long long node_offset = 0;
|
||||
|
||||
self = new_BLAKE2bObject(type);
|
||||
if (self == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Zero parameter block. */
|
||||
memset(&self->param, 0, sizeof(self->param));
|
||||
|
||||
/* Set digest size. */
|
||||
if (digest_size <= 0 || digest_size > BLAKE2B_OUTBYTES) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"digest_size must be between 1 and %d bytes",
|
||||
BLAKE2B_OUTBYTES);
|
||||
goto error;
|
||||
}
|
||||
self->param.digest_length = digest_size;
|
||||
|
||||
/* Set salt parameter. */
|
||||
if ((salt->obj != NULL) && salt->len) {
|
||||
if (salt->len > BLAKE2B_SALTBYTES) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"maximum salt length is %d bytes",
|
||||
BLAKE2B_SALTBYTES);
|
||||
goto error;
|
||||
}
|
||||
memcpy(self->param.salt, salt->buf, salt->len);
|
||||
}
|
||||
|
||||
/* Set personalization parameter. */
|
||||
if ((person->obj != NULL) && person->len) {
|
||||
if (person->len > BLAKE2B_PERSONALBYTES) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"maximum person length is %d bytes",
|
||||
BLAKE2B_PERSONALBYTES);
|
||||
goto error;
|
||||
}
|
||||
memcpy(self->param.personal, person->buf, person->len);
|
||||
}
|
||||
|
||||
/* Set tree parameters. */
|
||||
if (fanout < 0 || fanout > 255) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"fanout must be between 0 and 255");
|
||||
goto error;
|
||||
}
|
||||
self->param.fanout = (uint8_t)fanout;
|
||||
|
||||
if (depth <= 0 || depth > 255) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"depth must be between 1 and 255");
|
||||
goto error;
|
||||
}
|
||||
self->param.depth = (uint8_t)depth;
|
||||
|
||||
if (leaf_size_obj != NULL) {
|
||||
leaf_size = PyLong_AsUnsignedLong(leaf_size_obj);
|
||||
if (leaf_size == (unsigned long) -1 && PyErr_Occurred()) {
|
||||
goto error;
|
||||
}
|
||||
if (leaf_size > 0xFFFFFFFFU) {
|
||||
PyErr_SetString(PyExc_OverflowError, "leaf_size is too large");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
// NB: Simple assignment here would be incorrect on big endian platforms.
|
||||
store32(&(self->param.leaf_length), leaf_size);
|
||||
|
||||
if (node_offset_obj != NULL) {
|
||||
node_offset = PyLong_AsUnsignedLongLong(node_offset_obj);
|
||||
if (node_offset == (unsigned long long) -1 && PyErr_Occurred()) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_BLAKE2S
|
||||
if (node_offset > 0xFFFFFFFFFFFFULL) {
|
||||
/* maximum 2**48 - 1 */
|
||||
PyErr_SetString(PyExc_OverflowError, "node_offset is too large");
|
||||
goto error;
|
||||
}
|
||||
store48(&(self->param.node_offset), node_offset);
|
||||
#else
|
||||
// NB: Simple assignment here would be incorrect on big endian platforms.
|
||||
store64(&(self->param.node_offset), node_offset);
|
||||
#endif
|
||||
|
||||
if (node_depth < 0 || node_depth > 255) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"node_depth must be between 0 and 255");
|
||||
goto error;
|
||||
}
|
||||
self->param.node_depth = node_depth;
|
||||
|
||||
if (inner_size < 0 || inner_size > BLAKE2B_OUTBYTES) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"inner_size must be between 0 and is %d",
|
||||
BLAKE2B_OUTBYTES);
|
||||
goto error;
|
||||
}
|
||||
self->param.inner_length = inner_size;
|
||||
|
||||
/* Set key length. */
|
||||
if ((key->obj != NULL) && key->len) {
|
||||
if (key->len > BLAKE2B_KEYBYTES) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"maximum key length is %d bytes",
|
||||
BLAKE2B_KEYBYTES);
|
||||
goto error;
|
||||
}
|
||||
self->param.key_length = (uint8_t)key->len;
|
||||
}
|
||||
|
||||
/* Initialize hash state. */
|
||||
if (blake2b_init_param(&self->state, &self->param) < 0) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"error initializing hash state");
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Set last node flag (must come after initialization). */
|
||||
self->state.last_node = last_node;
|
||||
|
||||
/* Process key block if any. */
|
||||
if (self->param.key_length) {
|
||||
uint8_t block[BLAKE2B_BLOCKBYTES];
|
||||
memset(block, 0, sizeof(block));
|
||||
memcpy(block, key->buf, key->len);
|
||||
blake2b_update(&self->state, block, sizeof(block));
|
||||
secure_zero_memory(block, sizeof(block));
|
||||
}
|
||||
|
||||
/* Process initial data if any. */
|
||||
if (data != NULL) {
|
||||
GET_BUFFER_VIEW_OR_ERROR(data, &buf, goto error);
|
||||
|
||||
if (buf.len >= HASHLIB_GIL_MINSIZE) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
blake2b_update(&self->state, buf.buf, buf.len);
|
||||
Py_END_ALLOW_THREADS
|
||||
} else {
|
||||
blake2b_update(&self->state, buf.buf, buf.len);
|
||||
}
|
||||
PyBuffer_Release(&buf);
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
|
||||
error:
|
||||
if (self != NULL) {
|
||||
Py_DECREF(self);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_blake2.blake2b.copy
|
||||
|
||||
Return a copy of the hash object.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2b_copy_impl(BLAKE2bObject *self)
|
||||
/*[clinic end generated code: output=ff6acee5f93656ae input=e383c2d199fd8a2e]*/
|
||||
{
|
||||
BLAKE2bObject *cpy;
|
||||
|
||||
if ((cpy = new_BLAKE2bObject(Py_TYPE(self))) == NULL)
|
||||
return NULL;
|
||||
|
||||
ENTER_HASHLIB(self);
|
||||
cpy->param = self->param;
|
||||
cpy->state = self->state;
|
||||
LEAVE_HASHLIB(self);
|
||||
return (PyObject *)cpy;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_blake2.blake2b.update
|
||||
|
||||
data: object
|
||||
/
|
||||
|
||||
Update this hash object's state with the provided bytes-like object.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2b_update(BLAKE2bObject *self, PyObject *data)
|
||||
/*[clinic end generated code: output=010dfcbe22654359 input=ffc4aa6a6a225d31]*/
|
||||
{
|
||||
Py_buffer buf;
|
||||
|
||||
GET_BUFFER_VIEW_OR_ERROUT(data, &buf);
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
if (self->lock == NULL && buf.len >= HASHLIB_GIL_MINSIZE)
|
||||
self->lock = PyThread_allocate_lock();
|
||||
|
||||
if (self->lock != NULL) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
PyThread_acquire_lock(self->lock, 1);
|
||||
blake2b_update(&self->state, buf.buf, buf.len);
|
||||
PyThread_release_lock(self->lock);
|
||||
Py_END_ALLOW_THREADS
|
||||
} else {
|
||||
blake2b_update(&self->state, buf.buf, buf.len);
|
||||
}
|
||||
#else
|
||||
blake2b_update(&self->state, buf.buf, buf.len);
|
||||
#endif /* !WITH_THREAD */
|
||||
PyBuffer_Release(&buf);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_blake2.blake2b.digest
|
||||
|
||||
Return the digest value as a bytes object.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2b_digest_impl(BLAKE2bObject *self)
|
||||
/*[clinic end generated code: output=a5864660f4bfc61a input=7d21659e9c5fff02]*/
|
||||
{
|
||||
uint8_t digest[BLAKE2B_OUTBYTES];
|
||||
blake2b_state state_cpy;
|
||||
|
||||
ENTER_HASHLIB(self);
|
||||
state_cpy = self->state;
|
||||
blake2b_final(&state_cpy, digest, self->param.digest_length);
|
||||
LEAVE_HASHLIB(self);
|
||||
return PyBytes_FromStringAndSize((const char *)digest,
|
||||
self->param.digest_length);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_blake2.blake2b.hexdigest
|
||||
|
||||
Return the digest value as a string of hexadecimal digits.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2b_hexdigest_impl(BLAKE2bObject *self)
|
||||
/*[clinic end generated code: output=b5598a87d8794a60 input=76930f6946351f56]*/
|
||||
{
|
||||
uint8_t digest[BLAKE2B_OUTBYTES];
|
||||
blake2b_state state_cpy;
|
||||
|
||||
ENTER_HASHLIB(self);
|
||||
state_cpy = self->state;
|
||||
blake2b_final(&state_cpy, digest, self->param.digest_length);
|
||||
LEAVE_HASHLIB(self);
|
||||
return _Py_strhex((const char *)digest, self->param.digest_length);
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef py_blake2b_methods[] = {
|
||||
_BLAKE2_BLAKE2B_COPY_METHODDEF
|
||||
_BLAKE2_BLAKE2B_DIGEST_METHODDEF
|
||||
_BLAKE2_BLAKE2B_HEXDIGEST_METHODDEF
|
||||
_BLAKE2_BLAKE2B_UPDATE_METHODDEF
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_blake2b_get_name(BLAKE2bObject *self, void *closure)
|
||||
{
|
||||
return PyUnicode_FromString("blake2b");
|
||||
}
|
||||
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_blake2b_get_block_size(BLAKE2bObject *self, void *closure)
|
||||
{
|
||||
return PyLong_FromLong(BLAKE2B_BLOCKBYTES);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_blake2b_get_digest_size(BLAKE2bObject *self, void *closure)
|
||||
{
|
||||
return PyLong_FromLong(self->param.digest_length);
|
||||
}
|
||||
|
||||
|
||||
static PyGetSetDef py_blake2b_getsetters[] = {
|
||||
{"name", (getter)py_blake2b_get_name,
|
||||
NULL, NULL, NULL},
|
||||
{"block_size", (getter)py_blake2b_get_block_size,
|
||||
NULL, NULL, NULL},
|
||||
{"digest_size", (getter)py_blake2b_get_digest_size,
|
||||
NULL, NULL, NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
py_blake2b_dealloc(PyObject *self)
|
||||
{
|
||||
BLAKE2bObject *obj = (BLAKE2bObject *)self;
|
||||
|
||||
/* Try not to leave state in memory. */
|
||||
secure_zero_memory(&obj->param, sizeof(obj->param));
|
||||
secure_zero_memory(&obj->state, sizeof(obj->state));
|
||||
#ifdef WITH_THREAD
|
||||
if (obj->lock) {
|
||||
PyThread_free_lock(obj->lock);
|
||||
obj->lock = NULL;
|
||||
}
|
||||
#endif
|
||||
PyObject_Del(self);
|
||||
}
|
||||
|
||||
|
||||
PyTypeObject PyBlake2_BLAKE2bType = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_blake2.blake2b", /* tp_name */
|
||||
sizeof(BLAKE2bObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
py_blake2b_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||
py_blake2b_new__doc__, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
py_blake2b_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
py_blake2b_getsetters, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
py_blake2b_new, /* tp_new */
|
||||
};
|
105
third_party/python/Modules/_blake2/blake2module.c
vendored
Normal file
105
third_party/python/Modules/_blake2/blake2module.c
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Written in 2013 by Dmitry Chestnykh <dmitry@codingrobots.com>
|
||||
* Modified for CPython by Christian Heimes <christian@python.org>
|
||||
*
|
||||
* To the extent possible under law, the author have dedicated all
|
||||
* copyright and related and neighboring rights to this software to
|
||||
* the public domain worldwide. This software is distributed without
|
||||
* any warranty. http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "impl/blake2.h"
|
||||
|
||||
extern PyTypeObject PyBlake2_BLAKE2bType;
|
||||
extern PyTypeObject PyBlake2_BLAKE2sType;
|
||||
|
||||
|
||||
PyDoc_STRVAR(blake2mod__doc__,
|
||||
"_blake2b provides BLAKE2b for hashlib\n"
|
||||
);
|
||||
|
||||
|
||||
static struct PyMethodDef blake2mod_functions[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static struct PyModuleDef blake2_module = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"_blake2",
|
||||
blake2mod__doc__,
|
||||
-1,
|
||||
blake2mod_functions,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
#define ADD_INT(d, name, value) do { \
|
||||
PyObject *x = PyLong_FromLong(value); \
|
||||
if (!x) { \
|
||||
Py_DECREF(m); \
|
||||
return NULL; \
|
||||
} \
|
||||
if (PyDict_SetItemString(d, name, x) < 0) { \
|
||||
Py_DECREF(m); \
|
||||
return NULL; \
|
||||
} \
|
||||
Py_DECREF(x); \
|
||||
} while(0)
|
||||
|
||||
|
||||
PyMODINIT_FUNC
|
||||
PyInit__blake2(void)
|
||||
{
|
||||
PyObject *m;
|
||||
PyObject *d;
|
||||
|
||||
m = PyModule_Create(&blake2_module);
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
|
||||
/* BLAKE2b */
|
||||
Py_TYPE(&PyBlake2_BLAKE2bType) = &PyType_Type;
|
||||
if (PyType_Ready(&PyBlake2_BLAKE2bType) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(&PyBlake2_BLAKE2bType);
|
||||
PyModule_AddObject(m, "blake2b", (PyObject *)&PyBlake2_BLAKE2bType);
|
||||
|
||||
d = PyBlake2_BLAKE2bType.tp_dict;
|
||||
ADD_INT(d, "SALT_SIZE", BLAKE2B_SALTBYTES);
|
||||
ADD_INT(d, "PERSON_SIZE", BLAKE2B_PERSONALBYTES);
|
||||
ADD_INT(d, "MAX_KEY_SIZE", BLAKE2B_KEYBYTES);
|
||||
ADD_INT(d, "MAX_DIGEST_SIZE", BLAKE2B_OUTBYTES);
|
||||
|
||||
PyModule_AddIntConstant(m, "BLAKE2B_SALT_SIZE", BLAKE2B_SALTBYTES);
|
||||
PyModule_AddIntConstant(m, "BLAKE2B_PERSON_SIZE", BLAKE2B_PERSONALBYTES);
|
||||
PyModule_AddIntConstant(m, "BLAKE2B_MAX_KEY_SIZE", BLAKE2B_KEYBYTES);
|
||||
PyModule_AddIntConstant(m, "BLAKE2B_MAX_DIGEST_SIZE", BLAKE2B_OUTBYTES);
|
||||
|
||||
/* BLAKE2s */
|
||||
Py_TYPE(&PyBlake2_BLAKE2sType) = &PyType_Type;
|
||||
if (PyType_Ready(&PyBlake2_BLAKE2sType) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(&PyBlake2_BLAKE2sType);
|
||||
PyModule_AddObject(m, "blake2s", (PyObject *)&PyBlake2_BLAKE2sType);
|
||||
|
||||
d = PyBlake2_BLAKE2sType.tp_dict;
|
||||
ADD_INT(d, "SALT_SIZE", BLAKE2S_SALTBYTES);
|
||||
ADD_INT(d, "PERSON_SIZE", BLAKE2S_PERSONALBYTES);
|
||||
ADD_INT(d, "MAX_KEY_SIZE", BLAKE2S_KEYBYTES);
|
||||
ADD_INT(d, "MAX_DIGEST_SIZE", BLAKE2S_OUTBYTES);
|
||||
|
||||
PyModule_AddIntConstant(m, "BLAKE2S_SALT_SIZE", BLAKE2S_SALTBYTES);
|
||||
PyModule_AddIntConstant(m, "BLAKE2S_PERSON_SIZE", BLAKE2S_PERSONALBYTES);
|
||||
PyModule_AddIntConstant(m, "BLAKE2S_MAX_KEY_SIZE", BLAKE2S_KEYBYTES);
|
||||
PyModule_AddIntConstant(m, "BLAKE2S_MAX_DIGEST_SIZE", BLAKE2S_OUTBYTES);
|
||||
|
||||
return m;
|
||||
}
|
32
third_party/python/Modules/_blake2/blake2ns.h
vendored
Normal file
32
third_party/python/Modules/_blake2/blake2ns.h
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* Prefix all public blake2 symbols with PyBlake2_
|
||||
*/
|
||||
|
||||
#ifndef Py_BLAKE2_NS
|
||||
#define Py_BLAKE2_NS
|
||||
|
||||
#define blake2b PyBlake2_blake2b
|
||||
#define blake2b_compress PyBlake2_blake2b_compress
|
||||
#define blake2b_final PyBlake2_blake2b_final
|
||||
#define blake2b_init PyBlake2_blake2b_init
|
||||
#define blake2b_init_key PyBlake2_blake2b_init_key
|
||||
#define blake2b_init_param PyBlake2_blake2b_init_param
|
||||
#define blake2b_update PyBlake2_blake2b_update
|
||||
#define blake2bp PyBlake2_blake2bp
|
||||
#define blake2bp_final PyBlake2_blake2bp_final
|
||||
#define blake2bp_init PyBlake2_blake2bp_init
|
||||
#define blake2bp_init_key PyBlake2_blake2bp_init_key
|
||||
#define blake2bp_update PyBlake2_blake2bp_update
|
||||
#define blake2s PyBlake2_blake2s
|
||||
#define blake2s_compress PyBlake2_blake2s_compress
|
||||
#define blake2s_final PyBlake2_blake2s_final
|
||||
#define blake2s_init PyBlake2_blake2s_init
|
||||
#define blake2s_init_key PyBlake2_blake2s_init_key
|
||||
#define blake2s_init_param PyBlake2_blake2s_init_param
|
||||
#define blake2s_update PyBlake2_blake2s_update
|
||||
#define blake2sp PyBlake2_blake2sp
|
||||
#define blake2sp_final PyBlake2_blake2sp_final
|
||||
#define blake2sp_init PyBlake2_blake2sp_init
|
||||
#define blake2sp_init_key PyBlake2_blake2sp_init_key
|
||||
#define blake2sp_update PyBlake2_blake2sp_update
|
||||
|
||||
#endif /* Py_BLAKE2_NS */
|
463
third_party/python/Modules/_blake2/blake2s_impl.c
vendored
Normal file
463
third_party/python/Modules/_blake2/blake2s_impl.c
vendored
Normal file
|
@ -0,0 +1,463 @@
|
|||
/*
|
||||
* Written in 2013 by Dmitry Chestnykh <dmitry@codingrobots.com>
|
||||
* Modified for CPython by Christian Heimes <christian@python.org>
|
||||
*
|
||||
* To the extent possible under law, the author have dedicated all
|
||||
* copyright and related and neighboring rights to this software to
|
||||
* the public domain worldwide. This software is distributed without
|
||||
* any warranty. http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
/* WARNING: autogenerated file!
|
||||
*
|
||||
* The blake2s_impl.c is autogenerated from blake2s_impl.c.
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
#include "pystrhex.h"
|
||||
#ifdef WITH_THREAD
|
||||
#include "pythread.h"
|
||||
#endif
|
||||
|
||||
#include "../hashlib.h"
|
||||
#include "blake2ns.h"
|
||||
|
||||
#define HAVE_BLAKE2S 1
|
||||
#define BLAKE2_LOCAL_INLINE(type) Py_LOCAL_INLINE(type)
|
||||
|
||||
#include "impl/blake2.h"
|
||||
#include "impl/blake2-impl.h" /* for secure_zero_memory() and store48() */
|
||||
|
||||
#ifdef BLAKE2_USE_SSE
|
||||
#include "impl/blake2s.c"
|
||||
#else
|
||||
#include "impl/blake2s-ref.c"
|
||||
#endif
|
||||
|
||||
|
||||
extern PyTypeObject PyBlake2_BLAKE2sType;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
blake2s_param param;
|
||||
blake2s_state state;
|
||||
#ifdef WITH_THREAD
|
||||
PyThread_type_lock lock;
|
||||
#endif
|
||||
} BLAKE2sObject;
|
||||
|
||||
#include "clinic/blake2s_impl.c.h"
|
||||
|
||||
/*[clinic input]
|
||||
module _blake2
|
||||
class _blake2.blake2s "BLAKE2sObject *" "&PyBlake2_BLAKE2sType"
|
||||
[clinic start generated code]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=4b79d7ffe07286ce]*/
|
||||
|
||||
|
||||
static BLAKE2sObject *
|
||||
new_BLAKE2sObject(PyTypeObject *type)
|
||||
{
|
||||
BLAKE2sObject *self;
|
||||
self = (BLAKE2sObject *)type->tp_alloc(type, 0);
|
||||
#ifdef WITH_THREAD
|
||||
if (self != NULL) {
|
||||
self->lock = NULL;
|
||||
}
|
||||
#endif
|
||||
return self;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
@classmethod
|
||||
_blake2.blake2s.__new__ as py_blake2s_new
|
||||
data: object(c_default="NULL") = b''
|
||||
/
|
||||
*
|
||||
digest_size: int(c_default="BLAKE2S_OUTBYTES") = _blake2.blake2s.MAX_DIGEST_SIZE
|
||||
key: Py_buffer(c_default="NULL", py_default="b''") = None
|
||||
salt: Py_buffer(c_default="NULL", py_default="b''") = None
|
||||
person: Py_buffer(c_default="NULL", py_default="b''") = None
|
||||
fanout: int = 1
|
||||
depth: int = 1
|
||||
leaf_size as leaf_size_obj: object(c_default="NULL") = 0
|
||||
node_offset as node_offset_obj: object(c_default="NULL") = 0
|
||||
node_depth: int = 0
|
||||
inner_size: int = 0
|
||||
last_node: bool = False
|
||||
|
||||
Return a new BLAKE2s hash object.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
py_blake2s_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
|
||||
Py_buffer *key, Py_buffer *salt, Py_buffer *person,
|
||||
int fanout, int depth, PyObject *leaf_size_obj,
|
||||
PyObject *node_offset_obj, int node_depth,
|
||||
int inner_size, int last_node)
|
||||
/*[clinic end generated code: output=fe060b258a8cbfc6 input=3abfaabe7f5f62cc]*/
|
||||
{
|
||||
BLAKE2sObject *self = NULL;
|
||||
Py_buffer buf;
|
||||
|
||||
unsigned long leaf_size = 0;
|
||||
unsigned long long node_offset = 0;
|
||||
|
||||
self = new_BLAKE2sObject(type);
|
||||
if (self == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Zero parameter block. */
|
||||
memset(&self->param, 0, sizeof(self->param));
|
||||
|
||||
/* Set digest size. */
|
||||
if (digest_size <= 0 || digest_size > BLAKE2S_OUTBYTES) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"digest_size must be between 1 and %d bytes",
|
||||
BLAKE2S_OUTBYTES);
|
||||
goto error;
|
||||
}
|
||||
self->param.digest_length = digest_size;
|
||||
|
||||
/* Set salt parameter. */
|
||||
if ((salt->obj != NULL) && salt->len) {
|
||||
if (salt->len > BLAKE2S_SALTBYTES) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"maximum salt length is %d bytes",
|
||||
BLAKE2S_SALTBYTES);
|
||||
goto error;
|
||||
}
|
||||
memcpy(self->param.salt, salt->buf, salt->len);
|
||||
}
|
||||
|
||||
/* Set personalization parameter. */
|
||||
if ((person->obj != NULL) && person->len) {
|
||||
if (person->len > BLAKE2S_PERSONALBYTES) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"maximum person length is %d bytes",
|
||||
BLAKE2S_PERSONALBYTES);
|
||||
goto error;
|
||||
}
|
||||
memcpy(self->param.personal, person->buf, person->len);
|
||||
}
|
||||
|
||||
/* Set tree parameters. */
|
||||
if (fanout < 0 || fanout > 255) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"fanout must be between 0 and 255");
|
||||
goto error;
|
||||
}
|
||||
self->param.fanout = (uint8_t)fanout;
|
||||
|
||||
if (depth <= 0 || depth > 255) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"depth must be between 1 and 255");
|
||||
goto error;
|
||||
}
|
||||
self->param.depth = (uint8_t)depth;
|
||||
|
||||
if (leaf_size_obj != NULL) {
|
||||
leaf_size = PyLong_AsUnsignedLong(leaf_size_obj);
|
||||
if (leaf_size == (unsigned long) -1 && PyErr_Occurred()) {
|
||||
goto error;
|
||||
}
|
||||
if (leaf_size > 0xFFFFFFFFU) {
|
||||
PyErr_SetString(PyExc_OverflowError, "leaf_size is too large");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
// NB: Simple assignment here would be incorrect on big endian platforms.
|
||||
store32(&(self->param.leaf_length), leaf_size);
|
||||
|
||||
if (node_offset_obj != NULL) {
|
||||
node_offset = PyLong_AsUnsignedLongLong(node_offset_obj);
|
||||
if (node_offset == (unsigned long long) -1 && PyErr_Occurred()) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_BLAKE2S
|
||||
if (node_offset > 0xFFFFFFFFFFFFULL) {
|
||||
/* maximum 2**48 - 1 */
|
||||
PyErr_SetString(PyExc_OverflowError, "node_offset is too large");
|
||||
goto error;
|
||||
}
|
||||
store48(&(self->param.node_offset), node_offset);
|
||||
#else
|
||||
// NB: Simple assignment here would be incorrect on big endian platforms.
|
||||
store64(&(self->param.node_offset), node_offset);
|
||||
#endif
|
||||
|
||||
if (node_depth < 0 || node_depth > 255) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"node_depth must be between 0 and 255");
|
||||
goto error;
|
||||
}
|
||||
self->param.node_depth = node_depth;
|
||||
|
||||
if (inner_size < 0 || inner_size > BLAKE2S_OUTBYTES) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"inner_size must be between 0 and is %d",
|
||||
BLAKE2S_OUTBYTES);
|
||||
goto error;
|
||||
}
|
||||
self->param.inner_length = inner_size;
|
||||
|
||||
/* Set key length. */
|
||||
if ((key->obj != NULL) && key->len) {
|
||||
if (key->len > BLAKE2S_KEYBYTES) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"maximum key length is %d bytes",
|
||||
BLAKE2S_KEYBYTES);
|
||||
goto error;
|
||||
}
|
||||
self->param.key_length = (uint8_t)key->len;
|
||||
}
|
||||
|
||||
/* Initialize hash state. */
|
||||
if (blake2s_init_param(&self->state, &self->param) < 0) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"error initializing hash state");
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Set last node flag (must come after initialization). */
|
||||
self->state.last_node = last_node;
|
||||
|
||||
/* Process key block if any. */
|
||||
if (self->param.key_length) {
|
||||
uint8_t block[BLAKE2S_BLOCKBYTES];
|
||||
memset(block, 0, sizeof(block));
|
||||
memcpy(block, key->buf, key->len);
|
||||
blake2s_update(&self->state, block, sizeof(block));
|
||||
secure_zero_memory(block, sizeof(block));
|
||||
}
|
||||
|
||||
/* Process initial data if any. */
|
||||
if (data != NULL) {
|
||||
GET_BUFFER_VIEW_OR_ERROR(data, &buf, goto error);
|
||||
|
||||
if (buf.len >= HASHLIB_GIL_MINSIZE) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
blake2s_update(&self->state, buf.buf, buf.len);
|
||||
Py_END_ALLOW_THREADS
|
||||
} else {
|
||||
blake2s_update(&self->state, buf.buf, buf.len);
|
||||
}
|
||||
PyBuffer_Release(&buf);
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
|
||||
error:
|
||||
if (self != NULL) {
|
||||
Py_DECREF(self);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_blake2.blake2s.copy
|
||||
|
||||
Return a copy of the hash object.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2s_copy_impl(BLAKE2sObject *self)
|
||||
/*[clinic end generated code: output=5b90131c4eae275e input=0b9d44942f0fe4b2]*/
|
||||
{
|
||||
BLAKE2sObject *cpy;
|
||||
|
||||
if ((cpy = new_BLAKE2sObject(Py_TYPE(self))) == NULL)
|
||||
return NULL;
|
||||
|
||||
ENTER_HASHLIB(self);
|
||||
cpy->param = self->param;
|
||||
cpy->state = self->state;
|
||||
LEAVE_HASHLIB(self);
|
||||
return (PyObject *)cpy;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_blake2.blake2s.update
|
||||
|
||||
data: object
|
||||
/
|
||||
|
||||
Update this hash object's state with the provided bytes-like object.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2s_update(BLAKE2sObject *self, PyObject *data)
|
||||
/*[clinic end generated code: output=757dc087fec37815 input=97500db2f9de4aaa]*/
|
||||
{
|
||||
Py_buffer buf;
|
||||
|
||||
GET_BUFFER_VIEW_OR_ERROUT(data, &buf);
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
if (self->lock == NULL && buf.len >= HASHLIB_GIL_MINSIZE)
|
||||
self->lock = PyThread_allocate_lock();
|
||||
|
||||
if (self->lock != NULL) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
PyThread_acquire_lock(self->lock, 1);
|
||||
blake2s_update(&self->state, buf.buf, buf.len);
|
||||
PyThread_release_lock(self->lock);
|
||||
Py_END_ALLOW_THREADS
|
||||
} else {
|
||||
blake2s_update(&self->state, buf.buf, buf.len);
|
||||
}
|
||||
#else
|
||||
blake2s_update(&self->state, buf.buf, buf.len);
|
||||
#endif /* !WITH_THREAD */
|
||||
PyBuffer_Release(&buf);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_blake2.blake2s.digest
|
||||
|
||||
Return the digest value as a bytes object.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2s_digest_impl(BLAKE2sObject *self)
|
||||
/*[clinic end generated code: output=40c566ca4bc6bc51 input=f41e0b8d6d937454]*/
|
||||
{
|
||||
uint8_t digest[BLAKE2S_OUTBYTES];
|
||||
blake2s_state state_cpy;
|
||||
|
||||
ENTER_HASHLIB(self);
|
||||
state_cpy = self->state;
|
||||
blake2s_final(&state_cpy, digest, self->param.digest_length);
|
||||
LEAVE_HASHLIB(self);
|
||||
return PyBytes_FromStringAndSize((const char *)digest,
|
||||
self->param.digest_length);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_blake2.blake2s.hexdigest
|
||||
|
||||
Return the digest value as a string of hexadecimal digits.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2s_hexdigest_impl(BLAKE2sObject *self)
|
||||
/*[clinic end generated code: output=15153eb5e59c52eb input=c77a1321567e8952]*/
|
||||
{
|
||||
uint8_t digest[BLAKE2S_OUTBYTES];
|
||||
blake2s_state state_cpy;
|
||||
|
||||
ENTER_HASHLIB(self);
|
||||
state_cpy = self->state;
|
||||
blake2s_final(&state_cpy, digest, self->param.digest_length);
|
||||
LEAVE_HASHLIB(self);
|
||||
return _Py_strhex((const char *)digest, self->param.digest_length);
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef py_blake2s_methods[] = {
|
||||
_BLAKE2_BLAKE2S_COPY_METHODDEF
|
||||
_BLAKE2_BLAKE2S_DIGEST_METHODDEF
|
||||
_BLAKE2_BLAKE2S_HEXDIGEST_METHODDEF
|
||||
_BLAKE2_BLAKE2S_UPDATE_METHODDEF
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_blake2s_get_name(BLAKE2sObject *self, void *closure)
|
||||
{
|
||||
return PyUnicode_FromString("blake2s");
|
||||
}
|
||||
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_blake2s_get_block_size(BLAKE2sObject *self, void *closure)
|
||||
{
|
||||
return PyLong_FromLong(BLAKE2S_BLOCKBYTES);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_blake2s_get_digest_size(BLAKE2sObject *self, void *closure)
|
||||
{
|
||||
return PyLong_FromLong(self->param.digest_length);
|
||||
}
|
||||
|
||||
|
||||
static PyGetSetDef py_blake2s_getsetters[] = {
|
||||
{"name", (getter)py_blake2s_get_name,
|
||||
NULL, NULL, NULL},
|
||||
{"block_size", (getter)py_blake2s_get_block_size,
|
||||
NULL, NULL, NULL},
|
||||
{"digest_size", (getter)py_blake2s_get_digest_size,
|
||||
NULL, NULL, NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
py_blake2s_dealloc(PyObject *self)
|
||||
{
|
||||
BLAKE2sObject *obj = (BLAKE2sObject *)self;
|
||||
|
||||
/* Try not to leave state in memory. */
|
||||
secure_zero_memory(&obj->param, sizeof(obj->param));
|
||||
secure_zero_memory(&obj->state, sizeof(obj->state));
|
||||
#ifdef WITH_THREAD
|
||||
if (obj->lock) {
|
||||
PyThread_free_lock(obj->lock);
|
||||
obj->lock = NULL;
|
||||
}
|
||||
#endif
|
||||
PyObject_Del(self);
|
||||
}
|
||||
|
||||
|
||||
PyTypeObject PyBlake2_BLAKE2sType = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_blake2.blake2s", /* tp_name */
|
||||
sizeof(BLAKE2sObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
py_blake2s_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||
py_blake2s_new__doc__, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
py_blake2s_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
py_blake2s_getsetters, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
py_blake2s_new, /* tp_new */
|
||||
};
|
124
third_party/python/Modules/_blake2/clinic/blake2b_impl.c.h
vendored
Normal file
124
third_party/python/Modules/_blake2/clinic/blake2b_impl.c.h
vendored
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*[clinic input]
|
||||
preserve
|
||||
[clinic start generated code]*/
|
||||
|
||||
PyDoc_STRVAR(py_blake2b_new__doc__,
|
||||
"blake2b(data=b\'\', /, *, digest_size=_blake2.blake2b.MAX_DIGEST_SIZE,\n"
|
||||
" key=b\'\', salt=b\'\', person=b\'\', fanout=1, depth=1, leaf_size=0,\n"
|
||||
" node_offset=0, node_depth=0, inner_size=0, last_node=False)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return a new BLAKE2b hash object.");
|
||||
|
||||
static PyObject *
|
||||
py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
|
||||
Py_buffer *key, Py_buffer *salt, Py_buffer *person,
|
||||
int fanout, int depth, PyObject *leaf_size_obj,
|
||||
PyObject *node_offset_obj, int node_depth,
|
||||
int inner_size, int last_node);
|
||||
|
||||
static PyObject *
|
||||
py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"", "digest_size", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node", NULL};
|
||||
static _PyArg_Parser _parser = {"|O$iy*y*y*iiOOiip:blake2b", _keywords, 0};
|
||||
PyObject *data = NULL;
|
||||
int digest_size = BLAKE2B_OUTBYTES;
|
||||
Py_buffer key = {NULL, NULL};
|
||||
Py_buffer salt = {NULL, NULL};
|
||||
Py_buffer person = {NULL, NULL};
|
||||
int fanout = 1;
|
||||
int depth = 1;
|
||||
PyObject *leaf_size_obj = NULL;
|
||||
PyObject *node_offset_obj = NULL;
|
||||
int node_depth = 0;
|
||||
int inner_size = 0;
|
||||
int last_node = 0;
|
||||
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
|
||||
&data, &digest_size, &key, &salt, &person, &fanout, &depth, &leaf_size_obj, &node_offset_obj, &node_depth, &inner_size, &last_node)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = py_blake2b_new_impl(type, data, digest_size, &key, &salt, &person, fanout, depth, leaf_size_obj, node_offset_obj, node_depth, inner_size, last_node);
|
||||
|
||||
exit:
|
||||
/* Cleanup for key */
|
||||
if (key.obj) {
|
||||
PyBuffer_Release(&key);
|
||||
}
|
||||
/* Cleanup for salt */
|
||||
if (salt.obj) {
|
||||
PyBuffer_Release(&salt);
|
||||
}
|
||||
/* Cleanup for person */
|
||||
if (person.obj) {
|
||||
PyBuffer_Release(&person);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_blake2_blake2b_copy__doc__,
|
||||
"copy($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return a copy of the hash object.");
|
||||
|
||||
#define _BLAKE2_BLAKE2B_COPY_METHODDEF \
|
||||
{"copy", (PyCFunction)_blake2_blake2b_copy, METH_NOARGS, _blake2_blake2b_copy__doc__},
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2b_copy_impl(BLAKE2bObject *self);
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2b_copy(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _blake2_blake2b_copy_impl(self);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_blake2_blake2b_update__doc__,
|
||||
"update($self, data, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Update this hash object\'s state with the provided bytes-like object.");
|
||||
|
||||
#define _BLAKE2_BLAKE2B_UPDATE_METHODDEF \
|
||||
{"update", (PyCFunction)_blake2_blake2b_update, METH_O, _blake2_blake2b_update__doc__},
|
||||
|
||||
PyDoc_STRVAR(_blake2_blake2b_digest__doc__,
|
||||
"digest($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return the digest value as a bytes object.");
|
||||
|
||||
#define _BLAKE2_BLAKE2B_DIGEST_METHODDEF \
|
||||
{"digest", (PyCFunction)_blake2_blake2b_digest, METH_NOARGS, _blake2_blake2b_digest__doc__},
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2b_digest_impl(BLAKE2bObject *self);
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2b_digest(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _blake2_blake2b_digest_impl(self);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_blake2_blake2b_hexdigest__doc__,
|
||||
"hexdigest($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return the digest value as a string of hexadecimal digits.");
|
||||
|
||||
#define _BLAKE2_BLAKE2B_HEXDIGEST_METHODDEF \
|
||||
{"hexdigest", (PyCFunction)_blake2_blake2b_hexdigest, METH_NOARGS, _blake2_blake2b_hexdigest__doc__},
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2b_hexdigest_impl(BLAKE2bObject *self);
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2b_hexdigest(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _blake2_blake2b_hexdigest_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=0eb559f418fc0a21 input=a9049054013a1b77]*/
|
124
third_party/python/Modules/_blake2/clinic/blake2s_impl.c.h
vendored
Normal file
124
third_party/python/Modules/_blake2/clinic/blake2s_impl.c.h
vendored
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*[clinic input]
|
||||
preserve
|
||||
[clinic start generated code]*/
|
||||
|
||||
PyDoc_STRVAR(py_blake2s_new__doc__,
|
||||
"blake2s(data=b\'\', /, *, digest_size=_blake2.blake2s.MAX_DIGEST_SIZE,\n"
|
||||
" key=b\'\', salt=b\'\', person=b\'\', fanout=1, depth=1, leaf_size=0,\n"
|
||||
" node_offset=0, node_depth=0, inner_size=0, last_node=False)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return a new BLAKE2s hash object.");
|
||||
|
||||
static PyObject *
|
||||
py_blake2s_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
|
||||
Py_buffer *key, Py_buffer *salt, Py_buffer *person,
|
||||
int fanout, int depth, PyObject *leaf_size_obj,
|
||||
PyObject *node_offset_obj, int node_depth,
|
||||
int inner_size, int last_node);
|
||||
|
||||
static PyObject *
|
||||
py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"", "digest_size", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node", NULL};
|
||||
static _PyArg_Parser _parser = {"|O$iy*y*y*iiOOiip:blake2s", _keywords, 0};
|
||||
PyObject *data = NULL;
|
||||
int digest_size = BLAKE2S_OUTBYTES;
|
||||
Py_buffer key = {NULL, NULL};
|
||||
Py_buffer salt = {NULL, NULL};
|
||||
Py_buffer person = {NULL, NULL};
|
||||
int fanout = 1;
|
||||
int depth = 1;
|
||||
PyObject *leaf_size_obj = NULL;
|
||||
PyObject *node_offset_obj = NULL;
|
||||
int node_depth = 0;
|
||||
int inner_size = 0;
|
||||
int last_node = 0;
|
||||
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
|
||||
&data, &digest_size, &key, &salt, &person, &fanout, &depth, &leaf_size_obj, &node_offset_obj, &node_depth, &inner_size, &last_node)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = py_blake2s_new_impl(type, data, digest_size, &key, &salt, &person, fanout, depth, leaf_size_obj, node_offset_obj, node_depth, inner_size, last_node);
|
||||
|
||||
exit:
|
||||
/* Cleanup for key */
|
||||
if (key.obj) {
|
||||
PyBuffer_Release(&key);
|
||||
}
|
||||
/* Cleanup for salt */
|
||||
if (salt.obj) {
|
||||
PyBuffer_Release(&salt);
|
||||
}
|
||||
/* Cleanup for person */
|
||||
if (person.obj) {
|
||||
PyBuffer_Release(&person);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_blake2_blake2s_copy__doc__,
|
||||
"copy($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return a copy of the hash object.");
|
||||
|
||||
#define _BLAKE2_BLAKE2S_COPY_METHODDEF \
|
||||
{"copy", (PyCFunction)_blake2_blake2s_copy, METH_NOARGS, _blake2_blake2s_copy__doc__},
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2s_copy_impl(BLAKE2sObject *self);
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2s_copy(BLAKE2sObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _blake2_blake2s_copy_impl(self);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_blake2_blake2s_update__doc__,
|
||||
"update($self, data, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Update this hash object\'s state with the provided bytes-like object.");
|
||||
|
||||
#define _BLAKE2_BLAKE2S_UPDATE_METHODDEF \
|
||||
{"update", (PyCFunction)_blake2_blake2s_update, METH_O, _blake2_blake2s_update__doc__},
|
||||
|
||||
PyDoc_STRVAR(_blake2_blake2s_digest__doc__,
|
||||
"digest($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return the digest value as a bytes object.");
|
||||
|
||||
#define _BLAKE2_BLAKE2S_DIGEST_METHODDEF \
|
||||
{"digest", (PyCFunction)_blake2_blake2s_digest, METH_NOARGS, _blake2_blake2s_digest__doc__},
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2s_digest_impl(BLAKE2sObject *self);
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2s_digest(BLAKE2sObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _blake2_blake2s_digest_impl(self);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_blake2_blake2s_hexdigest__doc__,
|
||||
"hexdigest($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return the digest value as a string of hexadecimal digits.");
|
||||
|
||||
#define _BLAKE2_BLAKE2S_HEXDIGEST_METHODDEF \
|
||||
{"hexdigest", (PyCFunction)_blake2_blake2s_hexdigest, METH_NOARGS, _blake2_blake2s_hexdigest__doc__},
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2s_hexdigest_impl(BLAKE2sObject *self);
|
||||
|
||||
static PyObject *
|
||||
_blake2_blake2s_hexdigest(BLAKE2sObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return _blake2_blake2s_hexdigest_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=13d4b08ea9ee2d62 input=a9049054013a1b77]*/
|
74
third_party/python/Modules/_blake2/impl/blake2-config.h
vendored
Normal file
74
third_party/python/Modules/_blake2/impl/blake2-config.h
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef __BLAKE2_CONFIG_H__
|
||||
#define __BLAKE2_CONFIG_H__
|
||||
|
||||
/* These don't work everywhere */
|
||||
#if defined(__SSE2__) || defined(__x86_64__) || defined(__amd64__)
|
||||
#define HAVE_SSE2
|
||||
#endif
|
||||
|
||||
#if defined(__SSSE3__)
|
||||
#define HAVE_SSSE3
|
||||
#endif
|
||||
|
||||
#if defined(__SSE4_1__)
|
||||
#define HAVE_SSE41
|
||||
#endif
|
||||
|
||||
#if defined(__AVX__)
|
||||
#define HAVE_AVX
|
||||
#endif
|
||||
|
||||
#if defined(__XOP__)
|
||||
#define HAVE_XOP
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_AVX2
|
||||
#ifndef HAVE_AVX
|
||||
#define HAVE_AVX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XOP
|
||||
#ifndef HAVE_AVX
|
||||
#define HAVE_AVX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AVX
|
||||
#ifndef HAVE_SSE41
|
||||
#define HAVE_SSE41
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SSE41
|
||||
#ifndef HAVE_SSSE3
|
||||
#define HAVE_SSSE3
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SSSE3
|
||||
#define HAVE_SSE2
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SSE2)
|
||||
#error "This code requires at least SSE2."
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
139
third_party/python/Modules/_blake2/impl/blake2-impl.h
vendored
Normal file
139
third_party/python/Modules/_blake2/impl/blake2-impl.h
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef __BLAKE2_IMPL_H__
|
||||
#define __BLAKE2_IMPL_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
BLAKE2_LOCAL_INLINE(uint32_t) load32( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
uint32_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
#else
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
uint32_t w = *p++;
|
||||
w |= ( uint32_t )( *p++ ) << 8;
|
||||
w |= ( uint32_t )( *p++ ) << 16;
|
||||
w |= ( uint32_t )( *p++ ) << 24;
|
||||
return w;
|
||||
#endif
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(uint64_t) load64( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
uint64_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
#else
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
uint64_t w = *p++;
|
||||
w |= ( uint64_t )( *p++ ) << 8;
|
||||
w |= ( uint64_t )( *p++ ) << 16;
|
||||
w |= ( uint64_t )( *p++ ) << 24;
|
||||
w |= ( uint64_t )( *p++ ) << 32;
|
||||
w |= ( uint64_t )( *p++ ) << 40;
|
||||
w |= ( uint64_t )( *p++ ) << 48;
|
||||
w |= ( uint64_t )( *p++ ) << 56;
|
||||
return w;
|
||||
#endif
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(void) store32( void *dst, uint32_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w;
|
||||
#endif
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(void) store64( void *dst, uint64_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w;
|
||||
#endif
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(uint64_t) load48( const void *src )
|
||||
{
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
uint64_t w = *p++;
|
||||
w |= ( uint64_t )( *p++ ) << 8;
|
||||
w |= ( uint64_t )( *p++ ) << 16;
|
||||
w |= ( uint64_t )( *p++ ) << 24;
|
||||
w |= ( uint64_t )( *p++ ) << 32;
|
||||
w |= ( uint64_t )( *p++ ) << 40;
|
||||
return w;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(void) store48( void *dst, uint64_t w )
|
||||
{
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(uint32_t) rotl32( const uint32_t w, const unsigned c )
|
||||
{
|
||||
return ( w << c ) | ( w >> ( 32 - c ) );
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(uint64_t) rotl64( const uint64_t w, const unsigned c )
|
||||
{
|
||||
return ( w << c ) | ( w >> ( 64 - c ) );
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(uint32_t) rotr32( const uint32_t w, const unsigned c )
|
||||
{
|
||||
return ( w >> c ) | ( w << ( 32 - c ) );
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(uint64_t) rotr64( const uint64_t w, const unsigned c )
|
||||
{
|
||||
return ( w >> c ) | ( w << ( 64 - c ) );
|
||||
}
|
||||
|
||||
/* prevents compiler optimizing out memset() */
|
||||
BLAKE2_LOCAL_INLINE(void) secure_zero_memory(void *v, size_t n)
|
||||
{
|
||||
static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
|
||||
memset_v(v, 0, n);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
161
third_party/python/Modules/_blake2/impl/blake2.h
vendored
Normal file
161
third_party/python/Modules/_blake2/impl/blake2.h
vendored
Normal file
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - reference C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef __BLAKE2_H__
|
||||
#define __BLAKE2_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef BLAKE2_NO_INLINE
|
||||
#define BLAKE2_LOCAL_INLINE(type) static type
|
||||
#endif
|
||||
|
||||
#ifndef BLAKE2_LOCAL_INLINE
|
||||
#define BLAKE2_LOCAL_INLINE(type) static inline type
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum blake2s_constant
|
||||
{
|
||||
BLAKE2S_BLOCKBYTES = 64,
|
||||
BLAKE2S_OUTBYTES = 32,
|
||||
BLAKE2S_KEYBYTES = 32,
|
||||
BLAKE2S_SALTBYTES = 8,
|
||||
BLAKE2S_PERSONALBYTES = 8
|
||||
};
|
||||
|
||||
enum blake2b_constant
|
||||
{
|
||||
BLAKE2B_BLOCKBYTES = 128,
|
||||
BLAKE2B_OUTBYTES = 64,
|
||||
BLAKE2B_KEYBYTES = 64,
|
||||
BLAKE2B_SALTBYTES = 16,
|
||||
BLAKE2B_PERSONALBYTES = 16
|
||||
};
|
||||
|
||||
typedef struct __blake2s_state
|
||||
{
|
||||
uint32_t h[8];
|
||||
uint32_t t[2];
|
||||
uint32_t f[2];
|
||||
uint8_t buf[2 * BLAKE2S_BLOCKBYTES];
|
||||
size_t buflen;
|
||||
uint8_t last_node;
|
||||
} blake2s_state;
|
||||
|
||||
typedef struct __blake2b_state
|
||||
{
|
||||
uint64_t h[8];
|
||||
uint64_t t[2];
|
||||
uint64_t f[2];
|
||||
uint8_t buf[2 * BLAKE2B_BLOCKBYTES];
|
||||
size_t buflen;
|
||||
uint8_t last_node;
|
||||
} blake2b_state;
|
||||
|
||||
typedef struct __blake2sp_state
|
||||
{
|
||||
blake2s_state S[8][1];
|
||||
blake2s_state R[1];
|
||||
uint8_t buf[8 * BLAKE2S_BLOCKBYTES];
|
||||
size_t buflen;
|
||||
} blake2sp_state;
|
||||
|
||||
typedef struct __blake2bp_state
|
||||
{
|
||||
blake2b_state S[4][1];
|
||||
blake2b_state R[1];
|
||||
uint8_t buf[4 * BLAKE2B_BLOCKBYTES];
|
||||
size_t buflen;
|
||||
} blake2bp_state;
|
||||
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct __blake2s_param
|
||||
{
|
||||
uint8_t digest_length; /* 1 */
|
||||
uint8_t key_length; /* 2 */
|
||||
uint8_t fanout; /* 3 */
|
||||
uint8_t depth; /* 4 */
|
||||
uint32_t leaf_length; /* 8 */
|
||||
uint8_t node_offset[6];// 14
|
||||
uint8_t node_depth; /* 15 */
|
||||
uint8_t inner_length; /* 16 */
|
||||
/* uint8_t reserved[0]; */
|
||||
uint8_t salt[BLAKE2S_SALTBYTES]; /* 24 */
|
||||
uint8_t personal[BLAKE2S_PERSONALBYTES]; /* 32 */
|
||||
} blake2s_param;
|
||||
|
||||
typedef struct __blake2b_param
|
||||
{
|
||||
uint8_t digest_length; /* 1 */
|
||||
uint8_t key_length; /* 2 */
|
||||
uint8_t fanout; /* 3 */
|
||||
uint8_t depth; /* 4 */
|
||||
uint32_t leaf_length; /* 8 */
|
||||
uint64_t node_offset; /* 16 */
|
||||
uint8_t node_depth; /* 17 */
|
||||
uint8_t inner_length; /* 18 */
|
||||
uint8_t reserved[14]; /* 32 */
|
||||
uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */
|
||||
uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */
|
||||
} blake2b_param;
|
||||
#pragma pack(pop)
|
||||
|
||||
/* Streaming API */
|
||||
int blake2s_init( blake2s_state *S, const uint8_t outlen );
|
||||
int blake2s_init_key( blake2s_state *S, const uint8_t outlen, const void *key, const uint8_t keylen );
|
||||
int blake2s_init_param( blake2s_state *S, const blake2s_param *P );
|
||||
int blake2s_update( blake2s_state *S, const uint8_t *in, uint64_t inlen );
|
||||
int blake2s_final( blake2s_state *S, uint8_t *out, uint8_t outlen );
|
||||
|
||||
int blake2b_init( blake2b_state *S, const uint8_t outlen );
|
||||
int blake2b_init_key( blake2b_state *S, const uint8_t outlen, const void *key, const uint8_t keylen );
|
||||
int blake2b_init_param( blake2b_state *S, const blake2b_param *P );
|
||||
int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen );
|
||||
int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen );
|
||||
|
||||
int blake2sp_init( blake2sp_state *S, const uint8_t outlen );
|
||||
int blake2sp_init_key( blake2sp_state *S, const uint8_t outlen, const void *key, const uint8_t keylen );
|
||||
int blake2sp_update( blake2sp_state *S, const uint8_t *in, uint64_t inlen );
|
||||
int blake2sp_final( blake2sp_state *S, uint8_t *out, uint8_t outlen );
|
||||
|
||||
int blake2bp_init( blake2bp_state *S, const uint8_t outlen );
|
||||
int blake2bp_init_key( blake2bp_state *S, const uint8_t outlen, const void *key, const uint8_t keylen );
|
||||
int blake2bp_update( blake2bp_state *S, const uint8_t *in, uint64_t inlen );
|
||||
int blake2bp_final( blake2bp_state *S, uint8_t *out, uint8_t outlen );
|
||||
|
||||
/* Simple API */
|
||||
int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
|
||||
int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
|
||||
|
||||
int blake2sp( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
|
||||
int blake2bp( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
|
||||
|
||||
static inline int blake2( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen )
|
||||
{
|
||||
return blake2b( out, in, key, outlen, inlen, keylen );
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
70
third_party/python/Modules/_blake2/impl/blake2b-load-sse2.h
vendored
Normal file
70
third_party/python/Modules/_blake2/impl/blake2b-load-sse2.h
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef __BLAKE2B_LOAD_SSE2_H__
|
||||
#define __BLAKE2B_LOAD_SSE2_H__
|
||||
|
||||
#define LOAD_MSG_0_1(b0, b1) b0 = _mm_set_epi64x(m2, m0); b1 = _mm_set_epi64x(m6, m4)
|
||||
#define LOAD_MSG_0_2(b0, b1) b0 = _mm_set_epi64x(m3, m1); b1 = _mm_set_epi64x(m7, m5)
|
||||
#define LOAD_MSG_0_3(b0, b1) b0 = _mm_set_epi64x(m10, m8); b1 = _mm_set_epi64x(m14, m12)
|
||||
#define LOAD_MSG_0_4(b0, b1) b0 = _mm_set_epi64x(m11, m9); b1 = _mm_set_epi64x(m15, m13)
|
||||
#define LOAD_MSG_1_1(b0, b1) b0 = _mm_set_epi64x(m4, m14); b1 = _mm_set_epi64x(m13, m9)
|
||||
#define LOAD_MSG_1_2(b0, b1) b0 = _mm_set_epi64x(m8, m10); b1 = _mm_set_epi64x(m6, m15)
|
||||
#define LOAD_MSG_1_3(b0, b1) b0 = _mm_set_epi64x(m0, m1); b1 = _mm_set_epi64x(m5, m11)
|
||||
#define LOAD_MSG_1_4(b0, b1) b0 = _mm_set_epi64x(m2, m12); b1 = _mm_set_epi64x(m3, m7)
|
||||
#define LOAD_MSG_2_1(b0, b1) b0 = _mm_set_epi64x(m12, m11); b1 = _mm_set_epi64x(m15, m5)
|
||||
#define LOAD_MSG_2_2(b0, b1) b0 = _mm_set_epi64x(m0, m8); b1 = _mm_set_epi64x(m13, m2)
|
||||
#define LOAD_MSG_2_3(b0, b1) b0 = _mm_set_epi64x(m3, m10); b1 = _mm_set_epi64x(m9, m7)
|
||||
#define LOAD_MSG_2_4(b0, b1) b0 = _mm_set_epi64x(m6, m14); b1 = _mm_set_epi64x(m4, m1)
|
||||
#define LOAD_MSG_3_1(b0, b1) b0 = _mm_set_epi64x(m3, m7); b1 = _mm_set_epi64x(m11, m13)
|
||||
#define LOAD_MSG_3_2(b0, b1) b0 = _mm_set_epi64x(m1, m9); b1 = _mm_set_epi64x(m14, m12)
|
||||
#define LOAD_MSG_3_3(b0, b1) b0 = _mm_set_epi64x(m5, m2); b1 = _mm_set_epi64x(m15, m4)
|
||||
#define LOAD_MSG_3_4(b0, b1) b0 = _mm_set_epi64x(m10, m6); b1 = _mm_set_epi64x(m8, m0)
|
||||
#define LOAD_MSG_4_1(b0, b1) b0 = _mm_set_epi64x(m5, m9); b1 = _mm_set_epi64x(m10, m2)
|
||||
#define LOAD_MSG_4_2(b0, b1) b0 = _mm_set_epi64x(m7, m0); b1 = _mm_set_epi64x(m15, m4)
|
||||
#define LOAD_MSG_4_3(b0, b1) b0 = _mm_set_epi64x(m11, m14); b1 = _mm_set_epi64x(m3, m6)
|
||||
#define LOAD_MSG_4_4(b0, b1) b0 = _mm_set_epi64x(m12, m1); b1 = _mm_set_epi64x(m13, m8)
|
||||
#define LOAD_MSG_5_1(b0, b1) b0 = _mm_set_epi64x(m6, m2); b1 = _mm_set_epi64x(m8, m0)
|
||||
#define LOAD_MSG_5_2(b0, b1) b0 = _mm_set_epi64x(m10, m12); b1 = _mm_set_epi64x(m3, m11)
|
||||
#define LOAD_MSG_5_3(b0, b1) b0 = _mm_set_epi64x(m7, m4); b1 = _mm_set_epi64x(m1, m15)
|
||||
#define LOAD_MSG_5_4(b0, b1) b0 = _mm_set_epi64x(m5, m13); b1 = _mm_set_epi64x(m9, m14)
|
||||
#define LOAD_MSG_6_1(b0, b1) b0 = _mm_set_epi64x(m1, m12); b1 = _mm_set_epi64x(m4, m14)
|
||||
#define LOAD_MSG_6_2(b0, b1) b0 = _mm_set_epi64x(m15, m5); b1 = _mm_set_epi64x(m10, m13)
|
||||
#define LOAD_MSG_6_3(b0, b1) b0 = _mm_set_epi64x(m6, m0); b1 = _mm_set_epi64x(m8, m9)
|
||||
#define LOAD_MSG_6_4(b0, b1) b0 = _mm_set_epi64x(m3, m7); b1 = _mm_set_epi64x(m11, m2)
|
||||
#define LOAD_MSG_7_1(b0, b1) b0 = _mm_set_epi64x(m7, m13); b1 = _mm_set_epi64x(m3, m12)
|
||||
#define LOAD_MSG_7_2(b0, b1) b0 = _mm_set_epi64x(m14, m11); b1 = _mm_set_epi64x(m9, m1)
|
||||
#define LOAD_MSG_7_3(b0, b1) b0 = _mm_set_epi64x(m15, m5); b1 = _mm_set_epi64x(m2, m8)
|
||||
#define LOAD_MSG_7_4(b0, b1) b0 = _mm_set_epi64x(m4, m0); b1 = _mm_set_epi64x(m10, m6)
|
||||
#define LOAD_MSG_8_1(b0, b1) b0 = _mm_set_epi64x(m14, m6); b1 = _mm_set_epi64x(m0, m11)
|
||||
#define LOAD_MSG_8_2(b0, b1) b0 = _mm_set_epi64x(m9, m15); b1 = _mm_set_epi64x(m8, m3)
|
||||
#define LOAD_MSG_8_3(b0, b1) b0 = _mm_set_epi64x(m13, m12); b1 = _mm_set_epi64x(m10, m1)
|
||||
#define LOAD_MSG_8_4(b0, b1) b0 = _mm_set_epi64x(m7, m2); b1 = _mm_set_epi64x(m5, m4)
|
||||
#define LOAD_MSG_9_1(b0, b1) b0 = _mm_set_epi64x(m8, m10); b1 = _mm_set_epi64x(m1, m7)
|
||||
#define LOAD_MSG_9_2(b0, b1) b0 = _mm_set_epi64x(m4, m2); b1 = _mm_set_epi64x(m5, m6)
|
||||
#define LOAD_MSG_9_3(b0, b1) b0 = _mm_set_epi64x(m9, m15); b1 = _mm_set_epi64x(m13, m3)
|
||||
#define LOAD_MSG_9_4(b0, b1) b0 = _mm_set_epi64x(m14, m11); b1 = _mm_set_epi64x(m0, m12)
|
||||
#define LOAD_MSG_10_1(b0, b1) b0 = _mm_set_epi64x(m2, m0); b1 = _mm_set_epi64x(m6, m4)
|
||||
#define LOAD_MSG_10_2(b0, b1) b0 = _mm_set_epi64x(m3, m1); b1 = _mm_set_epi64x(m7, m5)
|
||||
#define LOAD_MSG_10_3(b0, b1) b0 = _mm_set_epi64x(m10, m8); b1 = _mm_set_epi64x(m14, m12)
|
||||
#define LOAD_MSG_10_4(b0, b1) b0 = _mm_set_epi64x(m11, m9); b1 = _mm_set_epi64x(m15, m13)
|
||||
#define LOAD_MSG_11_1(b0, b1) b0 = _mm_set_epi64x(m4, m14); b1 = _mm_set_epi64x(m13, m9)
|
||||
#define LOAD_MSG_11_2(b0, b1) b0 = _mm_set_epi64x(m8, m10); b1 = _mm_set_epi64x(m6, m15)
|
||||
#define LOAD_MSG_11_3(b0, b1) b0 = _mm_set_epi64x(m0, m1); b1 = _mm_set_epi64x(m5, m11)
|
||||
#define LOAD_MSG_11_4(b0, b1) b0 = _mm_set_epi64x(m2, m12); b1 = _mm_set_epi64x(m3, m7)
|
||||
|
||||
|
||||
#endif
|
||||
|
404
third_party/python/Modules/_blake2/impl/blake2b-load-sse41.h
vendored
Normal file
404
third_party/python/Modules/_blake2/impl/blake2b-load-sse41.h
vendored
Normal file
|
@ -0,0 +1,404 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef __BLAKE2B_LOAD_SSE41_H__
|
||||
#define __BLAKE2B_LOAD_SSE41_H__
|
||||
|
||||
#define LOAD_MSG_0_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m0, m1); \
|
||||
b1 = _mm_unpacklo_epi64(m2, m3); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_0_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m0, m1); \
|
||||
b1 = _mm_unpackhi_epi64(m2, m3); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_0_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m4, m5); \
|
||||
b1 = _mm_unpacklo_epi64(m6, m7); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_0_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m4, m5); \
|
||||
b1 = _mm_unpackhi_epi64(m6, m7); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_1_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m7, m2); \
|
||||
b1 = _mm_unpackhi_epi64(m4, m6); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_1_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m5, m4); \
|
||||
b1 = _mm_alignr_epi8(m3, m7, 8); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_1_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_shuffle_epi32(m0, _MM_SHUFFLE(1,0,3,2)); \
|
||||
b1 = _mm_unpackhi_epi64(m5, m2); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_1_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m6, m1); \
|
||||
b1 = _mm_unpackhi_epi64(m3, m1); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_2_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_alignr_epi8(m6, m5, 8); \
|
||||
b1 = _mm_unpackhi_epi64(m2, m7); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_2_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m4, m0); \
|
||||
b1 = _mm_blend_epi16(m1, m6, 0xF0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_2_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_blend_epi16(m5, m1, 0xF0); \
|
||||
b1 = _mm_unpackhi_epi64(m3, m4); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_2_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m7, m3); \
|
||||
b1 = _mm_alignr_epi8(m2, m0, 8); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_3_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m3, m1); \
|
||||
b1 = _mm_unpackhi_epi64(m6, m5); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_3_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m4, m0); \
|
||||
b1 = _mm_unpacklo_epi64(m6, m7); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_3_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_blend_epi16(m1, m2, 0xF0); \
|
||||
b1 = _mm_blend_epi16(m2, m7, 0xF0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_3_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m3, m5); \
|
||||
b1 = _mm_unpacklo_epi64(m0, m4); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_4_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m4, m2); \
|
||||
b1 = _mm_unpacklo_epi64(m1, m5); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_4_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_blend_epi16(m0, m3, 0xF0); \
|
||||
b1 = _mm_blend_epi16(m2, m7, 0xF0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_4_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_blend_epi16(m7, m5, 0xF0); \
|
||||
b1 = _mm_blend_epi16(m3, m1, 0xF0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_4_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_alignr_epi8(m6, m0, 8); \
|
||||
b1 = _mm_blend_epi16(m4, m6, 0xF0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_5_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m1, m3); \
|
||||
b1 = _mm_unpacklo_epi64(m0, m4); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_5_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m6, m5); \
|
||||
b1 = _mm_unpackhi_epi64(m5, m1); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_5_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_blend_epi16(m2, m3, 0xF0); \
|
||||
b1 = _mm_unpackhi_epi64(m7, m0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_5_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m6, m2); \
|
||||
b1 = _mm_blend_epi16(m7, m4, 0xF0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_6_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_blend_epi16(m6, m0, 0xF0); \
|
||||
b1 = _mm_unpacklo_epi64(m7, m2); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_6_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m2, m7); \
|
||||
b1 = _mm_alignr_epi8(m5, m6, 8); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_6_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m0, m3); \
|
||||
b1 = _mm_shuffle_epi32(m4, _MM_SHUFFLE(1,0,3,2)); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_6_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m3, m1); \
|
||||
b1 = _mm_blend_epi16(m1, m5, 0xF0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_7_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m6, m3); \
|
||||
b1 = _mm_blend_epi16(m6, m1, 0xF0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_7_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_alignr_epi8(m7, m5, 8); \
|
||||
b1 = _mm_unpackhi_epi64(m0, m4); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_7_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m2, m7); \
|
||||
b1 = _mm_unpacklo_epi64(m4, m1); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_7_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m0, m2); \
|
||||
b1 = _mm_unpacklo_epi64(m3, m5); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_8_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m3, m7); \
|
||||
b1 = _mm_alignr_epi8(m0, m5, 8); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_8_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m7, m4); \
|
||||
b1 = _mm_alignr_epi8(m4, m1, 8); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_8_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = m6; \
|
||||
b1 = _mm_alignr_epi8(m5, m0, 8); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_8_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_blend_epi16(m1, m3, 0xF0); \
|
||||
b1 = m2; \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_9_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m5, m4); \
|
||||
b1 = _mm_unpackhi_epi64(m3, m0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_9_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m1, m2); \
|
||||
b1 = _mm_blend_epi16(m3, m2, 0xF0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_9_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m7, m4); \
|
||||
b1 = _mm_unpackhi_epi64(m1, m6); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_9_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_alignr_epi8(m7, m5, 8); \
|
||||
b1 = _mm_unpacklo_epi64(m6, m0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_10_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m0, m1); \
|
||||
b1 = _mm_unpacklo_epi64(m2, m3); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_10_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m0, m1); \
|
||||
b1 = _mm_unpackhi_epi64(m2, m3); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_10_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m4, m5); \
|
||||
b1 = _mm_unpacklo_epi64(m6, m7); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_10_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpackhi_epi64(m4, m5); \
|
||||
b1 = _mm_unpackhi_epi64(m6, m7); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_11_1(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m7, m2); \
|
||||
b1 = _mm_unpackhi_epi64(m4, m6); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_11_2(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m5, m4); \
|
||||
b1 = _mm_alignr_epi8(m3, m7, 8); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_11_3(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_shuffle_epi32(m0, _MM_SHUFFLE(1,0,3,2)); \
|
||||
b1 = _mm_unpackhi_epi64(m5, m2); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LOAD_MSG_11_4(b0, b1) \
|
||||
do \
|
||||
{ \
|
||||
b0 = _mm_unpacklo_epi64(m6, m1); \
|
||||
b1 = _mm_unpackhi_epi64(m3, m1); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#endif
|
||||
|
420
third_party/python/Modules/_blake2/impl/blake2b-ref.c
vendored
Normal file
420
third_party/python/Modules/_blake2/impl/blake2b-ref.c
vendored
Normal file
|
@ -0,0 +1,420 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - reference C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "blake2.h"
|
||||
#include "blake2-impl.h"
|
||||
|
||||
static const uint64_t blake2b_IV[8] =
|
||||
{
|
||||
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
|
||||
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
|
||||
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
|
||||
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
|
||||
};
|
||||
|
||||
static const uint8_t blake2b_sigma[12][16] =
|
||||
{
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
|
||||
};
|
||||
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_set_lastnode( blake2b_state *S )
|
||||
{
|
||||
S->f[1] = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_clear_lastnode( blake2b_state *S )
|
||||
{
|
||||
S->f[1] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Some helper functions, not necessarily useful */
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_is_lastblock( const blake2b_state *S )
|
||||
{
|
||||
return S->f[0] != 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_set_lastblock( blake2b_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2b_set_lastnode( S );
|
||||
|
||||
S->f[0] = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_clear_lastblock( blake2b_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2b_clear_lastnode( S );
|
||||
|
||||
S->f[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_increment_counter( blake2b_state *S, const uint64_t inc )
|
||||
{
|
||||
S->t[0] += inc;
|
||||
S->t[1] += ( S->t[0] < inc );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Parameter-related functions */
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_digest_length( blake2b_param *P, const uint8_t digest_length )
|
||||
{
|
||||
P->digest_length = digest_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_fanout( blake2b_param *P, const uint8_t fanout )
|
||||
{
|
||||
P->fanout = fanout;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_max_depth( blake2b_param *P, const uint8_t depth )
|
||||
{
|
||||
P->depth = depth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_leaf_length( blake2b_param *P, const uint32_t leaf_length )
|
||||
{
|
||||
store32( &P->leaf_length, leaf_length );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_node_offset( blake2b_param *P, const uint64_t node_offset )
|
||||
{
|
||||
store64( &P->node_offset, node_offset );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_node_depth( blake2b_param *P, const uint8_t node_depth )
|
||||
{
|
||||
P->node_depth = node_depth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_inner_length( blake2b_param *P, const uint8_t inner_length )
|
||||
{
|
||||
P->inner_length = inner_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_salt( blake2b_param *P, const uint8_t salt[BLAKE2B_SALTBYTES] )
|
||||
{
|
||||
memcpy( P->salt, salt, BLAKE2B_SALTBYTES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_personal( blake2b_param *P, const uint8_t personal[BLAKE2B_PERSONALBYTES] )
|
||||
{
|
||||
memcpy( P->personal, personal, BLAKE2B_PERSONALBYTES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_init0( blake2b_state *S )
|
||||
{
|
||||
int i;
|
||||
memset( S, 0, sizeof( blake2b_state ) );
|
||||
|
||||
for( i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* init xors IV with input parameter block */
|
||||
int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
|
||||
{
|
||||
const uint8_t *p = ( const uint8_t * )( P );
|
||||
size_t i;
|
||||
|
||||
blake2b_init0( S );
|
||||
|
||||
/* IV XOR ParamBlock */
|
||||
for( i = 0; i < 8; ++i )
|
||||
S->h[i] ^= load64( p + sizeof( S->h[i] ) * i );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int blake2b_init( blake2b_state *S, const uint8_t outlen )
|
||||
{
|
||||
blake2b_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
||||
|
||||
P->digest_length = outlen;
|
||||
P->key_length = 0;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store64( &P->node_offset, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
memset( P->reserved, 0, sizeof( P->reserved ) );
|
||||
memset( P->salt, 0, sizeof( P->salt ) );
|
||||
memset( P->personal, 0, sizeof( P->personal ) );
|
||||
return blake2b_init_param( S, P );
|
||||
}
|
||||
|
||||
|
||||
int blake2b_init_key( blake2b_state *S, const uint8_t outlen, const void *key, const uint8_t keylen )
|
||||
{
|
||||
blake2b_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
||||
|
||||
if ( !key || !keylen || keylen > BLAKE2B_KEYBYTES ) return -1;
|
||||
|
||||
P->digest_length = outlen;
|
||||
P->key_length = keylen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store64( &P->node_offset, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
memset( P->reserved, 0, sizeof( P->reserved ) );
|
||||
memset( P->salt, 0, sizeof( P->salt ) );
|
||||
memset( P->personal, 0, sizeof( P->personal ) );
|
||||
|
||||
if( blake2b_init_param( S, P ) < 0 ) return -1;
|
||||
|
||||
{
|
||||
uint8_t block[BLAKE2B_BLOCKBYTES];
|
||||
memset( block, 0, BLAKE2B_BLOCKBYTES );
|
||||
memcpy( block, key, keylen );
|
||||
blake2b_update( S, block, BLAKE2B_BLOCKBYTES );
|
||||
secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES] )
|
||||
{
|
||||
uint64_t m[16];
|
||||
uint64_t v[16];
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 16; ++i )
|
||||
m[i] = load64( block + i * sizeof( m[i] ) );
|
||||
|
||||
for( i = 0; i < 8; ++i )
|
||||
v[i] = S->h[i];
|
||||
|
||||
v[ 8] = blake2b_IV[0];
|
||||
v[ 9] = blake2b_IV[1];
|
||||
v[10] = blake2b_IV[2];
|
||||
v[11] = blake2b_IV[3];
|
||||
v[12] = S->t[0] ^ blake2b_IV[4];
|
||||
v[13] = S->t[1] ^ blake2b_IV[5];
|
||||
v[14] = S->f[0] ^ blake2b_IV[6];
|
||||
v[15] = S->f[1] ^ blake2b_IV[7];
|
||||
#define G(r,i,a,b,c,d) \
|
||||
do { \
|
||||
a = a + b + m[blake2b_sigma[r][2*i+0]]; \
|
||||
d = rotr64(d ^ a, 32); \
|
||||
c = c + d; \
|
||||
b = rotr64(b ^ c, 24); \
|
||||
a = a + b + m[blake2b_sigma[r][2*i+1]]; \
|
||||
d = rotr64(d ^ a, 16); \
|
||||
c = c + d; \
|
||||
b = rotr64(b ^ c, 63); \
|
||||
} while(0)
|
||||
#define ROUND(r) \
|
||||
do { \
|
||||
G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
|
||||
G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
|
||||
G(r,2,v[ 2],v[ 6],v[10],v[14]); \
|
||||
G(r,3,v[ 3],v[ 7],v[11],v[15]); \
|
||||
G(r,4,v[ 0],v[ 5],v[10],v[15]); \
|
||||
G(r,5,v[ 1],v[ 6],v[11],v[12]); \
|
||||
G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
|
||||
G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
|
||||
} while(0)
|
||||
ROUND( 0 );
|
||||
ROUND( 1 );
|
||||
ROUND( 2 );
|
||||
ROUND( 3 );
|
||||
ROUND( 4 );
|
||||
ROUND( 5 );
|
||||
ROUND( 6 );
|
||||
ROUND( 7 );
|
||||
ROUND( 8 );
|
||||
ROUND( 9 );
|
||||
ROUND( 10 );
|
||||
ROUND( 11 );
|
||||
|
||||
for( i = 0; i < 8; ++i )
|
||||
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
|
||||
|
||||
#undef G
|
||||
#undef ROUND
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* inlen now in bytes */
|
||||
int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen )
|
||||
{
|
||||
while( inlen > 0 )
|
||||
{
|
||||
size_t left = S->buflen;
|
||||
size_t fill = 2 * BLAKE2B_BLOCKBYTES - left;
|
||||
|
||||
if( inlen > fill )
|
||||
{
|
||||
memcpy( S->buf + left, in, fill ); /* Fill buffer */
|
||||
S->buflen += fill;
|
||||
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
||||
blake2b_compress( S, S->buf ); /* Compress */
|
||||
memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES ); /* Shift buffer left */
|
||||
S->buflen -= BLAKE2B_BLOCKBYTES;
|
||||
in += fill;
|
||||
inlen -= fill;
|
||||
}
|
||||
else /* inlen <= fill */
|
||||
{
|
||||
memcpy( S->buf + left, in, (size_t)inlen );
|
||||
S->buflen += (size_t)inlen; /* Be lazy, do not compress */
|
||||
in += inlen;
|
||||
inlen -= inlen;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Is this correct? */
|
||||
int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen )
|
||||
{
|
||||
uint8_t buffer[BLAKE2B_OUTBYTES] = {0};
|
||||
int i;
|
||||
|
||||
if( out == NULL || outlen == 0 || outlen > BLAKE2B_OUTBYTES )
|
||||
return -1;
|
||||
|
||||
if( blake2b_is_lastblock( S ) )
|
||||
return -1;
|
||||
|
||||
if( S->buflen > BLAKE2B_BLOCKBYTES )
|
||||
{
|
||||
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
||||
blake2b_compress( S, S->buf );
|
||||
S->buflen -= BLAKE2B_BLOCKBYTES;
|
||||
memmove( S->buf, S->buf + BLAKE2B_BLOCKBYTES, S->buflen );
|
||||
}
|
||||
|
||||
blake2b_increment_counter( S, S->buflen );
|
||||
blake2b_set_lastblock( S );
|
||||
memset( S->buf + S->buflen, 0, 2 * BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */
|
||||
blake2b_compress( S, S->buf );
|
||||
|
||||
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
||||
store64( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
||||
|
||||
memcpy( out, buffer, outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* inlen, at least, should be uint64_t. Others can be size_t. */
|
||||
int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen )
|
||||
{
|
||||
blake2b_state S[1];
|
||||
|
||||
/* Verify parameters */
|
||||
if ( NULL == in && inlen > 0 ) return -1;
|
||||
|
||||
if ( NULL == out ) return -1;
|
||||
|
||||
if( NULL == key && keylen > 0 ) return -1;
|
||||
|
||||
if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
|
||||
|
||||
if( keylen > BLAKE2B_KEYBYTES ) return -1;
|
||||
|
||||
if( keylen > 0 )
|
||||
{
|
||||
if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( blake2b_init( S, outlen ) < 0 ) return -1;
|
||||
}
|
||||
|
||||
blake2b_update( S, ( const uint8_t * )in, inlen );
|
||||
blake2b_final( S, out, outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(SUPERCOP)
|
||||
int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen )
|
||||
{
|
||||
return blake2b( out, in, NULL, BLAKE2B_OUTBYTES, inlen, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BLAKE2B_SELFTEST)
|
||||
#include <string.h>
|
||||
#include "blake2-kat.h"
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
uint8_t key[BLAKE2B_KEYBYTES];
|
||||
uint8_t buf[KAT_LENGTH];
|
||||
size_t i;
|
||||
|
||||
for( i = 0; i < BLAKE2B_KEYBYTES; ++i )
|
||||
key[i] = ( uint8_t )i;
|
||||
|
||||
for( i = 0; i < KAT_LENGTH; ++i )
|
||||
buf[i] = ( uint8_t )i;
|
||||
|
||||
for( i = 0; i < KAT_LENGTH; ++i )
|
||||
{
|
||||
uint8_t hash[BLAKE2B_OUTBYTES];
|
||||
blake2b( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES );
|
||||
|
||||
if( 0 != memcmp( hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES ) )
|
||||
{
|
||||
puts( "error" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
puts( "ok" );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
159
third_party/python/Modules/_blake2/impl/blake2b-round.h
vendored
Normal file
159
third_party/python/Modules/_blake2/impl/blake2b-round.h
vendored
Normal file
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef __BLAKE2B_ROUND_H__
|
||||
#define __BLAKE2B_ROUND_H__
|
||||
|
||||
#define LOADU(p) _mm_loadu_si128( (const __m128i *)(p) )
|
||||
#define STOREU(p,r) _mm_storeu_si128((__m128i *)(p), r)
|
||||
|
||||
#define TOF(reg) _mm_castsi128_ps((reg))
|
||||
#define TOI(reg) _mm_castps_si128((reg))
|
||||
|
||||
#define LIKELY(x) __builtin_expect((x),1)
|
||||
|
||||
|
||||
/* Microarchitecture-specific macros */
|
||||
#ifndef HAVE_XOP
|
||||
#ifdef HAVE_SSSE3
|
||||
#define _mm_roti_epi64(x, c) \
|
||||
(-(c) == 32) ? _mm_shuffle_epi32((x), _MM_SHUFFLE(2,3,0,1)) \
|
||||
: (-(c) == 24) ? _mm_shuffle_epi8((x), r24) \
|
||||
: (-(c) == 16) ? _mm_shuffle_epi8((x), r16) \
|
||||
: (-(c) == 63) ? _mm_xor_si128(_mm_srli_epi64((x), -(c)), _mm_add_epi64((x), (x))) \
|
||||
: _mm_xor_si128(_mm_srli_epi64((x), -(c)), _mm_slli_epi64((x), 64-(-(c))))
|
||||
#else
|
||||
#define _mm_roti_epi64(r, c) _mm_xor_si128(_mm_srli_epi64( (r), -(c) ),_mm_slli_epi64( (r), 64-(-(c)) ))
|
||||
#endif
|
||||
#else
|
||||
/* ... */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1) \
|
||||
row1l = _mm_add_epi64(_mm_add_epi64(row1l, b0), row2l); \
|
||||
row1h = _mm_add_epi64(_mm_add_epi64(row1h, b1), row2h); \
|
||||
\
|
||||
row4l = _mm_xor_si128(row4l, row1l); \
|
||||
row4h = _mm_xor_si128(row4h, row1h); \
|
||||
\
|
||||
row4l = _mm_roti_epi64(row4l, -32); \
|
||||
row4h = _mm_roti_epi64(row4h, -32); \
|
||||
\
|
||||
row3l = _mm_add_epi64(row3l, row4l); \
|
||||
row3h = _mm_add_epi64(row3h, row4h); \
|
||||
\
|
||||
row2l = _mm_xor_si128(row2l, row3l); \
|
||||
row2h = _mm_xor_si128(row2h, row3h); \
|
||||
\
|
||||
row2l = _mm_roti_epi64(row2l, -24); \
|
||||
row2h = _mm_roti_epi64(row2h, -24); \
|
||||
|
||||
#define G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1) \
|
||||
row1l = _mm_add_epi64(_mm_add_epi64(row1l, b0), row2l); \
|
||||
row1h = _mm_add_epi64(_mm_add_epi64(row1h, b1), row2h); \
|
||||
\
|
||||
row4l = _mm_xor_si128(row4l, row1l); \
|
||||
row4h = _mm_xor_si128(row4h, row1h); \
|
||||
\
|
||||
row4l = _mm_roti_epi64(row4l, -16); \
|
||||
row4h = _mm_roti_epi64(row4h, -16); \
|
||||
\
|
||||
row3l = _mm_add_epi64(row3l, row4l); \
|
||||
row3h = _mm_add_epi64(row3h, row4h); \
|
||||
\
|
||||
row2l = _mm_xor_si128(row2l, row3l); \
|
||||
row2h = _mm_xor_si128(row2h, row3h); \
|
||||
\
|
||||
row2l = _mm_roti_epi64(row2l, -63); \
|
||||
row2h = _mm_roti_epi64(row2h, -63); \
|
||||
|
||||
#if defined(HAVE_SSSE3)
|
||||
#define DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \
|
||||
t0 = _mm_alignr_epi8(row2h, row2l, 8); \
|
||||
t1 = _mm_alignr_epi8(row2l, row2h, 8); \
|
||||
row2l = t0; \
|
||||
row2h = t1; \
|
||||
\
|
||||
t0 = row3l; \
|
||||
row3l = row3h; \
|
||||
row3h = t0; \
|
||||
\
|
||||
t0 = _mm_alignr_epi8(row4h, row4l, 8); \
|
||||
t1 = _mm_alignr_epi8(row4l, row4h, 8); \
|
||||
row4l = t1; \
|
||||
row4h = t0;
|
||||
|
||||
#define UNDIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \
|
||||
t0 = _mm_alignr_epi8(row2l, row2h, 8); \
|
||||
t1 = _mm_alignr_epi8(row2h, row2l, 8); \
|
||||
row2l = t0; \
|
||||
row2h = t1; \
|
||||
\
|
||||
t0 = row3l; \
|
||||
row3l = row3h; \
|
||||
row3h = t0; \
|
||||
\
|
||||
t0 = _mm_alignr_epi8(row4l, row4h, 8); \
|
||||
t1 = _mm_alignr_epi8(row4h, row4l, 8); \
|
||||
row4l = t1; \
|
||||
row4h = t0;
|
||||
#else
|
||||
|
||||
#define DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \
|
||||
t0 = row4l;\
|
||||
t1 = row2l;\
|
||||
row4l = row3l;\
|
||||
row3l = row3h;\
|
||||
row3h = row4l;\
|
||||
row4l = _mm_unpackhi_epi64(row4h, _mm_unpacklo_epi64(t0, t0)); \
|
||||
row4h = _mm_unpackhi_epi64(t0, _mm_unpacklo_epi64(row4h, row4h)); \
|
||||
row2l = _mm_unpackhi_epi64(row2l, _mm_unpacklo_epi64(row2h, row2h)); \
|
||||
row2h = _mm_unpackhi_epi64(row2h, _mm_unpacklo_epi64(t1, t1))
|
||||
|
||||
#define UNDIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \
|
||||
t0 = row3l;\
|
||||
row3l = row3h;\
|
||||
row3h = t0;\
|
||||
t0 = row2l;\
|
||||
t1 = row4l;\
|
||||
row2l = _mm_unpackhi_epi64(row2h, _mm_unpacklo_epi64(row2l, row2l)); \
|
||||
row2h = _mm_unpackhi_epi64(t0, _mm_unpacklo_epi64(row2h, row2h)); \
|
||||
row4l = _mm_unpackhi_epi64(row4l, _mm_unpacklo_epi64(row4h, row4h)); \
|
||||
row4h = _mm_unpackhi_epi64(row4h, _mm_unpacklo_epi64(t1, t1))
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SSE41)
|
||||
#include "blake2b-load-sse41.h"
|
||||
#else
|
||||
#include "blake2b-load-sse2.h"
|
||||
#endif
|
||||
|
||||
#define ROUND(r) \
|
||||
LOAD_MSG_ ##r ##_1(b0, b1); \
|
||||
G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \
|
||||
LOAD_MSG_ ##r ##_2(b0, b1); \
|
||||
G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \
|
||||
DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h); \
|
||||
LOAD_MSG_ ##r ##_3(b0, b1); \
|
||||
G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \
|
||||
LOAD_MSG_ ##r ##_4(b0, b1); \
|
||||
G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \
|
||||
UNDIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h);
|
||||
|
||||
#endif
|
||||
|
453
third_party/python/Modules/_blake2/impl/blake2b.c
vendored
Normal file
453
third_party/python/Modules/_blake2/impl/blake2b.c
vendored
Normal file
|
@ -0,0 +1,453 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "blake2.h"
|
||||
#include "blake2-impl.h"
|
||||
|
||||
#include "blake2-config.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h> /* for _mm_set_epi64x */
|
||||
#endif
|
||||
#include <emmintrin.h>
|
||||
#if defined(HAVE_SSSE3)
|
||||
#include <tmmintrin.h>
|
||||
#endif
|
||||
#if defined(HAVE_SSE41)
|
||||
#include <smmintrin.h>
|
||||
#endif
|
||||
#if defined(HAVE_AVX)
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
#if defined(HAVE_XOP)
|
||||
#include <x86intrin.h>
|
||||
#endif
|
||||
|
||||
#include "blake2b-round.h"
|
||||
|
||||
static const uint64_t blake2b_IV[8] =
|
||||
{
|
||||
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
|
||||
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
|
||||
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
|
||||
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
|
||||
};
|
||||
|
||||
static const uint8_t blake2b_sigma[12][16] =
|
||||
{
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
|
||||
};
|
||||
|
||||
|
||||
/* Some helper functions, not necessarily useful */
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_set_lastnode( blake2b_state *S )
|
||||
{
|
||||
S->f[1] = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_clear_lastnode( blake2b_state *S )
|
||||
{
|
||||
S->f[1] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_is_lastblock( const blake2b_state *S )
|
||||
{
|
||||
return S->f[0] != 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_set_lastblock( blake2b_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2b_set_lastnode( S );
|
||||
|
||||
S->f[0] = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_clear_lastblock( blake2b_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2b_clear_lastnode( S );
|
||||
|
||||
S->f[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_increment_counter( blake2b_state *S, const uint64_t inc )
|
||||
{
|
||||
#if __x86_64__
|
||||
/* ADD/ADC chain */
|
||||
__uint128_t t = ( ( __uint128_t )S->t[1] << 64 ) | S->t[0];
|
||||
t += inc;
|
||||
S->t[0] = ( uint64_t )( t >> 0 );
|
||||
S->t[1] = ( uint64_t )( t >> 64 );
|
||||
#else
|
||||
S->t[0] += inc;
|
||||
S->t[1] += ( S->t[0] < inc );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Parameter-related functions */
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_digest_length( blake2b_param *P, const uint8_t digest_length )
|
||||
{
|
||||
P->digest_length = digest_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_fanout( blake2b_param *P, const uint8_t fanout )
|
||||
{
|
||||
P->fanout = fanout;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_max_depth( blake2b_param *P, const uint8_t depth )
|
||||
{
|
||||
P->depth = depth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_leaf_length( blake2b_param *P, const uint32_t leaf_length )
|
||||
{
|
||||
P->leaf_length = leaf_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_node_offset( blake2b_param *P, const uint64_t node_offset )
|
||||
{
|
||||
P->node_offset = node_offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_node_depth( blake2b_param *P, const uint8_t node_depth )
|
||||
{
|
||||
P->node_depth = node_depth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_inner_length( blake2b_param *P, const uint8_t inner_length )
|
||||
{
|
||||
P->inner_length = inner_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_salt( blake2b_param *P, const uint8_t salt[BLAKE2B_SALTBYTES] )
|
||||
{
|
||||
memcpy( P->salt, salt, BLAKE2B_SALTBYTES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_param_set_personal( blake2b_param *P, const uint8_t personal[BLAKE2B_PERSONALBYTES] )
|
||||
{
|
||||
memcpy( P->personal, personal, BLAKE2B_PERSONALBYTES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_init0( blake2b_state *S )
|
||||
{
|
||||
int i;
|
||||
memset( S, 0, sizeof( blake2b_state ) );
|
||||
|
||||
for( i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* init xors IV with input parameter block */
|
||||
int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
|
||||
{
|
||||
/*blake2b_init0( S ); */
|
||||
const uint8_t * v = ( const uint8_t * )( blake2b_IV );
|
||||
const uint8_t * p = ( const uint8_t * )( P );
|
||||
uint8_t * h = ( uint8_t * )( S->h );
|
||||
int i;
|
||||
/* IV XOR ParamBlock */
|
||||
memset( S, 0, sizeof( blake2b_state ) );
|
||||
|
||||
for( i = 0; i < BLAKE2B_OUTBYTES; ++i ) h[i] = v[i] ^ p[i];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Some sort of default parameter block initialization, for sequential blake2b */
|
||||
int blake2b_init( blake2b_state *S, const uint8_t outlen )
|
||||
{
|
||||
const blake2b_param P =
|
||||
{
|
||||
outlen,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{0},
|
||||
{0},
|
||||
{0}
|
||||
};
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
||||
|
||||
return blake2b_init_param( S, &P );
|
||||
}
|
||||
|
||||
int blake2b_init_key( blake2b_state *S, const uint8_t outlen, const void *key, const uint8_t keylen )
|
||||
{
|
||||
const blake2b_param P =
|
||||
{
|
||||
outlen,
|
||||
keylen,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{0},
|
||||
{0},
|
||||
{0}
|
||||
};
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
||||
|
||||
if ( ( !keylen ) || keylen > BLAKE2B_KEYBYTES ) return -1;
|
||||
|
||||
if( blake2b_init_param( S, &P ) < 0 )
|
||||
return 0;
|
||||
|
||||
{
|
||||
uint8_t block[BLAKE2B_BLOCKBYTES];
|
||||
memset( block, 0, BLAKE2B_BLOCKBYTES );
|
||||
memcpy( block, key, keylen );
|
||||
blake2b_update( S, block, BLAKE2B_BLOCKBYTES );
|
||||
secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES] )
|
||||
{
|
||||
__m128i row1l, row1h;
|
||||
__m128i row2l, row2h;
|
||||
__m128i row3l, row3h;
|
||||
__m128i row4l, row4h;
|
||||
__m128i b0, b1;
|
||||
__m128i t0, t1;
|
||||
#if defined(HAVE_SSSE3) && !defined(HAVE_XOP)
|
||||
const __m128i r16 = _mm_setr_epi8( 2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9 );
|
||||
const __m128i r24 = _mm_setr_epi8( 3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10 );
|
||||
#endif
|
||||
#if defined(HAVE_SSE41)
|
||||
const __m128i m0 = LOADU( block + 00 );
|
||||
const __m128i m1 = LOADU( block + 16 );
|
||||
const __m128i m2 = LOADU( block + 32 );
|
||||
const __m128i m3 = LOADU( block + 48 );
|
||||
const __m128i m4 = LOADU( block + 64 );
|
||||
const __m128i m5 = LOADU( block + 80 );
|
||||
const __m128i m6 = LOADU( block + 96 );
|
||||
const __m128i m7 = LOADU( block + 112 );
|
||||
#else
|
||||
const uint64_t m0 = ( ( uint64_t * )block )[ 0];
|
||||
const uint64_t m1 = ( ( uint64_t * )block )[ 1];
|
||||
const uint64_t m2 = ( ( uint64_t * )block )[ 2];
|
||||
const uint64_t m3 = ( ( uint64_t * )block )[ 3];
|
||||
const uint64_t m4 = ( ( uint64_t * )block )[ 4];
|
||||
const uint64_t m5 = ( ( uint64_t * )block )[ 5];
|
||||
const uint64_t m6 = ( ( uint64_t * )block )[ 6];
|
||||
const uint64_t m7 = ( ( uint64_t * )block )[ 7];
|
||||
const uint64_t m8 = ( ( uint64_t * )block )[ 8];
|
||||
const uint64_t m9 = ( ( uint64_t * )block )[ 9];
|
||||
const uint64_t m10 = ( ( uint64_t * )block )[10];
|
||||
const uint64_t m11 = ( ( uint64_t * )block )[11];
|
||||
const uint64_t m12 = ( ( uint64_t * )block )[12];
|
||||
const uint64_t m13 = ( ( uint64_t * )block )[13];
|
||||
const uint64_t m14 = ( ( uint64_t * )block )[14];
|
||||
const uint64_t m15 = ( ( uint64_t * )block )[15];
|
||||
#endif
|
||||
row1l = LOADU( &S->h[0] );
|
||||
row1h = LOADU( &S->h[2] );
|
||||
row2l = LOADU( &S->h[4] );
|
||||
row2h = LOADU( &S->h[6] );
|
||||
row3l = LOADU( &blake2b_IV[0] );
|
||||
row3h = LOADU( &blake2b_IV[2] );
|
||||
row4l = _mm_xor_si128( LOADU( &blake2b_IV[4] ), LOADU( &S->t[0] ) );
|
||||
row4h = _mm_xor_si128( LOADU( &blake2b_IV[6] ), LOADU( &S->f[0] ) );
|
||||
ROUND( 0 );
|
||||
ROUND( 1 );
|
||||
ROUND( 2 );
|
||||
ROUND( 3 );
|
||||
ROUND( 4 );
|
||||
ROUND( 5 );
|
||||
ROUND( 6 );
|
||||
ROUND( 7 );
|
||||
ROUND( 8 );
|
||||
ROUND( 9 );
|
||||
ROUND( 10 );
|
||||
ROUND( 11 );
|
||||
row1l = _mm_xor_si128( row3l, row1l );
|
||||
row1h = _mm_xor_si128( row3h, row1h );
|
||||
STOREU( &S->h[0], _mm_xor_si128( LOADU( &S->h[0] ), row1l ) );
|
||||
STOREU( &S->h[2], _mm_xor_si128( LOADU( &S->h[2] ), row1h ) );
|
||||
row2l = _mm_xor_si128( row4l, row2l );
|
||||
row2h = _mm_xor_si128( row4h, row2h );
|
||||
STOREU( &S->h[4], _mm_xor_si128( LOADU( &S->h[4] ), row2l ) );
|
||||
STOREU( &S->h[6], _mm_xor_si128( LOADU( &S->h[6] ), row2h ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen )
|
||||
{
|
||||
while( inlen > 0 )
|
||||
{
|
||||
size_t left = S->buflen;
|
||||
size_t fill = 2 * BLAKE2B_BLOCKBYTES - left;
|
||||
|
||||
if( inlen > fill )
|
||||
{
|
||||
memcpy( S->buf + left, in, fill ); /* Fill buffer */
|
||||
S->buflen += fill;
|
||||
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
||||
blake2b_compress( S, S->buf ); /* Compress */
|
||||
memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES ); /* Shift buffer left */
|
||||
S->buflen -= BLAKE2B_BLOCKBYTES;
|
||||
in += fill;
|
||||
inlen -= fill;
|
||||
}
|
||||
else /* inlen <= fill */
|
||||
{
|
||||
memcpy( S->buf + left, in, inlen );
|
||||
S->buflen += inlen; /* Be lazy, do not compress */
|
||||
in += inlen;
|
||||
inlen -= inlen;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen )
|
||||
{
|
||||
if( outlen > BLAKE2B_OUTBYTES )
|
||||
return -1;
|
||||
|
||||
if( blake2b_is_lastblock( S ) )
|
||||
return -1;
|
||||
|
||||
if( S->buflen > BLAKE2B_BLOCKBYTES )
|
||||
{
|
||||
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
||||
blake2b_compress( S, S->buf );
|
||||
S->buflen -= BLAKE2B_BLOCKBYTES;
|
||||
memmove( S->buf, S->buf + BLAKE2B_BLOCKBYTES, S->buflen );
|
||||
}
|
||||
|
||||
blake2b_increment_counter( S, S->buflen );
|
||||
blake2b_set_lastblock( S );
|
||||
memset( S->buf + S->buflen, 0, 2 * BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */
|
||||
blake2b_compress( S, S->buf );
|
||||
memcpy( out, &S->h[0], outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen )
|
||||
{
|
||||
blake2b_state S[1];
|
||||
|
||||
/* Verify parameters */
|
||||
if ( NULL == in && inlen > 0 ) return -1;
|
||||
|
||||
if ( NULL == out ) return -1;
|
||||
|
||||
if( NULL == key && keylen > 0 ) return -1;
|
||||
|
||||
if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
|
||||
|
||||
if( keylen > BLAKE2B_KEYBYTES ) return -1;
|
||||
|
||||
if( keylen )
|
||||
{
|
||||
if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( blake2b_init( S, outlen ) < 0 ) return -1;
|
||||
}
|
||||
|
||||
blake2b_update( S, ( const uint8_t * )in, inlen );
|
||||
blake2b_final( S, out, outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(SUPERCOP)
|
||||
int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen )
|
||||
{
|
||||
return blake2b( out, in, NULL, BLAKE2B_OUTBYTES, inlen, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BLAKE2B_SELFTEST)
|
||||
#include <string.h>
|
||||
#include "blake2-kat.h"
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
uint8_t key[BLAKE2B_KEYBYTES];
|
||||
uint8_t buf[KAT_LENGTH];
|
||||
size_t i;
|
||||
|
||||
for( i = 0; i < BLAKE2B_KEYBYTES; ++i )
|
||||
key[i] = ( uint8_t )i;
|
||||
|
||||
for( i = 0; i < KAT_LENGTH; ++i )
|
||||
buf[i] = ( uint8_t )i;
|
||||
|
||||
for( i = 0; i < KAT_LENGTH; ++i )
|
||||
{
|
||||
uint8_t hash[BLAKE2B_OUTBYTES];
|
||||
blake2b( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES );
|
||||
|
||||
if( 0 != memcmp( hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES ) )
|
||||
{
|
||||
puts( "error" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
puts( "ok" );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
61
third_party/python/Modules/_blake2/impl/blake2s-load-sse2.h
vendored
Normal file
61
third_party/python/Modules/_blake2/impl/blake2s-load-sse2.h
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef __BLAKE2S_LOAD_SSE2_H__
|
||||
#define __BLAKE2S_LOAD_SSE2_H__
|
||||
|
||||
#define LOAD_MSG_0_1(buf) buf = _mm_set_epi32(m6,m4,m2,m0)
|
||||
#define LOAD_MSG_0_2(buf) buf = _mm_set_epi32(m7,m5,m3,m1)
|
||||
#define LOAD_MSG_0_3(buf) buf = _mm_set_epi32(m14,m12,m10,m8)
|
||||
#define LOAD_MSG_0_4(buf) buf = _mm_set_epi32(m15,m13,m11,m9)
|
||||
#define LOAD_MSG_1_1(buf) buf = _mm_set_epi32(m13,m9,m4,m14)
|
||||
#define LOAD_MSG_1_2(buf) buf = _mm_set_epi32(m6,m15,m8,m10)
|
||||
#define LOAD_MSG_1_3(buf) buf = _mm_set_epi32(m5,m11,m0,m1)
|
||||
#define LOAD_MSG_1_4(buf) buf = _mm_set_epi32(m3,m7,m2,m12)
|
||||
#define LOAD_MSG_2_1(buf) buf = _mm_set_epi32(m15,m5,m12,m11)
|
||||
#define LOAD_MSG_2_2(buf) buf = _mm_set_epi32(m13,m2,m0,m8)
|
||||
#define LOAD_MSG_2_3(buf) buf = _mm_set_epi32(m9,m7,m3,m10)
|
||||
#define LOAD_MSG_2_4(buf) buf = _mm_set_epi32(m4,m1,m6,m14)
|
||||
#define LOAD_MSG_3_1(buf) buf = _mm_set_epi32(m11,m13,m3,m7)
|
||||
#define LOAD_MSG_3_2(buf) buf = _mm_set_epi32(m14,m12,m1,m9)
|
||||
#define LOAD_MSG_3_3(buf) buf = _mm_set_epi32(m15,m4,m5,m2)
|
||||
#define LOAD_MSG_3_4(buf) buf = _mm_set_epi32(m8,m0,m10,m6)
|
||||
#define LOAD_MSG_4_1(buf) buf = _mm_set_epi32(m10,m2,m5,m9)
|
||||
#define LOAD_MSG_4_2(buf) buf = _mm_set_epi32(m15,m4,m7,m0)
|
||||
#define LOAD_MSG_4_3(buf) buf = _mm_set_epi32(m3,m6,m11,m14)
|
||||
#define LOAD_MSG_4_4(buf) buf = _mm_set_epi32(m13,m8,m12,m1)
|
||||
#define LOAD_MSG_5_1(buf) buf = _mm_set_epi32(m8,m0,m6,m2)
|
||||
#define LOAD_MSG_5_2(buf) buf = _mm_set_epi32(m3,m11,m10,m12)
|
||||
#define LOAD_MSG_5_3(buf) buf = _mm_set_epi32(m1,m15,m7,m4)
|
||||
#define LOAD_MSG_5_4(buf) buf = _mm_set_epi32(m9,m14,m5,m13)
|
||||
#define LOAD_MSG_6_1(buf) buf = _mm_set_epi32(m4,m14,m1,m12)
|
||||
#define LOAD_MSG_6_2(buf) buf = _mm_set_epi32(m10,m13,m15,m5)
|
||||
#define LOAD_MSG_6_3(buf) buf = _mm_set_epi32(m8,m9,m6,m0)
|
||||
#define LOAD_MSG_6_4(buf) buf = _mm_set_epi32(m11,m2,m3,m7)
|
||||
#define LOAD_MSG_7_1(buf) buf = _mm_set_epi32(m3,m12,m7,m13)
|
||||
#define LOAD_MSG_7_2(buf) buf = _mm_set_epi32(m9,m1,m14,m11)
|
||||
#define LOAD_MSG_7_3(buf) buf = _mm_set_epi32(m2,m8,m15,m5)
|
||||
#define LOAD_MSG_7_4(buf) buf = _mm_set_epi32(m10,m6,m4,m0)
|
||||
#define LOAD_MSG_8_1(buf) buf = _mm_set_epi32(m0,m11,m14,m6)
|
||||
#define LOAD_MSG_8_2(buf) buf = _mm_set_epi32(m8,m3,m9,m15)
|
||||
#define LOAD_MSG_8_3(buf) buf = _mm_set_epi32(m10,m1,m13,m12)
|
||||
#define LOAD_MSG_8_4(buf) buf = _mm_set_epi32(m5,m4,m7,m2)
|
||||
#define LOAD_MSG_9_1(buf) buf = _mm_set_epi32(m1,m7,m8,m10)
|
||||
#define LOAD_MSG_9_2(buf) buf = _mm_set_epi32(m5,m6,m4,m2)
|
||||
#define LOAD_MSG_9_3(buf) buf = _mm_set_epi32(m13,m3,m9,m15)
|
||||
#define LOAD_MSG_9_4(buf) buf = _mm_set_epi32(m0,m12,m14,m11)
|
||||
|
||||
|
||||
#endif
|
231
third_party/python/Modules/_blake2/impl/blake2s-load-sse41.h
vendored
Normal file
231
third_party/python/Modules/_blake2/impl/blake2s-load-sse41.h
vendored
Normal file
|
@ -0,0 +1,231 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef __BLAKE2S_LOAD_SSE41_H__
|
||||
#define __BLAKE2S_LOAD_SSE41_H__
|
||||
|
||||
#define LOAD_MSG_0_1(buf) \
|
||||
buf = TOI(_mm_shuffle_ps(TOF(m0), TOF(m1), _MM_SHUFFLE(2,0,2,0)));
|
||||
|
||||
#define LOAD_MSG_0_2(buf) \
|
||||
buf = TOI(_mm_shuffle_ps(TOF(m0), TOF(m1), _MM_SHUFFLE(3,1,3,1)));
|
||||
|
||||
#define LOAD_MSG_0_3(buf) \
|
||||
buf = TOI(_mm_shuffle_ps(TOF(m2), TOF(m3), _MM_SHUFFLE(2,0,2,0)));
|
||||
|
||||
#define LOAD_MSG_0_4(buf) \
|
||||
buf = TOI(_mm_shuffle_ps(TOF(m2), TOF(m3), _MM_SHUFFLE(3,1,3,1)));
|
||||
|
||||
#define LOAD_MSG_1_1(buf) \
|
||||
t0 = _mm_blend_epi16(m1, m2, 0x0C); \
|
||||
t1 = _mm_slli_si128(m3, 4); \
|
||||
t2 = _mm_blend_epi16(t0, t1, 0xF0); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(2,1,0,3));
|
||||
|
||||
#define LOAD_MSG_1_2(buf) \
|
||||
t0 = _mm_shuffle_epi32(m2,_MM_SHUFFLE(0,0,2,0)); \
|
||||
t1 = _mm_blend_epi16(m1,m3,0xC0); \
|
||||
t2 = _mm_blend_epi16(t0, t1, 0xF0); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(2,3,0,1));
|
||||
|
||||
#define LOAD_MSG_1_3(buf) \
|
||||
t0 = _mm_slli_si128(m1, 4); \
|
||||
t1 = _mm_blend_epi16(m2, t0, 0x30); \
|
||||
t2 = _mm_blend_epi16(m0, t1, 0xF0); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(2,3,0,1));
|
||||
|
||||
#define LOAD_MSG_1_4(buf) \
|
||||
t0 = _mm_unpackhi_epi32(m0,m1); \
|
||||
t1 = _mm_slli_si128(m3, 4); \
|
||||
t2 = _mm_blend_epi16(t0, t1, 0x0C); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(2,3,0,1));
|
||||
|
||||
#define LOAD_MSG_2_1(buf) \
|
||||
t0 = _mm_unpackhi_epi32(m2,m3); \
|
||||
t1 = _mm_blend_epi16(m3,m1,0x0C); \
|
||||
t2 = _mm_blend_epi16(t0, t1, 0x0F); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(3,1,0,2));
|
||||
|
||||
#define LOAD_MSG_2_2(buf) \
|
||||
t0 = _mm_unpacklo_epi32(m2,m0); \
|
||||
t1 = _mm_blend_epi16(t0, m0, 0xF0); \
|
||||
t2 = _mm_slli_si128(m3, 8); \
|
||||
buf = _mm_blend_epi16(t1, t2, 0xC0);
|
||||
|
||||
#define LOAD_MSG_2_3(buf) \
|
||||
t0 = _mm_blend_epi16(m0, m2, 0x3C); \
|
||||
t1 = _mm_srli_si128(m1, 12); \
|
||||
t2 = _mm_blend_epi16(t0,t1,0x03); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(1,0,3,2));
|
||||
|
||||
#define LOAD_MSG_2_4(buf) \
|
||||
t0 = _mm_slli_si128(m3, 4); \
|
||||
t1 = _mm_blend_epi16(m0, m1, 0x33); \
|
||||
t2 = _mm_blend_epi16(t1, t0, 0xC0); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(0,1,2,3));
|
||||
|
||||
#define LOAD_MSG_3_1(buf) \
|
||||
t0 = _mm_unpackhi_epi32(m0,m1); \
|
||||
t1 = _mm_unpackhi_epi32(t0, m2); \
|
||||
t2 = _mm_blend_epi16(t1, m3, 0x0C); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(3,1,0,2));
|
||||
|
||||
#define LOAD_MSG_3_2(buf) \
|
||||
t0 = _mm_slli_si128(m2, 8); \
|
||||
t1 = _mm_blend_epi16(m3,m0,0x0C); \
|
||||
t2 = _mm_blend_epi16(t1, t0, 0xC0); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(2,0,1,3));
|
||||
|
||||
#define LOAD_MSG_3_3(buf) \
|
||||
t0 = _mm_blend_epi16(m0,m1,0x0F); \
|
||||
t1 = _mm_blend_epi16(t0, m3, 0xC0); \
|
||||
buf = _mm_shuffle_epi32(t1, _MM_SHUFFLE(3,0,1,2));
|
||||
|
||||
#define LOAD_MSG_3_4(buf) \
|
||||
t0 = _mm_unpacklo_epi32(m0,m2); \
|
||||
t1 = _mm_unpackhi_epi32(m1,m2); \
|
||||
buf = _mm_unpacklo_epi64(t1,t0);
|
||||
|
||||
#define LOAD_MSG_4_1(buf) \
|
||||
t0 = _mm_unpacklo_epi64(m1,m2); \
|
||||
t1 = _mm_unpackhi_epi64(m0,m2); \
|
||||
t2 = _mm_blend_epi16(t0,t1,0x33); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(2,0,1,3));
|
||||
|
||||
#define LOAD_MSG_4_2(buf) \
|
||||
t0 = _mm_unpackhi_epi64(m1,m3); \
|
||||
t1 = _mm_unpacklo_epi64(m0,m1); \
|
||||
buf = _mm_blend_epi16(t0,t1,0x33);
|
||||
|
||||
#define LOAD_MSG_4_3(buf) \
|
||||
t0 = _mm_unpackhi_epi64(m3,m1); \
|
||||
t1 = _mm_unpackhi_epi64(m2,m0); \
|
||||
buf = _mm_blend_epi16(t1,t0,0x33);
|
||||
|
||||
#define LOAD_MSG_4_4(buf) \
|
||||
t0 = _mm_blend_epi16(m0,m2,0x03); \
|
||||
t1 = _mm_slli_si128(t0, 8); \
|
||||
t2 = _mm_blend_epi16(t1,m3,0x0F); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(1,2,0,3));
|
||||
|
||||
#define LOAD_MSG_5_1(buf) \
|
||||
t0 = _mm_unpackhi_epi32(m0,m1); \
|
||||
t1 = _mm_unpacklo_epi32(m0,m2); \
|
||||
buf = _mm_unpacklo_epi64(t0,t1);
|
||||
|
||||
#define LOAD_MSG_5_2(buf) \
|
||||
t0 = _mm_srli_si128(m2, 4); \
|
||||
t1 = _mm_blend_epi16(m0,m3,0x03); \
|
||||
buf = _mm_blend_epi16(t1,t0,0x3C);
|
||||
|
||||
#define LOAD_MSG_5_3(buf) \
|
||||
t0 = _mm_blend_epi16(m1,m0,0x0C); \
|
||||
t1 = _mm_srli_si128(m3, 4); \
|
||||
t2 = _mm_blend_epi16(t0,t1,0x30); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(1,2,3,0));
|
||||
|
||||
#define LOAD_MSG_5_4(buf) \
|
||||
t0 = _mm_unpacklo_epi64(m1,m2); \
|
||||
t1= _mm_shuffle_epi32(m3, _MM_SHUFFLE(0,2,0,1)); \
|
||||
buf = _mm_blend_epi16(t0,t1,0x33);
|
||||
|
||||
#define LOAD_MSG_6_1(buf) \
|
||||
t0 = _mm_slli_si128(m1, 12); \
|
||||
t1 = _mm_blend_epi16(m0,m3,0x33); \
|
||||
buf = _mm_blend_epi16(t1,t0,0xC0);
|
||||
|
||||
#define LOAD_MSG_6_2(buf) \
|
||||
t0 = _mm_blend_epi16(m3,m2,0x30); \
|
||||
t1 = _mm_srli_si128(m1, 4); \
|
||||
t2 = _mm_blend_epi16(t0,t1,0x03); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(2,1,3,0));
|
||||
|
||||
#define LOAD_MSG_6_3(buf) \
|
||||
t0 = _mm_unpacklo_epi64(m0,m2); \
|
||||
t1 = _mm_srli_si128(m1, 4); \
|
||||
buf = _mm_shuffle_epi32(_mm_blend_epi16(t0,t1,0x0C), _MM_SHUFFLE(2,3,1,0));
|
||||
|
||||
#define LOAD_MSG_6_4(buf) \
|
||||
t0 = _mm_unpackhi_epi32(m1,m2); \
|
||||
t1 = _mm_unpackhi_epi64(m0,t0); \
|
||||
buf = _mm_shuffle_epi32(t1, _MM_SHUFFLE(3,0,1,2));
|
||||
|
||||
#define LOAD_MSG_7_1(buf) \
|
||||
t0 = _mm_unpackhi_epi32(m0,m1); \
|
||||
t1 = _mm_blend_epi16(t0,m3,0x0F); \
|
||||
buf = _mm_shuffle_epi32(t1,_MM_SHUFFLE(2,0,3,1));
|
||||
|
||||
#define LOAD_MSG_7_2(buf) \
|
||||
t0 = _mm_blend_epi16(m2,m3,0x30); \
|
||||
t1 = _mm_srli_si128(m0,4); \
|
||||
t2 = _mm_blend_epi16(t0,t1,0x03); \
|
||||
buf = _mm_shuffle_epi32(t2, _MM_SHUFFLE(1,0,2,3));
|
||||
|
||||
#define LOAD_MSG_7_3(buf) \
|
||||
t0 = _mm_unpackhi_epi64(m0,m3); \
|
||||
t1 = _mm_unpacklo_epi64(m1,m2); \
|
||||
t2 = _mm_blend_epi16(t0,t1,0x3C); \
|
||||
buf = _mm_shuffle_epi32(t2,_MM_SHUFFLE(0,2,3,1));
|
||||
|
||||
#define LOAD_MSG_7_4(buf) \
|
||||
t0 = _mm_unpacklo_epi32(m0,m1); \
|
||||
t1 = _mm_unpackhi_epi32(m1,m2); \
|
||||
buf = _mm_unpacklo_epi64(t0,t1);
|
||||
|
||||
#define LOAD_MSG_8_1(buf) \
|
||||
t0 = _mm_unpackhi_epi32(m1,m3); \
|
||||
t1 = _mm_unpacklo_epi64(t0,m0); \
|
||||
t2 = _mm_blend_epi16(t1,m2,0xC0); \
|
||||
buf = _mm_shufflehi_epi16(t2,_MM_SHUFFLE(1,0,3,2));
|
||||
|
||||
#define LOAD_MSG_8_2(buf) \
|
||||
t0 = _mm_unpackhi_epi32(m0,m3); \
|
||||
t1 = _mm_blend_epi16(m2,t0,0xF0); \
|
||||
buf = _mm_shuffle_epi32(t1,_MM_SHUFFLE(0,2,1,3));
|
||||
|
||||
#define LOAD_MSG_8_3(buf) \
|
||||
t0 = _mm_blend_epi16(m2,m0,0x0C); \
|
||||
t1 = _mm_slli_si128(t0,4); \
|
||||
buf = _mm_blend_epi16(t1,m3,0x0F);
|
||||
|
||||
#define LOAD_MSG_8_4(buf) \
|
||||
t0 = _mm_blend_epi16(m1,m0,0x30); \
|
||||
buf = _mm_shuffle_epi32(t0,_MM_SHUFFLE(1,0,3,2));
|
||||
|
||||
#define LOAD_MSG_9_1(buf) \
|
||||
t0 = _mm_blend_epi16(m0,m2,0x03); \
|
||||
t1 = _mm_blend_epi16(m1,m2,0x30); \
|
||||
t2 = _mm_blend_epi16(t1,t0,0x0F); \
|
||||
buf = _mm_shuffle_epi32(t2,_MM_SHUFFLE(1,3,0,2));
|
||||
|
||||
#define LOAD_MSG_9_2(buf) \
|
||||
t0 = _mm_slli_si128(m0,4); \
|
||||
t1 = _mm_blend_epi16(m1,t0,0xC0); \
|
||||
buf = _mm_shuffle_epi32(t1,_MM_SHUFFLE(1,2,0,3));
|
||||
|
||||
#define LOAD_MSG_9_3(buf) \
|
||||
t0 = _mm_unpackhi_epi32(m0,m3); \
|
||||
t1 = _mm_unpacklo_epi32(m2,m3); \
|
||||
t2 = _mm_unpackhi_epi64(t0,t1); \
|
||||
buf = _mm_shuffle_epi32(t2,_MM_SHUFFLE(3,0,2,1));
|
||||
|
||||
#define LOAD_MSG_9_4(buf) \
|
||||
t0 = _mm_blend_epi16(m3,m2,0xC0); \
|
||||
t1 = _mm_unpacklo_epi32(m0,m3); \
|
||||
t2 = _mm_blend_epi16(t0,t1,0x0F); \
|
||||
buf = _mm_shuffle_epi32(t2,_MM_SHUFFLE(0,1,2,3));
|
||||
|
||||
#endif
|
||||
|
193
third_party/python/Modules/_blake2/impl/blake2s-load-xop.h
vendored
Normal file
193
third_party/python/Modules/_blake2/impl/blake2s-load-xop.h
vendored
Normal file
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef __BLAKE2S_LOAD_XOP_H__
|
||||
#define __BLAKE2S_LOAD_XOP_H__
|
||||
|
||||
#define TOB(x) ((x)*4*0x01010101 + 0x03020100) /* ..or not TOB */
|
||||
|
||||
#if 0
|
||||
/* Basic VPPERM emulation, for testing purposes */
|
||||
static __m128i _mm_perm_epi8(const __m128i src1, const __m128i src2, const __m128i sel)
|
||||
{
|
||||
const __m128i sixteen = _mm_set1_epi8(16);
|
||||
const __m128i t0 = _mm_shuffle_epi8(src1, sel);
|
||||
const __m128i s1 = _mm_shuffle_epi8(src2, _mm_sub_epi8(sel, sixteen));
|
||||
const __m128i mask = _mm_or_si128(_mm_cmpeq_epi8(sel, sixteen),
|
||||
_mm_cmpgt_epi8(sel, sixteen)); /* (>=16) = 0xff : 00 */
|
||||
return _mm_blendv_epi8(t0, s1, mask);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define LOAD_MSG_0_1(buf) \
|
||||
buf = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(6),TOB(4),TOB(2),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_0_2(buf) \
|
||||
buf = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(7),TOB(5),TOB(3),TOB(1)) );
|
||||
|
||||
#define LOAD_MSG_0_3(buf) \
|
||||
buf = _mm_perm_epi8(m2, m3, _mm_set_epi32(TOB(6),TOB(4),TOB(2),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_0_4(buf) \
|
||||
buf = _mm_perm_epi8(m2, m3, _mm_set_epi32(TOB(7),TOB(5),TOB(3),TOB(1)) );
|
||||
|
||||
#define LOAD_MSG_1_1(buf) \
|
||||
t0 = _mm_perm_epi8(m1, m2, _mm_set_epi32(TOB(0),TOB(5),TOB(0),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(5),TOB(2),TOB(1),TOB(6)) );
|
||||
|
||||
#define LOAD_MSG_1_2(buf) \
|
||||
t1 = _mm_perm_epi8(m1, m2, _mm_set_epi32(TOB(2),TOB(0),TOB(4),TOB(6)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(7),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_1_3(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(5),TOB(0),TOB(0),TOB(1)) ); \
|
||||
buf = _mm_perm_epi8(t0, m2, _mm_set_epi32(TOB(3),TOB(7),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_1_4(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(3),TOB(7),TOB(2),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(1),TOB(4)) );
|
||||
|
||||
#define LOAD_MSG_2_1(buf) \
|
||||
t0 = _mm_perm_epi8(m1, m2, _mm_set_epi32(TOB(0),TOB(1),TOB(0),TOB(7)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(7),TOB(2),TOB(4),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_2_2(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m2, _mm_set_epi32(TOB(0),TOB(2),TOB(0),TOB(4)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(5),TOB(2),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_2_3(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(7),TOB(3),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m2, _mm_set_epi32(TOB(5),TOB(2),TOB(1),TOB(6)) );
|
||||
|
||||
#define LOAD_MSG_2_4(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(4),TOB(1),TOB(6),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(1),TOB(6)) );
|
||||
|
||||
#define LOAD_MSG_3_1(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(0),TOB(3),TOB(7)) ); \
|
||||
t0 = _mm_perm_epi8(t0, m2, _mm_set_epi32(TOB(7),TOB(2),TOB(1),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(3),TOB(5),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_3_2(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m2, _mm_set_epi32(TOB(0),TOB(0),TOB(1),TOB(5)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(6),TOB(4),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_3_3(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(4),TOB(5),TOB(2)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(7),TOB(2),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_3_4(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(0),TOB(0),TOB(6)) ); \
|
||||
buf = _mm_perm_epi8(t1, m2, _mm_set_epi32(TOB(4),TOB(2),TOB(6),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_4_1(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(2),TOB(5),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m2, _mm_set_epi32(TOB(6),TOB(2),TOB(1),TOB(5)) );
|
||||
|
||||
#define LOAD_MSG_4_2(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(4),TOB(7),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(7),TOB(2),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_4_3(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(3),TOB(6),TOB(0),TOB(0)) ); \
|
||||
t0 = _mm_perm_epi8(t0, m2, _mm_set_epi32(TOB(3),TOB(2),TOB(7),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(1),TOB(6)) );
|
||||
|
||||
#define LOAD_MSG_4_4(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m2, _mm_set_epi32(TOB(0),TOB(4),TOB(0),TOB(1)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(5),TOB(2),TOB(4),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_5_1(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(0),TOB(6),TOB(2)) ); \
|
||||
buf = _mm_perm_epi8(t0, m2, _mm_set_epi32(TOB(4),TOB(2),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_5_2(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m2, _mm_set_epi32(TOB(3),TOB(7),TOB(6),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(1),TOB(4)) );
|
||||
|
||||
#define LOAD_MSG_5_3(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(1),TOB(0),TOB(7),TOB(4)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(3),TOB(7),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_5_4(buf) \
|
||||
t1 = _mm_perm_epi8(m1, m2, _mm_set_epi32(TOB(5),TOB(0),TOB(1),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(6),TOB(1),TOB(5)) );
|
||||
|
||||
#define LOAD_MSG_6_1(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(4),TOB(0),TOB(1),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(3),TOB(6),TOB(1),TOB(4)) );
|
||||
|
||||
#define LOAD_MSG_6_2(buf) \
|
||||
t1 = _mm_perm_epi8(m1, m2, _mm_set_epi32(TOB(6),TOB(0),TOB(0),TOB(1)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(5),TOB(7),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_6_3(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(0),TOB(6),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m2, _mm_set_epi32(TOB(4),TOB(5),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_6_4(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(2),TOB(3),TOB(7)) ); \
|
||||
buf = _mm_perm_epi8(t1, m2, _mm_set_epi32(TOB(7),TOB(2),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_7_1(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(3),TOB(0),TOB(7),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(3),TOB(4),TOB(1),TOB(5)) );
|
||||
|
||||
#define LOAD_MSG_7_2(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m2, _mm_set_epi32(TOB(5),TOB(1),TOB(0),TOB(7)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(6),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_7_3(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(2),TOB(0),TOB(0),TOB(5)) ); \
|
||||
t0 = _mm_perm_epi8(t0, m2, _mm_set_epi32(TOB(3),TOB(4),TOB(1),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(7),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_7_4(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(6),TOB(4),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t1, m2, _mm_set_epi32(TOB(6),TOB(2),TOB(1),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_8_1(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(0),TOB(0),TOB(0),TOB(6)) ); \
|
||||
t0 = _mm_perm_epi8(t0, m2, _mm_set_epi32(TOB(3),TOB(7),TOB(1),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(6),TOB(0)) );
|
||||
|
||||
#define LOAD_MSG_8_2(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m2, _mm_set_epi32(TOB(4),TOB(3),TOB(5),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(1),TOB(7)) );
|
||||
|
||||
#define LOAD_MSG_8_3(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m2, _mm_set_epi32(TOB(6),TOB(1),TOB(0),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(5),TOB(4)) ); \
|
||||
|
||||
#define LOAD_MSG_8_4(buf) \
|
||||
buf = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(5),TOB(4),TOB(7),TOB(2)) );
|
||||
|
||||
#define LOAD_MSG_9_1(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(1),TOB(7),TOB(0),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m2, _mm_set_epi32(TOB(3),TOB(2),TOB(4),TOB(6)) );
|
||||
|
||||
#define LOAD_MSG_9_2(buf) \
|
||||
buf = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(5),TOB(6),TOB(4),TOB(2)) );
|
||||
|
||||
#define LOAD_MSG_9_3(buf) \
|
||||
t0 = _mm_perm_epi8(m0, m2, _mm_set_epi32(TOB(0),TOB(3),TOB(5),TOB(0)) ); \
|
||||
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(5),TOB(2),TOB(1),TOB(7)) );
|
||||
|
||||
#define LOAD_MSG_9_4(buf) \
|
||||
t1 = _mm_perm_epi8(m0, m2, _mm_set_epi32(TOB(0),TOB(0),TOB(0),TOB(7)) ); \
|
||||
buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(4),TOB(6),TOB(0)) );
|
||||
|
||||
#endif
|
||||
|
411
third_party/python/Modules/_blake2/impl/blake2s-ref.c
vendored
Normal file
411
third_party/python/Modules/_blake2/impl/blake2s-ref.c
vendored
Normal file
|
@ -0,0 +1,411 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - reference C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "blake2.h"
|
||||
#include "blake2-impl.h"
|
||||
|
||||
static const uint32_t blake2s_IV[8] =
|
||||
{
|
||||
0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
|
||||
0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL
|
||||
};
|
||||
|
||||
static const uint8_t blake2s_sigma[10][16] =
|
||||
{
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
|
||||
};
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_set_lastnode( blake2s_state *S )
|
||||
{
|
||||
S->f[1] = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_clear_lastnode( blake2s_state *S )
|
||||
{
|
||||
S->f[1] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Some helper functions, not necessarily useful */
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_is_lastblock( const blake2s_state *S )
|
||||
{
|
||||
return S->f[0] != 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_set_lastblock( blake2s_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2s_set_lastnode( S );
|
||||
|
||||
S->f[0] = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_clear_lastblock( blake2s_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2s_clear_lastnode( S );
|
||||
|
||||
S->f[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_increment_counter( blake2s_state *S, const uint32_t inc )
|
||||
{
|
||||
S->t[0] += inc;
|
||||
S->t[1] += ( S->t[0] < inc );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Parameter-related functions */
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_digest_length( blake2s_param *P, const uint8_t digest_length )
|
||||
{
|
||||
P->digest_length = digest_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_fanout( blake2s_param *P, const uint8_t fanout )
|
||||
{
|
||||
P->fanout = fanout;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_max_depth( blake2s_param *P, const uint8_t depth )
|
||||
{
|
||||
P->depth = depth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_leaf_length( blake2s_param *P, const uint32_t leaf_length )
|
||||
{
|
||||
store32( &P->leaf_length, leaf_length );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_node_offset( blake2s_param *P, const uint64_t node_offset )
|
||||
{
|
||||
store48( P->node_offset, node_offset );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_node_depth( blake2s_param *P, const uint8_t node_depth )
|
||||
{
|
||||
P->node_depth = node_depth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_inner_length( blake2s_param *P, const uint8_t inner_length )
|
||||
{
|
||||
P->inner_length = inner_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_salt( blake2s_param *P, const uint8_t salt[BLAKE2S_SALTBYTES] )
|
||||
{
|
||||
memcpy( P->salt, salt, BLAKE2S_SALTBYTES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_personal( blake2s_param *P, const uint8_t personal[BLAKE2S_PERSONALBYTES] )
|
||||
{
|
||||
memcpy( P->personal, personal, BLAKE2S_PERSONALBYTES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_init0( blake2s_state *S )
|
||||
{
|
||||
int i;
|
||||
memset( S, 0, sizeof( blake2s_state ) );
|
||||
|
||||
for( i = 0; i < 8; ++i ) S->h[i] = blake2s_IV[i];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* init2 xors IV with input parameter block */
|
||||
int blake2s_init_param( blake2s_state *S, const blake2s_param *P )
|
||||
{
|
||||
const uint32_t *p = ( const uint32_t * )( P );
|
||||
size_t i;
|
||||
|
||||
blake2s_init0( S );
|
||||
|
||||
/* IV XOR ParamBlock */
|
||||
for( i = 0; i < 8; ++i )
|
||||
S->h[i] ^= load32( &p[i] );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Sequential blake2s initialization */
|
||||
int blake2s_init( blake2s_state *S, const uint8_t outlen )
|
||||
{
|
||||
blake2s_param P[1];
|
||||
|
||||
/* Move interval verification here? */
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
|
||||
|
||||
P->digest_length = outlen;
|
||||
P->key_length = 0;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store48( &P->node_offset, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
/* memset(P->reserved, 0, sizeof(P->reserved) ); */
|
||||
memset( P->salt, 0, sizeof( P->salt ) );
|
||||
memset( P->personal, 0, sizeof( P->personal ) );
|
||||
return blake2s_init_param( S, P );
|
||||
}
|
||||
|
||||
int blake2s_init_key( blake2s_state *S, const uint8_t outlen, const void *key, const uint8_t keylen )
|
||||
{
|
||||
blake2s_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
|
||||
|
||||
if ( !key || !keylen || keylen > BLAKE2S_KEYBYTES ) return -1;
|
||||
|
||||
P->digest_length = outlen;
|
||||
P->key_length = keylen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store48( &P->node_offset, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
/* memset(P->reserved, 0, sizeof(P->reserved) ); */
|
||||
memset( P->salt, 0, sizeof( P->salt ) );
|
||||
memset( P->personal, 0, sizeof( P->personal ) );
|
||||
|
||||
if( blake2s_init_param( S, P ) < 0 ) return -1;
|
||||
|
||||
{
|
||||
uint8_t block[BLAKE2S_BLOCKBYTES];
|
||||
memset( block, 0, BLAKE2S_BLOCKBYTES );
|
||||
memcpy( block, key, keylen );
|
||||
blake2s_update( S, block, BLAKE2S_BLOCKBYTES );
|
||||
secure_zero_memory( block, BLAKE2S_BLOCKBYTES ); /* Burn the key from stack */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int blake2s_compress( blake2s_state *S, const uint8_t block[BLAKE2S_BLOCKBYTES] )
|
||||
{
|
||||
uint32_t m[16];
|
||||
uint32_t v[16];
|
||||
size_t i;
|
||||
|
||||
for( i = 0; i < 16; ++i )
|
||||
m[i] = load32( block + i * sizeof( m[i] ) );
|
||||
|
||||
for( i = 0; i < 8; ++i )
|
||||
v[i] = S->h[i];
|
||||
|
||||
v[ 8] = blake2s_IV[0];
|
||||
v[ 9] = blake2s_IV[1];
|
||||
v[10] = blake2s_IV[2];
|
||||
v[11] = blake2s_IV[3];
|
||||
v[12] = S->t[0] ^ blake2s_IV[4];
|
||||
v[13] = S->t[1] ^ blake2s_IV[5];
|
||||
v[14] = S->f[0] ^ blake2s_IV[6];
|
||||
v[15] = S->f[1] ^ blake2s_IV[7];
|
||||
#define G(r,i,a,b,c,d) \
|
||||
do { \
|
||||
a = a + b + m[blake2s_sigma[r][2*i+0]]; \
|
||||
d = rotr32(d ^ a, 16); \
|
||||
c = c + d; \
|
||||
b = rotr32(b ^ c, 12); \
|
||||
a = a + b + m[blake2s_sigma[r][2*i+1]]; \
|
||||
d = rotr32(d ^ a, 8); \
|
||||
c = c + d; \
|
||||
b = rotr32(b ^ c, 7); \
|
||||
} while(0)
|
||||
#define ROUND(r) \
|
||||
do { \
|
||||
G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
|
||||
G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
|
||||
G(r,2,v[ 2],v[ 6],v[10],v[14]); \
|
||||
G(r,3,v[ 3],v[ 7],v[11],v[15]); \
|
||||
G(r,4,v[ 0],v[ 5],v[10],v[15]); \
|
||||
G(r,5,v[ 1],v[ 6],v[11],v[12]); \
|
||||
G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
|
||||
G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
|
||||
} while(0)
|
||||
ROUND( 0 );
|
||||
ROUND( 1 );
|
||||
ROUND( 2 );
|
||||
ROUND( 3 );
|
||||
ROUND( 4 );
|
||||
ROUND( 5 );
|
||||
ROUND( 6 );
|
||||
ROUND( 7 );
|
||||
ROUND( 8 );
|
||||
ROUND( 9 );
|
||||
|
||||
for( i = 0; i < 8; ++i )
|
||||
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
|
||||
|
||||
#undef G
|
||||
#undef ROUND
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int blake2s_update( blake2s_state *S, const uint8_t *in, uint64_t inlen )
|
||||
{
|
||||
while( inlen > 0 )
|
||||
{
|
||||
size_t left = S->buflen;
|
||||
size_t fill = 2 * BLAKE2S_BLOCKBYTES - left;
|
||||
|
||||
if( inlen > fill )
|
||||
{
|
||||
memcpy( S->buf + left, in, fill ); /* Fill buffer */
|
||||
S->buflen += fill;
|
||||
blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
|
||||
blake2s_compress( S, S->buf ); /* Compress */
|
||||
memcpy( S->buf, S->buf + BLAKE2S_BLOCKBYTES, BLAKE2S_BLOCKBYTES ); /* Shift buffer left */
|
||||
S->buflen -= BLAKE2S_BLOCKBYTES;
|
||||
in += fill;
|
||||
inlen -= fill;
|
||||
}
|
||||
else /* inlen <= fill */
|
||||
{
|
||||
memcpy( S->buf + left, in, (size_t)inlen );
|
||||
S->buflen += (size_t)inlen; /* Be lazy, do not compress */
|
||||
in += inlen;
|
||||
inlen -= inlen;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int blake2s_final( blake2s_state *S, uint8_t *out, uint8_t outlen )
|
||||
{
|
||||
uint8_t buffer[BLAKE2S_OUTBYTES] = {0};
|
||||
int i;
|
||||
|
||||
if( out == NULL || outlen == 0 || outlen > BLAKE2S_OUTBYTES )
|
||||
return -1;
|
||||
|
||||
if( blake2s_is_lastblock( S ) )
|
||||
return -1;
|
||||
|
||||
|
||||
if( S->buflen > BLAKE2S_BLOCKBYTES )
|
||||
{
|
||||
blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
|
||||
blake2s_compress( S, S->buf );
|
||||
S->buflen -= BLAKE2S_BLOCKBYTES;
|
||||
memmove( S->buf, S->buf + BLAKE2S_BLOCKBYTES, S->buflen );
|
||||
}
|
||||
|
||||
blake2s_increment_counter( S, ( uint32_t )S->buflen );
|
||||
blake2s_set_lastblock( S );
|
||||
memset( S->buf + S->buflen, 0, 2 * BLAKE2S_BLOCKBYTES - S->buflen ); /* Padding */
|
||||
blake2s_compress( S, S->buf );
|
||||
|
||||
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
||||
store32( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
||||
|
||||
memcpy( out, buffer, outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen )
|
||||
{
|
||||
blake2s_state S[1];
|
||||
|
||||
/* Verify parameters */
|
||||
if ( NULL == in && inlen > 0 ) return -1;
|
||||
|
||||
if ( NULL == out ) return -1;
|
||||
|
||||
if ( NULL == key && keylen > 0) return -1;
|
||||
|
||||
if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
|
||||
|
||||
if( keylen > BLAKE2S_KEYBYTES ) return -1;
|
||||
|
||||
if( keylen > 0 )
|
||||
{
|
||||
if( blake2s_init_key( S, outlen, key, keylen ) < 0 ) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( blake2s_init( S, outlen ) < 0 ) return -1;
|
||||
}
|
||||
|
||||
blake2s_update( S, ( const uint8_t * )in, inlen );
|
||||
blake2s_final( S, out, outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(SUPERCOP)
|
||||
int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen )
|
||||
{
|
||||
return blake2s( out, in, NULL, BLAKE2S_OUTBYTES, inlen, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BLAKE2S_SELFTEST)
|
||||
#include <string.h>
|
||||
#include "blake2-kat.h"
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
uint8_t key[BLAKE2S_KEYBYTES];
|
||||
uint8_t buf[KAT_LENGTH];
|
||||
size_t i;
|
||||
|
||||
for( i = 0; i < BLAKE2S_KEYBYTES; ++i )
|
||||
key[i] = ( uint8_t )i;
|
||||
|
||||
for( i = 0; i < KAT_LENGTH; ++i )
|
||||
buf[i] = ( uint8_t )i;
|
||||
|
||||
for( i = 0; i < KAT_LENGTH; ++i )
|
||||
{
|
||||
uint8_t hash[BLAKE2S_OUTBYTES];
|
||||
blake2s( hash, buf, key, BLAKE2S_OUTBYTES, i, BLAKE2S_KEYBYTES );
|
||||
|
||||
if( 0 != memcmp( hash, blake2s_keyed_kat[i], BLAKE2S_OUTBYTES ) )
|
||||
{
|
||||
puts( "error" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
puts( "ok" );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
90
third_party/python/Modules/_blake2/impl/blake2s-round.h
vendored
Normal file
90
third_party/python/Modules/_blake2/impl/blake2s-round.h
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef __BLAKE2S_ROUND_H__
|
||||
#define __BLAKE2S_ROUND_H__
|
||||
|
||||
#define LOADU(p) _mm_loadu_si128( (const __m128i *)(p) )
|
||||
#define STOREU(p,r) _mm_storeu_si128((__m128i *)(p), r)
|
||||
|
||||
#define TOF(reg) _mm_castsi128_ps((reg))
|
||||
#define TOI(reg) _mm_castps_si128((reg))
|
||||
|
||||
#define LIKELY(x) __builtin_expect((x),1)
|
||||
|
||||
|
||||
/* Microarchitecture-specific macros */
|
||||
#ifndef HAVE_XOP
|
||||
#ifdef HAVE_SSSE3
|
||||
#define _mm_roti_epi32(r, c) ( \
|
||||
(8==-(c)) ? _mm_shuffle_epi8(r,r8) \
|
||||
: (16==-(c)) ? _mm_shuffle_epi8(r,r16) \
|
||||
: _mm_xor_si128(_mm_srli_epi32( (r), -(c) ),_mm_slli_epi32( (r), 32-(-(c)) )) )
|
||||
#else
|
||||
#define _mm_roti_epi32(r, c) _mm_xor_si128(_mm_srli_epi32( (r), -(c) ),_mm_slli_epi32( (r), 32-(-(c)) ))
|
||||
#endif
|
||||
#else
|
||||
/* ... */
|
||||
#endif
|
||||
|
||||
|
||||
#define G1(row1,row2,row3,row4,buf) \
|
||||
row1 = _mm_add_epi32( _mm_add_epi32( row1, buf), row2 ); \
|
||||
row4 = _mm_xor_si128( row4, row1 ); \
|
||||
row4 = _mm_roti_epi32(row4, -16); \
|
||||
row3 = _mm_add_epi32( row3, row4 ); \
|
||||
row2 = _mm_xor_si128( row2, row3 ); \
|
||||
row2 = _mm_roti_epi32(row2, -12);
|
||||
|
||||
#define G2(row1,row2,row3,row4,buf) \
|
||||
row1 = _mm_add_epi32( _mm_add_epi32( row1, buf), row2 ); \
|
||||
row4 = _mm_xor_si128( row4, row1 ); \
|
||||
row4 = _mm_roti_epi32(row4, -8); \
|
||||
row3 = _mm_add_epi32( row3, row4 ); \
|
||||
row2 = _mm_xor_si128( row2, row3 ); \
|
||||
row2 = _mm_roti_epi32(row2, -7);
|
||||
|
||||
#define DIAGONALIZE(row1,row2,row3,row4) \
|
||||
row4 = _mm_shuffle_epi32( row4, _MM_SHUFFLE(2,1,0,3) ); \
|
||||
row3 = _mm_shuffle_epi32( row3, _MM_SHUFFLE(1,0,3,2) ); \
|
||||
row2 = _mm_shuffle_epi32( row2, _MM_SHUFFLE(0,3,2,1) );
|
||||
|
||||
#define UNDIAGONALIZE(row1,row2,row3,row4) \
|
||||
row4 = _mm_shuffle_epi32( row4, _MM_SHUFFLE(0,3,2,1) ); \
|
||||
row3 = _mm_shuffle_epi32( row3, _MM_SHUFFLE(1,0,3,2) ); \
|
||||
row2 = _mm_shuffle_epi32( row2, _MM_SHUFFLE(2,1,0,3) );
|
||||
|
||||
#if defined(HAVE_XOP)
|
||||
#include "blake2s-load-xop.h"
|
||||
#elif defined(HAVE_SSE41)
|
||||
#include "blake2s-load-sse41.h"
|
||||
#else
|
||||
#include "blake2s-load-sse2.h"
|
||||
#endif
|
||||
|
||||
#define ROUND(r) \
|
||||
LOAD_MSG_ ##r ##_1(buf1); \
|
||||
G1(row1,row2,row3,row4,buf1); \
|
||||
LOAD_MSG_ ##r ##_2(buf2); \
|
||||
G2(row1,row2,row3,row4,buf2); \
|
||||
DIAGONALIZE(row1,row2,row3,row4); \
|
||||
LOAD_MSG_ ##r ##_3(buf3); \
|
||||
G1(row1,row2,row3,row4,buf3); \
|
||||
LOAD_MSG_ ##r ##_4(buf4); \
|
||||
G2(row1,row2,row3,row4,buf4); \
|
||||
UNDIAGONALIZE(row1,row2,row3,row4); \
|
||||
|
||||
#endif
|
||||
|
435
third_party/python/Modules/_blake2/impl/blake2s.c
vendored
Normal file
435
third_party/python/Modules/_blake2/impl/blake2s.c
vendored
Normal file
|
@ -0,0 +1,435 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - optimized C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "blake2.h"
|
||||
#include "blake2-impl.h"
|
||||
|
||||
#include "blake2-config.h"
|
||||
|
||||
|
||||
#include <emmintrin.h>
|
||||
#if defined(HAVE_SSSE3)
|
||||
#include <tmmintrin.h>
|
||||
#endif
|
||||
#if defined(HAVE_SSE41)
|
||||
#include <smmintrin.h>
|
||||
#endif
|
||||
#if defined(HAVE_AVX)
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
#if defined(HAVE_XOP)
|
||||
#include <x86intrin.h>
|
||||
#endif
|
||||
|
||||
#include "blake2s-round.h"
|
||||
|
||||
static const uint32_t blake2s_IV[8] =
|
||||
{
|
||||
0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
|
||||
0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL
|
||||
};
|
||||
|
||||
static const uint8_t blake2s_sigma[10][16] =
|
||||
{
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
|
||||
};
|
||||
|
||||
|
||||
/* Some helper functions, not necessarily useful */
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_set_lastnode( blake2s_state *S )
|
||||
{
|
||||
S->f[1] = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_clear_lastnode( blake2s_state *S )
|
||||
{
|
||||
S->f[1] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_is_lastblock( const blake2s_state *S )
|
||||
{
|
||||
return S->f[0] != 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_set_lastblock( blake2s_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2s_set_lastnode( S );
|
||||
|
||||
S->f[0] = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_clear_lastblock( blake2s_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2s_clear_lastnode( S );
|
||||
|
||||
S->f[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_increment_counter( blake2s_state *S, const uint32_t inc )
|
||||
{
|
||||
uint64_t t = ( ( uint64_t )S->t[1] << 32 ) | S->t[0];
|
||||
t += inc;
|
||||
S->t[0] = ( uint32_t )( t >> 0 );
|
||||
S->t[1] = ( uint32_t )( t >> 32 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Parameter-related functions */
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_digest_length( blake2s_param *P, const uint8_t digest_length )
|
||||
{
|
||||
P->digest_length = digest_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_fanout( blake2s_param *P, const uint8_t fanout )
|
||||
{
|
||||
P->fanout = fanout;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_max_depth( blake2s_param *P, const uint8_t depth )
|
||||
{
|
||||
P->depth = depth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_leaf_length( blake2s_param *P, const uint32_t leaf_length )
|
||||
{
|
||||
P->leaf_length = leaf_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_node_offset( blake2s_param *P, const uint64_t node_offset )
|
||||
{
|
||||
store48( P->node_offset, node_offset );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_node_depth( blake2s_param *P, const uint8_t node_depth )
|
||||
{
|
||||
P->node_depth = node_depth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_inner_length( blake2s_param *P, const uint8_t inner_length )
|
||||
{
|
||||
P->inner_length = inner_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_salt( blake2s_param *P, const uint8_t salt[BLAKE2S_SALTBYTES] )
|
||||
{
|
||||
memcpy( P->salt, salt, BLAKE2S_SALTBYTES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_param_set_personal( blake2s_param *P, const uint8_t personal[BLAKE2S_PERSONALBYTES] )
|
||||
{
|
||||
memcpy( P->personal, personal, BLAKE2S_PERSONALBYTES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_init0( blake2s_state *S )
|
||||
{
|
||||
int i;
|
||||
memset( S, 0, sizeof( blake2s_state ) );
|
||||
|
||||
for( i = 0; i < 8; ++i ) S->h[i] = blake2s_IV[i];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* init2 xors IV with input parameter block */
|
||||
int blake2s_init_param( blake2s_state *S, const blake2s_param *P )
|
||||
{
|
||||
/*blake2s_init0( S ); */
|
||||
const uint8_t * v = ( const uint8_t * )( blake2s_IV );
|
||||
const uint8_t * p = ( const uint8_t * )( P );
|
||||
uint8_t * h = ( uint8_t * )( S->h );
|
||||
int i;
|
||||
/* IV XOR ParamBlock */
|
||||
memset( S, 0, sizeof( blake2s_state ) );
|
||||
|
||||
for( i = 0; i < BLAKE2S_OUTBYTES; ++i ) h[i] = v[i] ^ p[i];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Some sort of default parameter block initialization, for sequential blake2s */
|
||||
int blake2s_init( blake2s_state *S, const uint8_t outlen )
|
||||
{
|
||||
const blake2s_param P =
|
||||
{
|
||||
outlen,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
{0},
|
||||
0,
|
||||
0,
|
||||
{0},
|
||||
{0}
|
||||
};
|
||||
/* Move interval verification here? */
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
|
||||
return blake2s_init_param( S, &P );
|
||||
}
|
||||
|
||||
|
||||
int blake2s_init_key( blake2s_state *S, const uint8_t outlen, const void *key, const uint8_t keylen )
|
||||
{
|
||||
const blake2s_param P =
|
||||
{
|
||||
outlen,
|
||||
keylen,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
{0},
|
||||
0,
|
||||
0,
|
||||
{0},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* Move interval verification here? */
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
|
||||
|
||||
if ( ( !key ) || ( !keylen ) || keylen > BLAKE2S_KEYBYTES ) return -1;
|
||||
|
||||
if( blake2s_init_param( S, &P ) < 0 )
|
||||
return -1;
|
||||
|
||||
{
|
||||
uint8_t block[BLAKE2S_BLOCKBYTES];
|
||||
memset( block, 0, BLAKE2S_BLOCKBYTES );
|
||||
memcpy( block, key, keylen );
|
||||
blake2s_update( S, block, BLAKE2S_BLOCKBYTES );
|
||||
secure_zero_memory( block, BLAKE2S_BLOCKBYTES ); /* Burn the key from stack */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BLAKE2_LOCAL_INLINE(int) blake2s_compress( blake2s_state *S, const uint8_t block[BLAKE2S_BLOCKBYTES] )
|
||||
{
|
||||
__m128i row1, row2, row3, row4;
|
||||
__m128i buf1, buf2, buf3, buf4;
|
||||
#if defined(HAVE_SSE41)
|
||||
__m128i t0, t1;
|
||||
#if !defined(HAVE_XOP)
|
||||
__m128i t2;
|
||||
#endif
|
||||
#endif
|
||||
__m128i ff0, ff1;
|
||||
#if defined(HAVE_SSSE3) && !defined(HAVE_XOP)
|
||||
const __m128i r8 = _mm_set_epi8( 12, 15, 14, 13, 8, 11, 10, 9, 4, 7, 6, 5, 0, 3, 2, 1 );
|
||||
const __m128i r16 = _mm_set_epi8( 13, 12, 15, 14, 9, 8, 11, 10, 5, 4, 7, 6, 1, 0, 3, 2 );
|
||||
#endif
|
||||
#if defined(HAVE_SSE41)
|
||||
const __m128i m0 = LOADU( block + 00 );
|
||||
const __m128i m1 = LOADU( block + 16 );
|
||||
const __m128i m2 = LOADU( block + 32 );
|
||||
const __m128i m3 = LOADU( block + 48 );
|
||||
#else
|
||||
const uint32_t m0 = ( ( uint32_t * )block )[ 0];
|
||||
const uint32_t m1 = ( ( uint32_t * )block )[ 1];
|
||||
const uint32_t m2 = ( ( uint32_t * )block )[ 2];
|
||||
const uint32_t m3 = ( ( uint32_t * )block )[ 3];
|
||||
const uint32_t m4 = ( ( uint32_t * )block )[ 4];
|
||||
const uint32_t m5 = ( ( uint32_t * )block )[ 5];
|
||||
const uint32_t m6 = ( ( uint32_t * )block )[ 6];
|
||||
const uint32_t m7 = ( ( uint32_t * )block )[ 7];
|
||||
const uint32_t m8 = ( ( uint32_t * )block )[ 8];
|
||||
const uint32_t m9 = ( ( uint32_t * )block )[ 9];
|
||||
const uint32_t m10 = ( ( uint32_t * )block )[10];
|
||||
const uint32_t m11 = ( ( uint32_t * )block )[11];
|
||||
const uint32_t m12 = ( ( uint32_t * )block )[12];
|
||||
const uint32_t m13 = ( ( uint32_t * )block )[13];
|
||||
const uint32_t m14 = ( ( uint32_t * )block )[14];
|
||||
const uint32_t m15 = ( ( uint32_t * )block )[15];
|
||||
#endif
|
||||
row1 = ff0 = LOADU( &S->h[0] );
|
||||
row2 = ff1 = LOADU( &S->h[4] );
|
||||
row3 = _mm_setr_epi32( 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A );
|
||||
row4 = _mm_xor_si128( _mm_setr_epi32( 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 ), LOADU( &S->t[0] ) );
|
||||
ROUND( 0 );
|
||||
ROUND( 1 );
|
||||
ROUND( 2 );
|
||||
ROUND( 3 );
|
||||
ROUND( 4 );
|
||||
ROUND( 5 );
|
||||
ROUND( 6 );
|
||||
ROUND( 7 );
|
||||
ROUND( 8 );
|
||||
ROUND( 9 );
|
||||
STOREU( &S->h[0], _mm_xor_si128( ff0, _mm_xor_si128( row1, row3 ) ) );
|
||||
STOREU( &S->h[4], _mm_xor_si128( ff1, _mm_xor_si128( row2, row4 ) ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* inlen now in bytes */
|
||||
int blake2s_update( blake2s_state *S, const uint8_t *in, uint64_t inlen )
|
||||
{
|
||||
while( inlen > 0 )
|
||||
{
|
||||
size_t left = S->buflen;
|
||||
size_t fill = 2 * BLAKE2S_BLOCKBYTES - left;
|
||||
|
||||
if( inlen > fill )
|
||||
{
|
||||
memcpy( S->buf + left, in, fill ); /* Fill buffer */
|
||||
S->buflen += fill;
|
||||
blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
|
||||
blake2s_compress( S, S->buf ); /* Compress */
|
||||
memcpy( S->buf, S->buf + BLAKE2S_BLOCKBYTES, BLAKE2S_BLOCKBYTES ); /* Shift buffer left */
|
||||
S->buflen -= BLAKE2S_BLOCKBYTES;
|
||||
in += fill;
|
||||
inlen -= fill;
|
||||
}
|
||||
else /* inlen <= fill */
|
||||
{
|
||||
memcpy( S->buf + left, in, inlen );
|
||||
S->buflen += inlen; /* Be lazy, do not compress */
|
||||
in += inlen;
|
||||
inlen -= inlen;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Is this correct? */
|
||||
int blake2s_final( blake2s_state *S, uint8_t *out, uint8_t outlen )
|
||||
{
|
||||
uint8_t buffer[BLAKE2S_OUTBYTES] = {0};
|
||||
int i;
|
||||
|
||||
if( outlen > BLAKE2S_OUTBYTES )
|
||||
return -1;
|
||||
|
||||
if( blake2s_is_lastblock( S ) )
|
||||
return -1;
|
||||
|
||||
if( S->buflen > BLAKE2S_BLOCKBYTES )
|
||||
{
|
||||
blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
|
||||
blake2s_compress( S, S->buf );
|
||||
S->buflen -= BLAKE2S_BLOCKBYTES;
|
||||
memmove( S->buf, S->buf + BLAKE2S_BLOCKBYTES, S->buflen );
|
||||
}
|
||||
|
||||
blake2s_increment_counter( S, ( uint32_t )S->buflen );
|
||||
blake2s_set_lastblock( S );
|
||||
memset( S->buf + S->buflen, 0, 2 * BLAKE2S_BLOCKBYTES - S->buflen ); /* Padding */
|
||||
blake2s_compress( S, S->buf );
|
||||
|
||||
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
||||
store32( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
||||
|
||||
memcpy( out, buffer, outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* inlen, at least, should be uint64_t. Others can be size_t. */
|
||||
int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen )
|
||||
{
|
||||
blake2s_state S[1];
|
||||
|
||||
/* Verify parameters */
|
||||
if ( NULL == in && inlen > 0 ) return -1;
|
||||
|
||||
if ( NULL == out ) return -1;
|
||||
|
||||
if ( NULL == key && keylen > 0) return -1;
|
||||
|
||||
if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
|
||||
|
||||
if( keylen > BLAKE2S_KEYBYTES ) return -1;
|
||||
|
||||
if( keylen > 0 )
|
||||
{
|
||||
if( blake2s_init_key( S, outlen, key, keylen ) < 0 ) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( blake2s_init( S, outlen ) < 0 ) return -1;
|
||||
}
|
||||
|
||||
blake2s_update( S, ( const uint8_t * )in, inlen );
|
||||
blake2s_final( S, out, outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(SUPERCOP)
|
||||
int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen )
|
||||
{
|
||||
return blake2s( out, in, NULL, BLAKE2S_OUTBYTES, inlen, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BLAKE2S_SELFTEST)
|
||||
#include <string.h>
|
||||
#include "blake2-kat.h"
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
uint8_t key[BLAKE2S_KEYBYTES];
|
||||
uint8_t buf[KAT_LENGTH];
|
||||
size_t i;
|
||||
|
||||
for( i = 0; i < BLAKE2S_KEYBYTES; ++i )
|
||||
key[i] = ( uint8_t )i;
|
||||
|
||||
for( i = 0; i < KAT_LENGTH; ++i )
|
||||
buf[i] = ( uint8_t )i;
|
||||
|
||||
for( i = 0; i < KAT_LENGTH; ++i )
|
||||
{
|
||||
uint8_t hash[BLAKE2S_OUTBYTES];
|
||||
|
||||
if( blake2s( hash, buf, key, BLAKE2S_OUTBYTES, i, BLAKE2S_KEYBYTES ) < 0 ||
|
||||
0 != memcmp( hash, blake2s_keyed_kat[i], BLAKE2S_OUTBYTES ) )
|
||||
{
|
||||
puts( "error" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
puts( "ok" );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
806
third_party/python/Modules/_bz2module.c
vendored
Normal file
806
third_party/python/Modules/_bz2module.c
vendored
Normal file
|
@ -0,0 +1,806 @@
|
|||
/* _bz2 - Low-level Python interface to libbzip2. */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
|
||||
#include "Python.h"
|
||||
#include "structmember.h"
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
#include "pythread.h"
|
||||
#endif
|
||||
|
||||
#include <bzlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifndef BZ_CONFIG_ERROR
|
||||
#define BZ2_bzCompress bzCompress
|
||||
#define BZ2_bzCompressInit bzCompressInit
|
||||
#define BZ2_bzCompressEnd bzCompressEnd
|
||||
#define BZ2_bzDecompress bzDecompress
|
||||
#define BZ2_bzDecompressInit bzDecompressInit
|
||||
#define BZ2_bzDecompressEnd bzDecompressEnd
|
||||
#endif /* ! BZ_CONFIG_ERROR */
|
||||
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
#define ACQUIRE_LOCK(obj) do { \
|
||||
if (!PyThread_acquire_lock((obj)->lock, 0)) { \
|
||||
Py_BEGIN_ALLOW_THREADS \
|
||||
PyThread_acquire_lock((obj)->lock, 1); \
|
||||
Py_END_ALLOW_THREADS \
|
||||
} } while (0)
|
||||
#define RELEASE_LOCK(obj) PyThread_release_lock((obj)->lock)
|
||||
#else
|
||||
#define ACQUIRE_LOCK(obj)
|
||||
#define RELEASE_LOCK(obj)
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
bz_stream bzs;
|
||||
int flushed;
|
||||
#ifdef WITH_THREAD
|
||||
PyThread_type_lock lock;
|
||||
#endif
|
||||
} BZ2Compressor;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
bz_stream bzs;
|
||||
char eof; /* T_BOOL expects a char */
|
||||
PyObject *unused_data;
|
||||
char needs_input;
|
||||
char *input_buffer;
|
||||
size_t input_buffer_size;
|
||||
|
||||
/* bzs->avail_in is only 32 bit, so we store the true length
|
||||
separately. Conversion and looping is encapsulated in
|
||||
decompress_buf() */
|
||||
size_t bzs_avail_in_real;
|
||||
#ifdef WITH_THREAD
|
||||
PyThread_type_lock lock;
|
||||
#endif
|
||||
} BZ2Decompressor;
|
||||
|
||||
static PyTypeObject BZ2Compressor_Type;
|
||||
static PyTypeObject BZ2Decompressor_Type;
|
||||
|
||||
/* Helper functions. */
|
||||
|
||||
static int
|
||||
catch_bz2_error(int bzerror)
|
||||
{
|
||||
switch(bzerror) {
|
||||
case BZ_OK:
|
||||
case BZ_RUN_OK:
|
||||
case BZ_FLUSH_OK:
|
||||
case BZ_FINISH_OK:
|
||||
case BZ_STREAM_END:
|
||||
return 0;
|
||||
|
||||
#ifdef BZ_CONFIG_ERROR
|
||||
case BZ_CONFIG_ERROR:
|
||||
PyErr_SetString(PyExc_SystemError,
|
||||
"libbzip2 was not compiled correctly");
|
||||
return 1;
|
||||
#endif
|
||||
case BZ_PARAM_ERROR:
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Internal error - "
|
||||
"invalid parameters passed to libbzip2");
|
||||
return 1;
|
||||
case BZ_MEM_ERROR:
|
||||
PyErr_NoMemory();
|
||||
return 1;
|
||||
case BZ_DATA_ERROR:
|
||||
case BZ_DATA_ERROR_MAGIC:
|
||||
PyErr_SetString(PyExc_IOError, "Invalid data stream");
|
||||
return 1;
|
||||
case BZ_IO_ERROR:
|
||||
PyErr_SetString(PyExc_IOError, "Unknown I/O error");
|
||||
return 1;
|
||||
case BZ_UNEXPECTED_EOF:
|
||||
PyErr_SetString(PyExc_EOFError,
|
||||
"Compressed file ended before the logical "
|
||||
"end-of-stream was detected");
|
||||
return 1;
|
||||
case BZ_SEQUENCE_ERROR:
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"Internal error - "
|
||||
"Invalid sequence of commands sent to libbzip2");
|
||||
return 1;
|
||||
default:
|
||||
PyErr_Format(PyExc_IOError,
|
||||
"Unrecognized error from libbzip2: %d", bzerror);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if BUFSIZ < 8192
|
||||
#define INITIAL_BUFFER_SIZE 8192
|
||||
#else
|
||||
#define INITIAL_BUFFER_SIZE BUFSIZ
|
||||
#endif
|
||||
|
||||
static int
|
||||
grow_buffer(PyObject **buf, Py_ssize_t max_length)
|
||||
{
|
||||
/* Expand the buffer by an amount proportional to the current size,
|
||||
giving us amortized linear-time behavior. Use a less-than-double
|
||||
growth factor to avoid excessive allocation. */
|
||||
size_t size = PyBytes_GET_SIZE(*buf);
|
||||
size_t new_size = size + (size >> 3) + 6;
|
||||
|
||||
if (max_length > 0 && new_size > (size_t) max_length)
|
||||
new_size = (size_t) max_length;
|
||||
|
||||
if (new_size > size) {
|
||||
return _PyBytes_Resize(buf, new_size);
|
||||
} else { /* overflow */
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"Unable to allocate buffer - output too large");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* BZ2Compressor class. */
|
||||
|
||||
static PyObject *
|
||||
compress(BZ2Compressor *c, char *data, size_t len, int action)
|
||||
{
|
||||
size_t data_size = 0;
|
||||
PyObject *result;
|
||||
|
||||
result = PyBytes_FromStringAndSize(NULL, INITIAL_BUFFER_SIZE);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
c->bzs.next_in = data;
|
||||
c->bzs.avail_in = 0;
|
||||
c->bzs.next_out = PyBytes_AS_STRING(result);
|
||||
c->bzs.avail_out = INITIAL_BUFFER_SIZE;
|
||||
for (;;) {
|
||||
char *this_out;
|
||||
int bzerror;
|
||||
|
||||
/* On a 64-bit system, len might not fit in avail_in (an unsigned int).
|
||||
Do compression in chunks of no more than UINT_MAX bytes each. */
|
||||
if (c->bzs.avail_in == 0 && len > 0) {
|
||||
c->bzs.avail_in = (unsigned int)Py_MIN(len, UINT_MAX);
|
||||
len -= c->bzs.avail_in;
|
||||
}
|
||||
|
||||
/* In regular compression mode, stop when input data is exhausted. */
|
||||
if (action == BZ_RUN && c->bzs.avail_in == 0)
|
||||
break;
|
||||
|
||||
if (c->bzs.avail_out == 0) {
|
||||
size_t buffer_left = PyBytes_GET_SIZE(result) - data_size;
|
||||
if (buffer_left == 0) {
|
||||
if (grow_buffer(&result, -1) < 0)
|
||||
goto error;
|
||||
c->bzs.next_out = PyBytes_AS_STRING(result) + data_size;
|
||||
buffer_left = PyBytes_GET_SIZE(result) - data_size;
|
||||
}
|
||||
c->bzs.avail_out = (unsigned int)Py_MIN(buffer_left, UINT_MAX);
|
||||
}
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
this_out = c->bzs.next_out;
|
||||
bzerror = BZ2_bzCompress(&c->bzs, action);
|
||||
data_size += c->bzs.next_out - this_out;
|
||||
Py_END_ALLOW_THREADS
|
||||
if (catch_bz2_error(bzerror))
|
||||
goto error;
|
||||
|
||||
/* In flushing mode, stop when all buffered data has been flushed. */
|
||||
if (action == BZ_FINISH && bzerror == BZ_STREAM_END)
|
||||
break;
|
||||
}
|
||||
if (data_size != (size_t)PyBytes_GET_SIZE(result))
|
||||
if (_PyBytes_Resize(&result, data_size) < 0)
|
||||
goto error;
|
||||
return result;
|
||||
|
||||
error:
|
||||
Py_XDECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
module _bz2
|
||||
class _bz2.BZ2Compressor "BZ2Compressor *" "&BZ2Compressor_Type"
|
||||
class _bz2.BZ2Decompressor "BZ2Decompressor *" "&BZ2Decompressor_Type"
|
||||
[clinic start generated code]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=dc7d7992a79f9cb7]*/
|
||||
|
||||
#include "clinic/_bz2module.c.h"
|
||||
|
||||
/*[clinic input]
|
||||
_bz2.BZ2Compressor.compress
|
||||
|
||||
data: Py_buffer
|
||||
/
|
||||
|
||||
Provide data to the compressor object.
|
||||
|
||||
Returns a chunk of compressed data if possible, or b'' otherwise.
|
||||
|
||||
When you have finished providing data to the compressor, call the
|
||||
flush() method to finish the compression process.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_bz2_BZ2Compressor_compress_impl(BZ2Compressor *self, Py_buffer *data)
|
||||
/*[clinic end generated code: output=59365426e941fbcc input=85c963218070fc4c]*/
|
||||
{
|
||||
PyObject *result = NULL;
|
||||
|
||||
ACQUIRE_LOCK(self);
|
||||
if (self->flushed)
|
||||
PyErr_SetString(PyExc_ValueError, "Compressor has been flushed");
|
||||
else
|
||||
result = compress(self, data->buf, data->len, BZ_RUN);
|
||||
RELEASE_LOCK(self);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_bz2.BZ2Compressor.flush
|
||||
|
||||
Finish the compression process.
|
||||
|
||||
Returns the compressed data left in internal buffers.
|
||||
|
||||
The compressor object may not be used after this method is called.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_bz2_BZ2Compressor_flush_impl(BZ2Compressor *self)
|
||||
/*[clinic end generated code: output=3ef03fc1b092a701 input=d64405d3c6f76691]*/
|
||||
{
|
||||
PyObject *result = NULL;
|
||||
|
||||
ACQUIRE_LOCK(self);
|
||||
if (self->flushed)
|
||||
PyErr_SetString(PyExc_ValueError, "Repeated call to flush()");
|
||||
else {
|
||||
self->flushed = 1;
|
||||
result = compress(self, NULL, 0, BZ_FINISH);
|
||||
}
|
||||
RELEASE_LOCK(self);
|
||||
return result;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
BZ2Compressor_getstate(BZ2Compressor *self, PyObject *noargs)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError, "cannot serialize '%s' object",
|
||||
Py_TYPE(self)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void*
|
||||
BZ2_Malloc(void* ctx, int items, int size)
|
||||
{
|
||||
if (items < 0 || size < 0)
|
||||
return NULL;
|
||||
if (size != 0 && (size_t)items > (size_t)PY_SSIZE_T_MAX / (size_t)size)
|
||||
return NULL;
|
||||
/* PyMem_Malloc() cannot be used: compress() and decompress()
|
||||
release the GIL */
|
||||
return PyMem_RawMalloc((size_t)items * (size_t)size);
|
||||
}
|
||||
|
||||
static void
|
||||
BZ2_Free(void* ctx, void *ptr)
|
||||
{
|
||||
PyMem_RawFree(ptr);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_bz2.BZ2Compressor.__init__
|
||||
|
||||
compresslevel: int = 9
|
||||
Compression level, as a number between 1 and 9.
|
||||
/
|
||||
|
||||
Create a compressor object for compressing data incrementally.
|
||||
|
||||
For one-shot compression, use the compress() function instead.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static int
|
||||
_bz2_BZ2Compressor___init___impl(BZ2Compressor *self, int compresslevel)
|
||||
/*[clinic end generated code: output=c4e6adfd02963827 input=4e1ff7b8394b6e9a]*/
|
||||
{
|
||||
int bzerror;
|
||||
|
||||
if (!(1 <= compresslevel && compresslevel <= 9)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"compresslevel must be between 1 and 9");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
self->lock = PyThread_allocate_lock();
|
||||
if (self->lock == NULL) {
|
||||
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
self->bzs.opaque = NULL;
|
||||
self->bzs.bzalloc = BZ2_Malloc;
|
||||
self->bzs.bzfree = BZ2_Free;
|
||||
bzerror = BZ2_bzCompressInit(&self->bzs, compresslevel, 0, 0);
|
||||
if (catch_bz2_error(bzerror))
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
#ifdef WITH_THREAD
|
||||
PyThread_free_lock(self->lock);
|
||||
self->lock = NULL;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
BZ2Compressor_dealloc(BZ2Compressor *self)
|
||||
{
|
||||
BZ2_bzCompressEnd(&self->bzs);
|
||||
#ifdef WITH_THREAD
|
||||
if (self->lock != NULL)
|
||||
PyThread_free_lock(self->lock);
|
||||
#endif
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyMethodDef BZ2Compressor_methods[] = {
|
||||
_BZ2_BZ2COMPRESSOR_COMPRESS_METHODDEF
|
||||
_BZ2_BZ2COMPRESSOR_FLUSH_METHODDEF
|
||||
{"__getstate__", (PyCFunction)BZ2Compressor_getstate, METH_NOARGS},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
static PyTypeObject BZ2Compressor_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_bz2.BZ2Compressor", /* tp_name */
|
||||
sizeof(BZ2Compressor), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)BZ2Compressor_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_reserved */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||
_bz2_BZ2Compressor___init____doc__, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
BZ2Compressor_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
_bz2_BZ2Compressor___init__, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
PyType_GenericNew, /* tp_new */
|
||||
};
|
||||
|
||||
|
||||
/* BZ2Decompressor class. */
|
||||
|
||||
/* Decompress data of length d->bzs_avail_in_real in d->bzs.next_in. The output
|
||||
buffer is allocated dynamically and returned. At most max_length bytes are
|
||||
returned, so some of the input may not be consumed. d->bzs.next_in and
|
||||
d->bzs_avail_in_real are updated to reflect the consumed input. */
|
||||
static PyObject*
|
||||
decompress_buf(BZ2Decompressor *d, Py_ssize_t max_length)
|
||||
{
|
||||
/* data_size is strictly positive, but because we repeatedly have to
|
||||
compare against max_length and PyBytes_GET_SIZE we declare it as
|
||||
signed */
|
||||
Py_ssize_t data_size = 0;
|
||||
PyObject *result;
|
||||
bz_stream *bzs = &d->bzs;
|
||||
|
||||
if (max_length < 0 || max_length >= INITIAL_BUFFER_SIZE)
|
||||
result = PyBytes_FromStringAndSize(NULL, INITIAL_BUFFER_SIZE);
|
||||
else
|
||||
result = PyBytes_FromStringAndSize(NULL, max_length);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
bzs->next_out = PyBytes_AS_STRING(result);
|
||||
for (;;) {
|
||||
int bzret;
|
||||
size_t avail;
|
||||
|
||||
/* On a 64-bit system, buffer length might not fit in avail_out, so we
|
||||
do decompression in chunks of no more than UINT_MAX bytes
|
||||
each. Note that the expression for `avail` is guaranteed to be
|
||||
positive, so the cast is safe. */
|
||||
avail = (size_t) (PyBytes_GET_SIZE(result) - data_size);
|
||||
bzs->avail_out = (unsigned int)Py_MIN(avail, UINT_MAX);
|
||||
bzs->avail_in = (unsigned int)Py_MIN(d->bzs_avail_in_real, UINT_MAX);
|
||||
d->bzs_avail_in_real -= bzs->avail_in;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
bzret = BZ2_bzDecompress(bzs);
|
||||
data_size = bzs->next_out - PyBytes_AS_STRING(result);
|
||||
d->bzs_avail_in_real += bzs->avail_in;
|
||||
Py_END_ALLOW_THREADS
|
||||
if (catch_bz2_error(bzret))
|
||||
goto error;
|
||||
if (bzret == BZ_STREAM_END) {
|
||||
d->eof = 1;
|
||||
break;
|
||||
} else if (d->bzs_avail_in_real == 0) {
|
||||
break;
|
||||
} else if (bzs->avail_out == 0) {
|
||||
if (data_size == max_length)
|
||||
break;
|
||||
if (data_size == PyBytes_GET_SIZE(result) &&
|
||||
grow_buffer(&result, max_length) == -1)
|
||||
goto error;
|
||||
bzs->next_out = PyBytes_AS_STRING(result) + data_size;
|
||||
}
|
||||
}
|
||||
if (data_size != PyBytes_GET_SIZE(result))
|
||||
if (_PyBytes_Resize(&result, data_size) == -1)
|
||||
goto error;
|
||||
|
||||
return result;
|
||||
|
||||
error:
|
||||
Py_XDECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
decompress(BZ2Decompressor *d, char *data, size_t len, Py_ssize_t max_length)
|
||||
{
|
||||
char input_buffer_in_use;
|
||||
PyObject *result;
|
||||
bz_stream *bzs = &d->bzs;
|
||||
|
||||
/* Prepend unconsumed input if necessary */
|
||||
if (bzs->next_in != NULL) {
|
||||
size_t avail_now, avail_total;
|
||||
|
||||
/* Number of bytes we can append to input buffer */
|
||||
avail_now = (d->input_buffer + d->input_buffer_size)
|
||||
- (bzs->next_in + d->bzs_avail_in_real);
|
||||
|
||||
/* Number of bytes we can append if we move existing
|
||||
contents to beginning of buffer (overwriting
|
||||
consumed input) */
|
||||
avail_total = d->input_buffer_size - d->bzs_avail_in_real;
|
||||
|
||||
if (avail_total < len) {
|
||||
size_t offset = bzs->next_in - d->input_buffer;
|
||||
char *tmp;
|
||||
size_t new_size = d->input_buffer_size + len - avail_now;
|
||||
|
||||
/* Assign to temporary variable first, so we don't
|
||||
lose address of allocated buffer if realloc fails */
|
||||
tmp = PyMem_Realloc(d->input_buffer, new_size);
|
||||
if (tmp == NULL) {
|
||||
PyErr_SetNone(PyExc_MemoryError);
|
||||
return NULL;
|
||||
}
|
||||
d->input_buffer = tmp;
|
||||
d->input_buffer_size = new_size;
|
||||
|
||||
bzs->next_in = d->input_buffer + offset;
|
||||
}
|
||||
else if (avail_now < len) {
|
||||
memmove(d->input_buffer, bzs->next_in,
|
||||
d->bzs_avail_in_real);
|
||||
bzs->next_in = d->input_buffer;
|
||||
}
|
||||
memcpy((void*)(bzs->next_in + d->bzs_avail_in_real), data, len);
|
||||
d->bzs_avail_in_real += len;
|
||||
input_buffer_in_use = 1;
|
||||
}
|
||||
else {
|
||||
bzs->next_in = data;
|
||||
d->bzs_avail_in_real = len;
|
||||
input_buffer_in_use = 0;
|
||||
}
|
||||
|
||||
result = decompress_buf(d, max_length);
|
||||
if(result == NULL) {
|
||||
bzs->next_in = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (d->eof) {
|
||||
d->needs_input = 0;
|
||||
if (d->bzs_avail_in_real > 0) {
|
||||
Py_XSETREF(d->unused_data,
|
||||
PyBytes_FromStringAndSize(bzs->next_in, d->bzs_avail_in_real));
|
||||
if (d->unused_data == NULL)
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
else if (d->bzs_avail_in_real == 0) {
|
||||
bzs->next_in = NULL;
|
||||
d->needs_input = 1;
|
||||
}
|
||||
else {
|
||||
d->needs_input = 0;
|
||||
|
||||
/* If we did not use the input buffer, we now have
|
||||
to copy the tail from the caller's buffer into the
|
||||
input buffer */
|
||||
if (!input_buffer_in_use) {
|
||||
|
||||
/* Discard buffer if it's too small
|
||||
(resizing it may needlessly copy the current contents) */
|
||||
if (d->input_buffer != NULL &&
|
||||
d->input_buffer_size < d->bzs_avail_in_real) {
|
||||
PyMem_Free(d->input_buffer);
|
||||
d->input_buffer = NULL;
|
||||
}
|
||||
|
||||
/* Allocate if necessary */
|
||||
if (d->input_buffer == NULL) {
|
||||
d->input_buffer = PyMem_Malloc(d->bzs_avail_in_real);
|
||||
if (d->input_buffer == NULL) {
|
||||
PyErr_SetNone(PyExc_MemoryError);
|
||||
goto error;
|
||||
}
|
||||
d->input_buffer_size = d->bzs_avail_in_real;
|
||||
}
|
||||
|
||||
/* Copy tail */
|
||||
memcpy(d->input_buffer, bzs->next_in, d->bzs_avail_in_real);
|
||||
bzs->next_in = d->input_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
error:
|
||||
Py_XDECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_bz2.BZ2Decompressor.decompress
|
||||
|
||||
data: Py_buffer
|
||||
max_length: Py_ssize_t=-1
|
||||
|
||||
Decompress *data*, returning uncompressed data as bytes.
|
||||
|
||||
If *max_length* is nonnegative, returns at most *max_length* bytes of
|
||||
decompressed data. If this limit is reached and further output can be
|
||||
produced, *self.needs_input* will be set to ``False``. In this case, the next
|
||||
call to *decompress()* may provide *data* as b'' to obtain more of the output.
|
||||
|
||||
If all of the input data was decompressed and returned (either because this
|
||||
was less than *max_length* bytes, or because *max_length* was negative),
|
||||
*self.needs_input* will be set to True.
|
||||
|
||||
Attempting to decompress data after the end of stream is reached raises an
|
||||
EOFError. Any data found after the end of the stream is ignored and saved in
|
||||
the unused_data attribute.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_bz2_BZ2Decompressor_decompress_impl(BZ2Decompressor *self, Py_buffer *data,
|
||||
Py_ssize_t max_length)
|
||||
/*[clinic end generated code: output=23e41045deb240a3 input=52e1ffc66a8ea624]*/
|
||||
{
|
||||
PyObject *result = NULL;
|
||||
|
||||
ACQUIRE_LOCK(self);
|
||||
if (self->eof)
|
||||
PyErr_SetString(PyExc_EOFError, "End of stream already reached");
|
||||
else
|
||||
result = decompress(self, data->buf, data->len, max_length);
|
||||
RELEASE_LOCK(self);
|
||||
return result;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
BZ2Decompressor_getstate(BZ2Decompressor *self, PyObject *noargs)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError, "cannot serialize '%s' object",
|
||||
Py_TYPE(self)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_bz2.BZ2Decompressor.__init__
|
||||
|
||||
Create a decompressor object for decompressing data incrementally.
|
||||
|
||||
For one-shot decompression, use the decompress() function instead.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static int
|
||||
_bz2_BZ2Decompressor___init___impl(BZ2Decompressor *self)
|
||||
/*[clinic end generated code: output=e4d2b9bb866ab8f1 input=95f6500dcda60088]*/
|
||||
{
|
||||
int bzerror;
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
PyThread_type_lock lock = PyThread_allocate_lock();
|
||||
if (lock == NULL) {
|
||||
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
|
||||
return -1;
|
||||
}
|
||||
if (self->lock != NULL) {
|
||||
PyThread_free_lock(self->lock);
|
||||
}
|
||||
self->lock = lock;
|
||||
#endif
|
||||
|
||||
self->needs_input = 1;
|
||||
self->bzs_avail_in_real = 0;
|
||||
self->input_buffer = NULL;
|
||||
self->input_buffer_size = 0;
|
||||
Py_XSETREF(self->unused_data, PyBytes_FromStringAndSize(NULL, 0));
|
||||
if (self->unused_data == NULL)
|
||||
goto error;
|
||||
|
||||
bzerror = BZ2_bzDecompressInit(&self->bzs, 0, 0);
|
||||
if (catch_bz2_error(bzerror))
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
Py_CLEAR(self->unused_data);
|
||||
#ifdef WITH_THREAD
|
||||
PyThread_free_lock(self->lock);
|
||||
self->lock = NULL;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
BZ2Decompressor_dealloc(BZ2Decompressor *self)
|
||||
{
|
||||
if(self->input_buffer != NULL)
|
||||
PyMem_Free(self->input_buffer);
|
||||
BZ2_bzDecompressEnd(&self->bzs);
|
||||
Py_CLEAR(self->unused_data);
|
||||
#ifdef WITH_THREAD
|
||||
if (self->lock != NULL)
|
||||
PyThread_free_lock(self->lock);
|
||||
#endif
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyMethodDef BZ2Decompressor_methods[] = {
|
||||
_BZ2_BZ2DECOMPRESSOR_DECOMPRESS_METHODDEF
|
||||
{"__getstate__", (PyCFunction)BZ2Decompressor_getstate, METH_NOARGS},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(BZ2Decompressor_eof__doc__,
|
||||
"True if the end-of-stream marker has been reached.");
|
||||
|
||||
PyDoc_STRVAR(BZ2Decompressor_unused_data__doc__,
|
||||
"Data found after the end of the compressed stream.");
|
||||
|
||||
PyDoc_STRVAR(BZ2Decompressor_needs_input_doc,
|
||||
"True if more input is needed before more decompressed data can be produced.");
|
||||
|
||||
static PyMemberDef BZ2Decompressor_members[] = {
|
||||
{"eof", T_BOOL, offsetof(BZ2Decompressor, eof),
|
||||
READONLY, BZ2Decompressor_eof__doc__},
|
||||
{"unused_data", T_OBJECT_EX, offsetof(BZ2Decompressor, unused_data),
|
||||
READONLY, BZ2Decompressor_unused_data__doc__},
|
||||
{"needs_input", T_BOOL, offsetof(BZ2Decompressor, needs_input), READONLY,
|
||||
BZ2Decompressor_needs_input_doc},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static PyTypeObject BZ2Decompressor_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_bz2.BZ2Decompressor", /* tp_name */
|
||||
sizeof(BZ2Decompressor), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)BZ2Decompressor_dealloc,/* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_reserved */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||
_bz2_BZ2Decompressor___init____doc__, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
BZ2Decompressor_methods, /* tp_methods */
|
||||
BZ2Decompressor_members, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
_bz2_BZ2Decompressor___init__, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
PyType_GenericNew, /* tp_new */
|
||||
};
|
||||
|
||||
|
||||
/* Module initialization. */
|
||||
|
||||
static struct PyModuleDef _bz2module = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"_bz2",
|
||||
NULL,
|
||||
-1,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC
|
||||
PyInit__bz2(void)
|
||||
{
|
||||
PyObject *m;
|
||||
|
||||
if (PyType_Ready(&BZ2Compressor_Type) < 0)
|
||||
return NULL;
|
||||
if (PyType_Ready(&BZ2Decompressor_Type) < 0)
|
||||
return NULL;
|
||||
|
||||
m = PyModule_Create(&_bz2module);
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
|
||||
Py_INCREF(&BZ2Compressor_Type);
|
||||
PyModule_AddObject(m, "BZ2Compressor", (PyObject *)&BZ2Compressor_Type);
|
||||
|
||||
Py_INCREF(&BZ2Decompressor_Type);
|
||||
PyModule_AddObject(m, "BZ2Decompressor",
|
||||
(PyObject *)&BZ2Decompressor_Type);
|
||||
|
||||
return m;
|
||||
}
|
1138
third_party/python/Modules/_codecsmodule.c
vendored
Normal file
1138
third_party/python/Modules/_codecsmodule.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
2432
third_party/python/Modules/_collectionsmodule.c
vendored
Normal file
2432
third_party/python/Modules/_collectionsmodule.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
65
third_party/python/Modules/_cryptmodule.c
vendored
Normal file
65
third_party/python/Modules/_cryptmodule.c
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* cryptmodule.c - by Steve Majewski
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Module crypt */
|
||||
|
||||
/*[clinic input]
|
||||
module crypt
|
||||
[clinic start generated code]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=c6252cf4f2f2ae81]*/
|
||||
|
||||
#include "clinic/_cryptmodule.c.h"
|
||||
|
||||
/*[clinic input]
|
||||
crypt.crypt
|
||||
|
||||
word: str
|
||||
salt: str
|
||||
/
|
||||
|
||||
Hash a *word* with the given *salt* and return the hashed password.
|
||||
|
||||
*word* will usually be a user's password. *salt* (either a random 2 or 16
|
||||
character string, possibly prefixed with $digit$ to indicate the method)
|
||||
will be used to perturb the encryption algorithm and produce distinct
|
||||
results for a given *word*.
|
||||
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
crypt_crypt_impl(PyObject *module, const char *word, const char *salt)
|
||||
/*[clinic end generated code: output=0512284a03d2803c input=0e8edec9c364352b]*/
|
||||
{
|
||||
/* On some platforms (AtheOS) crypt returns NULL for an invalid
|
||||
salt. Return None in that case. XXX Maybe raise an exception? */
|
||||
return Py_BuildValue("s", crypt(word, salt));
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef crypt_methods[] = {
|
||||
CRYPT_CRYPT_METHODDEF
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
static struct PyModuleDef cryptmodule = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"_crypt",
|
||||
NULL,
|
||||
-1,
|
||||
crypt_methods,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC
|
||||
PyInit__crypt(void)
|
||||
{
|
||||
return PyModule_Create(&cryptmodule);
|
||||
}
|
1680
third_party/python/Modules/_csv.c
vendored
Normal file
1680
third_party/python/Modules/_csv.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
5616
third_party/python/Modules/_ctypes/_ctypes.c
vendored
Normal file
5616
third_party/python/Modules/_ctypes/_ctypes.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
899
third_party/python/Modules/_ctypes/_ctypes_test.c
vendored
Normal file
899
third_party/python/Modules/_ctypes/_ctypes_test.c
vendored
Normal file
|
@ -0,0 +1,899 @@
|
|||
#include <Python.h>
|
||||
|
||||
#ifdef MS_WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(MS_WIN32) || defined(__CYGWIN__)
|
||||
#define EXPORT(x) __declspec(dllexport) x
|
||||
#else
|
||||
#define EXPORT(x) x
|
||||
#endif
|
||||
|
||||
/* some functions handy for testing */
|
||||
|
||||
EXPORT(int)
|
||||
_testfunc_cbk_reg_int(int a, int b, int c, int d, int e,
|
||||
int (*func)(int, int, int, int, int))
|
||||
{
|
||||
return func(a*a, b*b, c*c, d*d, e*e);
|
||||
}
|
||||
|
||||
EXPORT(double)
|
||||
_testfunc_cbk_reg_double(double a, double b, double c, double d, double e,
|
||||
double (*func)(double, double, double, double, double))
|
||||
{
|
||||
return func(a*a, b*b, c*c, d*d, e*e);
|
||||
}
|
||||
|
||||
/*
|
||||
* This structure should be the same as in test_callbacks.py and the
|
||||
* method test_callback_large_struct. See issues 17310 and 20160: the
|
||||
* structure must be larger than 8 bytes long.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned long first;
|
||||
unsigned long second;
|
||||
unsigned long third;
|
||||
} Test;
|
||||
|
||||
EXPORT(void)
|
||||
_testfunc_cbk_large_struct(Test in, void (*func)(Test))
|
||||
{
|
||||
func(in);
|
||||
}
|
||||
|
||||
/*
|
||||
* See issue 29565. Update a structure passed by value;
|
||||
* the caller should not see any change.
|
||||
*/
|
||||
|
||||
EXPORT(void)
|
||||
_testfunc_large_struct_update_value(Test in)
|
||||
{
|
||||
((volatile Test *)&in)->first = 0x0badf00d;
|
||||
((volatile Test *)&in)->second = 0x0badf00d;
|
||||
((volatile Test *)&in)->third = 0x0badf00d;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
unsigned int first;
|
||||
unsigned int second;
|
||||
} TestReg;
|
||||
|
||||
|
||||
EXPORT(TestReg) last_tfrsuv_arg;
|
||||
|
||||
|
||||
EXPORT(void)
|
||||
_testfunc_reg_struct_update_value(TestReg in)
|
||||
{
|
||||
last_tfrsuv_arg = in;
|
||||
((volatile TestReg *)&in)->first = 0x0badf00d;
|
||||
((volatile TestReg *)&in)->second = 0x0badf00d;
|
||||
}
|
||||
|
||||
|
||||
EXPORT(void)testfunc_array(int values[4])
|
||||
{
|
||||
printf("testfunc_array %d %d %d %d\n",
|
||||
values[0],
|
||||
values[1],
|
||||
values[2],
|
||||
values[3]);
|
||||
}
|
||||
|
||||
EXPORT(long double)testfunc_Ddd(double a, double b)
|
||||
{
|
||||
long double result = (long double)(a * b);
|
||||
printf("testfunc_Ddd(%p, %p)\n", &a, &b);
|
||||
printf("testfunc_Ddd(%g, %g)\n", a, b);
|
||||
return result;
|
||||
}
|
||||
|
||||
EXPORT(long double)testfunc_DDD(long double a, long double b)
|
||||
{
|
||||
long double result = a * b;
|
||||
printf("testfunc_DDD(%p, %p)\n", &a, &b);
|
||||
printf("testfunc_DDD(%Lg, %Lg)\n", a, b);
|
||||
return result;
|
||||
}
|
||||
|
||||
EXPORT(int)testfunc_iii(int a, int b)
|
||||
{
|
||||
int result = a * b;
|
||||
printf("testfunc_iii(%p, %p)\n", &a, &b);
|
||||
return result;
|
||||
}
|
||||
|
||||
EXPORT(int)myprintf(char *fmt, ...)
|
||||
{
|
||||
int result;
|
||||
va_list argptr;
|
||||
va_start(argptr, fmt);
|
||||
result = vprintf(fmt, argptr);
|
||||
va_end(argptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
EXPORT(char *)my_strtok(char *token, const char *delim)
|
||||
{
|
||||
return strtok(token, delim);
|
||||
}
|
||||
|
||||
EXPORT(char *)my_strchr(const char *s, int c)
|
||||
{
|
||||
return strchr(s, c);
|
||||
}
|
||||
|
||||
|
||||
EXPORT(double) my_sqrt(double a)
|
||||
{
|
||||
return sqrt(a);
|
||||
}
|
||||
|
||||
EXPORT(void) my_qsort(void *base, size_t num, size_t width, int(*compare)(const void*, const void*))
|
||||
{
|
||||
qsort(base, num, width, compare);
|
||||
}
|
||||
|
||||
EXPORT(int *) _testfunc_ai8(int a[8])
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
EXPORT(void) _testfunc_v(int a, int b, int *presult)
|
||||
{
|
||||
*presult = a + b;
|
||||
}
|
||||
|
||||
EXPORT(int) _testfunc_i_bhilfd(signed char b, short h, int i, long l, float f, double d)
|
||||
{
|
||||
/* printf("_testfunc_i_bhilfd got %d %d %d %ld %f %f\n",
|
||||
b, h, i, l, f, d);
|
||||
*/
|
||||
return (int)(b + h + i + l + f + d);
|
||||
}
|
||||
|
||||
EXPORT(float) _testfunc_f_bhilfd(signed char b, short h, int i, long l, float f, double d)
|
||||
{
|
||||
/* printf("_testfunc_f_bhilfd got %d %d %d %ld %f %f\n",
|
||||
b, h, i, l, f, d);
|
||||
*/
|
||||
return (float)(b + h + i + l + f + d);
|
||||
}
|
||||
|
||||
EXPORT(double) _testfunc_d_bhilfd(signed char b, short h, int i, long l, float f, double d)
|
||||
{
|
||||
/* printf("_testfunc_d_bhilfd got %d %d %d %ld %f %f\n",
|
||||
b, h, i, l, f, d);
|
||||
*/
|
||||
return (double)(b + h + i + l + f + d);
|
||||
}
|
||||
|
||||
EXPORT(long double) _testfunc_D_bhilfD(signed char b, short h, int i, long l, float f, long double d)
|
||||
{
|
||||
/* printf("_testfunc_d_bhilfd got %d %d %d %ld %f %f\n",
|
||||
b, h, i, l, f, d);
|
||||
*/
|
||||
return (long double)(b + h + i + l + f + d);
|
||||
}
|
||||
|
||||
EXPORT(char *) _testfunc_p_p(void *s)
|
||||
{
|
||||
return (char *)s;
|
||||
}
|
||||
|
||||
EXPORT(void *) _testfunc_c_p_p(int *argcp, char **argv)
|
||||
{
|
||||
return argv[(*argcp)-1];
|
||||
}
|
||||
|
||||
EXPORT(void *) get_strchr(void)
|
||||
{
|
||||
return (void *)strchr;
|
||||
}
|
||||
|
||||
EXPORT(char *) my_strdup(char *src)
|
||||
{
|
||||
char *dst = (char *)malloc(strlen(src)+1);
|
||||
if (!dst)
|
||||
return NULL;
|
||||
strcpy(dst, src);
|
||||
return dst;
|
||||
}
|
||||
|
||||
EXPORT(void)my_free(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
#ifdef HAVE_WCHAR_H
|
||||
EXPORT(wchar_t *) my_wcsdup(wchar_t *src)
|
||||
{
|
||||
size_t len = wcslen(src);
|
||||
wchar_t *ptr = (wchar_t *)malloc((len + 1) * sizeof(wchar_t));
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
memcpy(ptr, src, (len+1) * sizeof(wchar_t));
|
||||
return ptr;
|
||||
}
|
||||
|
||||
EXPORT(size_t) my_wcslen(wchar_t *src)
|
||||
{
|
||||
return wcslen(src);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef MS_WIN32
|
||||
# ifndef __stdcall
|
||||
# define __stdcall /* */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int (*c)(int, int);
|
||||
int (__stdcall *s)(int, int);
|
||||
} FUNCS;
|
||||
|
||||
EXPORT(int) _testfunc_callfuncp(FUNCS *fp)
|
||||
{
|
||||
fp->c(1, 2);
|
||||
fp->s(3, 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT(int) _testfunc_deref_pointer(int *pi)
|
||||
{
|
||||
return *pi;
|
||||
}
|
||||
|
||||
#ifdef MS_WIN32
|
||||
EXPORT(int) _testfunc_piunk(IUnknown FAR *piunk)
|
||||
{
|
||||
piunk->lpVtbl->AddRef(piunk);
|
||||
return piunk->lpVtbl->Release(piunk);
|
||||
}
|
||||
#endif
|
||||
|
||||
EXPORT(int) _testfunc_callback_with_pointer(int (*func)(int *))
|
||||
{
|
||||
int table[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
|
||||
return (*func)(table);
|
||||
}
|
||||
|
||||
EXPORT(long long) _testfunc_q_bhilfdq(signed char b, short h, int i, long l, float f,
|
||||
double d, long long q)
|
||||
{
|
||||
return (long long)(b + h + i + l + f + d + q);
|
||||
}
|
||||
|
||||
EXPORT(long long) _testfunc_q_bhilfd(signed char b, short h, int i, long l, float f, double d)
|
||||
{
|
||||
return (long long)(b + h + i + l + f + d);
|
||||
}
|
||||
|
||||
EXPORT(int) _testfunc_callback_i_if(int value, int (*func)(int))
|
||||
{
|
||||
int sum = 0;
|
||||
while (value != 0) {
|
||||
sum += func(value);
|
||||
value /= 2;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
EXPORT(long long) _testfunc_callback_q_qf(long long value,
|
||||
long long (*func)(long long))
|
||||
{
|
||||
long long sum = 0;
|
||||
|
||||
while (value != 0) {
|
||||
sum += func(value);
|
||||
value /= 2;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
char *value;
|
||||
} SPAM;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
int num_spams;
|
||||
SPAM *spams;
|
||||
} EGG;
|
||||
|
||||
SPAM my_spams[2] = {
|
||||
{ "name1", "value1" },
|
||||
{ "name2", "value2" },
|
||||
};
|
||||
|
||||
EGG my_eggs[1] = {
|
||||
{ "first egg", 1, my_spams }
|
||||
};
|
||||
|
||||
EXPORT(int) getSPAMANDEGGS(EGG **eggs)
|
||||
{
|
||||
*eggs = my_eggs;
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef struct tagpoint {
|
||||
int x;
|
||||
int y;
|
||||
} point;
|
||||
|
||||
EXPORT(int) _testfunc_byval(point in, point *pout)
|
||||
{
|
||||
if (pout) {
|
||||
pout->x = in.x;
|
||||
pout->y = in.y;
|
||||
}
|
||||
return in.x + in.y;
|
||||
}
|
||||
|
||||
EXPORT (int) an_integer = 42;
|
||||
|
||||
EXPORT(int) get_an_integer(void)
|
||||
{
|
||||
return an_integer;
|
||||
}
|
||||
|
||||
EXPORT(double)
|
||||
integrate(double a, double b, double (*f)(double), long nstep)
|
||||
{
|
||||
double x, sum=0.0, dx=(b-a)/(double)nstep;
|
||||
for(x=a+0.5*dx; (b-x)*(x-a)>0.0; x+=dx)
|
||||
sum += f(x);
|
||||
return sum/(double)nstep;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
void (*initialize)(void *(*)(int), void(*)(void *));
|
||||
} xxx_library;
|
||||
|
||||
static void _xxx_init(void *(*Xalloc)(int), void (*Xfree)(void *))
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
printf("_xxx_init got %p %p\n", Xalloc, Xfree);
|
||||
printf("calling\n");
|
||||
ptr = Xalloc(32);
|
||||
Xfree(ptr);
|
||||
printf("calls done, ptr was %p\n", ptr);
|
||||
}
|
||||
|
||||
xxx_library _xxx_lib = {
|
||||
_xxx_init
|
||||
};
|
||||
|
||||
EXPORT(xxx_library) *library_get(void)
|
||||
{
|
||||
return &_xxx_lib;
|
||||
}
|
||||
|
||||
#ifdef MS_WIN32
|
||||
/* See Don Box (german), pp 79ff. */
|
||||
EXPORT(void) GetString(BSTR *pbstr)
|
||||
{
|
||||
*pbstr = SysAllocString(L"Goodbye!");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some do-nothing functions, for speed tests
|
||||
*/
|
||||
PyObject *py_func_si(PyObject *self, PyObject *args)
|
||||
{
|
||||
char *name;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "si", &name, &i))
|
||||
return NULL;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
EXPORT(void) _py_func_si(char *s, int i)
|
||||
{
|
||||
}
|
||||
|
||||
PyObject *py_func(PyObject *self, PyObject *args)
|
||||
{
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
EXPORT(void) _py_func(void)
|
||||
{
|
||||
}
|
||||
|
||||
EXPORT(long long) last_tf_arg_s;
|
||||
EXPORT(unsigned long long) last_tf_arg_u;
|
||||
|
||||
struct BITS {
|
||||
int A: 1, B:2, C:3, D:4, E: 5, F: 6, G: 7, H: 8, I: 9;
|
||||
short M: 1, N: 2, O: 3, P: 4, Q: 5, R: 6, S: 7;
|
||||
};
|
||||
|
||||
EXPORT(void) set_bitfields(struct BITS *bits, char name, int value)
|
||||
{
|
||||
switch (name) {
|
||||
case 'A': bits->A = value; break;
|
||||
case 'B': bits->B = value; break;
|
||||
case 'C': bits->C = value; break;
|
||||
case 'D': bits->D = value; break;
|
||||
case 'E': bits->E = value; break;
|
||||
case 'F': bits->F = value; break;
|
||||
case 'G': bits->G = value; break;
|
||||
case 'H': bits->H = value; break;
|
||||
case 'I': bits->I = value; break;
|
||||
|
||||
case 'M': bits->M = value; break;
|
||||
case 'N': bits->N = value; break;
|
||||
case 'O': bits->O = value; break;
|
||||
case 'P': bits->P = value; break;
|
||||
case 'Q': bits->Q = value; break;
|
||||
case 'R': bits->R = value; break;
|
||||
case 'S': bits->S = value; break;
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT(int) unpack_bitfields(struct BITS *bits, char name)
|
||||
{
|
||||
switch (name) {
|
||||
case 'A': return bits->A;
|
||||
case 'B': return bits->B;
|
||||
case 'C': return bits->C;
|
||||
case 'D': return bits->D;
|
||||
case 'E': return bits->E;
|
||||
case 'F': return bits->F;
|
||||
case 'G': return bits->G;
|
||||
case 'H': return bits->H;
|
||||
case 'I': return bits->I;
|
||||
|
||||
case 'M': return bits->M;
|
||||
case 'N': return bits->N;
|
||||
case 'O': return bits->O;
|
||||
case 'P': return bits->P;
|
||||
case 'Q': return bits->Q;
|
||||
case 'R': return bits->R;
|
||||
case 'S': return bits->S;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyMethodDef module_methods[] = {
|
||||
/* {"get_last_tf_arg_s", get_last_tf_arg_s, METH_NOARGS},
|
||||
{"get_last_tf_arg_u", get_last_tf_arg_u, METH_NOARGS},
|
||||
*/
|
||||
{"func_si", py_func_si, METH_VARARGS},
|
||||
{"func", py_func, METH_NOARGS},
|
||||
{ NULL, NULL, 0, NULL},
|
||||
};
|
||||
|
||||
#define S last_tf_arg_s = (long long)c
|
||||
#define U last_tf_arg_u = (unsigned long long)c
|
||||
|
||||
EXPORT(signed char) tf_b(signed char c) { S; return c/3; }
|
||||
EXPORT(unsigned char) tf_B(unsigned char c) { U; return c/3; }
|
||||
EXPORT(short) tf_h(short c) { S; return c/3; }
|
||||
EXPORT(unsigned short) tf_H(unsigned short c) { U; return c/3; }
|
||||
EXPORT(int) tf_i(int c) { S; return c/3; }
|
||||
EXPORT(unsigned int) tf_I(unsigned int c) { U; return c/3; }
|
||||
EXPORT(long) tf_l(long c) { S; return c/3; }
|
||||
EXPORT(unsigned long) tf_L(unsigned long c) { U; return c/3; }
|
||||
EXPORT(long long) tf_q(long long c) { S; return c/3; }
|
||||
EXPORT(unsigned long long) tf_Q(unsigned long long c) { U; return c/3; }
|
||||
EXPORT(float) tf_f(float c) { S; return c/3; }
|
||||
EXPORT(double) tf_d(double c) { S; return c/3; }
|
||||
EXPORT(long double) tf_D(long double c) { S; return c/3; }
|
||||
|
||||
#ifdef MS_WIN32
|
||||
EXPORT(signed char) __stdcall s_tf_b(signed char c) { S; return c/3; }
|
||||
EXPORT(unsigned char) __stdcall s_tf_B(unsigned char c) { U; return c/3; }
|
||||
EXPORT(short) __stdcall s_tf_h(short c) { S; return c/3; }
|
||||
EXPORT(unsigned short) __stdcall s_tf_H(unsigned short c) { U; return c/3; }
|
||||
EXPORT(int) __stdcall s_tf_i(int c) { S; return c/3; }
|
||||
EXPORT(unsigned int) __stdcall s_tf_I(unsigned int c) { U; return c/3; }
|
||||
EXPORT(long) __stdcall s_tf_l(long c) { S; return c/3; }
|
||||
EXPORT(unsigned long) __stdcall s_tf_L(unsigned long c) { U; return c/3; }
|
||||
EXPORT(long long) __stdcall s_tf_q(long long c) { S; return c/3; }
|
||||
EXPORT(unsigned long long) __stdcall s_tf_Q(unsigned long long c) { U; return c/3; }
|
||||
EXPORT(float) __stdcall s_tf_f(float c) { S; return c/3; }
|
||||
EXPORT(double) __stdcall s_tf_d(double c) { S; return c/3; }
|
||||
EXPORT(long double) __stdcall s_tf_D(long double c) { S; return c/3; }
|
||||
#endif
|
||||
/*******/
|
||||
|
||||
EXPORT(signed char) tf_bb(signed char x, signed char c) { S; return c/3; }
|
||||
EXPORT(unsigned char) tf_bB(signed char x, unsigned char c) { U; return c/3; }
|
||||
EXPORT(short) tf_bh(signed char x, short c) { S; return c/3; }
|
||||
EXPORT(unsigned short) tf_bH(signed char x, unsigned short c) { U; return c/3; }
|
||||
EXPORT(int) tf_bi(signed char x, int c) { S; return c/3; }
|
||||
EXPORT(unsigned int) tf_bI(signed char x, unsigned int c) { U; return c/3; }
|
||||
EXPORT(long) tf_bl(signed char x, long c) { S; return c/3; }
|
||||
EXPORT(unsigned long) tf_bL(signed char x, unsigned long c) { U; return c/3; }
|
||||
EXPORT(long long) tf_bq(signed char x, long long c) { S; return c/3; }
|
||||
EXPORT(unsigned long long) tf_bQ(signed char x, unsigned long long c) { U; return c/3; }
|
||||
EXPORT(float) tf_bf(signed char x, float c) { S; return c/3; }
|
||||
EXPORT(double) tf_bd(signed char x, double c) { S; return c/3; }
|
||||
EXPORT(long double) tf_bD(signed char x, long double c) { S; return c/3; }
|
||||
EXPORT(void) tv_i(int c) { S; return; }
|
||||
|
||||
#ifdef MS_WIN32
|
||||
EXPORT(signed char) __stdcall s_tf_bb(signed char x, signed char c) { S; return c/3; }
|
||||
EXPORT(unsigned char) __stdcall s_tf_bB(signed char x, unsigned char c) { U; return c/3; }
|
||||
EXPORT(short) __stdcall s_tf_bh(signed char x, short c) { S; return c/3; }
|
||||
EXPORT(unsigned short) __stdcall s_tf_bH(signed char x, unsigned short c) { U; return c/3; }
|
||||
EXPORT(int) __stdcall s_tf_bi(signed char x, int c) { S; return c/3; }
|
||||
EXPORT(unsigned int) __stdcall s_tf_bI(signed char x, unsigned int c) { U; return c/3; }
|
||||
EXPORT(long) __stdcall s_tf_bl(signed char x, long c) { S; return c/3; }
|
||||
EXPORT(unsigned long) __stdcall s_tf_bL(signed char x, unsigned long c) { U; return c/3; }
|
||||
EXPORT(long long) __stdcall s_tf_bq(signed char x, long long c) { S; return c/3; }
|
||||
EXPORT(unsigned long long) __stdcall s_tf_bQ(signed char x, unsigned long long c) { U; return c/3; }
|
||||
EXPORT(float) __stdcall s_tf_bf(signed char x, float c) { S; return c/3; }
|
||||
EXPORT(double) __stdcall s_tf_bd(signed char x, double c) { S; return c/3; }
|
||||
EXPORT(long double) __stdcall s_tf_bD(signed char x, long double c) { S; return c/3; }
|
||||
EXPORT(void) __stdcall s_tv_i(int c) { S; return; }
|
||||
#endif
|
||||
|
||||
/********/
|
||||
|
||||
#ifndef MS_WIN32
|
||||
|
||||
typedef struct {
|
||||
long x;
|
||||
long y;
|
||||
} POINT;
|
||||
|
||||
typedef struct {
|
||||
long left;
|
||||
long top;
|
||||
long right;
|
||||
long bottom;
|
||||
} RECT;
|
||||
|
||||
#endif
|
||||
|
||||
EXPORT(int) PointInRect(RECT *prc, POINT pt)
|
||||
{
|
||||
if (pt.x < prc->left)
|
||||
return 0;
|
||||
if (pt.x > prc->right)
|
||||
return 0;
|
||||
if (pt.y < prc->top)
|
||||
return 0;
|
||||
if (pt.y > prc->bottom)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EXPORT(long left = 10);
|
||||
EXPORT(long top = 20);
|
||||
EXPORT(long right = 30);
|
||||
EXPORT(long bottom = 40);
|
||||
|
||||
EXPORT(RECT) ReturnRect(int i, RECT ar, RECT* br, POINT cp, RECT dr,
|
||||
RECT *er, POINT fp, RECT gr)
|
||||
{
|
||||
/*Check input */
|
||||
if (ar.left + br->left + dr.left + er->left + gr.left != left * 5)
|
||||
{
|
||||
ar.left = 100;
|
||||
return ar;
|
||||
}
|
||||
if (ar.right + br->right + dr.right + er->right + gr.right != right * 5)
|
||||
{
|
||||
ar.right = 100;
|
||||
return ar;
|
||||
}
|
||||
if (cp.x != fp.x)
|
||||
{
|
||||
ar.left = -100;
|
||||
}
|
||||
if (cp.y != fp.y)
|
||||
{
|
||||
ar.left = -200;
|
||||
}
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
return ar;
|
||||
break;
|
||||
case 1:
|
||||
return dr;
|
||||
break;
|
||||
case 2:
|
||||
return gr;
|
||||
break;
|
||||
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
short x;
|
||||
short y;
|
||||
} S2H;
|
||||
|
||||
EXPORT(S2H) ret_2h_func(S2H inp)
|
||||
{
|
||||
inp.x *= 2;
|
||||
inp.y *= 3;
|
||||
return inp;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int a, b, c, d, e, f, g, h;
|
||||
} S8I;
|
||||
|
||||
EXPORT(S8I) ret_8i_func(S8I inp)
|
||||
{
|
||||
inp.a *= 2;
|
||||
inp.b *= 3;
|
||||
inp.c *= 4;
|
||||
inp.d *= 5;
|
||||
inp.e *= 6;
|
||||
inp.f *= 7;
|
||||
inp.g *= 8;
|
||||
inp.h *= 9;
|
||||
return inp;
|
||||
}
|
||||
|
||||
EXPORT(int) GetRectangle(int flag, RECT *prect)
|
||||
{
|
||||
if (flag == 0)
|
||||
return 0;
|
||||
prect->left = (int)flag;
|
||||
prect->top = (int)flag + 1;
|
||||
prect->right = (int)flag + 2;
|
||||
prect->bottom = (int)flag + 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EXPORT(void) TwoOutArgs(int a, int *pi, int b, int *pj)
|
||||
{
|
||||
*pi += a;
|
||||
*pj += b;
|
||||
}
|
||||
|
||||
#ifdef MS_WIN32
|
||||
|
||||
typedef struct {
|
||||
char f1;
|
||||
} Size1;
|
||||
|
||||
typedef struct {
|
||||
char f1;
|
||||
char f2;
|
||||
} Size2;
|
||||
|
||||
typedef struct {
|
||||
char f1;
|
||||
char f2;
|
||||
char f3;
|
||||
} Size3;
|
||||
|
||||
typedef struct {
|
||||
char f1;
|
||||
char f2;
|
||||
char f3;
|
||||
char f4;
|
||||
} Size4;
|
||||
|
||||
typedef struct {
|
||||
char f1;
|
||||
char f2;
|
||||
char f3;
|
||||
char f4;
|
||||
char f5;
|
||||
} Size5;
|
||||
|
||||
typedef struct {
|
||||
char f1;
|
||||
char f2;
|
||||
char f3;
|
||||
char f4;
|
||||
char f5;
|
||||
char f6;
|
||||
} Size6;
|
||||
|
||||
typedef struct {
|
||||
char f1;
|
||||
char f2;
|
||||
char f3;
|
||||
char f4;
|
||||
char f5;
|
||||
char f6;
|
||||
char f7;
|
||||
} Size7;
|
||||
|
||||
typedef struct {
|
||||
char f1;
|
||||
char f2;
|
||||
char f3;
|
||||
char f4;
|
||||
char f5;
|
||||
char f6;
|
||||
char f7;
|
||||
char f8;
|
||||
} Size8;
|
||||
|
||||
typedef struct {
|
||||
char f1;
|
||||
char f2;
|
||||
char f3;
|
||||
char f4;
|
||||
char f5;
|
||||
char f6;
|
||||
char f7;
|
||||
char f8;
|
||||
char f9;
|
||||
} Size9;
|
||||
|
||||
typedef struct {
|
||||
char f1;
|
||||
char f2;
|
||||
char f3;
|
||||
char f4;
|
||||
char f5;
|
||||
char f6;
|
||||
char f7;
|
||||
char f8;
|
||||
char f9;
|
||||
char f10;
|
||||
} Size10;
|
||||
|
||||
EXPORT(Size1) TestSize1() {
|
||||
Size1 f;
|
||||
f.f1 = 'a';
|
||||
return f;
|
||||
}
|
||||
|
||||
EXPORT(Size2) TestSize2() {
|
||||
Size2 f;
|
||||
f.f1 = 'a';
|
||||
f.f2 = 'b';
|
||||
return f;
|
||||
}
|
||||
|
||||
EXPORT(Size3) TestSize3() {
|
||||
Size3 f;
|
||||
f.f1 = 'a';
|
||||
f.f2 = 'b';
|
||||
f.f3 = 'c';
|
||||
return f;
|
||||
}
|
||||
|
||||
EXPORT(Size4) TestSize4() {
|
||||
Size4 f;
|
||||
f.f1 = 'a';
|
||||
f.f2 = 'b';
|
||||
f.f3 = 'c';
|
||||
f.f4 = 'd';
|
||||
return f;
|
||||
}
|
||||
|
||||
EXPORT(Size5) TestSize5() {
|
||||
Size5 f;
|
||||
f.f1 = 'a';
|
||||
f.f2 = 'b';
|
||||
f.f3 = 'c';
|
||||
f.f4 = 'd';
|
||||
f.f5 = 'e';
|
||||
return f;
|
||||
}
|
||||
|
||||
EXPORT(Size6) TestSize6() {
|
||||
Size6 f;
|
||||
f.f1 = 'a';
|
||||
f.f2 = 'b';
|
||||
f.f3 = 'c';
|
||||
f.f4 = 'd';
|
||||
f.f5 = 'e';
|
||||
f.f6 = 'f';
|
||||
return f;
|
||||
}
|
||||
|
||||
EXPORT(Size7) TestSize7() {
|
||||
Size7 f;
|
||||
f.f1 = 'a';
|
||||
f.f2 = 'b';
|
||||
f.f3 = 'c';
|
||||
f.f4 = 'd';
|
||||
f.f5 = 'e';
|
||||
f.f6 = 'f';
|
||||
f.f7 = 'g';
|
||||
return f;
|
||||
}
|
||||
|
||||
EXPORT(Size8) TestSize8() {
|
||||
Size8 f;
|
||||
f.f1 = 'a';
|
||||
f.f2 = 'b';
|
||||
f.f3 = 'c';
|
||||
f.f4 = 'd';
|
||||
f.f5 = 'e';
|
||||
f.f6 = 'f';
|
||||
f.f7 = 'g';
|
||||
f.f8 = 'h';
|
||||
return f;
|
||||
}
|
||||
|
||||
EXPORT(Size9) TestSize9() {
|
||||
Size9 f;
|
||||
f.f1 = 'a';
|
||||
f.f2 = 'b';
|
||||
f.f3 = 'c';
|
||||
f.f4 = 'd';
|
||||
f.f5 = 'e';
|
||||
f.f6 = 'f';
|
||||
f.f7 = 'g';
|
||||
f.f8 = 'h';
|
||||
f.f9 = 'i';
|
||||
return f;
|
||||
}
|
||||
|
||||
EXPORT(Size10) TestSize10() {
|
||||
Size10 f;
|
||||
f.f1 = 'a';
|
||||
f.f2 = 'b';
|
||||
f.f3 = 'c';
|
||||
f.f4 = 'd';
|
||||
f.f5 = 'e';
|
||||
f.f6 = 'f';
|
||||
f.f7 = 'g';
|
||||
f.f8 = 'h';
|
||||
f.f9 = 'i';
|
||||
f.f10 = 'j';
|
||||
return f;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MS_WIN32
|
||||
EXPORT(S2H) __stdcall s_ret_2h_func(S2H inp) { return ret_2h_func(inp); }
|
||||
EXPORT(S8I) __stdcall s_ret_8i_func(S8I inp) { return ret_8i_func(inp); }
|
||||
#endif
|
||||
|
||||
#ifdef MS_WIN32
|
||||
/* Should port this */
|
||||
#include <stdlib.h>
|
||||
#include <search.h>
|
||||
|
||||
EXPORT (HRESULT) KeepObject(IUnknown *punk)
|
||||
{
|
||||
static IUnknown *pobj;
|
||||
if (punk)
|
||||
punk->lpVtbl->AddRef(punk);
|
||||
if (pobj)
|
||||
pobj->lpVtbl->Release(pobj);
|
||||
pobj = punk;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static struct PyModuleDef _ctypes_testmodule = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"_ctypes_test",
|
||||
NULL,
|
||||
-1,
|
||||
module_methods,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC
|
||||
PyInit__ctypes_test(void)
|
||||
{
|
||||
return PyModule_Create(&_ctypes_testmodule);
|
||||
}
|
1
third_party/python/Modules/_ctypes/_ctypes_test.h
vendored
Normal file
1
third_party/python/Modules/_ctypes/_ctypes_test.h
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
extern int _testfunc_i_bhilfd(char b, short h, int i, long l, float f, double d);
|
588
third_party/python/Modules/_ctypes/callbacks.c
vendored
Normal file
588
third_party/python/Modules/_ctypes/callbacks.c
vendored
Normal file
|
@ -0,0 +1,588 @@
|
|||
#include "Python.h"
|
||||
#include "frameobject.h"
|
||||
|
||||
#include <ffi.h>
|
||||
#ifdef MS_WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "ctypes.h"
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static void
|
||||
CThunkObject_dealloc(PyObject *myself)
|
||||
{
|
||||
CThunkObject *self = (CThunkObject *)myself;
|
||||
PyObject_GC_UnTrack(self);
|
||||
Py_XDECREF(self->converters);
|
||||
Py_XDECREF(self->callable);
|
||||
Py_XDECREF(self->restype);
|
||||
if (self->pcl_write)
|
||||
ffi_closure_free(self->pcl_write);
|
||||
PyObject_GC_Del(self);
|
||||
}
|
||||
|
||||
static int
|
||||
CThunkObject_traverse(PyObject *myself, visitproc visit, void *arg)
|
||||
{
|
||||
CThunkObject *self = (CThunkObject *)myself;
|
||||
Py_VISIT(self->converters);
|
||||
Py_VISIT(self->callable);
|
||||
Py_VISIT(self->restype);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
CThunkObject_clear(PyObject *myself)
|
||||
{
|
||||
CThunkObject *self = (CThunkObject *)myself;
|
||||
Py_CLEAR(self->converters);
|
||||
Py_CLEAR(self->callable);
|
||||
Py_CLEAR(self->restype);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyTypeObject PyCThunk_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.CThunkObject",
|
||||
sizeof(CThunkObject), /* tp_basicsize */
|
||||
sizeof(ffi_type), /* tp_itemsize */
|
||||
CThunkObject_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_reserved */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
||||
"CThunkObject", /* tp_doc */
|
||||
CThunkObject_traverse, /* tp_traverse */
|
||||
CThunkObject_clear, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
};
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static void
|
||||
PrintError(const char *msg, ...)
|
||||
{
|
||||
char buf[512];
|
||||
PyObject *f = PySys_GetObject("stderr");
|
||||
va_list marker;
|
||||
|
||||
va_start(marker, msg);
|
||||
vsnprintf(buf, sizeof(buf), msg, marker);
|
||||
va_end(marker);
|
||||
if (f != NULL && f != Py_None)
|
||||
PyFile_WriteString(buf, f);
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
|
||||
#ifdef MS_WIN32
|
||||
/*
|
||||
* We must call AddRef() on non-NULL COM pointers we receive as arguments
|
||||
* to callback functions - these functions are COM method implementations.
|
||||
* The Python instances we create have a __del__ method which calls Release().
|
||||
*
|
||||
* The presence of a class attribute named '_needs_com_addref_' triggers this
|
||||
* behaviour. It would also be possible to call the AddRef() Python method,
|
||||
* after checking for PyObject_IsTrue(), but this would probably be somewhat
|
||||
* slower.
|
||||
*/
|
||||
static void
|
||||
TryAddRef(StgDictObject *dict, CDataObject *obj)
|
||||
{
|
||||
IUnknown *punk;
|
||||
|
||||
if (NULL == PyDict_GetItemString((PyObject *)dict, "_needs_com_addref_"))
|
||||
return;
|
||||
|
||||
punk = *(IUnknown **)obj->b_ptr;
|
||||
if (punk)
|
||||
punk->lpVtbl->AddRef(punk);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Call the python object with all arguments
|
||||
*
|
||||
*/
|
||||
static void _CallPythonObject(void *mem,
|
||||
ffi_type *restype,
|
||||
SETFUNC setfunc,
|
||||
PyObject *callable,
|
||||
PyObject *converters,
|
||||
int flags,
|
||||
void **pArgs)
|
||||
{
|
||||
Py_ssize_t i;
|
||||
PyObject *result;
|
||||
PyObject *arglist = NULL;
|
||||
Py_ssize_t nArgs;
|
||||
PyObject *error_object = NULL;
|
||||
int *space;
|
||||
#ifdef WITH_THREAD
|
||||
PyGILState_STATE state = PyGILState_Ensure();
|
||||
#endif
|
||||
|
||||
nArgs = PySequence_Length(converters);
|
||||
/* Hm. What to return in case of error?
|
||||
For COM, 0xFFFFFFFF seems better than 0.
|
||||
*/
|
||||
if (nArgs < 0) {
|
||||
PrintError("BUG: PySequence_Length");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
arglist = PyTuple_New(nArgs);
|
||||
if (!arglist) {
|
||||
PrintError("PyTuple_New()");
|
||||
goto Done;
|
||||
}
|
||||
for (i = 0; i < nArgs; ++i) {
|
||||
/* Note: new reference! */
|
||||
PyObject *cnv = PySequence_GetItem(converters, i);
|
||||
StgDictObject *dict;
|
||||
if (cnv)
|
||||
dict = PyType_stgdict(cnv);
|
||||
else {
|
||||
PrintError("Getting argument converter %d\n", i);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dict && dict->getfunc && !_ctypes_simple_instance(cnv)) {
|
||||
PyObject *v = dict->getfunc(*pArgs, dict->size);
|
||||
if (!v) {
|
||||
PrintError("create argument %d:\n", i);
|
||||
Py_DECREF(cnv);
|
||||
goto Done;
|
||||
}
|
||||
PyTuple_SET_ITEM(arglist, i, v);
|
||||
/* XXX XXX XX
|
||||
We have the problem that c_byte or c_short have dict->size of
|
||||
1 resp. 4, but these parameters are pushed as sizeof(int) bytes.
|
||||
BTW, the same problem occurs when they are pushed as parameters
|
||||
*/
|
||||
} else if (dict) {
|
||||
/* Hm, shouldn't we use PyCData_AtAddress() or something like that instead? */
|
||||
CDataObject *obj = (CDataObject *)PyObject_CallFunctionObjArgs(cnv, NULL);
|
||||
if (!obj) {
|
||||
PrintError("create argument %d:\n", i);
|
||||
Py_DECREF(cnv);
|
||||
goto Done;
|
||||
}
|
||||
if (!CDataObject_Check(obj)) {
|
||||
Py_DECREF(obj);
|
||||
Py_DECREF(cnv);
|
||||
PrintError("unexpected result of create argument %d:\n", i);
|
||||
goto Done;
|
||||
}
|
||||
memcpy(obj->b_ptr, *pArgs, dict->size);
|
||||
PyTuple_SET_ITEM(arglist, i, (PyObject *)obj);
|
||||
#ifdef MS_WIN32
|
||||
TryAddRef(dict, obj);
|
||||
#endif
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"cannot build parameter");
|
||||
PrintError("Parsing argument %d\n", i);
|
||||
Py_DECREF(cnv);
|
||||
goto Done;
|
||||
}
|
||||
Py_DECREF(cnv);
|
||||
/* XXX error handling! */
|
||||
pArgs++;
|
||||
}
|
||||
|
||||
#define CHECK(what, x) \
|
||||
if (x == NULL) _PyTraceback_Add(what, "_ctypes/callbacks.c", __LINE__ - 1), PyErr_Print()
|
||||
|
||||
if (flags & (FUNCFLAG_USE_ERRNO | FUNCFLAG_USE_LASTERROR)) {
|
||||
error_object = _ctypes_get_errobj(&space);
|
||||
if (error_object == NULL)
|
||||
goto Done;
|
||||
if (flags & FUNCFLAG_USE_ERRNO) {
|
||||
int temp = space[0];
|
||||
space[0] = errno;
|
||||
errno = temp;
|
||||
}
|
||||
#ifdef MS_WIN32
|
||||
if (flags & FUNCFLAG_USE_LASTERROR) {
|
||||
int temp = space[1];
|
||||
space[1] = GetLastError();
|
||||
SetLastError(temp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
result = PyObject_CallObject(callable, arglist);
|
||||
CHECK("'calling callback function'", result);
|
||||
|
||||
#ifdef MS_WIN32
|
||||
if (flags & FUNCFLAG_USE_LASTERROR) {
|
||||
int temp = space[1];
|
||||
space[1] = GetLastError();
|
||||
SetLastError(temp);
|
||||
}
|
||||
#endif
|
||||
if (flags & FUNCFLAG_USE_ERRNO) {
|
||||
int temp = space[0];
|
||||
space[0] = errno;
|
||||
errno = temp;
|
||||
}
|
||||
Py_XDECREF(error_object);
|
||||
|
||||
if ((restype != &ffi_type_void) && result) {
|
||||
PyObject *keep;
|
||||
assert(setfunc);
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
/* See the corresponding code in callproc.c, around line 961 */
|
||||
if (restype->type != FFI_TYPE_FLOAT && restype->size < sizeof(ffi_arg))
|
||||
mem = (char *)mem + sizeof(ffi_arg) - restype->size;
|
||||
#endif
|
||||
keep = setfunc(mem, result, 0);
|
||||
CHECK("'converting callback result'", keep);
|
||||
/* keep is an object we have to keep alive so that the result
|
||||
stays valid. If there is no such object, the setfunc will
|
||||
have returned Py_None.
|
||||
|
||||
If there is such an object, we have no choice than to keep
|
||||
it alive forever - but a refcount and/or memory leak will
|
||||
be the result. EXCEPT when restype is py_object - Python
|
||||
itself knows how to manage the refcount of these objects.
|
||||
*/
|
||||
if (keep == NULL) /* Could not convert callback result. */
|
||||
PyErr_WriteUnraisable(callable);
|
||||
else if (keep == Py_None) /* Nothing to keep */
|
||||
Py_DECREF(keep);
|
||||
else if (setfunc != _ctypes_get_fielddesc("O")->setfunc) {
|
||||
if (-1 == PyErr_WarnEx(PyExc_RuntimeWarning,
|
||||
"memory leak in callback function.",
|
||||
1))
|
||||
PyErr_WriteUnraisable(callable);
|
||||
}
|
||||
}
|
||||
Py_XDECREF(result);
|
||||
Done:
|
||||
Py_XDECREF(arglist);
|
||||
#ifdef WITH_THREAD
|
||||
PyGILState_Release(state);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void closure_fcn(ffi_cif *cif,
|
||||
void *resp,
|
||||
void **args,
|
||||
void *userdata)
|
||||
{
|
||||
CThunkObject *p = (CThunkObject *)userdata;
|
||||
|
||||
_CallPythonObject(resp,
|
||||
p->ffi_restype,
|
||||
p->setfunc,
|
||||
p->callable,
|
||||
p->converters,
|
||||
p->flags,
|
||||
args);
|
||||
}
|
||||
|
||||
static CThunkObject* CThunkObject_new(Py_ssize_t nArgs)
|
||||
{
|
||||
CThunkObject *p;
|
||||
Py_ssize_t i;
|
||||
|
||||
p = PyObject_GC_NewVar(CThunkObject, &PyCThunk_Type, nArgs);
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->pcl_write = NULL;
|
||||
p->pcl_exec = NULL;
|
||||
memset(&p->cif, 0, sizeof(p->cif));
|
||||
p->flags = 0;
|
||||
p->converters = NULL;
|
||||
p->callable = NULL;
|
||||
p->restype = NULL;
|
||||
p->setfunc = NULL;
|
||||
p->ffi_restype = NULL;
|
||||
|
||||
for (i = 0; i < nArgs + 1; ++i)
|
||||
p->atypes[i] = NULL;
|
||||
PyObject_GC_Track((PyObject *)p);
|
||||
return p;
|
||||
}
|
||||
|
||||
CThunkObject *_ctypes_alloc_callback(PyObject *callable,
|
||||
PyObject *converters,
|
||||
PyObject *restype,
|
||||
int flags)
|
||||
{
|
||||
int result;
|
||||
CThunkObject *p;
|
||||
Py_ssize_t nArgs, i;
|
||||
ffi_abi cc;
|
||||
|
||||
nArgs = PySequence_Size(converters);
|
||||
p = CThunkObject_new(nArgs);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
assert(CThunk_CheckExact((PyObject *)p));
|
||||
|
||||
p->pcl_write = ffi_closure_alloc(sizeof(ffi_closure),
|
||||
&p->pcl_exec);
|
||||
if (p->pcl_write == NULL) {
|
||||
PyErr_NoMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
p->flags = flags;
|
||||
for (i = 0; i < nArgs; ++i) {
|
||||
PyObject *cnv = PySequence_GetItem(converters, i);
|
||||
if (cnv == NULL)
|
||||
goto error;
|
||||
p->atypes[i] = _ctypes_get_ffi_type(cnv);
|
||||
Py_DECREF(cnv);
|
||||
}
|
||||
p->atypes[i] = NULL;
|
||||
|
||||
Py_INCREF(restype);
|
||||
p->restype = restype;
|
||||
if (restype == Py_None) {
|
||||
p->setfunc = NULL;
|
||||
p->ffi_restype = &ffi_type_void;
|
||||
} else {
|
||||
StgDictObject *dict = PyType_stgdict(restype);
|
||||
if (dict == NULL || dict->setfunc == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"invalid result type for callback function");
|
||||
goto error;
|
||||
}
|
||||
p->setfunc = dict->setfunc;
|
||||
p->ffi_restype = &dict->ffi_type_pointer;
|
||||
}
|
||||
|
||||
cc = FFI_DEFAULT_ABI;
|
||||
#if defined(MS_WIN32) && !defined(_WIN32_WCE) && !defined(MS_WIN64)
|
||||
if ((flags & FUNCFLAG_CDECL) == 0)
|
||||
cc = FFI_STDCALL;
|
||||
#endif
|
||||
result = ffi_prep_cif(&p->cif, cc,
|
||||
Py_SAFE_DOWNCAST(nArgs, Py_ssize_t, int),
|
||||
_ctypes_get_ffi_type(restype),
|
||||
&p->atypes[0]);
|
||||
if (result != FFI_OK) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"ffi_prep_cif failed with %d", result);
|
||||
goto error;
|
||||
}
|
||||
#if defined(X86_DARWIN) || defined(POWERPC_DARWIN)
|
||||
result = ffi_prep_closure(p->pcl_write, &p->cif, closure_fcn, p);
|
||||
#else
|
||||
result = ffi_prep_closure_loc(p->pcl_write, &p->cif, closure_fcn,
|
||||
p,
|
||||
p->pcl_exec);
|
||||
#endif
|
||||
if (result != FFI_OK) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"ffi_prep_closure failed with %d", result);
|
||||
goto error;
|
||||
}
|
||||
|
||||
Py_INCREF(converters);
|
||||
p->converters = converters;
|
||||
Py_INCREF(callable);
|
||||
p->callable = callable;
|
||||
return p;
|
||||
|
||||
error:
|
||||
Py_XDECREF(p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef MS_WIN32
|
||||
|
||||
static void LoadPython(void)
|
||||
{
|
||||
if (!Py_IsInitialized()) {
|
||||
#ifdef WITH_THREAD
|
||||
PyEval_InitThreads();
|
||||
#endif
|
||||
Py_Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
||||
{
|
||||
PyObject *mod, *func, *result;
|
||||
long retval;
|
||||
static PyObject *context;
|
||||
|
||||
if (context == NULL)
|
||||
context = PyUnicode_InternFromString("_ctypes.DllGetClassObject");
|
||||
|
||||
mod = PyImport_ImportModuleNoBlock("ctypes");
|
||||
if (!mod) {
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
/* There has been a warning before about this already */
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
func = PyObject_GetAttrString(mod, "DllGetClassObject");
|
||||
Py_DECREF(mod);
|
||||
if (!func) {
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
{
|
||||
PyObject *py_rclsid = PyLong_FromVoidPtr((void *)rclsid);
|
||||
PyObject *py_riid = PyLong_FromVoidPtr((void *)riid);
|
||||
PyObject *py_ppv = PyLong_FromVoidPtr(ppv);
|
||||
if (!py_rclsid || !py_riid || !py_ppv) {
|
||||
Py_XDECREF(py_rclsid);
|
||||
Py_XDECREF(py_riid);
|
||||
Py_XDECREF(py_ppv);
|
||||
Py_DECREF(func);
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
return E_FAIL;
|
||||
}
|
||||
result = PyObject_CallFunctionObjArgs(func,
|
||||
py_rclsid,
|
||||
py_riid,
|
||||
py_ppv,
|
||||
NULL);
|
||||
Py_DECREF(py_rclsid);
|
||||
Py_DECREF(py_riid);
|
||||
Py_DECREF(py_ppv);
|
||||
}
|
||||
Py_DECREF(func);
|
||||
if (!result) {
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
retval = PyLong_AsLong(result);
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
retval = E_FAIL;
|
||||
}
|
||||
Py_DECREF(result);
|
||||
return retval;
|
||||
}
|
||||
|
||||
STDAPI DllGetClassObject(REFCLSID rclsid,
|
||||
REFIID riid,
|
||||
LPVOID *ppv)
|
||||
{
|
||||
long result;
|
||||
#ifdef WITH_THREAD
|
||||
PyGILState_STATE state;
|
||||
#endif
|
||||
|
||||
LoadPython();
|
||||
#ifdef WITH_THREAD
|
||||
state = PyGILState_Ensure();
|
||||
#endif
|
||||
result = Call_GetClassObject(rclsid, riid, ppv);
|
||||
#ifdef WITH_THREAD
|
||||
PyGILState_Release(state);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
long Call_CanUnloadNow(void)
|
||||
{
|
||||
PyObject *mod, *func, *result;
|
||||
long retval;
|
||||
static PyObject *context;
|
||||
|
||||
if (context == NULL)
|
||||
context = PyUnicode_InternFromString("_ctypes.DllCanUnloadNow");
|
||||
|
||||
mod = PyImport_ImportModuleNoBlock("ctypes");
|
||||
if (!mod) {
|
||||
/* OutputDebugString("Could not import ctypes"); */
|
||||
/* We assume that this error can only occur when shutting
|
||||
down, so we silently ignore it */
|
||||
PyErr_Clear();
|
||||
return E_FAIL;
|
||||
}
|
||||
/* Other errors cannot be raised, but are printed to stderr */
|
||||
func = PyObject_GetAttrString(mod, "DllCanUnloadNow");
|
||||
Py_DECREF(mod);
|
||||
if (!func) {
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
result = PyObject_CallFunction(func, NULL);
|
||||
Py_DECREF(func);
|
||||
if (!result) {
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
retval = PyLong_AsLong(result);
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||
retval = E_FAIL;
|
||||
}
|
||||
Py_DECREF(result);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
DllRegisterServer and DllUnregisterServer still missing
|
||||
*/
|
||||
|
||||
STDAPI DllCanUnloadNow(void)
|
||||
{
|
||||
long result;
|
||||
#ifdef WITH_THREAD
|
||||
PyGILState_STATE state = PyGILState_Ensure();
|
||||
#endif
|
||||
result = Call_CanUnloadNow();
|
||||
#ifdef WITH_THREAD
|
||||
PyGILState_Release(state);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef Py_NO_ENABLE_SHARED
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvRes)
|
||||
{
|
||||
switch(fdwReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
DisableThreadLibraryCalls(hinstDLL);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
compile-command: "cd .. && python setup.py -q build_ext"
|
||||
End:
|
||||
*/
|
1835
third_party/python/Modules/_ctypes/callproc.c
vendored
Normal file
1835
third_party/python/Modules/_ctypes/callproc.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
1668
third_party/python/Modules/_ctypes/cfield.c
vendored
Normal file
1668
third_party/python/Modules/_ctypes/cfield.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
371
third_party/python/Modules/_ctypes/ctypes.h
vendored
Normal file
371
third_party/python/Modules/_ctypes/ctypes.h
vendored
Normal file
|
@ -0,0 +1,371 @@
|
|||
#if defined (__SVR4) && defined (__sun)
|
||||
# include <alloca.h>
|
||||
#endif
|
||||
|
||||
#ifndef MS_WIN32
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
#define PARAMFLAG_FIN 0x1
|
||||
#define PARAMFLAG_FOUT 0x2
|
||||
#define PARAMFLAG_FLCID 0x4
|
||||
#endif
|
||||
|
||||
typedef struct tagPyCArgObject PyCArgObject;
|
||||
typedef struct tagCDataObject CDataObject;
|
||||
typedef PyObject *(* GETFUNC)(void *, Py_ssize_t size);
|
||||
typedef PyObject *(* SETFUNC)(void *, PyObject *value, Py_ssize_t size);
|
||||
typedef PyCArgObject *(* PARAMFUNC)(CDataObject *obj);
|
||||
|
||||
/* A default buffer in CDataObject, which can be used for small C types. If
|
||||
this buffer is too small, PyMem_Malloc will be called to create a larger one,
|
||||
and this one is not used.
|
||||
|
||||
Making CDataObject a variable size object would be a better solution, but more
|
||||
difficult in the presence of PyCFuncPtrObject. Maybe later.
|
||||
*/
|
||||
union value {
|
||||
char c[16];
|
||||
short s;
|
||||
int i;
|
||||
long l;
|
||||
float f;
|
||||
double d;
|
||||
long long ll;
|
||||
long double D;
|
||||
};
|
||||
|
||||
/*
|
||||
Hm. Are there CDataObject's which do not need the b_objects member? In
|
||||
this case we probably should introduce b_flags to mark it as present... If
|
||||
b_objects is not present/unused b_length is unneeded as well.
|
||||
*/
|
||||
|
||||
struct tagCDataObject {
|
||||
PyObject_HEAD
|
||||
char *b_ptr; /* pointer to memory block */
|
||||
int b_needsfree; /* need _we_ free the memory? */
|
||||
CDataObject *b_base; /* pointer to base object or NULL */
|
||||
Py_ssize_t b_size; /* size of memory block in bytes */
|
||||
Py_ssize_t b_length; /* number of references we need */
|
||||
Py_ssize_t b_index; /* index of this object into base's
|
||||
b_object list */
|
||||
PyObject *b_objects; /* dictionary of references we need to keep, or Py_None */
|
||||
union value b_value;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
ffi_closure *pcl_write; /* the C callable, writeable */
|
||||
void *pcl_exec; /* the C callable, executable */
|
||||
ffi_cif cif;
|
||||
int flags;
|
||||
PyObject *converters;
|
||||
PyObject *callable;
|
||||
PyObject *restype;
|
||||
SETFUNC setfunc;
|
||||
ffi_type *ffi_restype;
|
||||
ffi_type *atypes[1];
|
||||
} CThunkObject;
|
||||
extern PyTypeObject PyCThunk_Type;
|
||||
#define CThunk_CheckExact(v) ((v)->ob_type == &PyCThunk_Type)
|
||||
|
||||
typedef struct {
|
||||
/* First part identical to tagCDataObject */
|
||||
PyObject_HEAD
|
||||
char *b_ptr; /* pointer to memory block */
|
||||
int b_needsfree; /* need _we_ free the memory? */
|
||||
CDataObject *b_base; /* pointer to base object or NULL */
|
||||
Py_ssize_t b_size; /* size of memory block in bytes */
|
||||
Py_ssize_t b_length; /* number of references we need */
|
||||
Py_ssize_t b_index; /* index of this object into base's
|
||||
b_object list */
|
||||
PyObject *b_objects; /* list of references we need to keep */
|
||||
union value b_value;
|
||||
/* end of tagCDataObject, additional fields follow */
|
||||
|
||||
CThunkObject *thunk;
|
||||
PyObject *callable;
|
||||
|
||||
/* These two fields will override the ones in the type's stgdict if
|
||||
they are set */
|
||||
PyObject *converters;
|
||||
PyObject *argtypes;
|
||||
PyObject *restype;
|
||||
PyObject *checker;
|
||||
PyObject *errcheck;
|
||||
#ifdef MS_WIN32
|
||||
int index;
|
||||
GUID *iid;
|
||||
#endif
|
||||
PyObject *paramflags;
|
||||
} PyCFuncPtrObject;
|
||||
|
||||
extern PyTypeObject PyCStgDict_Type;
|
||||
#define PyCStgDict_CheckExact(v) ((v)->ob_type == &PyCStgDict_Type)
|
||||
#define PyCStgDict_Check(v) PyObject_TypeCheck(v, &PyCStgDict_Type)
|
||||
|
||||
extern int PyCStructUnionType_update_stgdict(PyObject *fields, PyObject *type, int isStruct);
|
||||
extern int PyType_stginfo(PyTypeObject *self, Py_ssize_t *psize, Py_ssize_t *palign, Py_ssize_t *plength);
|
||||
extern int PyObject_stginfo(PyObject *self, Py_ssize_t *psize, Py_ssize_t *palign, Py_ssize_t *plength);
|
||||
|
||||
|
||||
|
||||
extern PyTypeObject PyCData_Type;
|
||||
#define CDataObject_CheckExact(v) ((v)->ob_type == &PyCData_Type)
|
||||
#define CDataObject_Check(v) PyObject_TypeCheck(v, &PyCData_Type)
|
||||
#define _CDataObject_HasExternalBuffer(v) ((v)->b_ptr != (char *)&(v)->b_value)
|
||||
|
||||
extern PyTypeObject PyCSimpleType_Type;
|
||||
#define PyCSimpleTypeObject_CheckExact(v) ((v)->ob_type == &PyCSimpleType_Type)
|
||||
#define PyCSimpleTypeObject_Check(v) PyObject_TypeCheck(v, &PyCSimpleType_Type)
|
||||
|
||||
extern PyTypeObject PyCField_Type;
|
||||
extern struct fielddesc *_ctypes_get_fielddesc(const char *fmt);
|
||||
|
||||
|
||||
extern PyObject *
|
||||
PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
|
||||
Py_ssize_t *pfield_size, int bitsize, int *pbitofs,
|
||||
Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign,
|
||||
int pack, int is_big_endian);
|
||||
|
||||
extern PyObject *PyCData_AtAddress(PyObject *type, void *buf);
|
||||
extern PyObject *PyCData_FromBytes(PyObject *type, char *data, Py_ssize_t length);
|
||||
|
||||
extern PyTypeObject PyCArrayType_Type;
|
||||
extern PyTypeObject PyCArray_Type;
|
||||
extern PyTypeObject PyCPointerType_Type;
|
||||
extern PyTypeObject PyCPointer_Type;
|
||||
extern PyTypeObject PyCFuncPtr_Type;
|
||||
extern PyTypeObject PyCFuncPtrType_Type;
|
||||
extern PyTypeObject PyCStructType_Type;
|
||||
|
||||
#define PyCArrayTypeObject_Check(v) PyObject_TypeCheck(v, &PyCArrayType_Type)
|
||||
#define ArrayObject_Check(v) PyObject_TypeCheck(v, &PyCArray_Type)
|
||||
#define PointerObject_Check(v) PyObject_TypeCheck(v, &PyCPointer_Type)
|
||||
#define PyCPointerTypeObject_Check(v) PyObject_TypeCheck(v, &PyCPointerType_Type)
|
||||
#define PyCFuncPtrObject_Check(v) PyObject_TypeCheck(v, &PyCFuncPtr_Type)
|
||||
#define PyCFuncPtrTypeObject_Check(v) PyObject_TypeCheck(v, &PyCFuncPtrType_Type)
|
||||
#define PyCStructTypeObject_Check(v) PyObject_TypeCheck(v, &PyCStructType_Type)
|
||||
|
||||
extern PyObject *
|
||||
PyCArrayType_from_ctype(PyObject *itemtype, Py_ssize_t length);
|
||||
|
||||
extern PyMethodDef _ctypes_module_methods[];
|
||||
|
||||
extern CThunkObject *_ctypes_alloc_callback(PyObject *callable,
|
||||
PyObject *converters,
|
||||
PyObject *restype,
|
||||
int flags);
|
||||
/* a table entry describing a predefined ctypes type */
|
||||
struct fielddesc {
|
||||
char code;
|
||||
SETFUNC setfunc;
|
||||
GETFUNC getfunc;
|
||||
ffi_type *pffi_type; /* always statically allocated */
|
||||
SETFUNC setfunc_swapped;
|
||||
GETFUNC getfunc_swapped;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Py_ssize_t offset;
|
||||
Py_ssize_t size;
|
||||
Py_ssize_t index; /* Index into CDataObject's
|
||||
object array */
|
||||
PyObject *proto; /* a type or NULL */
|
||||
GETFUNC getfunc; /* getter function if proto is NULL */
|
||||
SETFUNC setfunc; /* setter function if proto is NULL */
|
||||
int anonymous;
|
||||
} CFieldObject;
|
||||
|
||||
/* A subclass of PyDictObject, used as the instance dictionary of ctypes
|
||||
metatypes */
|
||||
typedef struct {
|
||||
PyDictObject dict; /* first part identical to PyDictObject */
|
||||
/* The size and align fields are unneeded, they are in ffi_type as well. As
|
||||
an experiment shows, it's trivial to get rid of them, the only thing to
|
||||
remember is that in PyCArrayType_new the ffi_type fields must be filled in -
|
||||
so far it was unneeded because libffi doesn't support arrays at all
|
||||
(because they are passed as pointers to function calls anyway). But it's
|
||||
too much risk to change that now, and there are other fields which doesn't
|
||||
belong into this structure anyway. Maybe in ctypes 2.0... (ctypes 2000?)
|
||||
*/
|
||||
Py_ssize_t size; /* number of bytes */
|
||||
Py_ssize_t align; /* alignment requirements */
|
||||
Py_ssize_t length; /* number of fields */
|
||||
ffi_type ffi_type_pointer;
|
||||
PyObject *proto; /* Only for Pointer/ArrayObject */
|
||||
SETFUNC setfunc; /* Only for simple objects */
|
||||
GETFUNC getfunc; /* Only for simple objects */
|
||||
PARAMFUNC paramfunc;
|
||||
|
||||
/* Following fields only used by PyCFuncPtrType_Type instances */
|
||||
PyObject *argtypes; /* tuple of CDataObjects */
|
||||
PyObject *converters; /* tuple([t.from_param for t in argtypes]) */
|
||||
PyObject *restype; /* CDataObject or NULL */
|
||||
PyObject *checker;
|
||||
int flags; /* calling convention and such */
|
||||
|
||||
/* pep3118 fields, pointers neeed PyMem_Free */
|
||||
char *format;
|
||||
int ndim;
|
||||
Py_ssize_t *shape;
|
||||
/* Py_ssize_t *strides; */ /* unused in ctypes */
|
||||
/* Py_ssize_t *suboffsets; */ /* unused in ctypes */
|
||||
|
||||
} StgDictObject;
|
||||
|
||||
/****************************************************************
|
||||
StgDictObject fields
|
||||
|
||||
setfunc and getfunc is only set for simple data types, it is copied from the
|
||||
corresponding fielddesc entry. These are functions to set and get the value
|
||||
in a memory block.
|
||||
They should probably by used by other types as well.
|
||||
|
||||
proto is only used for Pointer and Array types - it points to the item type
|
||||
object.
|
||||
|
||||
Probably all the magic ctypes methods (like from_param) should have C
|
||||
callable wrappers in the StgDictObject. For simple data type, for example,
|
||||
the fielddesc table could have entries for C codec from_param functions or
|
||||
other methods as well, if a subtype overrides this method in Python at
|
||||
construction time, or assigns to it later, tp_setattro should update the
|
||||
StgDictObject function to a generic one.
|
||||
|
||||
Currently, PyCFuncPtr types have 'converters' and 'checker' entries in their
|
||||
type dict. They are only used to cache attributes from other entries, which
|
||||
is wrong.
|
||||
|
||||
One use case is the .value attribute that all simple types have. But some
|
||||
complex structures, like VARIANT, represent a single value also, and should
|
||||
have this attribute.
|
||||
|
||||
Another use case is a _check_retval_ function, which is called when a ctypes
|
||||
type is used as return type of a function to validate and compute the return
|
||||
value.
|
||||
|
||||
Common ctypes protocol:
|
||||
|
||||
- setfunc: store a python value in a memory block
|
||||
- getfunc: convert data from a memory block into a python value
|
||||
|
||||
- checkfunc: validate and convert a return value from a function call
|
||||
- toparamfunc: convert a python value into a function argument
|
||||
|
||||
*****************************************************************/
|
||||
|
||||
/* May return NULL, but does not set an exception! */
|
||||
extern StgDictObject *PyType_stgdict(PyObject *obj);
|
||||
|
||||
/* May return NULL, but does not set an exception! */
|
||||
extern StgDictObject *PyObject_stgdict(PyObject *self);
|
||||
|
||||
extern int PyCStgDict_clone(StgDictObject *src, StgDictObject *dst);
|
||||
|
||||
typedef int(* PPROC)(void);
|
||||
|
||||
PyObject *_ctypes_callproc(PPROC pProc,
|
||||
PyObject *arguments,
|
||||
#ifdef MS_WIN32
|
||||
IUnknown *pIUnk,
|
||||
GUID *iid,
|
||||
#endif
|
||||
int flags,
|
||||
PyObject *argtypes,
|
||||
PyObject *restype,
|
||||
PyObject *checker);
|
||||
|
||||
|
||||
#define FUNCFLAG_STDCALL 0x0
|
||||
#define FUNCFLAG_CDECL 0x1
|
||||
#define FUNCFLAG_HRESULT 0x2
|
||||
#define FUNCFLAG_PYTHONAPI 0x4
|
||||
#define FUNCFLAG_USE_ERRNO 0x8
|
||||
#define FUNCFLAG_USE_LASTERROR 0x10
|
||||
|
||||
#define TYPEFLAG_ISPOINTER 0x100
|
||||
#define TYPEFLAG_HASPOINTER 0x200
|
||||
|
||||
#define DICTFLAG_FINAL 0x1000
|
||||
|
||||
struct tagPyCArgObject {
|
||||
PyObject_HEAD
|
||||
ffi_type *pffi_type;
|
||||
char tag;
|
||||
union {
|
||||
char c;
|
||||
char b;
|
||||
short h;
|
||||
int i;
|
||||
long l;
|
||||
long long q;
|
||||
long double D;
|
||||
double d;
|
||||
float f;
|
||||
void *p;
|
||||
} value;
|
||||
PyObject *obj;
|
||||
Py_ssize_t size; /* for the 'V' tag */
|
||||
};
|
||||
|
||||
extern PyTypeObject PyCArg_Type;
|
||||
#define PyCArg_CheckExact(v) ((v)->ob_type == &PyCArg_Type)
|
||||
extern PyCArgObject *PyCArgObject_new(void);
|
||||
|
||||
extern PyObject *
|
||||
PyCData_get(PyObject *type, GETFUNC getfunc, PyObject *src,
|
||||
Py_ssize_t index, Py_ssize_t size, char *ptr);
|
||||
|
||||
extern int
|
||||
PyCData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
|
||||
Py_ssize_t index, Py_ssize_t size, char *ptr);
|
||||
|
||||
extern void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...);
|
||||
|
||||
struct basespec {
|
||||
CDataObject *base;
|
||||
Py_ssize_t index;
|
||||
char *adr;
|
||||
};
|
||||
|
||||
extern char basespec_string[];
|
||||
|
||||
extern ffi_type *_ctypes_get_ffi_type(PyObject *obj);
|
||||
|
||||
/* exception classes */
|
||||
extern PyObject *PyExc_ArgError;
|
||||
|
||||
extern char *_ctypes_conversion_encoding;
|
||||
extern char *_ctypes_conversion_errors;
|
||||
|
||||
#if defined(HAVE_WCHAR_H)
|
||||
# define CTYPES_UNICODE
|
||||
#endif
|
||||
|
||||
|
||||
extern void _ctypes_free_closure(void *);
|
||||
extern void *_ctypes_alloc_closure(void);
|
||||
|
||||
extern PyObject *PyCData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr);
|
||||
extern char *_ctypes_alloc_format_string(const char *prefix, const char *suffix);
|
||||
extern char *_ctypes_alloc_format_string_with_shape(int ndim,
|
||||
const Py_ssize_t *shape,
|
||||
const char *prefix, const char *suffix);
|
||||
|
||||
extern int _ctypes_simple_instance(PyObject *obj);
|
||||
|
||||
extern PyObject *_ctypes_ptrtype_cache;
|
||||
PyObject *_ctypes_get_errobj(int **pspace);
|
||||
|
||||
#ifdef MS_WIN32
|
||||
extern PyObject *ComError;
|
||||
#endif
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
compile-command: "python setup.py -q build install --home ~"
|
||||
End:
|
||||
*/
|
27
third_party/python/Modules/_ctypes/ctypes_dlfcn.h
vendored
Normal file
27
third_party/python/Modules/_ctypes/ctypes_dlfcn.h
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef _CTYPES_DLFCN_H_
|
||||
#define _CTYPES_DLFCN_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef MS_WIN32
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifndef CTYPES_DARWIN_DLFCN
|
||||
|
||||
#define ctypes_dlsym dlsym
|
||||
#define ctypes_dlerror dlerror
|
||||
#define ctypes_dlopen dlopen
|
||||
#define ctypes_dlclose dlclose
|
||||
#define ctypes_dladdr dladdr
|
||||
|
||||
#endif /* !CTYPES_DARWIN_DLFCN */
|
||||
|
||||
#endif /* !MS_WIN32 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* _CTYPES_DLFCN_H_ */
|
31
third_party/python/Modules/_ctypes/darwin/LICENSE
vendored
Normal file
31
third_party/python/Modules/_ctypes/darwin/LICENSE
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
Copyright (c) 2002 Jorge Acereda <jacereda@users.sourceforge.net> &
|
||||
Peter O'Gorman <ogorman@users.sourceforge.net>
|
||||
|
||||
Portions may be copyright others, see the AUTHORS file included with this
|
||||
distribution.
|
||||
|
||||
Maintained by Peter O'Gorman <ogorman@users.sourceforge.net>
|
||||
|
||||
Bug Reports and other queries should go to <ogorman@users.sourceforge.net>
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
95
third_party/python/Modules/_ctypes/darwin/README
vendored
Normal file
95
third_party/python/Modules/_ctypes/darwin/README
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
dlcompat for Darwin
|
||||
=========================
|
||||
|
||||
This is dlcompat, a small library that emulates the dlopen()
|
||||
interface on top of Darwin's dyld API.
|
||||
|
||||
dlcompat allows loading a ".dylib" library (as long as the RTLD_LOCAL
|
||||
flag isn't passed to dlopen()). It can be configured to yield a warning
|
||||
when trying to close it (dynamic libraries cannot currently be unloaded).
|
||||
|
||||
It automatically searches for modules in several directories when no
|
||||
absolute path is specified and the module is not found in the current
|
||||
directory.
|
||||
|
||||
The paths searched are those specified in the environment variables
|
||||
LD_LIBRARY_PATH and DYLD_LIBRARY_PATH plus /lib, /usr/local/lib and
|
||||
/usr/lib or the path specified in the environment variable
|
||||
DYLD_FALLBACK_LIBRARY_PATH.
|
||||
|
||||
In the default install the behavior of dlsym is to automatically prepend
|
||||
an underscore to passed in symbol names, this allows easier porting of
|
||||
applications which were written specifically for ELF based lifeforms.
|
||||
|
||||
Installation
|
||||
--------------
|
||||
Type:
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
|
||||
This will compile the source file, generate both a static and shared
|
||||
library called libdl and install it into /usr/local/lib. The header
|
||||
file dlfcn.h will be installed in /usr/local/include.
|
||||
|
||||
If you want to place the files somewhere else, run
|
||||
|
||||
make clean
|
||||
./configure --prefix=<prefix>
|
||||
make
|
||||
sudo make install
|
||||
|
||||
where <prefix> is the hierarchy you want to install into, e.g. /usr
|
||||
for /usr/lib and /usr/include (_NOT_ recommended!).
|
||||
|
||||
To enable debugging output (useful for me), run
|
||||
|
||||
make clean
|
||||
./configure --enable-debug
|
||||
make
|
||||
sudo make install
|
||||
|
||||
If you want old dlcompat style behavior of not prepending the underscore
|
||||
on calls to dlsym then type:
|
||||
|
||||
make clean
|
||||
./configure --enable-fink
|
||||
make
|
||||
sudo make install
|
||||
|
||||
Usage
|
||||
-------
|
||||
Software that uses GNU autoconf will likely check for a library called
|
||||
libdl, that's why I named it that way. For software that doesn't find
|
||||
the library on its own, you must add a '-ldl' to the appropriate
|
||||
Makefile (or environment) variable, usually LIBS.
|
||||
|
||||
If you installed dlcompat into a directory other than /usr/local/lib,
|
||||
you must tell the compiler where to find it. Add '-L<prefix>/lib' to
|
||||
LDFLAGS (or CFLAGS) and '-I<prefix>/include' to CPPFLAGS (or CFLAGS).
|
||||
|
||||
Notes
|
||||
-----
|
||||
If you are writing new software and plan to have Mac OX X compatibility you
|
||||
should look at the dyld api's in /usr/include/mach-o/dyld.h, rather than
|
||||
using dlcompat, using the native api's is the supported method of loading
|
||||
dynamically on Mac OS X, if you want an small example, look at dlfcn_simple.c,
|
||||
which should help get you started.
|
||||
|
||||
Also note that the functions in dlcompat are not thread safe, and while it is not
|
||||
POSIX spec compliant, it is about as close to compliance as it is going to get though.
|
||||
|
||||
You can always get the latest version from opendarwin cvs:
|
||||
|
||||
cvs -d :pserver:anonymous@anoncvs.opendarwin.org:/cvs/od login
|
||||
cvs -z3 -d :pserver:anonymous@anoncvs.opendarwin.org:/cvs/od \
|
||||
co -d dlcompat proj/dlcompat
|
||||
|
||||
|
||||
It is hoped that this library will be useful, and as bug free as possible, if you find
|
||||
any bugs please let us know about them so they can be fixed.
|
||||
|
||||
Please send bug reports to Peter O'Gorman <ogorman@users.sourceforge.net>
|
||||
|
||||
Thanks.
|
||||
|
11
third_party/python/Modules/_ctypes/darwin/README.ctypes
vendored
Normal file
11
third_party/python/Modules/_ctypes/darwin/README.ctypes
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
The files in this directory are taken from
|
||||
http://www.opendarwin.org/cgi-bin/cvsweb.cgi/~checkout~/proj/dlcompat/
|
||||
|
||||
The LICENSE in this directory applies to these files.
|
||||
|
||||
Thomas Heller, Jan 2003
|
||||
|
||||
These files have been modified so they fall back to the system
|
||||
dlfcn calls if available in libSystem.
|
||||
|
||||
Bob Ippolito, Feb 2006
|
84
third_party/python/Modules/_ctypes/darwin/dlfcn.h
vendored
Normal file
84
third_party/python/Modules/_ctypes/darwin/dlfcn.h
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
Copyright (c) 2002 Jorge Acereda <jacereda@users.sourceforge.net> &
|
||||
Peter O'Gorman <ogorman@users.sourceforge.net>
|
||||
|
||||
Portions may be copyright others, see the AUTHORS file included with this
|
||||
distribution.
|
||||
|
||||
Maintained by Peter O'Gorman <ogorman@users.sourceforge.net>
|
||||
|
||||
Bug Reports and other queries should go to <ogorman@users.sourceforge.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef _DLFCN_H_
|
||||
#define _DLFCN_H_
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Structure filled in by dladdr().
|
||||
*/
|
||||
|
||||
typedef struct dl_info {
|
||||
const char *dli_fname; /* Pathname of shared object */
|
||||
void *dli_fbase; /* Base address of shared object */
|
||||
const char *dli_sname; /* Name of nearest symbol */
|
||||
void *dli_saddr; /* Address of nearest symbol */
|
||||
} Dl_info;
|
||||
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_2
|
||||
#warning CTYPES_DARWIN_DLFCN
|
||||
#define CTYPES_DARWIN_DLFCN
|
||||
extern void * (*ctypes_dlopen)(const char *path, int mode);
|
||||
extern void * (*ctypes_dlsym)(void * handle, const char *symbol);
|
||||
extern const char * (*ctypes_dlerror)(void);
|
||||
extern int (*ctypes_dlclose)(void * handle);
|
||||
extern int (*ctypes_dladdr)(const void *, Dl_info *);
|
||||
#else
|
||||
extern void * dlopen(const char *path, int mode);
|
||||
extern void * dlsym(void * handle, const char *symbol);
|
||||
extern const char * dlerror(void);
|
||||
extern int dlclose(void * handle);
|
||||
extern int dladdr(const void *, Dl_info *);
|
||||
#endif
|
||||
|
||||
#define RTLD_LAZY 0x1
|
||||
#define RTLD_NOW 0x2
|
||||
#define RTLD_LOCAL 0x4
|
||||
#define RTLD_GLOBAL 0x8
|
||||
#define RTLD_NOLOAD 0x10
|
||||
#define RTLD_NODELETE 0x80
|
||||
|
||||
/* These are from the Mac OS X 10.4 headers */
|
||||
#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */
|
||||
#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _DLFCN_H_ */
|
272
third_party/python/Modules/_ctypes/darwin/dlfcn_simple.c
vendored
Normal file
272
third_party/python/Modules/_ctypes/darwin/dlfcn_simple.c
vendored
Normal file
|
@ -0,0 +1,272 @@
|
|||
/*
|
||||
Copyright (c) 2002 Peter O'Gorman <ogorman@users.sourceforge.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/* Just to prove that it isn't that hard to add Mac calls to your code :)
|
||||
This works with pretty much everything, including kde3 xemacs and the gimp,
|
||||
I'd guess that it'd work in at least 95% of cases, use this as your starting
|
||||
point, rather than the mess that is dlfcn.c, assuming that your code does not
|
||||
require ref counting or symbol lookups in dependent libraries
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
#include "dlfcn.h"
|
||||
|
||||
#ifdef CTYPES_DARWIN_DLFCN
|
||||
|
||||
#define ERR_STR_LEN 256
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_3
|
||||
#define MAC_OS_X_VERSION_10_3 1030
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
||||
#define DARWIN_HAS_DLOPEN
|
||||
extern void * dlopen(const char *path, int mode) __attribute__((weak_import));
|
||||
extern void * dlsym(void * handle, const char *symbol) __attribute__((weak_import));
|
||||
extern const char * dlerror(void) __attribute__((weak_import));
|
||||
extern int dlclose(void * handle) __attribute__((weak_import));
|
||||
extern int dladdr(const void *, Dl_info *) __attribute__((weak_import));
|
||||
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */
|
||||
|
||||
#ifndef DARWIN_HAS_DLOPEN
|
||||
#define dlopen darwin_dlopen
|
||||
#define dlsym darwin_dlsym
|
||||
#define dlerror darwin_dlerror
|
||||
#define dlclose darwin_dlclose
|
||||
#define dladdr darwin_dladdr
|
||||
#endif
|
||||
|
||||
void * (*ctypes_dlopen)(const char *path, int mode);
|
||||
void * (*ctypes_dlsym)(void * handle, const char *symbol);
|
||||
const char * (*ctypes_dlerror)(void);
|
||||
int (*ctypes_dlclose)(void * handle);
|
||||
int (*ctypes_dladdr)(const void *, Dl_info *);
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3
|
||||
/* Mac OS X 10.3+ has dlopen, so strip all this dead code to avoid warnings */
|
||||
|
||||
static void *dlsymIntern(void *handle, const char *symbol);
|
||||
|
||||
static const char *error(int setget, const char *str, ...);
|
||||
|
||||
/* Set and get the error string for use by dlerror */
|
||||
static const char *error(int setget, const char *str, ...)
|
||||
{
|
||||
static char errstr[ERR_STR_LEN];
|
||||
static int err_filled = 0;
|
||||
const char *retval;
|
||||
va_list arg;
|
||||
if (setget == 0)
|
||||
{
|
||||
va_start(arg, str);
|
||||
strncpy(errstr, "dlcompat: ", ERR_STR_LEN);
|
||||
vsnprintf(errstr + 10, ERR_STR_LEN - 10, str, arg);
|
||||
va_end(arg);
|
||||
err_filled = 1;
|
||||
retval = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!err_filled)
|
||||
retval = NULL;
|
||||
else
|
||||
retval = errstr;
|
||||
err_filled = 0;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* darwin_dlopen */
|
||||
static void *darwin_dlopen(const char *path, int mode)
|
||||
{
|
||||
void *module = 0;
|
||||
NSObjectFileImage ofi = 0;
|
||||
NSObjectFileImageReturnCode ofirc;
|
||||
|
||||
/* If we got no path, the app wants the global namespace, use -1 as the marker
|
||||
in this case */
|
||||
if (!path)
|
||||
return (void *)-1;
|
||||
|
||||
/* Create the object file image, works for things linked with the -bundle arg to ld */
|
||||
ofirc = NSCreateObjectFileImageFromFile(path, &ofi);
|
||||
switch (ofirc)
|
||||
{
|
||||
case NSObjectFileImageSuccess:
|
||||
/* It was okay, so use NSLinkModule to link in the image */
|
||||
module = NSLinkModule(ofi, path,
|
||||
NSLINKMODULE_OPTION_RETURN_ON_ERROR
|
||||
| (mode & RTLD_GLOBAL) ? 0 : NSLINKMODULE_OPTION_PRIVATE
|
||||
| (mode & RTLD_LAZY) ? 0 : NSLINKMODULE_OPTION_BINDNOW);
|
||||
NSDestroyObjectFileImage(ofi);
|
||||
break;
|
||||
case NSObjectFileImageInappropriateFile:
|
||||
/* It may have been a dynamic library rather than a bundle, try to load it */
|
||||
module = (void *)NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
|
||||
break;
|
||||
default:
|
||||
/* God knows what we got */
|
||||
error(0, "Can not open \"%s\"", path);
|
||||
return 0;
|
||||
}
|
||||
if (!module)
|
||||
error(0, "Can not open \"%s\"", path);
|
||||
return module;
|
||||
|
||||
}
|
||||
|
||||
/* dlsymIntern is used by dlsym to find the symbol */
|
||||
static void *dlsymIntern(void *handle, const char *symbol)
|
||||
{
|
||||
NSSymbol nssym = 0;
|
||||
/* If the handle is -1, if is the app global context */
|
||||
if (handle == (void *)-1)
|
||||
{
|
||||
/* Global context, use NSLookupAndBindSymbol */
|
||||
if (NSIsSymbolNameDefined(symbol))
|
||||
{
|
||||
nssym = NSLookupAndBindSymbol(symbol);
|
||||
}
|
||||
|
||||
}
|
||||
/* Now see if the handle is a struch mach_header* or not, use NSLookupSymbol in image
|
||||
for libraries, and NSLookupSymbolInModule for bundles */
|
||||
else
|
||||
{
|
||||
/* Check for both possible magic numbers depending on x86/ppc byte order */
|
||||
if ((((struct mach_header *)handle)->magic == MH_MAGIC) ||
|
||||
(((struct mach_header *)handle)->magic == MH_CIGAM))
|
||||
{
|
||||
if (NSIsSymbolNameDefinedInImage((struct mach_header *)handle, symbol))
|
||||
{
|
||||
nssym = NSLookupSymbolInImage((struct mach_header *)handle,
|
||||
symbol,
|
||||
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND
|
||||
| NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
nssym = NSLookupSymbolInModule(handle, symbol);
|
||||
}
|
||||
}
|
||||
if (!nssym)
|
||||
{
|
||||
error(0, "Symbol \"%s\" Not found", symbol);
|
||||
return NULL;
|
||||
}
|
||||
return NSAddressOfSymbol(nssym);
|
||||
}
|
||||
|
||||
static const char *darwin_dlerror(void)
|
||||
{
|
||||
return error(1, (char *)NULL);
|
||||
}
|
||||
|
||||
static int darwin_dlclose(void *handle)
|
||||
{
|
||||
if ((((struct mach_header *)handle)->magic == MH_MAGIC) ||
|
||||
(((struct mach_header *)handle)->magic == MH_CIGAM))
|
||||
{
|
||||
error(0, "Can't remove dynamic libraries on darwin");
|
||||
return 0;
|
||||
}
|
||||
if (!NSUnLinkModule(handle, 0))
|
||||
{
|
||||
error(0, "unable to unlink module %s", NSNameOfModule(handle));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* dlsym, prepend the underscore and call dlsymIntern */
|
||||
static void *darwin_dlsym(void *handle, const char *symbol)
|
||||
{
|
||||
static char undersym[257]; /* Saves calls to malloc(3) */
|
||||
int sym_len = strlen(symbol);
|
||||
void *value = NULL;
|
||||
char *malloc_sym = NULL;
|
||||
|
||||
if (sym_len < 256)
|
||||
{
|
||||
snprintf(undersym, 256, "_%s", symbol);
|
||||
value = dlsymIntern(handle, undersym);
|
||||
}
|
||||
else
|
||||
{
|
||||
malloc_sym = malloc(sym_len + 2);
|
||||
if (malloc_sym)
|
||||
{
|
||||
sprintf(malloc_sym, "_%s", symbol);
|
||||
value = dlsymIntern(handle, malloc_sym);
|
||||
free(malloc_sym);
|
||||
}
|
||||
else
|
||||
{
|
||||
error(0, "Unable to allocate memory");
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static int darwin_dladdr(const void *handle, Dl_info *info) {
|
||||
return 0;
|
||||
}
|
||||
#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 */
|
||||
|
||||
#if __GNUC__ < 4
|
||||
#pragma CALL_ON_LOAD ctypes_dlfcn_init
|
||||
#else
|
||||
static void __attribute__ ((constructor)) ctypes_dlfcn_init(void);
|
||||
static
|
||||
#endif
|
||||
void ctypes_dlfcn_init(void) {
|
||||
if (dlopen != NULL) {
|
||||
ctypes_dlsym = dlsym;
|
||||
ctypes_dlopen = dlopen;
|
||||
ctypes_dlerror = dlerror;
|
||||
ctypes_dlclose = dlclose;
|
||||
ctypes_dladdr = dladdr;
|
||||
} else {
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3
|
||||
ctypes_dlsym = darwin_dlsym;
|
||||
ctypes_dlopen = darwin_dlopen;
|
||||
ctypes_dlerror = darwin_dlerror;
|
||||
ctypes_dlclose = darwin_dlclose;
|
||||
ctypes_dladdr = darwin_dladdr;
|
||||
#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 */
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CTYPES_DARWIN_DLFCN */
|
209
third_party/python/Modules/_ctypes/libffi.diff
vendored
Normal file
209
third_party/python/Modules/_ctypes/libffi.diff
vendored
Normal file
|
@ -0,0 +1,209 @@
|
|||
diff -urN libffi-3.1/configure libffi/configure
|
||||
--- libffi-3.1/configure 2014-05-19 15:44:03.000000000 +0200
|
||||
+++ libffi/configure 2014-08-09 21:51:07.877871443 +0200
|
||||
@@ -17236,6 +17236,10 @@
|
||||
fi
|
||||
;;
|
||||
|
||||
+ i*86-*-nto-qnx*)
|
||||
+ TARGET=X86; TARGETDIR=x86
|
||||
+ ;;
|
||||
+
|
||||
x86_64-*-darwin*)
|
||||
TARGET=X86_DARWIN; TARGETDIR=x86
|
||||
;;
|
||||
@@ -17298,12 +17302,12 @@
|
||||
;;
|
||||
|
||||
mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
|
||||
- TARGET=MIPS; TARGETDIR=mips
|
||||
+ TARGET=MIPS_IRIX; TARGETDIR=mips
|
||||
;;
|
||||
mips*-*linux* | mips*-*-openbsd*)
|
||||
# Support 128-bit long double for NewABI.
|
||||
HAVE_LONG_DOUBLE='defined(__mips64)'
|
||||
- TARGET=MIPS; TARGETDIR=mips
|
||||
+ TARGET=MIPS_LINUX; TARGETDIR=mips
|
||||
;;
|
||||
|
||||
nios2*-linux*)
|
||||
@@ -17373,7 +17377,7 @@
|
||||
as_fn_error $? "\"libffi has not been ported to $host.\"" "$LINENO" 5
|
||||
fi
|
||||
|
||||
- if test x$TARGET = xMIPS; then
|
||||
+ if expr x$TARGET : 'xMIPS' > /dev/null; then
|
||||
MIPS_TRUE=
|
||||
MIPS_FALSE='#'
|
||||
else
|
||||
@@ -18814,6 +18818,12 @@
|
||||
ac_config_files="$ac_config_files include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc"
|
||||
|
||||
|
||||
+ac_config_links="$ac_config_links include/ffi_common.h:include/ffi_common.h"
|
||||
+
|
||||
+
|
||||
+ac_config_files="$ac_config_files fficonfig.py"
|
||||
+
|
||||
+
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
# tests run on this system so they can be shared between configure
|
||||
@@ -20126,6 +20136,8 @@
|
||||
"testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;;
|
||||
"man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
|
||||
"libffi.pc") CONFIG_FILES="$CONFIG_FILES libffi.pc" ;;
|
||||
+ "include/ffi_common.h") CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;;
|
||||
+ "fficonfig.py") CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;;
|
||||
|
||||
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
|
||||
esac
|
||||
diff -urN libffi-3.1/configure.ac libffi/configure.ac
|
||||
--- libffi-3.1/configure.ac 2014-05-11 15:57:49.000000000 +0200
|
||||
+++ libffi/configure.ac 2014-08-09 21:51:07.877871443 +0200
|
||||
@@ -1,4 +1,7 @@
|
||||
dnl Process this with autoconf to create configure
|
||||
+#
|
||||
+# file from libffi - slightly patched for Python's ctypes
|
||||
+#
|
||||
|
||||
AC_PREREQ(2.68)
|
||||
|
||||
@@ -144,6 +147,9 @@
|
||||
AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
|
||||
fi
|
||||
;;
|
||||
+ i*86-*-nto-qnx*)
|
||||
+ TARGET=X86; TARGETDIR=x86
|
||||
+ ;;
|
||||
i?86-*-darwin*)
|
||||
TARGET=X86_DARWIN; TARGETDIR=x86
|
||||
;;
|
||||
@@ -218,12 +224,12 @@
|
||||
;;
|
||||
|
||||
mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
|
||||
- TARGET=MIPS; TARGETDIR=mips
|
||||
+ TARGET=MIPS_IRIX; TARGETDIR=mips
|
||||
;;
|
||||
mips*-*linux* | mips*-*-openbsd*)
|
||||
# Support 128-bit long double for NewABI.
|
||||
HAVE_LONG_DOUBLE='defined(__mips64)'
|
||||
- TARGET=MIPS; TARGETDIR=mips
|
||||
+ TARGET=MIPS_LINUX; TARGETDIR=mips
|
||||
;;
|
||||
|
||||
nios2*-linux*)
|
||||
@@ -293,7 +299,7 @@
|
||||
AC_MSG_ERROR(["libffi has not been ported to $host."])
|
||||
fi
|
||||
|
||||
-AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
|
||||
+AM_CONDITIONAL(MIPS,[expr x$TARGET : 'xMIPS' > /dev/null])
|
||||
AM_CONDITIONAL(BFIN, test x$TARGET = xBFIN)
|
||||
AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
|
||||
AM_CONDITIONAL(X86, test x$TARGET = xX86)
|
||||
@@ -617,4 +623,8 @@
|
||||
|
||||
AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
|
||||
|
||||
+AC_CONFIG_LINKS(include/ffi_common.h:include/ffi_common.h)
|
||||
+
|
||||
+AC_CONFIG_FILES(fficonfig.py)
|
||||
+
|
||||
AC_OUTPUT
|
||||
diff -urN libffi-3.1/fficonfig.py.in libffi/fficonfig.py.in
|
||||
--- libffi-3.1/fficonfig.py.in 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ libffi/fficonfig.py.in 2014-08-09 21:43:25.229871827 +0200
|
||||
@@ -0,0 +1,35 @@
|
||||
+ffi_sources = """
|
||||
+src/prep_cif.c
|
||||
+src/closures.c
|
||||
+""".split()
|
||||
+
|
||||
+ffi_platforms = {
|
||||
+ 'MIPS_IRIX': ['src/mips/ffi.c', 'src/mips/o32.S', 'src/mips/n32.S'],
|
||||
+ 'MIPS_LINUX': ['src/mips/ffi.c', 'src/mips/o32.S'],
|
||||
+ 'X86': ['src/x86/ffi.c', 'src/x86/sysv.S', 'src/x86/win32.S'],
|
||||
+ 'X86_FREEBSD': ['src/x86/ffi.c', 'src/x86/freebsd.S'],
|
||||
+ 'X86_WIN32': ['src/x86/ffi.c', 'src/x86/win32.S'],
|
||||
+ 'SPARC': ['src/sparc/ffi.c', 'src/sparc/v8.S', 'src/sparc/v9.S'],
|
||||
+ 'ALPHA': ['src/alpha/ffi.c', 'src/alpha/osf.S'],
|
||||
+ 'IA64': ['src/ia64/ffi.c', 'src/ia64/unix.S'],
|
||||
+ 'M32R': ['src/m32r/sysv.S', 'src/m32r/ffi.c'],
|
||||
+ 'M68K': ['src/m68k/ffi.c', 'src/m68k/sysv.S'],
|
||||
+ 'POWERPC': ['src/powerpc/ffi.c', 'src/powerpc/ffi_sysv.c', 'src/powerpc/ffi_linux64.c', 'src/powerpc/sysv.S', 'src/powerpc/ppc_closure.S', 'src/powerpc/linux64.S', 'src/powerpc/linux64_closure.S'],
|
||||
+ 'POWERPC_AIX': ['src/powerpc/ffi_darwin.c', 'src/powerpc/aix.S', 'src/powerpc/aix_closure.S'],
|
||||
+ 'POWERPC_FREEBSD': ['src/powerpc/ffi.c', 'src/powerpc/sysv.S', 'src/powerpc/ppc_closure.S'],
|
||||
+ 'AARCH64': ['src/aarch64/sysv.S', 'src/aarch64/ffi.c'],
|
||||
+ 'ARM': ['src/arm/sysv.S', 'src/arm/ffi.c'],
|
||||
+ 'LIBFFI_CRIS': ['src/cris/sysv.S', 'src/cris/ffi.c'],
|
||||
+ 'FRV': ['src/frv/eabi.S', 'src/frv/ffi.c'],
|
||||
+ 'S390': ['src/s390/sysv.S', 'src/s390/ffi.c'],
|
||||
+ 'X86_64': ['src/x86/ffi64.c', 'src/x86/unix64.S', 'src/x86/ffi.c', 'src/x86/sysv.S'],
|
||||
+ 'SH': ['src/sh/sysv.S', 'src/sh/ffi.c'],
|
||||
+ 'SH64': ['src/sh64/sysv.S', 'src/sh64/ffi.c'],
|
||||
+ 'PA': ['src/pa/linux.S', 'src/pa/ffi.c'],
|
||||
+ 'PA_LINUX': ['src/pa/linux.S', 'src/pa/ffi.c'],
|
||||
+ 'PA_HPUX': ['src/pa/hpux32.S', 'src/pa/ffi.c'],
|
||||
+}
|
||||
+
|
||||
+ffi_sources += ffi_platforms['@TARGET@']
|
||||
+
|
||||
+ffi_cflags = '@CFLAGS@'
|
||||
diff -urN libffi-3.1/src/dlmalloc.c libffi/src/dlmalloc.c
|
||||
--- libffi-3.1/src/dlmalloc.c 2014-04-25 19:45:13.000000000 +0200
|
||||
+++ libffi/src/dlmalloc.c 2014-08-09 21:51:07.881871443 +0200
|
||||
@@ -457,6 +457,11 @@
|
||||
#define LACKS_ERRNO_H
|
||||
#define MALLOC_FAILURE_ACTION
|
||||
#define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */
|
||||
+#elif !defined _GNU_SOURCE
|
||||
+/* mremap() on Linux requires this via sys/mman.h
|
||||
+ * See roundup issue 10309
|
||||
+ */
|
||||
+#define _GNU_SOURCE 1
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef __OS2__
|
||||
@@ -4497,7 +4502,7 @@
|
||||
char* tbase = (char*)(CALL_MMAP(tsize));
|
||||
if (tbase != CMFAIL) {
|
||||
m = init_user_mstate(tbase, tsize);
|
||||
- set_segment_flags(&m->seg, IS_MMAPPED_BIT);
|
||||
+ (void)set_segment_flags(&m->seg, IS_MMAPPED_BIT);
|
||||
set_lock(m, locked);
|
||||
}
|
||||
}
|
||||
@@ -4512,7 +4517,7 @@
|
||||
if (capacity > msize + TOP_FOOT_SIZE &&
|
||||
capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) {
|
||||
m = init_user_mstate((char*)base, capacity);
|
||||
- set_segment_flags(&m->seg, EXTERN_BIT);
|
||||
+ (void)set_segment_flags(&m->seg, EXTERN_BIT);
|
||||
set_lock(m, locked);
|
||||
}
|
||||
return (mspace)m;
|
||||
diff -urN libffi-3.1/src/arm/ffi.c libffi/src/arm/ffi.c
|
||||
--- libffi-3.1/src/arm/ffi.c Sat Aug 09 23:52:34 2014 +0200
|
||||
+++ libffi/src/arm/ffi.c Sat Aug 09 23:58:38 2014 +0200
|
||||
@@ -154,9 +154,6 @@
|
||||
|
||||
int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
|
||||
{
|
||||
- // make sure we are using FFI_VFP
|
||||
- FFI_ASSERT(ecif->cif->abi == FFI_VFP);
|
||||
-
|
||||
register unsigned int i, vi = 0;
|
||||
register void **p_argv;
|
||||
register char *argp, *regp, *eo_regp;
|
||||
@@ -165,6 +162,9 @@
|
||||
char done_with_regs = 0;
|
||||
char is_vfp_type;
|
||||
|
||||
+ // make sure we are using FFI_VFP
|
||||
+ FFI_ASSERT(ecif->cif->abi == FFI_VFP);
|
||||
+
|
||||
/* the first 4 words on the stack are used for values passed in core
|
||||
* registers. */
|
||||
regp = stack;
|
5105
third_party/python/Modules/_ctypes/libffi/ChangeLog
vendored
Normal file
5105
third_party/python/Modules/_ctypes/libffi/ChangeLog
vendored
Normal file
File diff suppressed because it is too large
Load diff
584
third_party/python/Modules/_ctypes/libffi/ChangeLog.libffi
vendored
Normal file
584
third_party/python/Modules/_ctypes/libffi/ChangeLog.libffi
vendored
Normal file
|
@ -0,0 +1,584 @@
|
|||
2011-02-08 Andreas Tobler <andreast@fgznet.ch>
|
||||
|
||||
* testsuite/lib/libffi.exp: Tweak for stand-alone mode.
|
||||
|
||||
2009-12-25 Samuli Suominen <ssuominen@gentoo.org>
|
||||
|
||||
* configure.ac: Undefine _AC_ARG_VAR_PRECIOUS for autoconf 2.64.
|
||||
* configure: Rebuilt.
|
||||
* fficonfig.h.in: Rebuilt.
|
||||
|
||||
2009-06-16 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* testsuite/libffi.call/cls_align_sint64.c,
|
||||
testsuite/libffi.call/cls_align_uint64.c,
|
||||
testsuite/libffi.call/cls_longdouble_va.c,
|
||||
testsuite/libffi.call/cls_ulonglong.c,
|
||||
testsuite/libffi.call/return_ll1.c,
|
||||
testsuite/libffi.call/stret_medium2.c: Fix printf format
|
||||
specifiers.
|
||||
* testsuite/libffi.call/huge_struct.c: Ad x86 XFAILs.
|
||||
* testsuite/libffi.call/float2.c: Fix dg-excess-errors.
|
||||
* testsuite/libffi.call/ffitest.h,
|
||||
testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define.
|
||||
|
||||
2009-06-12 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* testsuite/libffi.call/cls_align_sint64.c,
|
||||
testsuite/libffi.call/cls_align_uint64.c,
|
||||
testsuite/libffi.call/cls_ulonglong.c,
|
||||
testsuite/libffi.call/return_ll1.c,
|
||||
testsuite/libffi.call/stret_medium2.c: Fix printf format
|
||||
specifiers.
|
||||
testsuite/libffi.special/unwindtest.cc: include stdint.h.
|
||||
|
||||
2009-06-11 Timothy Wall <twall@users.sf.net>
|
||||
|
||||
* Makefile.am,
|
||||
configure.ac,
|
||||
include/ffi.h.in,
|
||||
include/ffi_common.h,
|
||||
src/closures.c,
|
||||
src/dlmalloc.c,
|
||||
src/x86/ffi.c,
|
||||
src/x86/ffitarget.h,
|
||||
src/x86/win64.S (new),
|
||||
README: Added win64 support (mingw or MSVC)
|
||||
* Makefile.in,
|
||||
include/Makefile.in,
|
||||
man/Makefile.in,
|
||||
testsuite/Makefile.in,
|
||||
configure,
|
||||
aclocal.m4: Regenerated
|
||||
* ltcf-c.sh: properly escape cygwin/w32 path
|
||||
* man/ffi_call.3: Clarify size requirements for return value.
|
||||
* src/x86/ffi64.c: Fix filename in comment.
|
||||
* src/x86/win32.S: Remove unused extern.
|
||||
|
||||
* testsuite/libffi.call/closure_fn0.c,
|
||||
testsuite/libffi.call/closure_fn1.c,
|
||||
testsuite/libffi.call/closure_fn2.c,
|
||||
testsuite/libffi.call/closure_fn3.c,
|
||||
testsuite/libffi.call/closure_fn4.c,
|
||||
testsuite/libffi.call/closure_fn5.c,
|
||||
testsuite/libffi.call/closure_fn6.c,
|
||||
testsuite/libffi.call/closure_stdcall.c,
|
||||
testsuite/libffi.call/cls_12byte.c,
|
||||
testsuite/libffi.call/cls_16byte.c,
|
||||
testsuite/libffi.call/cls_18byte.c,
|
||||
testsuite/libffi.call/cls_19byte.c,
|
||||
testsuite/libffi.call/cls_1_1byte.c,
|
||||
testsuite/libffi.call/cls_20byte.c,
|
||||
testsuite/libffi.call/cls_20byte1.c,
|
||||
testsuite/libffi.call/cls_24byte.c,
|
||||
testsuite/libffi.call/cls_2byte.c,
|
||||
testsuite/libffi.call/cls_3_1byte.c,
|
||||
testsuite/libffi.call/cls_3byte1.c,
|
||||
testsuite/libffi.call/cls_3byte2.c,
|
||||
testsuite/libffi.call/cls_4_1byte.c,
|
||||
testsuite/libffi.call/cls_4byte.c,
|
||||
testsuite/libffi.call/cls_5_1_byte.c,
|
||||
testsuite/libffi.call/cls_5byte.c,
|
||||
testsuite/libffi.call/cls_64byte.c,
|
||||
testsuite/libffi.call/cls_6_1_byte.c,
|
||||
testsuite/libffi.call/cls_6byte.c,
|
||||
testsuite/libffi.call/cls_7_1_byte.c,
|
||||
testsuite/libffi.call/cls_7byte.c,
|
||||
testsuite/libffi.call/cls_8byte.c,
|
||||
testsuite/libffi.call/cls_9byte1.c,
|
||||
testsuite/libffi.call/cls_9byte2.c,
|
||||
testsuite/libffi.call/cls_align_double.c,
|
||||
testsuite/libffi.call/cls_align_float.c,
|
||||
testsuite/libffi.call/cls_align_longdouble.c,
|
||||
testsuite/libffi.call/cls_align_longdouble_split.c,
|
||||
testsuite/libffi.call/cls_align_longdouble_split2.c,
|
||||
testsuite/libffi.call/cls_align_pointer.c,
|
||||
testsuite/libffi.call/cls_align_sint16.c,
|
||||
testsuite/libffi.call/cls_align_sint32.c,
|
||||
testsuite/libffi.call/cls_align_sint64.c,
|
||||
testsuite/libffi.call/cls_align_uint16.c,
|
||||
testsuite/libffi.call/cls_align_uint32.c,
|
||||
testsuite/libffi.call/cls_align_uint64.c,
|
||||
testsuite/libffi.call/cls_dbls_struct.c,
|
||||
testsuite/libffi.call/cls_double.c,
|
||||
testsuite/libffi.call/cls_double_va.c,
|
||||
testsuite/libffi.call/cls_float.c,
|
||||
testsuite/libffi.call/cls_longdouble.c,
|
||||
testsuite/libffi.call/cls_longdouble_va.c,
|
||||
testsuite/libffi.call/cls_multi_schar.c,
|
||||
testsuite/libffi.call/cls_multi_sshort.c,
|
||||
testsuite/libffi.call/cls_multi_sshortchar.c,
|
||||
testsuite/libffi.call/cls_multi_uchar.c,
|
||||
testsuite/libffi.call/cls_multi_ushort.c,
|
||||
testsuite/libffi.call/cls_multi_ushortchar.c,
|
||||
testsuite/libffi.call/cls_pointer.c,
|
||||
testsuite/libffi.call/cls_pointer_stack.c,
|
||||
testsuite/libffi.call/cls_schar.c,
|
||||
testsuite/libffi.call/cls_sint.c,
|
||||
testsuite/libffi.call/cls_sshort.c,
|
||||
testsuite/libffi.call/cls_uchar.c,
|
||||
testsuite/libffi.call/cls_uint.c,
|
||||
testsuite/libffi.call/cls_ulonglong.c,
|
||||
testsuite/libffi.call/cls_ushort.c,
|
||||
testsuite/libffi.call/err_bad_abi.c,
|
||||
testsuite/libffi.call/err_bad_typedef.c,
|
||||
testsuite/libffi.call/float2.c,
|
||||
testsuite/libffi.call/huge_struct.c,
|
||||
testsuite/libffi.call/nested_struct.c,
|
||||
testsuite/libffi.call/nested_struct1.c,
|
||||
testsuite/libffi.call/nested_struct10.c,
|
||||
testsuite/libffi.call/nested_struct2.c,
|
||||
testsuite/libffi.call/nested_struct3.c,
|
||||
testsuite/libffi.call/nested_struct4.c,
|
||||
testsuite/libffi.call/nested_struct5.c,
|
||||
testsuite/libffi.call/nested_struct6.c,
|
||||
testsuite/libffi.call/nested_struct7.c,
|
||||
testsuite/libffi.call/nested_struct8.c,
|
||||
testsuite/libffi.call/nested_struct9.c,
|
||||
testsuite/libffi.call/problem1.c,
|
||||
testsuite/libffi.call/return_ldl.c,
|
||||
testsuite/libffi.call/return_ll1.c,
|
||||
testsuite/libffi.call/stret_large.c,
|
||||
testsuite/libffi.call/stret_large2.c,
|
||||
testsuite/libffi.call/stret_medium.c,
|
||||
testsuite/libffi.call/stret_medium2.c,
|
||||
testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead
|
||||
of checking for MMAP. Use intptr_t instead of long casts.
|
||||
|
||||
2009-06-04 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* src/powerpc/ffitarget.h: Fix misapplied merge from gcc.
|
||||
|
||||
2009-06-04 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* src/mips/o32.S,
|
||||
src/mips/n32.S: Fix licence formatting.
|
||||
|
||||
2009-06-04 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* src/x86/darwin.S: Fix licence formatting.
|
||||
src/x86/win32.S: Likewise.
|
||||
src/sh64/sysv.S: Likewise.
|
||||
src/sh/sysv.S: Likewise.
|
||||
|
||||
2009-06-04 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* src/sh64/ffi.c: Remove lint directives. Was missing from merge
|
||||
of Andreas Tobler's patch from 2006-04-22.
|
||||
|
||||
2009-06-04 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* src/sh/ffi.c: Apply missing hunk from Alexandre Oliva's patch of
|
||||
2007-03-07.
|
||||
|
||||
2008-12-26 Timothy Wall <twall@users.sf.net>
|
||||
|
||||
* testsuite/libffi.call/cls_longdouble.c,
|
||||
testsuite/libffi.call/cls_longdouble_va.c,
|
||||
testsuite/libffi.call/cls_align_longdouble.c,
|
||||
testsuite/libffi.call/cls_align_longdouble_split.c,
|
||||
testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected
|
||||
failures on x86_64 cygwin/mingw.
|
||||
|
||||
2008-12-22 Timothy Wall <twall@users.sf.net>
|
||||
|
||||
* testsuite/libffi.call/closure_fn0.c,
|
||||
testsuite/libffi.call/closure_fn1.c,
|
||||
testsuite/libffi.call/closure_fn2.c,
|
||||
testsuite/libffi.call/closure_fn3.c,
|
||||
testsuite/libffi.call/closure_fn4.c,
|
||||
testsuite/libffi.call/closure_fn5.c,
|
||||
testsuite/libffi.call/closure_fn6.c,
|
||||
testsuite/libffi.call/closure_loc_fn0.c,
|
||||
testsuite/libffi.call/closure_stdcall.c,
|
||||
testsuite/libffi.call/cls_align_pointer.c,
|
||||
testsuite/libffi.call/cls_pointer.c,
|
||||
testsuite/libffi.call/cls_pointer_stack.c: use portable cast from
|
||||
pointer to integer (intptr_t).
|
||||
* testsuite/libffi.call/cls_longdouble.c: disable for win64.
|
||||
|
||||
2008-12-19 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.8.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-11-11 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.7.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-08-25 Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
* src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and
|
||||
FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum.
|
||||
Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT.
|
||||
Adjust copyright notice.
|
||||
* src/powerpc/ffi.c: Add two new flags to indicate if we have one
|
||||
register or two register to use for FFI_SYSV structs.
|
||||
(ffi_prep_cif_machdep): Pass the right register flag introduced above.
|
||||
(ffi_closure_helper_SYSV): Fix the return type for
|
||||
FFI_SYSV_TYPE_SMALL_STRUCT. Comment.
|
||||
Adjust copyright notice.
|
||||
|
||||
2008-07-24 Anthony Green <green@redhat.com>
|
||||
|
||||
* testsuite/libffi.call/cls_dbls_struct.c,
|
||||
testsuite/libffi.call/cls_double_va.c,
|
||||
testsuite/libffi.call/cls_longdouble.c,
|
||||
testsuite/libffi.call/cls_longdouble_va.c,
|
||||
testsuite/libffi.call/cls_pointer.c,
|
||||
testsuite/libffi.call/cls_pointer_stack.c,
|
||||
testsuite/libffi.call/err_bad_abi.c: Clean up failures from
|
||||
compiler warnings.
|
||||
|
||||
2008-07-17 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.6.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision. Add documentation.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-07-16 Kaz Kojima <kkojima@gcc.gnu.org>
|
||||
|
||||
* src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned
|
||||
int.
|
||||
|
||||
2008-07-16 Kaz Kojima <kkojima@gcc.gnu.org>
|
||||
|
||||
* src/sh/sysv.S: Add .note.GNU-stack on Linux.
|
||||
* src/sh64/sysv.S: Likewise.
|
||||
|
||||
2008-04-03 Anthony Green <green@redhat.com>
|
||||
|
||||
* libffi.pc.in (Libs): Add -L${libdir}.
|
||||
* configure.ac: Bump version to 3.0.5.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-04-03 Anthony Green <green@redhat.com>
|
||||
Xerces Ranby <xerxes@zafena.se>
|
||||
|
||||
* include/ffi.h.in: Wrap definition of target architecture to
|
||||
protect from double definitions.
|
||||
|
||||
2008-03-22 Moriyoshi Koizumi <moriyoshi@gmail.com>
|
||||
|
||||
* src/x86/ffi.c (ffi_prep_closure_loc): Fix for bug revealed in
|
||||
closure_loc_fn0.c.
|
||||
* testsuite/libffi.call/closure_loc_fn0.c (closure_loc_test_fn0):
|
||||
New test.
|
||||
|
||||
2008-03-04 Anthony Green <green@redhat.com>
|
||||
Blake Chaffin
|
||||
hos@tamanegi.org
|
||||
|
||||
* testsuite/libffi.call/cls_align_longdouble_split2.c
|
||||
testsuite/libffi.call/cls_align_longdouble_split.c
|
||||
testsuite/libffi.call/cls_dbls_struct.c
|
||||
testsuite/libffi.call/cls_double_va.c
|
||||
testsuite/libffi.call/cls_longdouble.c
|
||||
testsuite/libffi.call/cls_longdouble_va.c
|
||||
testsuite/libffi.call/cls_pointer.c
|
||||
testsuite/libffi.call/cls_pointer_stack.c
|
||||
testsuite/libffi.call/err_bad_abi.c
|
||||
testsuite/libffi.call/err_bad_typedef.c
|
||||
testsuite/libffi.call/huge_struct.c
|
||||
testsuite/libffi.call/stret_large2.c
|
||||
testsuite/libffi.call/stret_large.c
|
||||
testsuite/libffi.call/stret_medium2.c
|
||||
testsuite/libffi.call/stret_medium.c: New tests from Apple.
|
||||
|
||||
2008-02-26 Jakub Jelinek <jakub@redhat.com>
|
||||
Anthony Green <green@redhat.com>
|
||||
|
||||
* src/alpha/osf.S: Add .note.GNU-stack on Linux.
|
||||
* src/s390/sysv.S: Likewise.
|
||||
* src/powerpc/linux64.S: Likewise.
|
||||
* src/powerpc/linux64_closure.S: Likewise.
|
||||
* src/powerpc/ppc_closure.S: Likewise.
|
||||
* src/powerpc/sysv.S: Likewise.
|
||||
* src/x86/unix64.S: Likewise.
|
||||
* src/x86/sysv.S: Likewise.
|
||||
* src/sparc/v8.S: Likewise.
|
||||
* src/sparc/v9.S: Likewise.
|
||||
* src/m68k/sysv.S: Likewise.
|
||||
* src/ia64/unix.S: Likewise.
|
||||
* src/arm/sysv.S: Likewise.
|
||||
|
||||
2008-02-26 Anthony Green <green@redhat.com>
|
||||
Thomas Heller <theller@ctypes.org>
|
||||
|
||||
* src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C
|
||||
comment.
|
||||
|
||||
2008-02-26 Anthony Green <green@redhat.org>
|
||||
Thomas Heller <theller@ctypes.org>
|
||||
|
||||
* include/ffi.h.in: Change void (*)() to void (*)(void).
|
||||
|
||||
2008-02-26 Anthony Green <green@redhat.org>
|
||||
Thomas Heller <theller@ctypes.org>
|
||||
|
||||
* src/alpha/ffi.c: Change void (*)() to void (*)(void).
|
||||
src/alpha/osf.S, src/arm/ffi.c, src/frv/ffi.c, src/ia64/ffi.c,
|
||||
src/ia64/unix.S, src/java_raw_api.c, src/m32r/ffi.c,
|
||||
src/mips/ffi.c, src/pa/ffi.c, src/pa/hpux32.S, src/pa/linux.S,
|
||||
src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/raw_api.c,
|
||||
src/s390/ffi.c, src/sh/ffi.c, src/sh64/ffi.c, src/sparc/ffi.c,
|
||||
src/x86/ffi.c, src/x86/unix64.S, src/x86/darwin64.S,
|
||||
src/x86/ffi64.c: Ditto.
|
||||
|
||||
2008-02-24 Anthony Green <green@redhat.org>
|
||||
|
||||
* configure.ac: Accept openbsd*, not just openbsd.
|
||||
Bump version to 3.0.4.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-02-22 Anthony Green <green@redhat.com>
|
||||
|
||||
* README: Clean up list of tested platforms.
|
||||
|
||||
2008-02-22 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.3.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release. Clean up test docs.
|
||||
|
||||
2008-02-22 Bjoern Koenig <bkoenig@alpha-tierchen.de>
|
||||
Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
* configure.ac: Add amd64-*-freebsd* target.
|
||||
* configure: Regenerate.
|
||||
|
||||
2008-02-22 Thomas Heller <theller@ctypes.org>
|
||||
|
||||
* configure.ac: Add x86 OpenBSD support.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2008-02-21 Thomas Heller <theller@ctypes.org>
|
||||
|
||||
* README: Change "make test" to "make check".
|
||||
|
||||
2008-02-21 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.2.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-02-21 Björn König <bkoenig@alpha-tierchen.de>
|
||||
|
||||
* src/x86/freebsd.S: New file.
|
||||
* configure.ac: Add x86 FreeBSD support.
|
||||
* Makefile.am: Ditto.
|
||||
|
||||
2008-02-15 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.1.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-02-15 David Daney <ddaney@avtrex.com>
|
||||
|
||||
* src/mips/ffi.c: Remove extra '>' from include directive.
|
||||
(ffi_prep_closure_loc): Use clear_location instead of tramp.
|
||||
|
||||
2008-02-15 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.0.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
|
||||
2008-02-15 David Daney <ddaney@avtrex.com>
|
||||
|
||||
* src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE):
|
||||
Define (conditionally), and use it to include cachectl.h.
|
||||
(ffi_prep_closure_loc): Fix cache flushing.
|
||||
* src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define.
|
||||
|
||||
2008-02-15 Anthony Green <green@redhat.com>
|
||||
|
||||
* man/ffi_call.3, man/ffi_prep_cif.3, man/ffi.3:
|
||||
Update dates and remove all references to ffi_prep_closure.
|
||||
* configure.ac: Bump version to 2.99.9.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
|
||||
2008-02-15 Anthony Green <green@redhat.com>
|
||||
|
||||
* man/ffi_prep_closure.3: Delete.
|
||||
* man/Makefile.am (EXTRA_DIST): Remove ffi_prep_closure.3.
|
||||
(man_MANS): Ditto.
|
||||
* man/Makefile.in: Rebuilt.
|
||||
* configure.ac: Bump version to 2.99.8.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 2.99.7.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* include/ffi.h.in LICENSE src/debug.c src/closures.c
|
||||
src/ffitest.c src/s390/sysv.S src/s390/ffitarget.h
|
||||
src/types.c src/m68k/ffitarget.h src/raw_api.c src/frv/ffi.c
|
||||
src/frv/ffitarget.h src/sh/ffi.c src/sh/sysv.S
|
||||
src/sh/ffitarget.h src/powerpc/ffitarget.h src/pa/ffi.c
|
||||
src/pa/ffitarget.h src/pa/linux.S src/java_raw_api.c
|
||||
src/cris/ffitarget.h src/x86/ffi.c src/x86/sysv.S
|
||||
src/x86/unix64.S src/x86/win32.S src/x86/ffitarget.h
|
||||
src/x86/ffi64.c src/x86/darwin.S src/ia64/ffi.c
|
||||
src/ia64/ffitarget.h src/ia64/ia64_flags.h src/ia64/unix.S
|
||||
src/sparc/ffi.c src/sparc/v9.S src/sparc/ffitarget.h
|
||||
src/sparc/v8.S src/alpha/ffi.c src/alpha/ffitarget.h
|
||||
src/alpha/osf.S src/sh64/ffi.c src/sh64/sysv.S
|
||||
src/sh64/ffitarget.h src/mips/ffi.c src/mips/ffitarget.h
|
||||
src/mips/n32.S src/mips/o32.S src/arm/ffi.c src/arm/sysv.S
|
||||
src/arm/ffitarget.h src/prep_cif.c: Update license text.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* README: Update tested platforms.
|
||||
* configure.ac: Bump version to 2.99.6.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 2.99.5.
|
||||
* configure: Rebuilt.
|
||||
* Makefile.am (EXTRA_DIST): Add darwin64.S
|
||||
* Makefile.in: Rebuilt.
|
||||
* testsuite/lib/libffi-dg.exp: Remove libstdc++ bits from GCC tree.
|
||||
* LICENSE: Update WARRANTY.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* libffi.pc.in (libdir): Fix libdir definition.
|
||||
* configure.ac: Bump version to 2.99.4.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* README: Update.
|
||||
* libffi.info: New file.
|
||||
* doc/stamp-vti: New file.
|
||||
* configure.ac: Bump version to 2.99.3.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* Makefile.am (SUBDIRS): Add man dir.
|
||||
* Makefile.in: Rebuilt.
|
||||
* configure.ac: Create Makefile.
|
||||
* configure: Rebuilt.
|
||||
* man/ffi_call.3 man/ffi_prep_cif.3 man/ffi_prep_closure.3
|
||||
man/Makefile.am man/Makefile.in: New files.
|
||||
|
||||
2008-02-14 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* aclocal.m4, Makefile.in, configure, fficonfig.h.in: Rebuilt.
|
||||
* mdate-sh, texinfo.tex: New files.
|
||||
* Makefile.am (info_TEXINFOS): New variable.
|
||||
* doc/libffi.texi: New file.
|
||||
* doc/version.texi: Likewise.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* Makefile.am (AM_CFLAGS): Don't compile with -D$(TARGET).
|
||||
(lib_LTLIBRARIES): Define.
|
||||
(toolexeclib_LIBRARIES): Undefine.
|
||||
* Makefile.in: Rebuilt.
|
||||
* configure.ac: Reset version to 2.99.1.
|
||||
* configure.in: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* libffi.pc.in: Use @PACKAGE_NAME@ and @PACKAGE_VERSION@.
|
||||
* configure.ac: Reset version to 2.99.1.
|
||||
* configure.in: Rebuilt.
|
||||
* Makefile.am (EXTRA_DIST): Add ChangeLog.libffi.
|
||||
* Makefile.in: Rebuilt.
|
||||
* LICENSE: Update copyright notice.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* include/Makefile.am (nodist_includes_HEADERS): Define. Don't
|
||||
distribute ffitarget.h or ffi.h from the build include dir.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* include/Makefile.am (includesdir): Install headers under libdir.
|
||||
(pkgconfigdir): Define. Install libffi.pc.
|
||||
* include/Makefile.in: Rebuilt.
|
||||
* libffi.pc.in: Create.
|
||||
* libtool-version: Increment CURRENT
|
||||
* configure.ac: Add libffi.pc.in
|
||||
* configure: Rebuilt.
|
||||
|
||||
2008-02-03 Anthony Green <green@redhat.com>
|
||||
|
||||
* include/Makefile.am (includesdir): Fix header install with
|
||||
DESTDIR.
|
||||
* include/Makefile.in: Rebuilt.
|
||||
|
||||
2008-02-03 Timothy Wall <twall@users.sf.net>
|
||||
|
||||
* src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return
|
||||
offset based on code pointer, not data pointer.
|
||||
|
||||
2008-02-01 Anthony Green <green@redhat.com>
|
||||
|
||||
* include/Makefile.am: Fix header installs.
|
||||
* Makefile.am: Ditto.
|
||||
* include/Makefile.in: Rebuilt.
|
||||
* Makefile.in: Ditto.
|
||||
|
||||
2008-02-01 Anthony Green <green@redhat.com>
|
||||
|
||||
* src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL,
|
||||
FFI_INIT_TRAMPOLINE): Revert my broken changes to twall's last
|
||||
patch.
|
||||
|
||||
2008-01-31 Anthony Green <green@redhat.com>
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Add missing files.
|
||||
* testsuite/Makefile.am: Ditto.
|
||||
* Makefile.in, testsuite/Makefile.in: Rebuilt.
|
||||
|
||||
2008-01-31 Timothy Wall <twall@users.sf.net>
|
||||
|
||||
* testsuite/libffi.call/closure_stdcall.c: Add test for stdcall
|
||||
closures.
|
||||
* src/x86/ffitarget.h: Increase size of trampoline for stdcall
|
||||
closures.
|
||||
* src/x86/win32.S: Add assembly for stdcall closure.
|
||||
* src/x86/ffi.c: Initialize stdcall closure trampoline.
|
||||
|
||||
2008-01-30 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR libffi/34612
|
||||
* src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when
|
||||
returning struct.
|
||||
|
||||
* testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer"
|
||||
tests.
|
||||
|
||||
2008-01-30 Anthony Green <green@redhat.com>
|
||||
|
||||
* Makefile.am, include/Makefile.am: Move headers to
|
||||
libffi_la_SOURCES for new automake.
|
||||
* Makefile.in, include/Makefile.in: Rebuilt.
|
||||
|
||||
* testsuite/lib/wrapper.exp: Copied from gcc tree to allow for
|
||||
execution outside of gcc tree.
|
||||
* testsuite/lib/target-libpath.exp: Ditto.
|
||||
|
||||
* testsuite/lib/libffi-dg.exp: Many changes to allow for execution
|
||||
outside of gcc tree.
|
||||
|
6000
third_party/python/Modules/_ctypes/libffi/ChangeLog.libffi-3.1
vendored
Normal file
6000
third_party/python/Modules/_ctypes/libffi/ChangeLog.libffi-3.1
vendored
Normal file
File diff suppressed because it is too large
Load diff
40
third_party/python/Modules/_ctypes/libffi/ChangeLog.libgcj
vendored
Normal file
40
third_party/python/Modules/_ctypes/libffi/ChangeLog.libgcj
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
2004-01-14 Kelley Cook <kcook@gcc.gnu.org>
|
||||
|
||||
* configure.in: Add in AC_PREREQ(2.13)
|
||||
|
||||
2003-02-20 Alexandre Oliva <aoliva@redhat.com>
|
||||
|
||||
* configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to
|
||||
config.status.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2002-01-27 Alexandre Oliva <aoliva@redhat.com>
|
||||
|
||||
* configure.in (toolexecdir, toolexeclibdir): Set and AC_SUBST.
|
||||
Remove USE_LIBDIR conditional.
|
||||
* Makefile.am (toolexecdir, toolexeclibdir): Don't override.
|
||||
* Makefile.in, configure: Rebuilt.
|
||||
|
||||
Mon Aug 9 18:33:38 1999 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
|
||||
|
||||
* include/Makefile.in: Rebuilt.
|
||||
* Makefile.in: Rebuilt
|
||||
* Makefile.am (toolexeclibdir): Add $(MULTISUBDIR) even for native
|
||||
builds.
|
||||
Use USE_LIBDIR.
|
||||
|
||||
* configure: Rebuilt.
|
||||
* configure.in (USE_LIBDIR): Define for native builds.
|
||||
Use lowercase in configure --help explanations.
|
||||
|
||||
1999-08-08 Anthony Green <green@cygnus.com>
|
||||
|
||||
* include/ffi.h.in (FFI_FN): Remove `...'.
|
||||
|
||||
1999-08-08 Anthony Green <green@cygnus.com>
|
||||
|
||||
* Makefile.in: Rebuilt.
|
||||
* Makefile.am (AM_CFLAGS): Compile with -fexceptions.
|
||||
|
||||
* src/x86/sysv.S: Add exception handling metadata.
|
||||
|
764
third_party/python/Modules/_ctypes/libffi/ChangeLog.v1
vendored
Normal file
764
third_party/python/Modules/_ctypes/libffi/ChangeLog.v1
vendored
Normal file
|
@ -0,0 +1,764 @@
|
|||
The libffi version 1 ChangeLog archive.
|
||||
|
||||
Version 1 of libffi had per-directory ChangeLogs. Current and future
|
||||
versions have a single ChangeLog file in the root directory. The
|
||||
version 1 ChangeLogs have all been concatenated into this file for
|
||||
future reference only.
|
||||
|
||||
--- libffi ----------------------------------------------------------------
|
||||
|
||||
Mon Oct 5 02:17:50 1998 Anthony Green <green@cygnus.com>
|
||||
|
||||
* configure.in: Boosted rev.
|
||||
* configure, Makefile.in, aclocal.m4: Rebuilt.
|
||||
* README: Boosted rev and updated release notes.
|
||||
|
||||
Mon Oct 5 01:03:03 1998 Anthony Green <green@cygnus.com>
|
||||
|
||||
* configure.in: Boosted rev.
|
||||
* configure, Makefile.in, aclocal.m4: Rebuilt.
|
||||
* README: Boosted rev and updated release notes.
|
||||
|
||||
1998-07-25 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* m68k/ffi.c (ffi_prep_cif_machdep): Use bitmask for cif->flags.
|
||||
Correctly handle small structures.
|
||||
(ffi_prep_args): Also handle small structures.
|
||||
(ffi_call): Pass size of return type to ffi_call_SYSV.
|
||||
* m68k/sysv.S: Adjust for above changes. Correctly align small
|
||||
structures in the return value.
|
||||
|
||||
* types.c (uint64, sint64) [M68K]: Change alignment to 4.
|
||||
|
||||
Fri Apr 17 17:26:58 1998 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* configure.in: Boosted rev.
|
||||
* configure,Makefile.in,aclocal.m4: Rebuilt.
|
||||
* README: Boosted rev and added release notes.
|
||||
|
||||
Sun Feb 22 00:50:41 1998 Geoff Keating <geoffk@ozemail.com.au>
|
||||
|
||||
* configure.in: Add PowerPC config bits.
|
||||
|
||||
1998-02-14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* configure.in: Add m68k config bits. Change AC_CANONICAL_SYSTEM
|
||||
to AC_CANONICAL_HOST, this is not a compiler. Use $host instead
|
||||
of $target. Remove AC_CHECK_SIZEOF(char), we already know the
|
||||
result. Fix argument of AC_ARG_ENABLE.
|
||||
* configure, fficonfig.h.in: Rebuilt.
|
||||
|
||||
Tue Feb 10 20:53:40 1998 Richard Henderson <rth@cygnus.com>
|
||||
|
||||
* configure.in: Add Alpha config bits.
|
||||
|
||||
Tue May 13 13:39:20 1997 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* README: Updated dates and reworded Irix comments.
|
||||
|
||||
* configure.in: Removed AC_PROG_RANLIB.
|
||||
|
||||
* Makefile.in, aclocal.m4, config.guess, config.sub, configure,
|
||||
ltmain.sh, */Makefile.in: libtoolized again and rebuilt with
|
||||
automake and autoconf.
|
||||
|
||||
Sat May 10 18:44:50 1997 Tom Tromey <tromey@cygnus.com>
|
||||
|
||||
* configure, aclocal.m4: Rebuilt.
|
||||
* configure.in: Don't compute EXTRADIST; now handled in
|
||||
src/Makefile.in. Removed macros implied by AM_INIT_AUTOMAKE.
|
||||
Don't run AM_MAINTAINER_MODE.
|
||||
|
||||
Thu May 8 14:34:05 1997 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* missing, ltmain.sh, ltconfig.sh: Created. These are new files
|
||||
required by automake and libtool.
|
||||
|
||||
* README: Boosted rev to 1.14. Added notes.
|
||||
|
||||
* acconfig.h: Moved PACKAGE and VERSION for new automake.
|
||||
|
||||
* configure.in: Changes for libtool.
|
||||
|
||||
* Makefile.am (check): make test now make check. Uses libtool now.
|
||||
|
||||
* Makefile.in, configure.in, aclocal.h, fficonfig.h.in: Rebuilt.
|
||||
|
||||
Thu May 1 16:27:07 1997 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* missing: Added file required by new automake.
|
||||
|
||||
Tue Nov 26 14:10:42 1996 Anthony Green <green@csk3.cygnus.com>
|
||||
|
||||
* acconfig.h: Added USING_PURIFY flag. This is defined when
|
||||
--enable-purify-safety was used at configure time.
|
||||
|
||||
* configure.in (allsources): Added --enable-purify-safety switch.
|
||||
(VERSION): Boosted rev to 1.13.
|
||||
* configure: Rebuilt.
|
||||
|
||||
Fri Nov 22 06:46:12 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* configure.in (VERSION): Boosted rev to 1.12.
|
||||
Removed special CFLAGS hack for gcc.
|
||||
* configure: Rebuilt.
|
||||
|
||||
* README: Boosted rev to 1.12. Added notes.
|
||||
|
||||
* Many files: Cygnus Support changed to Cygnus Solutions.
|
||||
|
||||
Wed Oct 30 11:15:25 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* configure.in (VERSION): Boosted rev to 1.11.
|
||||
* configure: Rebuilt.
|
||||
|
||||
* README: Boosted rev to 1.11. Added notes about GNU make.
|
||||
|
||||
Tue Oct 29 12:25:12 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* configure.in: Fixed -Wall trick.
|
||||
(VERSION): Boosted rev.
|
||||
* configure: Rebuilt
|
||||
|
||||
* acconfig.h: Needed for --enable-debug configure switch.
|
||||
|
||||
* README: Boosted rev to 1.09. Added more notes on building
|
||||
libffi, and LCLint.
|
||||
|
||||
* configure.in: Added --enable-debug switch. Boosted rev to
|
||||
1.09.
|
||||
* configure: Rebuilt
|
||||
|
||||
Tue Oct 15 13:11:28 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* configure.in (VERSION): Boosted rev to 1.08
|
||||
* configure: Rebuilt.
|
||||
|
||||
* README: Added n32 bug fix notes.
|
||||
|
||||
* Makefile.am: Added "make lint" production.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
Mon Oct 14 10:54:46 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* README: Added web page reference.
|
||||
|
||||
* configure.in, README: Boosted rev to 1.05
|
||||
* configure: Rebuilt.
|
||||
|
||||
* README: Fixed n32 sample code.
|
||||
|
||||
Fri Oct 11 17:09:28 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* README: Added sparc notes.
|
||||
|
||||
* configure.in, README: Boosted rev to 1.04.
|
||||
* configure: Rebuilt.
|
||||
|
||||
Thu Oct 10 10:31:03 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* configure.in, README: Boosted rev to 1.03.
|
||||
* configure: Rebuilt.
|
||||
|
||||
* README: Added struct notes.
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Added LICENSE to distribution.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
* README: Removed Linux section. No special notes now
|
||||
because aggregates arg/return types work.
|
||||
|
||||
Wed Oct 9 16:16:42 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* README, configure.in (VERSION): Boosted rev to 1.02
|
||||
* configure: Rebuilt.
|
||||
|
||||
Tue Oct 8 11:56:33 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* README (NOTE): Added n32 notes.
|
||||
|
||||
* Makefile.am: Added test production.
|
||||
* Makefile: Rebuilt
|
||||
|
||||
* README: spell checked!
|
||||
|
||||
* configure.in (VERSION): Boosted rev to 1.01
|
||||
* configure: Rebuilt.
|
||||
|
||||
Mon Oct 7 15:50:22 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* configure.in: Added nasty bit to support SGI tools.
|
||||
* configure: Rebuilt.
|
||||
|
||||
* README: Added SGI notes. Added note about automake bug.
|
||||
|
||||
Mon Oct 7 11:00:28 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* README: Rewrote intro, and fixed examples.
|
||||
|
||||
Fri Oct 4 10:19:55 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* configure.in: -D$TARGET is no longer used as a compiler switch.
|
||||
It is now inserted into ffi.h at configure time.
|
||||
* configure: Rebuilt.
|
||||
|
||||
* FFI_ABI and FFI_STATUS are now ffi_abi and ffi_status.
|
||||
|
||||
Thu Oct 3 13:47:34 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* README, LICENSE: Created. Wrote some docs.
|
||||
|
||||
* configure.in: Don't barf on i586-unknown-linuxaout.
|
||||
Added EXTRADIST code for "make dist".
|
||||
* configure: Rebuilt.
|
||||
|
||||
* */Makefile.in: Rebuilt with patched automake.
|
||||
|
||||
Tue Oct 1 17:12:25 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* Makefile.am, aclocal.m4, config.guess, config.sub,
|
||||
configure.in, fficonfig.h.in, install-sh, mkinstalldirs,
|
||||
stamp-h.in: Created
|
||||
* Makefile.in, configure: Generated
|
||||
|
||||
--- libffi/include --------------------------------------------------------
|
||||
|
||||
Tue Feb 24 13:09:36 1998 Anthony Green <green@gerbil.cygnus.com>
|
||||
|
||||
* ffi_mips.h: Updated FFI_TYPE_STRUCT_* values based on
|
||||
ffi.h.in changes. This is a work-around for SGI's "simple"
|
||||
assembler.
|
||||
|
||||
Sun Feb 22 00:51:55 1998 Geoff Keating <geoffk@ozemail.com.au>
|
||||
|
||||
* ffi.h.in: PowerPC support.
|
||||
|
||||
1998-02-14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* ffi.h.in: Add m68k support.
|
||||
(FFI_TYPE_LONGDOUBLE): Make it a separate value.
|
||||
|
||||
Tue Feb 10 20:55:16 1998 Richard Henderson <rth@cygnus.com>
|
||||
|
||||
* ffi.h.in (SIZEOF_ARG): Use a pointer type by default.
|
||||
|
||||
* ffi.h.in: Alpha support.
|
||||
|
||||
Fri Nov 22 06:48:45 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.h.in, ffi_common.h: Cygnus Support -> Cygnus Solutions.
|
||||
|
||||
Wed Nov 20 22:31:01 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.h.in: Added ffi_type_void definition.
|
||||
|
||||
Tue Oct 29 12:22:40 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* Makefile.am (hack_DATA): Always install ffi_mips.h.
|
||||
|
||||
* ffi.h.in: Removed FFI_DEBUG. It's now in the correct
|
||||
place (acconfig.h).
|
||||
Added #include <stddef.h> for size_t definition.
|
||||
|
||||
Tue Oct 15 17:23:35 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.h.in, ffi_common.h, ffi_mips.h: More clean up.
|
||||
Commented out #define of FFI_DEBUG.
|
||||
|
||||
Tue Oct 15 13:01:06 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi_common.h: Added bool definition.
|
||||
|
||||
* ffi.h.in, ffi_common.h: Clean up based on LCLint output.
|
||||
Added funny /*@...@*/ comments to annotate source.
|
||||
|
||||
Mon Oct 14 12:29:23 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.h.in: Interface changes based on feedback from Jim
|
||||
Blandy.
|
||||
|
||||
Fri Oct 11 16:49:35 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.h.in: Small change for sparc support.
|
||||
|
||||
Thu Oct 10 14:53:37 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi_mips.h: Added FFI_TYPE_STRUCT_* definitions for
|
||||
special structure return types.
|
||||
|
||||
Wed Oct 9 13:55:57 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.h.in: Added SIZEOF_ARG definition for X86
|
||||
|
||||
Tue Oct 8 11:40:36 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.h.in (FFI_FN): Added macro for eliminating compiler warnings.
|
||||
Use it to case your function pointers to the proper type.
|
||||
|
||||
* ffi_mips.h (SIZEOF_ARG): Added magic to fix type promotion bug.
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Added ffi_mips.h to EXTRA_DIST.
|
||||
* Makefile: Rebuilt.
|
||||
|
||||
* ffi_mips.h: Created. Moved all common mips definitions here.
|
||||
|
||||
Mon Oct 7 10:58:12 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.h.in: The SGI assember is very picky about parens. Redefined
|
||||
some macros to avoid problems.
|
||||
|
||||
* ffi.h.in: Added FFI_DEFAULT_ABI definitions. Also added
|
||||
externs for pointer, and 64bit integral ffi_types.
|
||||
|
||||
Fri Oct 4 09:51:37 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.h.in: Added FFI_ABI member to ffi_cif and changed
|
||||
function prototypes accordingly.
|
||||
Added #define @TARGET@. Now programs including ffi.h don't
|
||||
have to specify this themselves.
|
||||
|
||||
Thu Oct 3 15:36:44 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.h.in: Changed ffi_prep_cif's values from void* to void**
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Added EXTRA_DIST for "make dist"
|
||||
to work.
|
||||
* Makefile.in: Regenerated.
|
||||
|
||||
Wed Oct 2 10:16:59 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* Makefile.am: Created
|
||||
* Makefile.in: Generated
|
||||
|
||||
* ffi_common.h: Added rcsid comment
|
||||
|
||||
Tue Oct 1 17:13:51 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.h.in, ffi_common.h: Created
|
||||
|
||||
--- libffi/src ------------------------------------------------------------
|
||||
|
||||
Mon Oct 5 02:17:50 1998 Anthony Green <green@cygnus.com>
|
||||
|
||||
* arm/ffi.c, arm/sysv.S: Created.
|
||||
|
||||
* Makefile.am: Added arm files.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
Mon Oct 5 01:41:38 1998 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* Makefile.am (libffi_la_LDFLAGS): Incremented revision.
|
||||
|
||||
Sun Oct 4 16:27:17 1998 Anthony Green <green@cygnus.com>
|
||||
|
||||
* alpha/osf.S (ffi_call_osf): Patch for DU assembler.
|
||||
|
||||
* ffitest.c (main): long long and long double return values work
|
||||
for x86.
|
||||
|
||||
Fri Apr 17 11:50:58 1998 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
* ffitest.c (main): Floating point tests not executed for systems
|
||||
with broken lond double (SunOS 4 w/ GCC).
|
||||
|
||||
* types.c: Fixed x86 alignment info for long long types.
|
||||
|
||||
Thu Apr 16 07:15:28 1998 Anthony Green <green@ada.cygnus.com>
|
||||
|
||||
* ffitest.c: Added more notes about GCC bugs under Irix 6.
|
||||
|
||||
Wed Apr 15 08:42:22 1998 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffitest.c (struct5): New test function.
|
||||
(main): New test with struct5.
|
||||
|
||||
Thu Mar 5 10:48:11 1998 Anthony Green <green@tootie.to.cygnus.com>
|
||||
|
||||
* prep_cif.c (initialize_aggregate): Fix assertion for
|
||||
nested structures.
|
||||
|
||||
Tue Feb 24 16:33:41 1998 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* prep_cif.c (ffi_prep_cif): Added long double support for sparc.
|
||||
|
||||
Sun Feb 22 00:52:18 1998 Geoff Keating <geoffk@ozemail.com.au>
|
||||
|
||||
* powerpc/asm.h: New file.
|
||||
* powerpc/ffi.c: New file.
|
||||
* powerpc/sysv.S: New file.
|
||||
* Makefile.am: PowerPC port.
|
||||
* ffitest.c (main): Allow all tests to run even in presence of gcc
|
||||
bug on PowerPC.
|
||||
|
||||
1998-02-17 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* mips/ffi.c: Fixed comment typo.
|
||||
|
||||
* x86/ffi.c (ffi_prep_cif_machdep), x86/sysv.S (retfloat):
|
||||
Fixed x86 long double return handling.
|
||||
|
||||
* types.c: Fixed x86 long double alignment info.
|
||||
|
||||
1998-02-14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* types.c: Add m68k support.
|
||||
|
||||
* ffitest.c (floating): Add long double parameter.
|
||||
(return_ll, ldblit): New functions to test long long and long
|
||||
double return value.
|
||||
(main): Fix type error in assignment of ts[1-4]_type.elements.
|
||||
Add tests for long long and long double arguments and return
|
||||
values.
|
||||
|
||||
* prep_cif.c (ffi_prep_cif) [M68K]: Don't allocate argument for
|
||||
struct value pointer.
|
||||
|
||||
* m68k/ffi.c, m68k/sysv.S: New files.
|
||||
* Makefile.am: Add bits for m68k port. Add kludge to work around
|
||||
automake deficiency.
|
||||
(test): Don't require "." in $PATH.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
Wed Feb 11 07:36:50 1998 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
Tue Feb 10 20:56:00 1998 Richard Henderson <rth@cygnus.com>
|
||||
|
||||
* alpha/ffi.c, alpha/osf.S: New files.
|
||||
* Makefile.am: Alpha port.
|
||||
|
||||
Tue Nov 18 14:12:07 1997 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* mips/ffi.c (ffi_prep_cif_machdep): Initialize rstruct_flag
|
||||
for n32.
|
||||
|
||||
Tue Jun 3 17:18:20 1997 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffitest.c (main): Added hack to get structure tests working
|
||||
correctly.
|
||||
|
||||
Sat May 10 19:06:42 1997 Tom Tromey <tromey@cygnus.com>
|
||||
|
||||
* Makefile.in: Rebuilt.
|
||||
* Makefile.am (EXTRA_DIST): Explicitly list all distributable
|
||||
files in subdirs.
|
||||
(VERSION, CC): Removed.
|
||||
|
||||
Thu May 8 17:19:01 1997 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* Makefile.am: Many changes for new automake and libtool.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
Fri Nov 22 06:57:56 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffitest.c (main): Fixed test case for non mips machines.
|
||||
|
||||
Wed Nov 20 22:31:59 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* types.c: Added ffi_type_void declaration.
|
||||
|
||||
Tue Oct 29 13:07:19 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffitest.c (main): Fixed character constants.
|
||||
(main): Emit warning for structure test 3 failure on Sun.
|
||||
|
||||
* Makefile.am (VPATH): Fixed VPATH def'n so automake won't
|
||||
strip it out.
|
||||
Moved distdir hack from libffi to automake.
|
||||
(ffitest): Added missing -c for $(COMPILE) (change in automake).
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
Tue Oct 15 13:08:20 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* Makefile.am: Added "make lint" production.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
* prep_cif.c (STACK_ARG_SIZE): Improved STACK_ARG_SIZE macro.
|
||||
Clean up based on LCLint output. Added funny /*@...@*/ comments to
|
||||
annotate source.
|
||||
|
||||
* ffitest.c, debug.c: Cleaned up code.
|
||||
|
||||
Mon Oct 14 12:26:56 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffitest.c: Changes based on interface changes.
|
||||
|
||||
* prep_cif.c (ffi_prep_cif): Cleaned up interface based on
|
||||
feedback from Jim Blandy.
|
||||
|
||||
Fri Oct 11 15:53:18 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffitest.c: Reordered tests while porting to sparc.
|
||||
Made changes to handle lame structure passing for sparc.
|
||||
Removed calls to fflush().
|
||||
|
||||
* prep_cif.c (ffi_prep_cif): Added special case for sparc
|
||||
aggregate type arguments.
|
||||
|
||||
Thu Oct 10 09:56:51 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffitest.c (main): Added structure passing/returning tests.
|
||||
|
||||
* prep_cif.c (ffi_prep_cif): Perform proper initialization
|
||||
of structure return types if needed.
|
||||
(initialize_aggregate): Bug fix
|
||||
|
||||
Wed Oct 9 16:04:20 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* types.c: Added special definitions for x86 (double doesn't
|
||||
need double word alignment).
|
||||
|
||||
* ffitest.c: Added many tests
|
||||
|
||||
Tue Oct 8 09:19:22 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* prep_cif.c (ffi_prep_cif): Fixed assertion.
|
||||
|
||||
* debug.c (ffi_assert): Must return a non void now.
|
||||
|
||||
* Makefile.am: Added test production.
|
||||
* Makefile: Rebuilt.
|
||||
|
||||
* ffitest.c (main): Created.
|
||||
|
||||
* types.c: Created. Stripped common code out of */ffi.c.
|
||||
|
||||
* prep_cif.c: Added missing stdlib.h include.
|
||||
|
||||
* debug.c (ffi_type_test): Used "a" to eliminate compiler
|
||||
warnings in non-debug builds. Included ffi_common.h.
|
||||
|
||||
Mon Oct 7 15:36:42 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* Makefile.am: Added a rule for .s -> .o
|
||||
This is required by the SGI compiler.
|
||||
* Makefile: Rebuilt.
|
||||
|
||||
Fri Oct 4 09:51:08 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* prep_cif.c (initialize_aggregate): Moved abi specification
|
||||
to ffi_prep_cif().
|
||||
|
||||
Thu Oct 3 15:37:37 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* prep_cif.c (ffi_prep_cif): Changed values from void* to void**.
|
||||
(initialize_aggregate): Fixed aggregate type initialization.
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Added support code for "make dist".
|
||||
* Makefile.in: Regenerated.
|
||||
|
||||
Wed Oct 2 11:41:57 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* debug.c, prep_cif: Created.
|
||||
|
||||
* Makefile.am: Added debug.o and prep_cif.o to OBJ.
|
||||
* Makefile.in: Regenerated.
|
||||
|
||||
* Makefile.am (INCLUDES): Added missing -I../include
|
||||
* Makefile.in: Regenerated.
|
||||
|
||||
Tue Oct 1 17:11:51 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* error.c, Makefile.am: Created.
|
||||
* Makefile.in: Generated.
|
||||
|
||||
--- libffi/src/x86 --------------------------------------------------------
|
||||
|
||||
Sun Oct 4 16:27:17 1998 Anthony Green <green@cygnus.com>
|
||||
|
||||
* sysv.S (retlongdouble): Fixed long long return value support.
|
||||
* ffi.c (ffi_prep_cif_machdep): Ditto.
|
||||
|
||||
Wed May 13 04:30:33 1998 Anthony Green <green@raft.ppp.tsoft.net>
|
||||
|
||||
* ffi.c (ffi_prep_cif_machdep): Fixed long double return value
|
||||
support.
|
||||
|
||||
Wed Apr 15 08:43:20 1998 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.c (ffi_prep_args): small struct support was missing.
|
||||
|
||||
Thu May 8 16:53:58 1997 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* objects.mak: Removed.
|
||||
|
||||
Mon Dec 2 15:12:58 1996 Tom Tromey <tromey@cygnus.com>
|
||||
|
||||
* sysv.S: Use .balign, for a.out Linux boxes.
|
||||
|
||||
Tue Oct 15 13:06:50 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.c: Clean up based on LCLint output.
|
||||
Added funny /*@...@*/ comments to annotate source.
|
||||
|
||||
Fri Oct 11 16:43:38 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.c (ffi_call): Added assertion for bad ABIs.
|
||||
|
||||
Wed Oct 9 13:57:27 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* sysv.S (retdouble): Fixed double return problems.
|
||||
|
||||
* ffi.c (ffi_call): Corrected fn arg definition.
|
||||
(ffi_prep_cif_machdep): Fixed double return problems
|
||||
|
||||
Tue Oct 8 12:12:49 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.c: Moved ffi_type definitions to types.c.
|
||||
(ffi_prep_args): Fixed type promotion bug.
|
||||
|
||||
Mon Oct 7 15:53:06 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.c (FFI_*_TYPEDEF): Removed redundant ';'
|
||||
|
||||
Fri Oct 4 09:54:53 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.c (ffi_call): Removed FFI_ABI arg, and swapped
|
||||
remaining args.
|
||||
|
||||
Wed Oct 2 10:07:05 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.c, sysv.S, objects.mak: Created.
|
||||
(ffi_prep_cif): cif->rvalue no longer initialized to NULL.
|
||||
(ffi_prep_cif_machdep): Moved machine independent cif processing
|
||||
to src/prep_cif.c. Introduced ffi_prep_cif_machdep().
|
||||
|
||||
--- libffi/src/mips -------------------------------------------------------
|
||||
|
||||
Tue Feb 17 17:18:07 1998 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* o32.S: Fixed typo in comment.
|
||||
|
||||
* ffi.c (ffi_prep_cif_machdep): Fixed argument processing.
|
||||
|
||||
Thu May 8 16:53:58 1997 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* o32.s, n32.s: Wrappers for SGI tool support.
|
||||
|
||||
* objects.mak: Removed.
|
||||
|
||||
Tue Oct 29 14:37:45 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.c (ffi_prep_args): Changed int z to size_t z.
|
||||
|
||||
Tue Oct 15 13:17:25 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* n32.S: Fixed bad stack munging.
|
||||
|
||||
* ffi.c: Moved prototypes for ffi_call_?32() to here from
|
||||
ffi_mips.h because extended_cif is not defined in ffi_mips.h.
|
||||
|
||||
Mon Oct 14 12:42:02 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.c: Interface changes based on feedback from Jim Blandy.
|
||||
|
||||
Thu Oct 10 11:22:16 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* n32.S, ffi.c: Lots of changes to support passing and
|
||||
returning structures with the n32 calling convention.
|
||||
|
||||
* n32.S: Fixed fn pointer bug.
|
||||
|
||||
* ffi.c (ffi_prep_cif_machdep): Fix for o32 structure
|
||||
return values.
|
||||
(ffi_prep_args): Fixed n32 structure passing when structures
|
||||
partially fit in registers.
|
||||
|
||||
Wed Oct 9 13:49:25 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* objects.mak: Added n32.o.
|
||||
|
||||
* n32.S: Created.
|
||||
|
||||
* ffi.c (ffi_prep_args): Added magic to support proper
|
||||
n32 processing.
|
||||
|
||||
Tue Oct 8 10:37:35 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.c: Moved ffi_type definitions to types.c.
|
||||
(ffi_prep_args): Fixed type promotion bug.
|
||||
|
||||
* o32.S: This code is only built for o32 compiles.
|
||||
A lot of the #define cruft has moved to ffi_mips.h.
|
||||
|
||||
* ffi.c (ffi_prep_cif_machdep): Fixed arg flags. Second arg
|
||||
is only processed if the first is either a float or double.
|
||||
|
||||
Mon Oct 7 15:33:59 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* o32.S: Modified to compile under each of o32, n32 and n64.
|
||||
|
||||
* ffi.c (FFI_*_TYPEDEF): Removed redundant ';'
|
||||
|
||||
Fri Oct 4 09:53:25 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.c (ffi_call): Removed FFI_ABI arg, and swapped
|
||||
remaining args.
|
||||
|
||||
Wed Oct 2 17:41:22 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* o32.S: Removed crufty definitions.
|
||||
|
||||
Wed Oct 2 12:53:42 1996 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.c (ffi_prep_cif): cif->rvalue no longer initialized to NULL.
|
||||
(ffi_prep_cif_machdep): Moved all machine independent cif processing
|
||||
to src/prep_cif.c. Introduced ffi_prep_cif_machdep. Return types
|
||||
of FFI_TYPE_STRUCT are no different than FFI_TYPE_INT.
|
||||
|
||||
Tue Oct 1 17:11:02 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.c, o32.S, object.mak: Created
|
||||
|
||||
--- libffi/src/sparc ------------------------------------------------------
|
||||
|
||||
Tue Feb 24 16:33:18 1998 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* ffi.c (ffi_prep_args): Added long double support.
|
||||
|
||||
Thu May 8 16:53:58 1997 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* objects.mak: Removed.
|
||||
|
||||
Thu May 1 16:07:56 1997 Anthony Green <green@hoser.cygnus.com>
|
||||
|
||||
* v8.S: Fixed minor portability problem reported by
|
||||
Russ McManus <mcmanr@eq.gs.com>.
|
||||
|
||||
Tue Nov 26 14:12:43 1996 Anthony Green <green@csk3.cygnus.com>
|
||||
|
||||
* v8.S: Used STACKFRAME define elsewhere.
|
||||
|
||||
* ffi.c (ffi_prep_args): Zero out space when USING_PURIFY
|
||||
is set.
|
||||
(ffi_prep_cif_machdep): Allocate the correct stack frame
|
||||
space for functions with < 6 args.
|
||||
|
||||
Tue Oct 29 15:08:55 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.c (ffi_prep_args): int z is now size_t z.
|
||||
|
||||
Mon Oct 14 13:31:24 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* v8.S (ffi_call_V8): Gordon rewrites this again. It looks
|
||||
great now.
|
||||
|
||||
* ffi.c (ffi_call): The comment about hijacked registers
|
||||
is no longer valid after gordoni hacked v8.S.
|
||||
|
||||
* v8.S (ffi_call_V8): Rewrote with gordoni. Much simpler.
|
||||
|
||||
* v8.S, ffi.c: ffi_call() had changed to accept more than
|
||||
two args, so v8.S had to change (because it hijacks incoming
|
||||
arg registers).
|
||||
|
||||
* ffi.c: Interface changes based on feedback from Jim Blandy.
|
||||
|
||||
Thu Oct 10 17:48:16 1996 Anthony Green <green@rtl.cygnus.com>
|
||||
|
||||
* ffi.c, v8.S, objects.mak: Created.
|
||||
|
||||
|
21
third_party/python/Modules/_ctypes/libffi/LICENSE
vendored
Normal file
21
third_party/python/Modules/_ctypes/libffi/LICENSE
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
libffi - Copyright (c) 1996-2014 Anthony Green, Red Hat, Inc and others.
|
||||
See source files for details.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
254
third_party/python/Modules/_ctypes/libffi/Makefile.am
vendored
Normal file
254
third_party/python/Modules/_ctypes/libffi/Makefile.am
vendored
Normal file
|
@ -0,0 +1,254 @@
|
|||
## Process this with automake to create Makefile.in
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign subdir-objects
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = include testsuite man
|
||||
|
||||
EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj \
|
||||
src/aarch64/ffi.c src/aarch64/ffitarget.h src/aarch64/sysv.S \
|
||||
src/alpha/ffi.c src/alpha/osf.S \
|
||||
src/alpha/ffitarget.h src/arc/ffi.c src/arc/arcompact.S \
|
||||
src/arc/ffitarget.h src/arm/ffi.c src/arm/sysv.S \
|
||||
src/arm/ffitarget.h src/avr32/ffi.c src/avr32/sysv.S \
|
||||
src/avr32/ffitarget.h src/cris/ffi.c src/cris/sysv.S \
|
||||
src/cris/ffitarget.h src/ia64/ffi.c src/ia64/ffitarget.h \
|
||||
src/ia64/ia64_flags.h src/ia64/unix.S src/mips/ffi.c \
|
||||
src/mips/n32.S src/mips/o32.S src/metag/ffi.c \
|
||||
src/metag/ffitarget.h src/metag/sysv.S src/moxie/ffi.c \
|
||||
src/moxie/ffitarget.h src/moxie/eabi.S src/mips/ffitarget.h \
|
||||
src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \
|
||||
src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \
|
||||
src/m88k/ffi.c src/m88k/obsd.S src/m88k/ffitarget.h \
|
||||
src/microblaze/ffi.c src/microblaze/sysv.S \
|
||||
src/microblaze/ffitarget.h \
|
||||
src/nios2/ffi.c src/nios2/ffitarget.h src/nios2/sysv.S \
|
||||
src/powerpc/ffi.c src/powerpc/ffi_powerpc.h \
|
||||
src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \
|
||||
src/powerpc/sysv.S src/powerpc/linux64.S \
|
||||
src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \
|
||||
src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S \
|
||||
src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \
|
||||
src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \
|
||||
src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \
|
||||
src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h src/sh64/ffi.c \
|
||||
src/sh64/sysv.S src/sh64/ffitarget.h src/sparc/v8.S \
|
||||
src/sparc/v9.S src/sparc/ffitarget.h src/sparc/ffi.c \
|
||||
src/x86/darwin64.S src/x86/ffi.c src/x86/sysv.S \
|
||||
src/x86/win32.S src/x86/darwin.S src/x86/win64.S \
|
||||
src/x86/freebsd.S src/x86/ffi64.c src/x86/unix64.S \
|
||||
src/x86/ffitarget.h src/pa/ffitarget.h src/pa/ffi.c \
|
||||
src/pa/linux.S src/pa/hpux32.S src/frv/ffi.c src/bfin/ffi.c \
|
||||
src/bfin/ffitarget.h src/bfin/sysv.S src/frv/eabi.S \
|
||||
src/frv/ffitarget.h src/dlmalloc.c src/tile/ffi.c \
|
||||
src/tile/ffitarget.h src/tile/tile.S libtool-version \
|
||||
src/vax/ffi.c src/vax/ffitarget.h src/vax/elfbsd.S \
|
||||
src/xtensa/ffitarget.h src/xtensa/ffi.c src/xtensa/sysv.S \
|
||||
ChangeLog.libffi m4/libtool.m4 m4/lt~obsolete.m4 \
|
||||
m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \
|
||||
m4/ltversion.m4 src/arm/gentramp.sh src/debug.c msvcc.sh \
|
||||
generate-darwin-source-and-headers.py \
|
||||
libffi.xcodeproj/project.pbxproj src/arm/trampoline.S \
|
||||
libtool-ldflags ChangeLog.libffi-3.1
|
||||
|
||||
info_TEXINFOS = doc/libffi.texi
|
||||
|
||||
## ################################################################
|
||||
|
||||
##
|
||||
## This section is for make and multilib madness.
|
||||
##
|
||||
|
||||
# Work around what appears to be a GNU make bug handling MAKEFLAGS
|
||||
# values defined in terms of make variables, as is the case for CC and
|
||||
# friends when we are called from the top level Makefile.
|
||||
AM_MAKEFLAGS = \
|
||||
'AR_FLAGS=$(AR_FLAGS)' \
|
||||
'CC_FOR_BUILD=$(CC_FOR_BUILD)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'CXXFLAGS=$(CXXFLAGS)' \
|
||||
'CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)' \
|
||||
'CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)' \
|
||||
'INSTALL=$(INSTALL)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_PROGRAM=$(INSTALL_PROGRAM)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'JC1FLAGS=$(JC1FLAGS)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBCFLAGS=$(LIBCFLAGS)' \
|
||||
'LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)' \
|
||||
'MAKE=$(MAKE)' \
|
||||
'MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)' \
|
||||
'PICFLAG=$(PICFLAG)' \
|
||||
'PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)' \
|
||||
'RUNTESTFLAGS=$(RUNTESTFLAGS)' \
|
||||
'SHELL=$(SHELL)' \
|
||||
'exec_prefix=$(exec_prefix)' \
|
||||
'infodir=$(infodir)' \
|
||||
'libdir=$(libdir)' \
|
||||
'mandir=$(mandir)' \
|
||||
'prefix=$(prefix)' \
|
||||
'AR=$(AR)' \
|
||||
'AS=$(AS)' \
|
||||
'CC=$(CC)' \
|
||||
'CXX=$(CXX)' \
|
||||
'LD=$(LD)' \
|
||||
'NM=$(NM)' \
|
||||
'RANLIB=$(RANLIB)' \
|
||||
'DESTDIR=$(DESTDIR)'
|
||||
|
||||
# Subdir rules rely on $(FLAGS_TO_PASS)
|
||||
FLAGS_TO_PASS = $(AM_MAKEFLAGS)
|
||||
|
||||
MAKEOVERRIDES=
|
||||
|
||||
toolexeclib_LTLIBRARIES = libffi.la
|
||||
noinst_LTLIBRARIES = libffi_convenience.la
|
||||
|
||||
libffi_la_SOURCES = src/prep_cif.c src/types.c \
|
||||
src/raw_api.c src/java_raw_api.c src/closures.c
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libffi.pc
|
||||
|
||||
nodist_libffi_la_SOURCES =
|
||||
|
||||
if FFI_DEBUG
|
||||
nodist_libffi_la_SOURCES += src/debug.c
|
||||
endif
|
||||
|
||||
if MIPS
|
||||
nodist_libffi_la_SOURCES += src/mips/ffi.c src/mips/o32.S src/mips/n32.S
|
||||
endif
|
||||
if BFIN
|
||||
nodist_libffi_la_SOURCES += src/bfin/ffi.c src/bfin/sysv.S
|
||||
endif
|
||||
if X86
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/sysv.S src/x86/win32.S
|
||||
endif
|
||||
if X86_FREEBSD
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/freebsd.S src/x86/win32.S
|
||||
endif
|
||||
if X86_WIN32
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win32.S
|
||||
endif
|
||||
if X86_WIN64
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win64.S
|
||||
endif
|
||||
if X86_DARWIN
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S
|
||||
if X86_DARWIN32
|
||||
nodist_libffi_la_SOURCES += src/x86/win32.S
|
||||
endif
|
||||
endif
|
||||
if SPARC
|
||||
nodist_libffi_la_SOURCES += src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S
|
||||
endif
|
||||
if ALPHA
|
||||
nodist_libffi_la_SOURCES += src/alpha/ffi.c src/alpha/osf.S
|
||||
endif
|
||||
if IA64
|
||||
nodist_libffi_la_SOURCES += src/ia64/ffi.c src/ia64/unix.S
|
||||
endif
|
||||
if M32R
|
||||
nodist_libffi_la_SOURCES += src/m32r/sysv.S src/m32r/ffi.c
|
||||
endif
|
||||
if M68K
|
||||
nodist_libffi_la_SOURCES += src/m68k/ffi.c src/m68k/sysv.S
|
||||
endif
|
||||
if M88K
|
||||
nodist_libffi_la_SOURCES += src/m88k/ffi.c src/m88k/obsd.S
|
||||
endif
|
||||
if MOXIE
|
||||
nodist_libffi_la_SOURCES += src/moxie/ffi.c src/moxie/eabi.S
|
||||
endif
|
||||
if MICROBLAZE
|
||||
nodist_libffi_la_SOURCES += src/microblaze/ffi.c src/microblaze/sysv.S
|
||||
endif
|
||||
if NIOS2
|
||||
nodist_libffi_la_SOURCES += src/nios2/sysv.S src/nios2/ffi.c
|
||||
endif
|
||||
if POWERPC
|
||||
nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
|
||||
endif
|
||||
if POWERPC_AIX
|
||||
nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
|
||||
endif
|
||||
if POWERPC_DARWIN
|
||||
nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
|
||||
endif
|
||||
if POWERPC_FREEBSD
|
||||
nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
|
||||
endif
|
||||
if AARCH64
|
||||
nodist_libffi_la_SOURCES += src/aarch64/sysv.S src/aarch64/ffi.c
|
||||
endif
|
||||
if ARC
|
||||
nodist_libffi_la_SOURCES += src/arc/arcompact.S src/arc/ffi.c
|
||||
endif
|
||||
if ARM
|
||||
nodist_libffi_la_SOURCES += src/arm/sysv.S src/arm/ffi.c
|
||||
if FFI_EXEC_TRAMPOLINE_TABLE
|
||||
nodist_libffi_la_SOURCES += src/arm/trampoline.S
|
||||
endif
|
||||
endif
|
||||
if AVR32
|
||||
nodist_libffi_la_SOURCES += src/avr32/sysv.S src/avr32/ffi.c
|
||||
endif
|
||||
if LIBFFI_CRIS
|
||||
nodist_libffi_la_SOURCES += src/cris/sysv.S src/cris/ffi.c
|
||||
endif
|
||||
if FRV
|
||||
nodist_libffi_la_SOURCES += src/frv/eabi.S src/frv/ffi.c
|
||||
endif
|
||||
if S390
|
||||
nodist_libffi_la_SOURCES += src/s390/sysv.S src/s390/ffi.c
|
||||
endif
|
||||
if X86_64
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S
|
||||
endif
|
||||
if SH
|
||||
nodist_libffi_la_SOURCES += src/sh/sysv.S src/sh/ffi.c
|
||||
endif
|
||||
if SH64
|
||||
nodist_libffi_la_SOURCES += src/sh64/sysv.S src/sh64/ffi.c
|
||||
endif
|
||||
if PA_LINUX
|
||||
nodist_libffi_la_SOURCES += src/pa/linux.S src/pa/ffi.c
|
||||
endif
|
||||
if PA_HPUX
|
||||
nodist_libffi_la_SOURCES += src/pa/hpux32.S src/pa/ffi.c
|
||||
endif
|
||||
if TILE
|
||||
nodist_libffi_la_SOURCES += src/tile/tile.S src/tile/ffi.c
|
||||
endif
|
||||
if XTENSA
|
||||
nodist_libffi_la_SOURCES += src/xtensa/sysv.S src/xtensa/ffi.c
|
||||
endif
|
||||
if METAG
|
||||
nodist_libffi_la_SOURCES += src/metag/sysv.S src/metag/ffi.c
|
||||
endif
|
||||
if VAX
|
||||
nodist_libffi_la_SOURCES += src/vax/elfbsd.S src/vax/ffi.c
|
||||
endif
|
||||
|
||||
libffi_convenience_la_SOURCES = $(libffi_la_SOURCES)
|
||||
nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES)
|
||||
|
||||
LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS))
|
||||
|
||||
AM_CFLAGS =
|
||||
if FFI_DEBUG
|
||||
# Build debug. Define FFI_DEBUG on the commandline so that, when building with
|
||||
# MSVC, it can link against the debug CRT.
|
||||
AM_CFLAGS += -DFFI_DEBUG
|
||||
endif
|
||||
|
||||
libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS)
|
||||
|
||||
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
|
||||
AM_CCASFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
dist-hook:
|
||||
if [ -d $(top_srcdir)/.git ] ; then (cd $(top_srcdir); git log --no-decorate) ; else echo 'See git log for history.' ; fi > $(distdir)/ChangeLog
|
2156
third_party/python/Modules/_ctypes/libffi/Makefile.in
vendored
Normal file
2156
third_party/python/Modules/_ctypes/libffi/Makefile.in
vendored
Normal file
File diff suppressed because it is too large
Load diff
428
third_party/python/Modules/_ctypes/libffi/README
vendored
Normal file
428
third_party/python/Modules/_ctypes/libffi/README
vendored
Normal file
|
@ -0,0 +1,428 @@
|
|||
Status
|
||||
======
|
||||
|
||||
libffi-3.1 was released on May 19, 2014. Check the libffi web page
|
||||
for updates: <URL:http://sourceware.org/libffi/>.
|
||||
|
||||
|
||||
What is libffi?
|
||||
===============
|
||||
|
||||
Compilers for high level languages generate code that follow certain
|
||||
conventions. These conventions are necessary, in part, for separate
|
||||
compilation to work. One such convention is the "calling
|
||||
convention". The "calling convention" is essentially a set of
|
||||
assumptions made by the compiler about where function arguments will
|
||||
be found on entry to a function. A "calling convention" also specifies
|
||||
where the return value for a function is found.
|
||||
|
||||
Some programs may not know at the time of compilation what arguments
|
||||
are to be passed to a function. For instance, an interpreter may be
|
||||
told at run-time about the number and types of arguments used to call
|
||||
a given function. Libffi can be used in such programs to provide a
|
||||
bridge from the interpreter program to compiled code.
|
||||
|
||||
The libffi library provides a portable, high level programming
|
||||
interface to various calling conventions. This allows a programmer to
|
||||
call any function specified by a call interface description at run
|
||||
time.
|
||||
|
||||
FFI stands for Foreign Function Interface. A foreign function
|
||||
interface is the popular name for the interface that allows code
|
||||
written in one language to call code written in another language. The
|
||||
libffi library really only provides the lowest, machine dependent
|
||||
layer of a fully featured foreign function interface. A layer must
|
||||
exist above libffi that handles type conversions for values passed
|
||||
between the two languages.
|
||||
|
||||
|
||||
Supported Platforms
|
||||
===================
|
||||
|
||||
Libffi has been ported to many different platforms.
|
||||
For specific configuration details and testing status, please
|
||||
refer to the wiki page here:
|
||||
|
||||
http://www.moxielogic.org/wiki/index.php?title=Libffi_3.1
|
||||
|
||||
At the time of release, the following basic configurations have been
|
||||
tested:
|
||||
|
||||
|-----------------+------------------+-------------------------|
|
||||
| Architecture | Operating System | Compiler |
|
||||
|-----------------+------------------+-------------------------|
|
||||
| AArch64 (ARM64) | iOS | Clang |
|
||||
| AArch64 | Linux | GCC |
|
||||
| Alpha | Linux | GCC |
|
||||
| Alpha | Tru64 | GCC |
|
||||
| ARC | Linux | GCC |
|
||||
| ARM | Linux | GCC |
|
||||
| ARM | iOS | GCC |
|
||||
| AVR32 | Linux | GCC |
|
||||
| Blackfin | uClinux | GCC |
|
||||
| HPPA | HPUX | GCC |
|
||||
| IA-64 | Linux | GCC |
|
||||
| M68K | FreeMiNT | GCC |
|
||||
| M68K | Linux | GCC |
|
||||
| M68K | RTEMS | GCC |
|
||||
| M88K | OpenBSD/mvme88k | GCC |
|
||||
| Meta | Linux | GCC |
|
||||
| MicroBlaze | Linux | GCC |
|
||||
| MIPS | IRIX | GCC |
|
||||
| MIPS | Linux | GCC |
|
||||
| MIPS | RTEMS | GCC |
|
||||
| MIPS64 | Linux | GCC |
|
||||
| Moxie | Bare metal | GCC |
|
||||
| Nios II | Linux | GCC |
|
||||
| PowerPC 32-bit | AIX | IBM XL C |
|
||||
| PowerPC 64-bit | AIX | IBM XL C |
|
||||
| PowerPC | AMIGA | GCC |
|
||||
| PowerPC | Linux | GCC |
|
||||
| PowerPC | Mac OSX | GCC |
|
||||
| PowerPC | FreeBSD | GCC |
|
||||
| PowerPC 64-bit | FreeBSD | GCC |
|
||||
| PowerPC 64-bit | Linux ELFv1 | GCC |
|
||||
| PowerPC 64-bit | Linux ELFv2 | GCC |
|
||||
| S390 | Linux | GCC |
|
||||
| S390X | Linux | GCC |
|
||||
| SPARC | Linux | GCC |
|
||||
| SPARC | Solaris | GCC |
|
||||
| SPARC | Solaris | Oracle Solaris Studio C |
|
||||
| SPARC64 | Linux | GCC |
|
||||
| SPARC64 | FreeBSD | GCC |
|
||||
| SPARC64 | Solaris | Oracle Solaris Studio C |
|
||||
| TILE-Gx/TILEPro | Linux | GCC |
|
||||
| VAX | OpenBSD/vax | GCC |
|
||||
| X86 | FreeBSD | GCC |
|
||||
| X86 | GNU HURD | GCC |
|
||||
| X86 | Interix | GCC |
|
||||
| X86 | kFreeBSD | GCC |
|
||||
| X86 | Linux | GCC |
|
||||
| X86 | Mac OSX | GCC |
|
||||
| X86 | OpenBSD | GCC |
|
||||
| X86 | OS/2 | GCC |
|
||||
| X86 | Solaris | GCC |
|
||||
| X86 | Solaris | Oracle Solaris Studio C |
|
||||
| X86 | Windows/Cygwin | GCC |
|
||||
| X86 | Windows/MingW | GCC |
|
||||
| X86-64 | FreeBSD | GCC |
|
||||
| X86-64 | Linux | GCC |
|
||||
| X86-64 | Linux/x32 | GCC |
|
||||
| X86-64 | OpenBSD | GCC |
|
||||
| X86-64 | Solaris | Oracle Solaris Studio C |
|
||||
| X86-64 | Windows/MingW | GCC |
|
||||
| Xtensa | Linux | GCC |
|
||||
|-----------------+------------------+-------------------------|
|
||||
|
||||
Please send additional platform test results to
|
||||
libffi-discuss@sourceware.org and feel free to update the wiki page
|
||||
above.
|
||||
|
||||
Installing libffi
|
||||
=================
|
||||
|
||||
First you must configure the distribution for your particular
|
||||
system. Go to the directory you wish to build libffi in and run the
|
||||
"configure" program found in the root directory of the libffi source
|
||||
distribution.
|
||||
|
||||
If you're building libffi directly from version control, configure won't
|
||||
exist yet; run ./autogen.sh first.
|
||||
|
||||
You may want to tell configure where to install the libffi library and
|
||||
header files. To do that, use the --prefix configure switch. Libffi
|
||||
will install under /usr/local by default.
|
||||
|
||||
If you want to enable extra run-time debugging checks use the the
|
||||
--enable-debug configure switch. This is useful when your program dies
|
||||
mysteriously while using libffi.
|
||||
|
||||
Another useful configure switch is --enable-purify-safety. Using this
|
||||
will add some extra code which will suppress certain warnings when you
|
||||
are using Purify with libffi. Only use this switch when using
|
||||
Purify, as it will slow down the library.
|
||||
|
||||
It's also possible to build libffi on Windows platforms with
|
||||
Microsoft's Visual C++ compiler. In this case, use the msvcc.sh
|
||||
wrapper script during configuration like so:
|
||||
|
||||
path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP=\"cl -nologo -EP\"
|
||||
|
||||
For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64" and
|
||||
CXX="path/to/msvcc.sh -m64". You may also need to specify --build
|
||||
appropriately.
|
||||
|
||||
When building with MSVC under a MingW environment, you may need to
|
||||
remove the line in configure that sets 'fix_srcfile_path' to a 'cygpath'
|
||||
command. ('cygpath' is not present in MingW, and is not required when
|
||||
using MingW-style paths.)
|
||||
|
||||
For iOS builds, the 'libffi.xcodeproj' Xcode project is available.
|
||||
|
||||
Configure has many other options. Use "configure --help" to see them all.
|
||||
|
||||
Once configure has finished, type "make". Note that you must be using
|
||||
GNU make. You can ftp GNU make from ftp.gnu.org:/pub/gnu/make .
|
||||
|
||||
To ensure that libffi is working as advertised, type "make check".
|
||||
This will require that you have DejaGNU installed.
|
||||
|
||||
To install the library and header files, type "make install".
|
||||
|
||||
|
||||
History
|
||||
=======
|
||||
|
||||
See the git log for details at http://github.com/atgreen/libffi.
|
||||
|
||||
3.1 May-19-14
|
||||
Add AArch64 (ARM64) iOS support.
|
||||
Add Nios II support.
|
||||
Add m88k and DEC VAX support.
|
||||
Add support for stdcall, thiscall, and fastcall on non-Windows
|
||||
32-bit x86 targets such as Linux.
|
||||
Various Android, MIPS N32, x86, FreeBSD and UltraSPARC IIi
|
||||
fixes.
|
||||
Make the testsuite more robust: eliminate several spurious
|
||||
failures, and respect the $CC and $CXX environment variables.
|
||||
Archive off the manually maintained ChangeLog in favor of git
|
||||
log.
|
||||
|
||||
3.0.13 Mar-17-13
|
||||
Add Meta support.
|
||||
Add missing Moxie bits.
|
||||
Fix stack alignment bug on 32-bit x86.
|
||||
Build fix for m68000 targets.
|
||||
Build fix for soft-float Power targets.
|
||||
Fix the install dir location for some platforms when building
|
||||
with GCC (OS X, Solaris).
|
||||
Fix Cygwin regression.
|
||||
|
||||
3.0.12 Feb-11-13
|
||||
Add Moxie support.
|
||||
Add AArch64 support.
|
||||
Add Blackfin support.
|
||||
Add TILE-Gx/TILEPro support.
|
||||
Add MicroBlaze support.
|
||||
Add Xtensa support.
|
||||
Add support for PaX enabled kernels with MPROTECT.
|
||||
Add support for native vendor compilers on
|
||||
Solaris and AIX.
|
||||
Work around LLVM/GCC interoperability issue on x86_64.
|
||||
|
||||
3.0.11 Apr-11-12
|
||||
Lots of build fixes.
|
||||
Add support for variadic functions (ffi_prep_cif_var).
|
||||
Add Linux/x32 support.
|
||||
Add thiscall, fastcall and MSVC cdecl support on Windows.
|
||||
Add Amiga and newer MacOS support.
|
||||
Add m68k FreeMiNT support.
|
||||
Integration with iOS' xcode build tools.
|
||||
Fix Octeon and MC68881 support.
|
||||
Fix code pessimizations.
|
||||
|
||||
3.0.10 Aug-23-11
|
||||
Add support for Apple's iOS.
|
||||
Add support for ARM VFP ABI.
|
||||
Add RTEMS support for MIPS and M68K.
|
||||
Fix instruction cache clearing problems on
|
||||
ARM and SPARC.
|
||||
Fix the N64 build on mips-sgi-irix6.5.
|
||||
Enable builds with Microsoft's compiler.
|
||||
Enable x86 builds with Oracle's Solaris compiler.
|
||||
Fix support for calling code compiled with Oracle's Sparc
|
||||
Solaris compiler.
|
||||
Testsuite fixes for Tru64 Unix.
|
||||
Additional platform support.
|
||||
|
||||
3.0.9 Dec-31-09
|
||||
Add AVR32 and win64 ports. Add ARM softfp support.
|
||||
Many fixes for AIX, Solaris, HP-UX, *BSD.
|
||||
Several PowerPC and x86-64 bug fixes.
|
||||
Build DLL for windows.
|
||||
|
||||
3.0.8 Dec-19-08
|
||||
Add *BSD, BeOS, and PA-Linux support.
|
||||
|
||||
3.0.7 Nov-11-08
|
||||
Fix for ppc FreeBSD.
|
||||
(thanks to Andreas Tobler)
|
||||
|
||||
3.0.6 Jul-17-08
|
||||
Fix for closures on sh.
|
||||
Mark the sh/sh64 stack as non-executable.
|
||||
(both thanks to Kaz Kojima)
|
||||
|
||||
3.0.5 Apr-3-08
|
||||
Fix libffi.pc file.
|
||||
Fix #define ARM for IcedTea users.
|
||||
Fix x86 closure bug.
|
||||
|
||||
3.0.4 Feb-24-08
|
||||
Fix x86 OpenBSD configury.
|
||||
|
||||
3.0.3 Feb-22-08
|
||||
Enable x86 OpenBSD thanks to Thomas Heller, and
|
||||
x86-64 FreeBSD thanks to Björn König and Andreas Tobler.
|
||||
Clean up test instruction in README.
|
||||
|
||||
3.0.2 Feb-21-08
|
||||
Improved x86 FreeBSD support.
|
||||
Thanks to Björn König.
|
||||
|
||||
3.0.1 Feb-15-08
|
||||
Fix instruction cache flushing bug on MIPS.
|
||||
Thanks to David Daney.
|
||||
|
||||
3.0.0 Feb-15-08
|
||||
Many changes, mostly thanks to the GCC project.
|
||||
Cygnus Solutions is now Red Hat.
|
||||
|
||||
[10 years go by...]
|
||||
|
||||
1.20 Oct-5-98
|
||||
Raffaele Sena produces ARM port.
|
||||
|
||||
1.19 Oct-5-98
|
||||
Fixed x86 long double and long long return support.
|
||||
m68k bug fixes from Andreas Schwab.
|
||||
Patch for DU assembler compatibility for the Alpha from Richard
|
||||
Henderson.
|
||||
|
||||
1.18 Apr-17-98
|
||||
Bug fixes and MIPS configuration changes.
|
||||
|
||||
1.17 Feb-24-98
|
||||
Bug fixes and m68k port from Andreas Schwab. PowerPC port from
|
||||
Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes.
|
||||
|
||||
1.16 Feb-11-98
|
||||
Richard Henderson produces Alpha port.
|
||||
|
||||
1.15 Dec-4-97
|
||||
Fixed an n32 ABI bug. New libtool, auto* support.
|
||||
|
||||
1.14 May-13-97
|
||||
libtool is now used to generate shared and static libraries.
|
||||
Fixed a minor portability problem reported by Russ McManus
|
||||
<mcmanr@eq.gs.com>.
|
||||
|
||||
1.13 Dec-2-96
|
||||
Added --enable-purify-safety to keep Purify from complaining
|
||||
about certain low level code.
|
||||
Sparc fix for calling functions with < 6 args.
|
||||
Linux x86 a.out fix.
|
||||
|
||||
1.12 Nov-22-96
|
||||
Added missing ffi_type_void, needed for supporting void return
|
||||
types. Fixed test case for non MIPS machines. Cygnus Support
|
||||
is now Cygnus Solutions.
|
||||
|
||||
1.11 Oct-30-96
|
||||
Added notes about GNU make.
|
||||
|
||||
1.10 Oct-29-96
|
||||
Added configuration fix for non GNU compilers.
|
||||
|
||||
1.09 Oct-29-96
|
||||
Added --enable-debug configure switch. Clean-ups based on LCLint
|
||||
feedback. ffi_mips.h is always installed. Many configuration
|
||||
fixes. Fixed ffitest.c for sparc builds.
|
||||
|
||||
1.08 Oct-15-96
|
||||
Fixed n32 problem. Many clean-ups.
|
||||
|
||||
1.07 Oct-14-96
|
||||
Gordon Irlam rewrites v8.S again. Bug fixes.
|
||||
|
||||
1.06 Oct-14-96
|
||||
Gordon Irlam improved the sparc port.
|
||||
|
||||
1.05 Oct-14-96
|
||||
Interface changes based on feedback.
|
||||
|
||||
1.04 Oct-11-96
|
||||
Sparc port complete (modulo struct passing bug).
|
||||
|
||||
1.03 Oct-10-96
|
||||
Passing struct args, and returning struct values works for
|
||||
all architectures/calling conventions. Expanded tests.
|
||||
|
||||
1.02 Oct-9-96
|
||||
Added SGI n32 support. Fixed bugs in both o32 and Linux support.
|
||||
Added "make test".
|
||||
|
||||
1.01 Oct-8-96
|
||||
Fixed float passing bug in mips version. Restructured some
|
||||
of the code. Builds cleanly with SGI tools.
|
||||
|
||||
1.00 Oct-7-96
|
||||
First release. No public announcement.
|
||||
|
||||
|
||||
Authors & Credits
|
||||
=================
|
||||
|
||||
libffi was originally written by Anthony Green <green@moxielogic.com>.
|
||||
|
||||
The developers of the GNU Compiler Collection project have made
|
||||
innumerable valuable contributions. See the ChangeLog file for
|
||||
details.
|
||||
|
||||
Some of the ideas behind libffi were inspired by Gianni Mariani's free
|
||||
gencall library for Silicon Graphics machines.
|
||||
|
||||
The closure mechanism was designed and implemented by Kresten Krab
|
||||
Thorup.
|
||||
|
||||
Major processor architecture ports were contributed by the following
|
||||
developers:
|
||||
|
||||
aarch64 Marcus Shawcroft, James Greenhalgh
|
||||
alpha Richard Henderson
|
||||
arm Raffaele Sena
|
||||
blackfin Alexandre Keunecke I. de Mendonca
|
||||
cris Simon Posnjak, Hans-Peter Nilsson
|
||||
frv Anthony Green
|
||||
ia64 Hans Boehm
|
||||
m32r Kazuhiro Inaoka
|
||||
m68k Andreas Schwab
|
||||
m88k Miod Vallat
|
||||
microblaze Nathan Rossi
|
||||
mips Anthony Green, Casey Marshall
|
||||
mips64 David Daney
|
||||
moxie Anthony Green
|
||||
nios ii Sandra Loosemore
|
||||
pa Randolph Chung, Dave Anglin, Andreas Tobler
|
||||
powerpc Geoffrey Keating, Andreas Tobler,
|
||||
David Edelsohn, John Hornkvist
|
||||
powerpc64 Jakub Jelinek
|
||||
s390 Gerhard Tonn, Ulrich Weigand
|
||||
sh Kaz Kojima
|
||||
sh64 Kaz Kojima
|
||||
sparc Anthony Green, Gordon Irlam
|
||||
tile-gx/tilepro Walter Lee
|
||||
vax Miod Vallat
|
||||
x86 Anthony Green, Jon Beniston
|
||||
x86-64 Bo Thorsen
|
||||
xtensa Chris Zankel
|
||||
|
||||
Jesper Skov and Andrew Haley both did more than their fair share of
|
||||
stepping through the code and tracking down bugs.
|
||||
|
||||
Thanks also to Tom Tromey for bug fixes, documentation and
|
||||
configuration help.
|
||||
|
||||
Thanks to Jim Blandy, who provided some useful feedback on the libffi
|
||||
interface.
|
||||
|
||||
Andreas Tobler has done a tremendous amount of work on the testsuite.
|
||||
|
||||
Alex Oliva solved the executable page problem for SElinux.
|
||||
|
||||
The list above is almost certainly incomplete and inaccurate. I'm
|
||||
happy to make corrections or additions upon request.
|
||||
|
||||
If you have a problem, or have found a bug, please send a note to the
|
||||
author at green@moxielogic.com, or the project mailing list at
|
||||
libffi-discuss@sourceware.org.
|
92
third_party/python/Modules/_ctypes/libffi/acinclude.m4
vendored
Normal file
92
third_party/python/Modules/_ctypes/libffi/acinclude.m4
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
# mmap(2) blacklisting. Some platforms provide the mmap library routine
|
||||
# but don't support all of the features we need from it.
|
||||
AC_DEFUN([AC_FUNC_MMAP_BLACKLIST],
|
||||
[
|
||||
AC_CHECK_HEADER([sys/mman.h],
|
||||
[libffi_header_sys_mman_h=yes], [libffi_header_sys_mman_h=no])
|
||||
AC_CHECK_FUNC([mmap], [libffi_func_mmap=yes], [libffi_func_mmap=no])
|
||||
if test "$libffi_header_sys_mman_h" != yes \
|
||||
|| test "$libffi_func_mmap" != yes; then
|
||||
ac_cv_func_mmap_file=no
|
||||
ac_cv_func_mmap_dev_zero=no
|
||||
ac_cv_func_mmap_anon=no
|
||||
else
|
||||
AC_CACHE_CHECK([whether read-only mmap of a plain file works],
|
||||
ac_cv_func_mmap_file,
|
||||
[# Add a system to this blacklist if
|
||||
# mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
|
||||
# memory area containing the same data that you'd get if you applied
|
||||
# read() to the same fd. The only system known to have a problem here
|
||||
# is VMS, where text files have record structure.
|
||||
case "$host_os" in
|
||||
vms* | ultrix*)
|
||||
ac_cv_func_mmap_file=no ;;
|
||||
*)
|
||||
ac_cv_func_mmap_file=yes;;
|
||||
esac])
|
||||
AC_CACHE_CHECK([whether mmap from /dev/zero works],
|
||||
ac_cv_func_mmap_dev_zero,
|
||||
[# Add a system to this blacklist if it has mmap() but /dev/zero
|
||||
# does not exist, or if mmapping /dev/zero does not give anonymous
|
||||
# zeroed pages with both the following properties:
|
||||
# 1. If you map N consecutive pages in with one call, and then
|
||||
# unmap any subset of those pages, the pages that were not
|
||||
# explicitly unmapped remain accessible.
|
||||
# 2. If you map two adjacent blocks of memory and then unmap them
|
||||
# both at once, they must both go away.
|
||||
# Systems known to be in this category are Windows (all variants),
|
||||
# VMS, and Darwin.
|
||||
case "$host_os" in
|
||||
vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
|
||||
ac_cv_func_mmap_dev_zero=no ;;
|
||||
*)
|
||||
ac_cv_func_mmap_dev_zero=yes;;
|
||||
esac])
|
||||
|
||||
# Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
|
||||
AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon,
|
||||
[AC_TRY_COMPILE(
|
||||
[#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef MAP_ANONYMOUS
|
||||
#define MAP_ANONYMOUS MAP_ANON
|
||||
#endif
|
||||
],
|
||||
[int n = MAP_ANONYMOUS;],
|
||||
ac_cv_decl_map_anon=yes,
|
||||
ac_cv_decl_map_anon=no)])
|
||||
|
||||
if test $ac_cv_decl_map_anon = no; then
|
||||
ac_cv_func_mmap_anon=no
|
||||
else
|
||||
AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
|
||||
ac_cv_func_mmap_anon,
|
||||
[# Add a system to this blacklist if it has mmap() and MAP_ANON or
|
||||
# MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
|
||||
# doesn't give anonymous zeroed pages with the same properties listed
|
||||
# above for use of /dev/zero.
|
||||
# Systems known to be in this category are Windows, VMS, and SCO Unix.
|
||||
case "$host_os" in
|
||||
vms* | cygwin* | pe | mingw* | sco* | udk* )
|
||||
ac_cv_func_mmap_anon=no ;;
|
||||
*)
|
||||
ac_cv_func_mmap_anon=yes;;
|
||||
esac])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ac_cv_func_mmap_file = yes; then
|
||||
AC_DEFINE(HAVE_MMAP_FILE, 1,
|
||||
[Define if read-only mmap of a plain file works.])
|
||||
fi
|
||||
if test $ac_cv_func_mmap_dev_zero = yes; then
|
||||
AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
|
||||
[Define if mmap of /dev/zero works.])
|
||||
fi
|
||||
if test $ac_cv_func_mmap_anon = yes; then
|
||||
AC_DEFINE(HAVE_MMAP_ANON, 1,
|
||||
[Define if mmap with MAP_ANON(YMOUS) works.])
|
||||
fi
|
||||
])
|
1961
third_party/python/Modules/_ctypes/libffi/aclocal.m4
vendored
Normal file
1961
third_party/python/Modules/_ctypes/libffi/aclocal.m4
vendored
Normal file
File diff suppressed because it is too large
Load diff
347
third_party/python/Modules/_ctypes/libffi/compile
vendored
Executable file
347
third_party/python/Modules/_ctypes/libffi/compile
vendored
Executable file
|
@ -0,0 +1,347 @@
|
|||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2012-10-14.11; # UTC
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/lib$lib.a"; then
|
||||
found=yes
|
||||
lib=$dir/lib$lib.a
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
1558
third_party/python/Modules/_ctypes/libffi/config.guess
vendored
Executable file
1558
third_party/python/Modules/_ctypes/libffi/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load diff
1788
third_party/python/Modules/_ctypes/libffi/config.sub
vendored
Executable file
1788
third_party/python/Modules/_ctypes/libffi/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load diff
21691
third_party/python/Modules/_ctypes/libffi/configure
vendored
Executable file
21691
third_party/python/Modules/_ctypes/libffi/configure
vendored
Executable file
File diff suppressed because it is too large
Load diff
630
third_party/python/Modules/_ctypes/libffi/configure.ac
vendored
Normal file
630
third_party/python/Modules/_ctypes/libffi/configure.ac
vendored
Normal file
|
@ -0,0 +1,630 @@
|
|||
dnl Process this with autoconf to create configure
|
||||
#
|
||||
# file from libffi - slightly patched for Python's ctypes
|
||||
#
|
||||
|
||||
AC_PREREQ(2.68)
|
||||
|
||||
AC_INIT([libffi], [3.1], [http://github.com/atgreen/libffi/issues])
|
||||
AC_CONFIG_HEADERS([fficonfig.h])
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
target_alias=${target_alias-$host_alias}
|
||||
|
||||
case "${host}" in
|
||||
frv*-elf)
|
||||
LDFLAGS=`echo $LDFLAGS | sed "s/\-B[^ ]*libgloss\/frv\///"`\ -B`pwd`/../libgloss/frv/
|
||||
;;
|
||||
esac
|
||||
|
||||
AX_ENABLE_BUILDDIR
|
||||
|
||||
AM_INIT_AUTOMAKE
|
||||
|
||||
# The same as in boehm-gc and libstdc++. Have to borrow it from there.
|
||||
# We must force CC to /not/ be precious variables; otherwise
|
||||
# the wrong, non-multilib-adjusted value will be used in multilibs.
|
||||
# As a side effect, we have to subst CFLAGS ourselves.
|
||||
# Also save and restore CFLAGS, since AC_PROG_CC will come up with
|
||||
# defaults of its own if none are provided.
|
||||
|
||||
m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
|
||||
m4_define([_AC_ARG_VAR_PRECIOUS],[])
|
||||
save_CFLAGS=$CFLAGS
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
CFLAGS=$save_CFLAGS
|
||||
m4_undefine([_AC_ARG_VAR_PRECIOUS])
|
||||
m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
|
||||
AM_PROG_AS
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_LIBTOOL
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
# Test for 64-bit build.
|
||||
AC_CHECK_SIZEOF([size_t])
|
||||
|
||||
AX_COMPILER_VENDOR
|
||||
AX_CC_MAXOPT
|
||||
# The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro
|
||||
# compiler.
|
||||
if test "$ax_cv_c_compiler_vendor" != "sun"; then
|
||||
AX_CFLAGS_WARN_ALL
|
||||
fi
|
||||
|
||||
if test "x$GCC" = "xyes"; then
|
||||
CFLAGS="$CFLAGS -fexceptions"
|
||||
fi
|
||||
|
||||
cat > local.exp <<EOF
|
||||
set CC_FOR_TARGET "$CC"
|
||||
set CXX_FOR_TARGET "$CXX"
|
||||
EOF
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_CHECK_HEADERS(sys/mman.h)
|
||||
AC_CHECK_FUNCS(mmap)
|
||||
AC_FUNC_MMAP_BLACKLIST
|
||||
|
||||
dnl The -no-testsuite modules omit the test subdir.
|
||||
AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
|
||||
|
||||
TARGETDIR="unknown"
|
||||
HAVE_LONG_DOUBLE_VARIANT=0
|
||||
case "$host" in
|
||||
aarch64*-*-*)
|
||||
TARGET=AARCH64; TARGETDIR=aarch64
|
||||
;;
|
||||
|
||||
alpha*-*-*)
|
||||
TARGET=ALPHA; TARGETDIR=alpha;
|
||||
# Support 128-bit long double, changeable via command-line switch.
|
||||
HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
|
||||
;;
|
||||
|
||||
arc*-*-*)
|
||||
TARGET=ARC; TARGETDIR=arc
|
||||
;;
|
||||
|
||||
arm*-*-*)
|
||||
TARGET=ARM; TARGETDIR=arm
|
||||
;;
|
||||
|
||||
amd64-*-freebsd* | amd64-*-openbsd*)
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
;;
|
||||
|
||||
amd64-*-freebsd*)
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
;;
|
||||
|
||||
amd64-*-freebsd*)
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
;;
|
||||
|
||||
avr32*-*-*)
|
||||
TARGET=AVR32; TARGETDIR=avr32
|
||||
;;
|
||||
|
||||
bfin*)
|
||||
TARGET=BFIN; TARGETDIR=bfin
|
||||
;;
|
||||
|
||||
cris-*-*)
|
||||
TARGET=LIBFFI_CRIS; TARGETDIR=cris
|
||||
;;
|
||||
|
||||
frv-*-*)
|
||||
TARGET=FRV; TARGETDIR=frv
|
||||
;;
|
||||
|
||||
hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*)
|
||||
TARGET=PA_LINUX; TARGETDIR=pa
|
||||
;;
|
||||
hppa*64-*-hpux*)
|
||||
TARGET=PA64_HPUX; TARGETDIR=pa
|
||||
;;
|
||||
hppa*-*-hpux*)
|
||||
TARGET=PA_HPUX; TARGETDIR=pa
|
||||
;;
|
||||
|
||||
i?86-*-freebsd* | i?86-*-openbsd*)
|
||||
TARGET=X86_FREEBSD; TARGETDIR=x86
|
||||
;;
|
||||
i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*)
|
||||
TARGET=X86_WIN32; TARGETDIR=x86
|
||||
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
||||
# We must also check with_cross_host to decide if this is a native
|
||||
# or cross-build and select where to install dlls appropriately.
|
||||
if test -n "$with_cross_host" &&
|
||||
test x"$with_cross_host" != x"no"; then
|
||||
AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
|
||||
else
|
||||
AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
|
||||
fi
|
||||
;;
|
||||
i*86-*-nto-qnx*)
|
||||
TARGET=X86; TARGETDIR=x86
|
||||
;;
|
||||
i?86-*-darwin*)
|
||||
TARGET=X86_DARWIN; TARGETDIR=x86
|
||||
;;
|
||||
i?86-*-solaris2.1[[0-9]]*)
|
||||
TARGETDIR=x86
|
||||
if test $ac_cv_sizeof_size_t = 4; then
|
||||
TARGET=X86;
|
||||
else
|
||||
TARGET=X86_64;
|
||||
fi
|
||||
;;
|
||||
|
||||
x86_64-*-darwin*)
|
||||
TARGET=X86_DARWIN; TARGETDIR=x86
|
||||
;;
|
||||
|
||||
x86_64-*-cygwin* | x86_64-*-mingw*)
|
||||
TARGET=X86_WIN64; TARGETDIR=x86
|
||||
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
||||
# We must also check with_cross_host to decide if this is a native
|
||||
# or cross-build and select where to install dlls appropriately.
|
||||
if test -n "$with_cross_host" &&
|
||||
test x"$with_cross_host" != x"no"; then
|
||||
AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
|
||||
else
|
||||
AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
|
||||
fi
|
||||
;;
|
||||
|
||||
i?86-*-* | x86_64-*-*)
|
||||
TARGETDIR=x86
|
||||
if test $ac_cv_sizeof_size_t = 4; then
|
||||
case "$host" in
|
||||
*-gnux32)
|
||||
TARGET=X86_64
|
||||
;;
|
||||
*)
|
||||
TARGET=X86
|
||||
;;
|
||||
esac
|
||||
else
|
||||
TARGET=X86_64;
|
||||
fi
|
||||
;;
|
||||
|
||||
ia64*-*-*)
|
||||
TARGET=IA64; TARGETDIR=ia64
|
||||
;;
|
||||
|
||||
m32r*-*-*)
|
||||
TARGET=M32R; TARGETDIR=m32r
|
||||
;;
|
||||
|
||||
m68k-*-*)
|
||||
TARGET=M68K; TARGETDIR=m68k
|
||||
;;
|
||||
|
||||
m88k-*-*)
|
||||
TARGET=M88K; TARGETDIR=m88k
|
||||
;;
|
||||
|
||||
microblaze*-*-*)
|
||||
TARGET=MICROBLAZE; TARGETDIR=microblaze
|
||||
;;
|
||||
|
||||
moxie-*-*)
|
||||
TARGET=MOXIE; TARGETDIR=moxie
|
||||
;;
|
||||
|
||||
metag-*-*)
|
||||
TARGET=METAG; TARGETDIR=metag
|
||||
;;
|
||||
|
||||
mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
|
||||
TARGET=MIPS_IRIX; TARGETDIR=mips
|
||||
;;
|
||||
mips*-*linux* | mips*-*-openbsd*)
|
||||
# Support 128-bit long double for NewABI.
|
||||
HAVE_LONG_DOUBLE='defined(__mips64)'
|
||||
TARGET=MIPS_LINUX; TARGETDIR=mips
|
||||
;;
|
||||
|
||||
nios2*-linux*)
|
||||
TARGET=NIOS2; TARGETDIR=nios2
|
||||
;;
|
||||
|
||||
powerpc*-*-linux* | powerpc-*-sysv*)
|
||||
TARGET=POWERPC; TARGETDIR=powerpc
|
||||
HAVE_LONG_DOUBLE_VARIANT=1
|
||||
;;
|
||||
powerpc-*-amigaos*)
|
||||
TARGET=POWERPC; TARGETDIR=powerpc
|
||||
;;
|
||||
powerpc-*-beos*)
|
||||
TARGET=POWERPC; TARGETDIR=powerpc
|
||||
;;
|
||||
powerpc-*-darwin* | powerpc64-*-darwin*)
|
||||
TARGET=POWERPC_DARWIN; TARGETDIR=powerpc
|
||||
;;
|
||||
powerpc-*-aix* | rs6000-*-aix*)
|
||||
TARGET=POWERPC_AIX; TARGETDIR=powerpc
|
||||
;;
|
||||
powerpc-*-freebsd* | powerpc-*-openbsd*)
|
||||
TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
|
||||
HAVE_LONG_DOUBLE_VARIANT=1
|
||||
;;
|
||||
powerpc64-*-freebsd*)
|
||||
TARGET=POWERPC; TARGETDIR=powerpc
|
||||
;;
|
||||
powerpc*-*-rtems*)
|
||||
TARGET=POWERPC; TARGETDIR=powerpc
|
||||
;;
|
||||
|
||||
s390-*-* | s390x-*-*)
|
||||
TARGET=S390; TARGETDIR=s390
|
||||
;;
|
||||
|
||||
sh-*-* | sh[[34]]*-*-*)
|
||||
TARGET=SH; TARGETDIR=sh
|
||||
;;
|
||||
sh64-*-* | sh5*-*-*)
|
||||
TARGET=SH64; TARGETDIR=sh64
|
||||
;;
|
||||
|
||||
sparc*-*-*)
|
||||
TARGET=SPARC; TARGETDIR=sparc
|
||||
;;
|
||||
|
||||
tile*-*)
|
||||
TARGET=TILE; TARGETDIR=tile
|
||||
;;
|
||||
|
||||
vax-*-*)
|
||||
TARGET=VAX; TARGETDIR=vax
|
||||
;;
|
||||
|
||||
xtensa*-*)
|
||||
TARGET=XTENSA; TARGETDIR=xtensa
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
AC_SUBST(AM_RUNTESTFLAGS)
|
||||
AC_SUBST(AM_LTLDFLAGS)
|
||||
|
||||
if test $TARGETDIR = unknown; then
|
||||
AC_MSG_ERROR(["libffi has not been ported to $host."])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(MIPS,[expr x$TARGET : 'xMIPS' > /dev/null])
|
||||
AM_CONDITIONAL(BFIN, test x$TARGET = xBFIN)
|
||||
AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
|
||||
AM_CONDITIONAL(X86, test x$TARGET = xX86)
|
||||
AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
|
||||
AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
|
||||
AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
|
||||
AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
|
||||
AM_CONDITIONAL(X86_DARWIN32, test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 4)
|
||||
AM_CONDITIONAL(X86_DARWIN64, test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 8)
|
||||
AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
|
||||
AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
|
||||
AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
|
||||
AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
|
||||
AM_CONDITIONAL(M88K, test x$TARGET = xM88K)
|
||||
AM_CONDITIONAL(MICROBLAZE, test x$TARGET = xMICROBLAZE)
|
||||
AM_CONDITIONAL(METAG, test x$TARGET = xMETAG)
|
||||
AM_CONDITIONAL(MOXIE, test x$TARGET = xMOXIE)
|
||||
AM_CONDITIONAL(NIOS2, test x$TARGET = xNIOS2)
|
||||
AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
|
||||
AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
|
||||
AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
|
||||
AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
|
||||
AM_CONDITIONAL(AARCH64, test x$TARGET = xAARCH64)
|
||||
AM_CONDITIONAL(ARC, test x$TARGET = xARC)
|
||||
AM_CONDITIONAL(ARM, test x$TARGET = xARM)
|
||||
AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
|
||||
AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
|
||||
AM_CONDITIONAL(FRV, test x$TARGET = xFRV)
|
||||
AM_CONDITIONAL(S390, test x$TARGET = xS390)
|
||||
AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
|
||||
AM_CONDITIONAL(SH, test x$TARGET = xSH)
|
||||
AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
|
||||
AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX)
|
||||
AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX)
|
||||
AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX)
|
||||
AM_CONDITIONAL(TILE, test x$TARGET = xTILE)
|
||||
AM_CONDITIONAL(VAX, test x$TARGET = xVAX)
|
||||
AM_CONDITIONAL(XTENSA, test x$TARGET = xXTENSA)
|
||||
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_FUNCS(memcpy)
|
||||
AC_FUNC_ALLOCA
|
||||
|
||||
AC_CHECK_SIZEOF(double)
|
||||
AC_CHECK_SIZEOF(long double)
|
||||
|
||||
# Also AC_SUBST this variable for ffi.h.
|
||||
if test -z "$HAVE_LONG_DOUBLE"; then
|
||||
HAVE_LONG_DOUBLE=0
|
||||
if test $ac_cv_sizeof_long_double != 0; then
|
||||
if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
|
||||
AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
|
||||
HAVE_LONG_DOUBLE=1
|
||||
else
|
||||
if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
|
||||
HAVE_LONG_DOUBLE=1
|
||||
AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(HAVE_LONG_DOUBLE)
|
||||
AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
|
||||
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
GCC_AS_CFI_PSEUDO_OP
|
||||
|
||||
if test x$TARGET = xSPARC; then
|
||||
AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
|
||||
libffi_cv_as_sparc_ua_pcrel, [
|
||||
save_CFLAGS="$CFLAGS"
|
||||
save_LDFLAGS="$LDFLAGS"
|
||||
CFLAGS="$CFLAGS -fpic"
|
||||
LDFLAGS="$LDFLAGS -shared"
|
||||
AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
|
||||
[libffi_cv_as_sparc_ua_pcrel=yes],
|
||||
[libffi_cv_as_sparc_ua_pcrel=no])
|
||||
CFLAGS="$save_CFLAGS"
|
||||
LDFLAGS="$save_LDFLAGS"])
|
||||
if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
|
||||
AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
|
||||
[Define if your assembler and linker support unaligned PC relative relocs.])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([assembler .register pseudo-op support],
|
||||
libffi_cv_as_register_pseudo_op, [
|
||||
libffi_cv_as_register_pseudo_op=unknown
|
||||
# Check if we have .register
|
||||
AC_TRY_COMPILE(,[asm (".register %g2, #scratch");],
|
||||
[libffi_cv_as_register_pseudo_op=yes],
|
||||
[libffi_cv_as_register_pseudo_op=no])
|
||||
])
|
||||
if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
|
||||
AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
|
||||
[Define if your assembler supports .register.])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
|
||||
AC_CACHE_CHECK([assembler supports pc related relocs],
|
||||
libffi_cv_as_x86_pcrel, [
|
||||
libffi_cv_as_x86_pcrel=no
|
||||
echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
|
||||
if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
|
||||
libffi_cv_as_x86_pcrel=yes
|
||||
fi
|
||||
])
|
||||
if test "x$libffi_cv_as_x86_pcrel" = xyes; then
|
||||
AC_DEFINE(HAVE_AS_X86_PCREL, 1,
|
||||
[Define if your assembler supports PC relative relocs.])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([assembler .ascii pseudo-op support],
|
||||
libffi_cv_as_ascii_pseudo_op, [
|
||||
libffi_cv_as_ascii_pseudo_op=unknown
|
||||
# Check if we have .ascii
|
||||
AC_TRY_COMPILE(,[asm (".ascii \\"string\\"");],
|
||||
[libffi_cv_as_ascii_pseudo_op=yes],
|
||||
[libffi_cv_as_ascii_pseudo_op=no])
|
||||
])
|
||||
if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then
|
||||
AC_DEFINE(HAVE_AS_ASCII_PSEUDO_OP, 1,
|
||||
[Define if your assembler supports .ascii.])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([assembler .string pseudo-op support],
|
||||
libffi_cv_as_string_pseudo_op, [
|
||||
libffi_cv_as_string_pseudo_op=unknown
|
||||
# Check if we have .string
|
||||
AC_TRY_COMPILE(,[asm (".string \\"string\\"");],
|
||||
[libffi_cv_as_string_pseudo_op=yes],
|
||||
[libffi_cv_as_string_pseudo_op=no])
|
||||
])
|
||||
if test "x$libffi_cv_as_string_pseudo_op" = xyes; then
|
||||
AC_DEFINE(HAVE_AS_STRING_PSEUDO_OP, 1,
|
||||
[Define if your assembler supports .string.])
|
||||
fi
|
||||
fi
|
||||
|
||||
# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
|
||||
AC_ARG_ENABLE(pax_emutramp,
|
||||
[ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC],
|
||||
if test "$enable_pax_emutramp" = "yes"; then
|
||||
AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
|
||||
[Define this if you want to enable pax emulated trampolines])
|
||||
fi)
|
||||
|
||||
LT_SYS_SYMBOL_USCORE
|
||||
if test "x$sys_symbol_underscore" = xyes; then
|
||||
AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.])
|
||||
fi
|
||||
|
||||
FFI_EXEC_TRAMPOLINE_TABLE=0
|
||||
case "$target" in
|
||||
*arm*-apple-darwin*)
|
||||
FFI_EXEC_TRAMPOLINE_TABLE=1
|
||||
AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1,
|
||||
[Cannot use PROT_EXEC on this target, so, we revert to
|
||||
alternative means])
|
||||
;;
|
||||
*-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
|
||||
AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
|
||||
[Cannot use malloc on this target, so, we revert to
|
||||
alternative means])
|
||||
;;
|
||||
esac
|
||||
AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1)
|
||||
AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE)
|
||||
|
||||
if test x$TARGET = xX86_64; then
|
||||
AC_CACHE_CHECK([toolchain supports unwind section type],
|
||||
libffi_cv_as_x86_64_unwind_section_type, [
|
||||
cat > conftest1.s << EOF
|
||||
.text
|
||||
.globl foo
|
||||
foo:
|
||||
jmp bar
|
||||
.section .eh_frame,"a",@unwind
|
||||
bar:
|
||||
EOF
|
||||
|
||||
cat > conftest2.c << EOF
|
||||
extern void foo();
|
||||
int main(){foo();}
|
||||
EOF
|
||||
|
||||
libffi_cv_as_x86_64_unwind_section_type=no
|
||||
# we ensure that we can compile _and_ link an assembly file containing an @unwind section
|
||||
# since the compiler can support it and not the linker (ie old binutils)
|
||||
if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
|
||||
$CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
|
||||
libffi_cv_as_x86_64_unwind_section_type=yes
|
||||
fi
|
||||
])
|
||||
if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
|
||||
AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
|
||||
[Define if your assembler supports unwind section type.])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$GCC" = "xyes"; then
|
||||
AC_CACHE_CHECK([whether .eh_frame section should be read-only],
|
||||
libffi_cv_ro_eh_frame, [
|
||||
libffi_cv_ro_eh_frame=no
|
||||
echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
|
||||
if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then
|
||||
objdump -h conftest.o > conftest.dump 2>&1
|
||||
libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1`
|
||||
libffi_test_line=`expr $libffi_eh_frame_line + 1`p
|
||||
sed -n $libffi_test_line conftest.dump > conftest.line
|
||||
if grep READONLY conftest.line > /dev/null; then
|
||||
libffi_cv_ro_eh_frame=yes
|
||||
fi
|
||||
fi
|
||||
rm -f conftest.*
|
||||
])
|
||||
if test "x$libffi_cv_ro_eh_frame" = xyes; then
|
||||
AC_DEFINE(HAVE_RO_EH_FRAME, 1,
|
||||
[Define if .eh_frame sections should be read-only.])
|
||||
AC_DEFINE(EH_FRAME_FLAGS, "a",
|
||||
[Define to the flags needed for the .section .eh_frame directive. ])
|
||||
else
|
||||
AC_DEFINE(EH_FRAME_FLAGS, "aw",
|
||||
[Define to the flags needed for the .section .eh_frame directive. ])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
|
||||
libffi_cv_hidden_visibility_attribute, [
|
||||
echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c
|
||||
libffi_cv_hidden_visibility_attribute=no
|
||||
if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
|
||||
if grep '\.hidden.*foo' conftest.s >/dev/null; then
|
||||
libffi_cv_hidden_visibility_attribute=yes
|
||||
fi
|
||||
fi
|
||||
rm -f conftest.*
|
||||
])
|
||||
if test $libffi_cv_hidden_visibility_attribute = yes; then
|
||||
AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
|
||||
[Define if __attribute__((visibility("hidden"))) is supported.])
|
||||
fi
|
||||
fi
|
||||
|
||||
AH_BOTTOM([
|
||||
#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
|
||||
#ifdef LIBFFI_ASM
|
||||
#define FFI_HIDDEN(name) .hidden name
|
||||
#else
|
||||
#define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
|
||||
#endif
|
||||
#else
|
||||
#ifdef LIBFFI_ASM
|
||||
#define FFI_HIDDEN(name)
|
||||
#else
|
||||
#define FFI_HIDDEN
|
||||
#endif
|
||||
#endif
|
||||
])
|
||||
|
||||
AC_SUBST(TARGET)
|
||||
AC_SUBST(TARGETDIR)
|
||||
|
||||
AC_SUBST(SHELL)
|
||||
|
||||
AC_ARG_ENABLE(debug,
|
||||
[ --enable-debug debugging mode],
|
||||
if test "$enable_debug" = "yes"; then
|
||||
AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
|
||||
fi)
|
||||
AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
|
||||
|
||||
AC_ARG_ENABLE(structs,
|
||||
[ --disable-structs omit code for struct support],
|
||||
if test "$enable_structs" = "no"; then
|
||||
AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.])
|
||||
fi)
|
||||
AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
|
||||
|
||||
AC_ARG_ENABLE(raw-api,
|
||||
[ --disable-raw-api make the raw api unavailable],
|
||||
if test "$enable_raw_api" = "no"; then
|
||||
AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.])
|
||||
fi)
|
||||
|
||||
AC_ARG_ENABLE(purify-safety,
|
||||
[ --enable-purify-safety purify-safe mode],
|
||||
if test "$enable_purify_safety" = "yes"; then
|
||||
AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
|
||||
fi)
|
||||
|
||||
# These variables are only ever used when we cross-build to X86_WIN32.
|
||||
# And we only support this with GCC, so...
|
||||
if test "x$GCC" = "xyes"; then
|
||||
if test -n "$with_cross_host" &&
|
||||
test x"$with_cross_host" != x"no"; then
|
||||
toolexecdir='$(exec_prefix)/$(target_alias)'
|
||||
toolexeclibdir='$(toolexecdir)/lib'
|
||||
else
|
||||
toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
|
||||
toolexeclibdir='$(libdir)'
|
||||
fi
|
||||
multi_os_directory=`$CC $CFLAGS -print-multi-os-directory`
|
||||
case $multi_os_directory in
|
||||
.) ;; # Avoid trailing /.
|
||||
../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
|
||||
esac
|
||||
AC_SUBST(toolexecdir)
|
||||
else
|
||||
toolexeclibdir='$(libdir)'
|
||||
fi
|
||||
AC_SUBST(toolexeclibdir)
|
||||
|
||||
AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
|
||||
AC_CONFIG_COMMANDS(src, [
|
||||
test -d src || mkdir src
|
||||
test -d src/$TARGETDIR || mkdir src/$TARGETDIR
|
||||
], [TARGETDIR="$TARGETDIR"])
|
||||
|
||||
AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
|
||||
|
||||
AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
|
||||
|
||||
AC_CONFIG_LINKS(include/ffi_common.h:include/ffi_common.h)
|
||||
|
||||
AC_CONFIG_FILES(fficonfig.py)
|
||||
|
||||
AC_OUTPUT
|
791
third_party/python/Modules/_ctypes/libffi/depcomp
vendored
Executable file
791
third_party/python/Modules/_ctypes/libffi/depcomp
vendored
Executable file
|
@ -0,0 +1,791 @@
|
|||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2013-05-30.07; # UTC
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by 'PROGRAMS ARGS'.
|
||||
object Object file output by 'PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputting dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get the directory component of the given path, and save it in the
|
||||
# global variables '$dir'. Note that this directory component will
|
||||
# be either empty or ending with a '/' character. This is deliberate.
|
||||
set_dir_from ()
|
||||
{
|
||||
case $1 in
|
||||
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
|
||||
*) dir=;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Get the suffix-stripped basename of the given path, and save it the
|
||||
# global variable '$base'.
|
||||
set_base_from ()
|
||||
{
|
||||
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
|
||||
}
|
||||
|
||||
# If no dependency file was actually created by the compiler invocation,
|
||||
# we still have to create a dummy depfile, to avoid errors with the
|
||||
# Makefile "include basename.Plo" scheme.
|
||||
make_dummy_depfile ()
|
||||
{
|
||||
echo "#dummy" > "$depfile"
|
||||
}
|
||||
|
||||
# Factor out some common post-processing of the generated depfile.
|
||||
# Requires the auxiliary global variable '$tmpdepfile' to be set.
|
||||
aix_post_process_depfile ()
|
||||
{
|
||||
# If the compiler actually managed to produce a dependency file,
|
||||
# post-process it.
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form 'foo.o: dependency.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# $object: dependency.h
|
||||
# and one to simply output
|
||||
# dependency.h:
|
||||
# which is needed to avoid the deleted-header problem.
|
||||
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
|
||||
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
|
||||
} > "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
}
|
||||
|
||||
# A tabulation character.
|
||||
tab=' '
|
||||
# A newline character.
|
||||
nl='
|
||||
'
|
||||
# Character ranges might be problematic outside the C locale.
|
||||
# These definitions help.
|
||||
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
lower=abcdefghijklmnopqrstuvwxyz
|
||||
digits=0123456789
|
||||
alpha=${upper}${lower}
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Avoid interferences from the environment.
|
||||
gccflag= dashmflag=
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
if test "$depmode" = msvc7msys; then
|
||||
# This is just like msvc7 but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvc7
|
||||
fi
|
||||
|
||||
if test "$depmode" = xlc; then
|
||||
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
|
||||
gccflag=-qmakedep=gcc,-MF
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
|
||||
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
|
||||
## (see the conditional assignment to $gccflag above).
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say). Also, it might not be
|
||||
## supported by the other compilers which use the 'gcc' depmode.
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The second -e expression handles DOS-style file names with drive
|
||||
# letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the "deleted header file" problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
## Some versions of gcc put a space before the ':'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well. hp depmode also adds that space, but also prefixes the VPATH
|
||||
## to the object. Take care to not repeat it in the output.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like '#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
|
||||
| tr "$nl" ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
xlc)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts '$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
tcc)
|
||||
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
|
||||
# FIXME: That version still under development at the moment of writing.
|
||||
# Make that this statement remains true also for stable, released
|
||||
# versions.
|
||||
# It will wrap lines (doesn't matter whether long or short) with a
|
||||
# trailing '\', as in:
|
||||
#
|
||||
# foo.o : \
|
||||
# foo.c \
|
||||
# foo.h \
|
||||
#
|
||||
# It will put a trailing '\' even on the last line, and will use leading
|
||||
# spaces rather than leading tabs (at least since its commit 0394caf7
|
||||
# "Emit spaces for -MD").
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
|
||||
# We have to change lines of the first kind to '$object: \'.
|
||||
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
|
||||
# And for each line of the second kind, we have to emit a 'dep.h:'
|
||||
# dummy dependency, to avoid the deleted-header problem.
|
||||
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
## The order of this option in the case statement is important, since the
|
||||
## shell code in configure will try each of these formats in the order
|
||||
## listed in this file. A plain '-MD' option would be understood by many
|
||||
## compilers, so we must ensure this comes after the gcc and icc options.
|
||||
pgcc)
|
||||
# Portland's C compiler understands '-MD'.
|
||||
# Will always output deps to 'file.d' where file is the root name of the
|
||||
# source file under compilation, even if file resides in a subdirectory.
|
||||
# The object file name does not affect the name of the '.d' file.
|
||||
# pgcc 10.2 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using '\' :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
set_dir_from "$object"
|
||||
# Use the source, not the object, to determine the base name, since
|
||||
# that's sadly what pgcc will do too.
|
||||
set_base_from "$source"
|
||||
tmpdepfile=$base.d
|
||||
|
||||
# For projects that build the same source file twice into different object
|
||||
# files, the pgcc approach of using the *source* file root name can cause
|
||||
# problems in parallel builds. Use a locking strategy to avoid stomping on
|
||||
# the same $tmpdepfile.
|
||||
lockdir=$base.d-lock
|
||||
trap "
|
||||
echo '$0: caught signal, cleaning up...' >&2
|
||||
rmdir '$lockdir'
|
||||
exit 1
|
||||
" 1 2 13 15
|
||||
numtries=100
|
||||
i=$numtries
|
||||
while test $i -gt 0; do
|
||||
# mkdir is a portable test-and-set.
|
||||
if mkdir "$lockdir" 2>/dev/null; then
|
||||
# This process acquired the lock.
|
||||
"$@" -MD
|
||||
stat=$?
|
||||
# Release the lock.
|
||||
rmdir "$lockdir"
|
||||
break
|
||||
else
|
||||
# If the lock is being held by a different process, wait
|
||||
# until the winning process is done or we timeout.
|
||||
while test -d "$lockdir" && test $i -gt 0; do
|
||||
sleep 1
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
fi
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
trap - 1 2 13 15
|
||||
if test $i -le 0; then
|
||||
echo "$0: failed to acquire lock after $numtries attempts" >&2
|
||||
echo "$0: check lockdir '$lockdir'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add 'dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in 'foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# Libtool generates 2 separate objects for the 2 libraries. These
|
||||
# two compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
|
||||
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
# Same post-processing that is required for AIX mode.
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
msvc7)
|
||||
if test "$libtool" = yes; then
|
||||
showIncludes=-Wc,-showIncludes
|
||||
else
|
||||
showIncludes=-showIncludes
|
||||
fi
|
||||
"$@" $showIncludes > "$tmpdepfile"
|
||||
stat=$?
|
||||
grep -v '^Note: including file: ' "$tmpdepfile"
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The first sed program below extracts the file names and escapes
|
||||
# backslashes for cygpath. The second sed program outputs the file
|
||||
# name when reading, but also accumulates all include files in the
|
||||
# hold buffer in order to output them again at the end. This only
|
||||
# works with sed implementations that can handle large buffers.
|
||||
sed < "$tmpdepfile" -n '
|
||||
/^Note: including file: *\(.*\)/ {
|
||||
s//\1/
|
||||
s/\\/\\\\/g
|
||||
p
|
||||
}' | $cygpath_u | sort -u | sed -n '
|
||||
s/ /\\ /g
|
||||
s/\(.*\)/'"$tab"'\1 \\/p
|
||||
s/.\(.*\) \\/\1:/
|
||||
H
|
||||
$ {
|
||||
s/.*/'"$tab"'/
|
||||
G
|
||||
p
|
||||
}' >> "$depfile"
|
||||
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvc7msys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for ':'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this sed invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
# makedepend may prepend the VPATH from the source file name to the object.
|
||||
# No need to regex-escape $object, excess matching of '.' is harmless.
|
||||
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process the last invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed '1,2d' "$tmpdepfile" \
|
||||
| tr ' ' "$nl" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E \
|
||||
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
| sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
|
||||
echo "$tab" >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
618
third_party/python/Modules/_ctypes/libffi/doc/libffi.info
vendored
Normal file
618
third_party/python/Modules/_ctypes/libffi/doc/libffi.info
vendored
Normal file
|
@ -0,0 +1,618 @@
|
|||
This is libffi.info, produced by makeinfo version 5.1 from libffi.texi.
|
||||
|
||||
This manual is for Libffi, a portable foreign-function interface
|
||||
library.
|
||||
|
||||
Copyright (C) 2008, 2010, 2011 Red Hat, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2, or (at
|
||||
your option) any later version. A copy of the license is included
|
||||
in the section entitled "GNU General Public License".
|
||||
|
||||
INFO-DIR-SECTION Development
|
||||
START-INFO-DIR-ENTRY
|
||||
* libffi: (libffi). Portable foreign-function interface library.
|
||||
END-INFO-DIR-ENTRY
|
||||
|
||||
|
||||
File: libffi.info, Node: Top, Next: Introduction, Up: (dir)
|
||||
|
||||
libffi
|
||||
******
|
||||
|
||||
This manual is for Libffi, a portable foreign-function interface
|
||||
library.
|
||||
|
||||
Copyright (C) 2008, 2010, 2011 Red Hat, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2, or (at
|
||||
your option) any later version. A copy of the license is included
|
||||
in the section entitled "GNU General Public License".
|
||||
|
||||
* Menu:
|
||||
|
||||
* Introduction:: What is libffi?
|
||||
* Using libffi:: How to use libffi.
|
||||
* Missing Features:: Things libffi can't do.
|
||||
* Index:: Index.
|
||||
|
||||
|
||||
File: libffi.info, Node: Introduction, Next: Using libffi, Prev: Top, Up: Top
|
||||
|
||||
1 What is libffi?
|
||||
*****************
|
||||
|
||||
Compilers for high level languages generate code that follow certain
|
||||
conventions. These conventions are necessary, in part, for separate
|
||||
compilation to work. One such convention is the "calling convention".
|
||||
The calling convention is a set of assumptions made by the compiler
|
||||
about where function arguments will be found on entry to a function. A
|
||||
calling convention also specifies where the return value for a function
|
||||
is found. The calling convention is also sometimes called the "ABI" or
|
||||
"Application Binary Interface".
|
||||
|
||||
Some programs may not know at the time of compilation what arguments
|
||||
are to be passed to a function. For instance, an interpreter may be
|
||||
told at run-time about the number and types of arguments used to call a
|
||||
given function. 'Libffi' can be used in such programs to provide a
|
||||
bridge from the interpreter program to compiled code.
|
||||
|
||||
The 'libffi' library provides a portable, high level programming
|
||||
interface to various calling conventions. This allows a programmer to
|
||||
call any function specified by a call interface description at run time.
|
||||
|
||||
FFI stands for Foreign Function Interface. A foreign function
|
||||
interface is the popular name for the interface that allows code written
|
||||
in one language to call code written in another language. The 'libffi'
|
||||
library really only provides the lowest, machine dependent layer of a
|
||||
fully featured foreign function interface. A layer must exist above
|
||||
'libffi' that handles type conversions for values passed between the two
|
||||
languages.
|
||||
|
||||
|
||||
File: libffi.info, Node: Using libffi, Next: Missing Features, Prev: Introduction, Up: Top
|
||||
|
||||
2 Using libffi
|
||||
**************
|
||||
|
||||
* Menu:
|
||||
|
||||
* The Basics:: The basic libffi API.
|
||||
* Simple Example:: A simple example.
|
||||
* Types:: libffi type descriptions.
|
||||
* Multiple ABIs:: Different passing styles on one platform.
|
||||
* The Closure API:: Writing a generic function.
|
||||
* Closure Example:: A closure example.
|
||||
|
||||
|
||||
File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
|
||||
|
||||
2.1 The Basics
|
||||
==============
|
||||
|
||||
'Libffi' assumes that you have a pointer to the function you wish to
|
||||
call and that you know the number and types of arguments to pass it, as
|
||||
well as the return type of the function.
|
||||
|
||||
The first thing you must do is create an 'ffi_cif' object that
|
||||
matches the signature of the function you wish to call. This is a
|
||||
separate step because it is common to make multiple calls using a single
|
||||
'ffi_cif'. The "cif" in 'ffi_cif' stands for Call InterFace. To
|
||||
prepare a call interface object, use the function 'ffi_prep_cif'.
|
||||
|
||||
-- Function: ffi_status ffi_prep_cif (ffi_cif *CIF, ffi_abi ABI,
|
||||
unsigned int NARGS, ffi_type *RTYPE, ffi_type **ARGTYPES)
|
||||
This initializes CIF according to the given parameters.
|
||||
|
||||
ABI is the ABI to use; normally 'FFI_DEFAULT_ABI' is what you want.
|
||||
*note Multiple ABIs:: for more information.
|
||||
|
||||
NARGS is the number of arguments that this function accepts.
|
||||
|
||||
RTYPE is a pointer to an 'ffi_type' structure that describes the
|
||||
return type of the function. *Note Types::.
|
||||
|
||||
ARGTYPES is a vector of 'ffi_type' pointers. ARGTYPES must have
|
||||
NARGS elements. If NARGS is 0, this argument is ignored.
|
||||
|
||||
'ffi_prep_cif' returns a 'libffi' status code, of type
|
||||
'ffi_status'. This will be either 'FFI_OK' if everything worked
|
||||
properly; 'FFI_BAD_TYPEDEF' if one of the 'ffi_type' objects is
|
||||
incorrect; or 'FFI_BAD_ABI' if the ABI parameter is invalid.
|
||||
|
||||
If the function being called is variadic (varargs) then
|
||||
'ffi_prep_cif_var' must be used instead of 'ffi_prep_cif'.
|
||||
|
||||
-- Function: ffi_status ffi_prep_cif_var (ffi_cif *CIF, ffi_abi varabi,
|
||||
unsigned int NFIXEDARGS, unsigned int varntotalargs, ffi_type
|
||||
*RTYPE, ffi_type **ARGTYPES)
|
||||
This initializes CIF according to the given parameters for a call
|
||||
to a variadic function. In general it's operation is the same as
|
||||
for 'ffi_prep_cif' except that:
|
||||
|
||||
NFIXEDARGS is the number of fixed arguments, prior to any variadic
|
||||
arguments. It must be greater than zero.
|
||||
|
||||
NTOTALARGS the total number of arguments, including variadic and
|
||||
fixed arguments.
|
||||
|
||||
Note that, different cif's must be prepped for calls to the same
|
||||
function when different numbers of arguments are passed.
|
||||
|
||||
Also note that a call to 'ffi_prep_cif_var' with
|
||||
NFIXEDARGS=NOTOTALARGS is NOT equivalent to a call to
|
||||
'ffi_prep_cif'.
|
||||
|
||||
To call a function using an initialized 'ffi_cif', use the 'ffi_call'
|
||||
function:
|
||||
|
||||
-- Function: void ffi_call (ffi_cif *CIF, void *FN, void *RVALUE, void
|
||||
**AVALUES)
|
||||
This calls the function FN according to the description given in
|
||||
CIF. CIF must have already been prepared using 'ffi_prep_cif'.
|
||||
|
||||
RVALUE is a pointer to a chunk of memory that will hold the result
|
||||
of the function call. This must be large enough to hold the
|
||||
result, no smaller than the system register size (generally 32 or
|
||||
64 bits), and must be suitably aligned; it is the caller's
|
||||
responsibility to ensure this. If CIF declares that the function
|
||||
returns 'void' (using 'ffi_type_void'), then RVALUE is ignored.
|
||||
|
||||
AVALUES is a vector of 'void *' pointers that point to the memory
|
||||
locations holding the argument values for a call. If CIF declares
|
||||
that the function has no arguments (i.e., NARGS was 0), then
|
||||
AVALUES is ignored. Note that argument values may be modified by
|
||||
the callee (for instance, structs passed by value); the burden of
|
||||
copying pass-by-value arguments is placed on the caller.
|
||||
|
||||
|
||||
File: libffi.info, Node: Simple Example, Next: Types, Prev: The Basics, Up: Using libffi
|
||||
|
||||
2.2 Simple Example
|
||||
==================
|
||||
|
||||
Here is a trivial example that calls 'puts' a few times.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ffi.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
ffi_cif cif;
|
||||
ffi_type *args[1];
|
||||
void *values[1];
|
||||
char *s;
|
||||
ffi_arg rc;
|
||||
|
||||
/* Initialize the argument info vectors */
|
||||
args[0] = &ffi_type_pointer;
|
||||
values[0] = &s;
|
||||
|
||||
/* Initialize the cif */
|
||||
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
|
||||
&ffi_type_sint, args) == FFI_OK)
|
||||
{
|
||||
s = "Hello World!";
|
||||
ffi_call(&cif, puts, &rc, values);
|
||||
/* rc now holds the result of the call to puts */
|
||||
|
||||
/* values holds a pointer to the function's arg, so to
|
||||
call puts() again all we need to do is change the
|
||||
value of s */
|
||||
s = "This is cool!";
|
||||
ffi_call(&cif, puts, &rc, values);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
File: libffi.info, Node: Types, Next: Multiple ABIs, Prev: Simple Example, Up: Using libffi
|
||||
|
||||
2.3 Types
|
||||
=========
|
||||
|
||||
* Menu:
|
||||
|
||||
* Primitive Types:: Built-in types.
|
||||
* Structures:: Structure types.
|
||||
* Type Example:: Structure type example.
|
||||
|
||||
|
||||
File: libffi.info, Node: Primitive Types, Next: Structures, Up: Types
|
||||
|
||||
2.3.1 Primitive Types
|
||||
---------------------
|
||||
|
||||
'Libffi' provides a number of built-in type descriptors that can be used
|
||||
to describe argument and return types:
|
||||
|
||||
'ffi_type_void'
|
||||
The type 'void'. This cannot be used for argument types, only for
|
||||
return values.
|
||||
|
||||
'ffi_type_uint8'
|
||||
An unsigned, 8-bit integer type.
|
||||
|
||||
'ffi_type_sint8'
|
||||
A signed, 8-bit integer type.
|
||||
|
||||
'ffi_type_uint16'
|
||||
An unsigned, 16-bit integer type.
|
||||
|
||||
'ffi_type_sint16'
|
||||
A signed, 16-bit integer type.
|
||||
|
||||
'ffi_type_uint32'
|
||||
An unsigned, 32-bit integer type.
|
||||
|
||||
'ffi_type_sint32'
|
||||
A signed, 32-bit integer type.
|
||||
|
||||
'ffi_type_uint64'
|
||||
An unsigned, 64-bit integer type.
|
||||
|
||||
'ffi_type_sint64'
|
||||
A signed, 64-bit integer type.
|
||||
|
||||
'ffi_type_float'
|
||||
The C 'float' type.
|
||||
|
||||
'ffi_type_double'
|
||||
The C 'double' type.
|
||||
|
||||
'ffi_type_uchar'
|
||||
The C 'unsigned char' type.
|
||||
|
||||
'ffi_type_schar'
|
||||
The C 'signed char' type. (Note that there is not an exact
|
||||
equivalent to the C 'char' type in 'libffi'; ordinarily you should
|
||||
either use 'ffi_type_schar' or 'ffi_type_uchar' depending on
|
||||
whether 'char' is signed.)
|
||||
|
||||
'ffi_type_ushort'
|
||||
The C 'unsigned short' type.
|
||||
|
||||
'ffi_type_sshort'
|
||||
The C 'short' type.
|
||||
|
||||
'ffi_type_uint'
|
||||
The C 'unsigned int' type.
|
||||
|
||||
'ffi_type_sint'
|
||||
The C 'int' type.
|
||||
|
||||
'ffi_type_ulong'
|
||||
The C 'unsigned long' type.
|
||||
|
||||
'ffi_type_slong'
|
||||
The C 'long' type.
|
||||
|
||||
'ffi_type_longdouble'
|
||||
On platforms that have a C 'long double' type, this is defined. On
|
||||
other platforms, it is not.
|
||||
|
||||
'ffi_type_pointer'
|
||||
A generic 'void *' pointer. You should use this for all pointers,
|
||||
regardless of their real type.
|
||||
|
||||
Each of these is of type 'ffi_type', so you must take the address
|
||||
when passing to 'ffi_prep_cif'.
|
||||
|
||||
|
||||
File: libffi.info, Node: Structures, Next: Type Example, Prev: Primitive Types, Up: Types
|
||||
|
||||
2.3.2 Structures
|
||||
----------------
|
||||
|
||||
Although 'libffi' has no special support for unions or bit-fields, it is
|
||||
perfectly happy passing structures back and forth. You must first
|
||||
describe the structure to 'libffi' by creating a new 'ffi_type' object
|
||||
for it.
|
||||
|
||||
-- Data type: ffi_type
|
||||
The 'ffi_type' has the following members:
|
||||
'size_t size'
|
||||
This is set by 'libffi'; you should initialize it to zero.
|
||||
|
||||
'unsigned short alignment'
|
||||
This is set by 'libffi'; you should initialize it to zero.
|
||||
|
||||
'unsigned short type'
|
||||
For a structure, this should be set to 'FFI_TYPE_STRUCT'.
|
||||
|
||||
'ffi_type **elements'
|
||||
This is a 'NULL'-terminated array of pointers to 'ffi_type'
|
||||
objects. There is one element per field of the struct.
|
||||
|
||||
|
||||
File: libffi.info, Node: Type Example, Prev: Structures, Up: Types
|
||||
|
||||
2.3.3 Type Example
|
||||
------------------
|
||||
|
||||
The following example initializes a 'ffi_type' object representing the
|
||||
'tm' struct from Linux's 'time.h'.
|
||||
|
||||
Here is how the struct is defined:
|
||||
|
||||
struct tm {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
/* Those are for future use. */
|
||||
long int __tm_gmtoff__;
|
||||
__const char *__tm_zone__;
|
||||
};
|
||||
|
||||
Here is the corresponding code to describe this struct to 'libffi':
|
||||
|
||||
{
|
||||
ffi_type tm_type;
|
||||
ffi_type *tm_type_elements[12];
|
||||
int i;
|
||||
|
||||
tm_type.size = tm_type.alignment = 0;
|
||||
tm_type.type = FFI_TYPE_STRUCT;
|
||||
tm_type.elements = &tm_type_elements;
|
||||
|
||||
for (i = 0; i < 9; i++)
|
||||
tm_type_elements[i] = &ffi_type_sint;
|
||||
|
||||
tm_type_elements[9] = &ffi_type_slong;
|
||||
tm_type_elements[10] = &ffi_type_pointer;
|
||||
tm_type_elements[11] = NULL;
|
||||
|
||||
/* tm_type can now be used to represent tm argument types and
|
||||
return types for ffi_prep_cif() */
|
||||
}
|
||||
|
||||
|
||||
File: libffi.info, Node: Multiple ABIs, Next: The Closure API, Prev: Types, Up: Using libffi
|
||||
|
||||
2.4 Multiple ABIs
|
||||
=================
|
||||
|
||||
A given platform may provide multiple different ABIs at once. For
|
||||
instance, the x86 platform has both 'stdcall' and 'fastcall' functions.
|
||||
|
||||
'libffi' provides some support for this. However, this is
|
||||
necessarily platform-specific.
|
||||
|
||||
|
||||
File: libffi.info, Node: The Closure API, Next: Closure Example, Prev: Multiple ABIs, Up: Using libffi
|
||||
|
||||
2.5 The Closure API
|
||||
===================
|
||||
|
||||
'libffi' also provides a way to write a generic function - a function
|
||||
that can accept and decode any combination of arguments. This can be
|
||||
useful when writing an interpreter, or to provide wrappers for arbitrary
|
||||
functions.
|
||||
|
||||
This facility is called the "closure API". Closures are not supported
|
||||
on all platforms; you can check the 'FFI_CLOSURES' define to determine
|
||||
whether they are supported on the current platform.
|
||||
|
||||
Because closures work by assembling a tiny function at runtime, they
|
||||
require special allocation on platforms that have a non-executable heap.
|
||||
Memory management for closures is handled by a pair of functions:
|
||||
|
||||
-- Function: void *ffi_closure_alloc (size_t SIZE, void **CODE)
|
||||
Allocate a chunk of memory holding SIZE bytes. This returns a
|
||||
pointer to the writable address, and sets *CODE to the
|
||||
corresponding executable address.
|
||||
|
||||
SIZE should be sufficient to hold a 'ffi_closure' object.
|
||||
|
||||
-- Function: void ffi_closure_free (void *WRITABLE)
|
||||
Free memory allocated using 'ffi_closure_alloc'. The argument is
|
||||
the writable address that was returned.
|
||||
|
||||
Once you have allocated the memory for a closure, you must construct
|
||||
a 'ffi_cif' describing the function call. Finally you can prepare the
|
||||
closure function:
|
||||
|
||||
-- Function: ffi_status ffi_prep_closure_loc (ffi_closure *CLOSURE,
|
||||
ffi_cif *CIF, void (*FUN) (ffi_cif *CIF, void *RET, void
|
||||
**ARGS, void *USER_DATA), void *USER_DATA, void *CODELOC)
|
||||
Prepare a closure function.
|
||||
|
||||
CLOSURE is the address of a 'ffi_closure' object; this is the
|
||||
writable address returned by 'ffi_closure_alloc'.
|
||||
|
||||
CIF is the 'ffi_cif' describing the function parameters.
|
||||
|
||||
USER_DATA is an arbitrary datum that is passed, uninterpreted, to
|
||||
your closure function.
|
||||
|
||||
CODELOC is the executable address returned by 'ffi_closure_alloc'.
|
||||
|
||||
FUN is the function which will be called when the closure is
|
||||
invoked. It is called with the arguments:
|
||||
CIF
|
||||
The 'ffi_cif' passed to 'ffi_prep_closure_loc'.
|
||||
|
||||
RET
|
||||
A pointer to the memory used for the function's return value.
|
||||
FUN must fill this, unless the function is declared as
|
||||
returning 'void'.
|
||||
|
||||
ARGS
|
||||
A vector of pointers to memory holding the arguments to the
|
||||
function.
|
||||
|
||||
USER_DATA
|
||||
The same USER_DATA that was passed to 'ffi_prep_closure_loc'.
|
||||
|
||||
'ffi_prep_closure_loc' will return 'FFI_OK' if everything went ok,
|
||||
and something else on error.
|
||||
|
||||
After calling 'ffi_prep_closure_loc', you can cast CODELOC to the
|
||||
appropriate pointer-to-function type.
|
||||
|
||||
You may see old code referring to 'ffi_prep_closure'. This function
|
||||
is deprecated, as it cannot handle the need for separate writable and
|
||||
executable addresses.
|
||||
|
||||
|
||||
File: libffi.info, Node: Closure Example, Prev: The Closure API, Up: Using libffi
|
||||
|
||||
2.6 Closure Example
|
||||
===================
|
||||
|
||||
A trivial example that creates a new 'puts' by binding 'fputs' with
|
||||
'stdout'.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ffi.h>
|
||||
|
||||
/* Acts like puts with the file given at time of enclosure. */
|
||||
void puts_binding(ffi_cif *cif, void *ret, void* args[],
|
||||
void *stream)
|
||||
{
|
||||
*(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream);
|
||||
}
|
||||
|
||||
typedef int (*puts_t)(char *);
|
||||
|
||||
int main()
|
||||
{
|
||||
ffi_cif cif;
|
||||
ffi_type *args[1];
|
||||
ffi_closure *closure;
|
||||
|
||||
void *bound_puts;
|
||||
int rc;
|
||||
|
||||
/* Allocate closure and bound_puts */
|
||||
closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
|
||||
|
||||
if (closure)
|
||||
{
|
||||
/* Initialize the argument info vectors */
|
||||
args[0] = &ffi_type_pointer;
|
||||
|
||||
/* Initialize the cif */
|
||||
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
|
||||
&ffi_type_sint, args) == FFI_OK)
|
||||
{
|
||||
/* Initialize the closure, setting stream to stdout */
|
||||
if (ffi_prep_closure_loc(closure, &cif, puts_binding,
|
||||
stdout, bound_puts) == FFI_OK)
|
||||
{
|
||||
rc = ((puts_t)bound_puts)("Hello World!");
|
||||
/* rc now holds the result of the call to fputs */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Deallocate both closure, and bound_puts */
|
||||
ffi_closure_free(closure);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi, Up: Top
|
||||
|
||||
3 Missing Features
|
||||
******************
|
||||
|
||||
'libffi' is missing a few features. We welcome patches to add support
|
||||
for these.
|
||||
|
||||
* Variadic closures.
|
||||
|
||||
* There is no support for bit fields in structures.
|
||||
|
||||
* The closure API is
|
||||
|
||||
* The "raw" API is undocumented.
|
||||
|
||||
Note that variadic support is very new and tested on a relatively
|
||||
small number of platforms.
|
||||
|
||||
|
||||
File: libffi.info, Node: Index, Prev: Missing Features, Up: Top
|
||||
|
||||
Index
|
||||
*****
|
||||
|
||||
|