AppPkg/.../Python-2.7.10: AppPkg.dsc, pyconfig.h, PyMod-2.7.10

Apply UEFI-specific changes to files to make them equivalent to the Python 2.7.2 versions.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Daryl McDaniel <edk2-lists@mc2research.org>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>

---
 AppPkg/AppPkg.dsc                                  |   5 +-
 .../Python/Python-2.7.10/Ia32/pyconfig.h           |  93 ++++++++----
 .../Python-2.7.10/PyMod-2.7.10/Lib/ntpath.py       |  30 +++-
 .../Python/Python-2.7.10/PyMod-2.7.10/Lib/os.py    |  35 ++++-
 .../Python/Python-2.7.10/PyMod-2.7.10/Lib/pydoc.py |  17 +++
 .../Python/Python-2.7.10/PyMod-2.7.10/Lib/site.py  | 165 ++++++---------------
 .../Python-2.7.10/PyMod-2.7.10/Modules/_sre.c      | 150 ++++++++++---------
 .../Python-2.7.10/PyMod-2.7.10/Modules/addrinfo.h  | 101 +++++++------
 .../PyMod-2.7.10/Modules/errnomodule.c             |  57 ++++++-
 .../PyMod-2.7.10/Modules/expat/expat_external.h    |   4 +-
 .../Python-2.7.10/PyMod-2.7.10/Modules/getpath.c   | 143 +++++-------------
 .../Python-2.7.10/PyMod-2.7.10/Modules/main.c      |  61 ++++----
 .../PyMod-2.7.10/Modules/selectmodule.c            |  43 ++++--
 .../PyMod-2.7.10/Modules/zlib/gzguts.h             |  10 +-
 .../PyMod-2.7.10/Modules/zlib/zutil.h              |  11 +-
 .../PyMod-2.7.10/Objects/longobject.c              |  14 +-
 .../PyMod-2.7.10/Objects/stringlib/localeutil.h    |  17 ++-
 .../PyMod-2.7.10/Python/getcopyright.c             |  24 ++-
 .../Python-2.7.10/PyMod-2.7.10/Python/marshal.c    |  21 ++-
 .../Python-2.7.10/PyMod-2.7.10/Python/random.c     |  32 +++-
 .../Python/Python-2.7.10/X64/pyconfig.h            |  63 ++++++--
 21 files changed, 640 insertions(+), 456 deletions(-)


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19462 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Daryl McDaniel
2015-12-23 00:15:45 +00:00
committed by darylm503
parent 5285ac3eba
commit d11973f1ca
21 changed files with 634 additions and 450 deletions

View File

@@ -2,6 +2,16 @@
* Secret Labs' Regular Expression Engine
*
* regular expression matching engine
Copyright (c) 2015, Daryl McDaniel. All rights reserved.<BR>
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
* partial history:
* 1999-10-24 fl created (based on existing template matcher code)
@@ -34,6 +44,10 @@
* other compatibility work.
*/
/* Get rid of these macros to prevent collisions between EFI and Python in this file. */
#undef RETURN_ERROR
#undef RETURN_SUCCESS
#ifndef SRE_RECURSIVE
static char copyright[] =
@@ -84,7 +98,7 @@ static char copyright[] =
/* -------------------------------------------------------------------- */
#if defined(_MSC_VER)
#pragma optimize("agtw", on) /* doesn't seem to make much difference... */
#pragma optimize("gt", on) /* doesn't seem to make much difference... */
#pragma warning(disable: 4710) /* who cares if functions are not inlined ;-) */
/* fastest possible local call under MSVC */
#define LOCAL(type) static __inline type __fastcall
@@ -2147,8 +2161,8 @@ pattern_findall(PatternObject* self, PyObject* args, PyObject* kw)
#endif
}
if (PyErr_Occurred())
goto error;
if (PyErr_Occurred())
goto error;
if (status <= 0) {
if (status == 0)
@@ -2284,8 +2298,8 @@ pattern_split(PatternObject* self, PyObject* args, PyObject* kw)
#endif
}
if (PyErr_Occurred())
goto error;
if (PyErr_Occurred())
goto error;
if (status <= 0) {
if (status == 0)
@@ -2381,10 +2395,10 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string,
b = bint;
if (ptr) {
if (b == 1) {
literal = sre_literal_template((unsigned char *)ptr, n);
literal = sre_literal_template((unsigned char *)ptr, n);
} else {
#if defined(HAVE_UNICODE)
literal = sre_uliteral_template((Py_UNICODE *)ptr, n);
literal = sre_uliteral_template((Py_UNICODE *)ptr, n);
#endif
}
} else {
@@ -2436,8 +2450,8 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string,
#endif
}
if (PyErr_Occurred())
goto error;
if (PyErr_Occurred())
goto error;
if (status <= 0) {
if (status == 0)
@@ -2655,20 +2669,20 @@ PyDoc_STRVAR(pattern_doc, "Compiled regular expression objects");
static PyMethodDef pattern_methods[] = {
{"match", (PyCFunction) pattern_match, METH_VARARGS|METH_KEYWORDS,
pattern_match_doc},
pattern_match_doc},
{"search", (PyCFunction) pattern_search, METH_VARARGS|METH_KEYWORDS,
pattern_search_doc},
pattern_search_doc},
{"sub", (PyCFunction) pattern_sub, METH_VARARGS|METH_KEYWORDS,
pattern_sub_doc},
pattern_sub_doc},
{"subn", (PyCFunction) pattern_subn, METH_VARARGS|METH_KEYWORDS,
pattern_subn_doc},
pattern_subn_doc},
{"split", (PyCFunction) pattern_split, METH_VARARGS|METH_KEYWORDS,
pattern_split_doc},
pattern_split_doc},
{"findall", (PyCFunction) pattern_findall, METH_VARARGS|METH_KEYWORDS,
pattern_findall_doc},
pattern_findall_doc},
#if PY_VERSION_HEX >= 0x02020000
{"finditer", (PyCFunction) pattern_finditer, METH_VARARGS,
pattern_finditer_doc},
pattern_finditer_doc},
#endif
{"scanner", (PyCFunction) pattern_scanner, METH_VARARGS},
{"__copy__", (PyCFunction) pattern_copy, METH_NOARGS},
@@ -2692,28 +2706,28 @@ statichere PyTypeObject Pattern_Type = {
(destructor)pattern_dealloc, /*tp_dealloc*/
0, /* tp_print */
0, /* tp_getattrn */
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 */
pattern_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
offsetof(PatternObject, weakreflist), /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
pattern_methods, /* tp_methods */
pattern_members, /* tp_members */
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 */
pattern_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
offsetof(PatternObject, weakreflist), /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
pattern_methods, /* tp_methods */
pattern_members, /* tp_members */
};
static int _validate(PatternObject *self); /* Forward */
@@ -3756,9 +3770,9 @@ static PyTypeObject Match_Type = {
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
match_methods, /* tp_methods */
match_members, /* tp_members */
match_getset, /* tp_getset */
match_methods, /* tp_methods */
match_members, /* tp_members */
match_getset, /* tp_getset */
};
static PyObject*
@@ -3909,7 +3923,7 @@ static PyMethodDef scanner_methods[] = {
#define SCAN_OFF(x) offsetof(ScannerObject, x)
static PyMemberDef scanner_members[] = {
{"pattern", T_OBJECT, SCAN_OFF(pattern), READONLY},
{"pattern", T_OBJECT, SCAN_OFF(pattern), READONLY},
{NULL} /* Sentinel */
};
@@ -3918,31 +3932,31 @@ statichere PyTypeObject Scanner_Type = {
0, "_" SRE_MODULE ".SRE_Scanner",
sizeof(ScannerObject), 0,
(destructor)scanner_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 */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
scanner_methods, /* tp_methods */
scanner_members, /* tp_members */
0, /* tp_getset */
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 */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
scanner_methods, /* tp_methods */
scanner_members, /* tp_members */
0, /* tp_getset */
};
static PyObject*
@@ -4000,7 +4014,7 @@ PyMODINIT_FUNC init_sre(void)
m = Py_InitModule("_" SRE_MODULE, _functions);
if (m == NULL)
return;
return;
d = PyModule_GetDict(m);
x = PyInt_FromLong(SRE_MAGIC);

View File

@@ -1,4 +1,13 @@
/*
/** @file
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
* All rights reserved.
*
@@ -25,7 +34,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
**/
#ifndef HAVE_GETADDRINFO
@@ -123,49 +132,51 @@
#endif /* !HAVE_GETNAMEINFO */
#ifndef HAVE_ADDRINFO
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
size_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for hostname */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};
#endif /* !HAVE_ADDRINFO */
#ifndef _SYS_SOCKET_H_
#ifndef HAVE_ADDRINFO
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
size_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for hostname */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};
#endif /* !HAVE_ADDRINFO */
#ifndef HAVE_SOCKADDR_STORAGE
/*
* RFC 2553: protocol-independent placeholder for socket addresses
*/
#define _SS_MAXSIZE 128
#ifdef HAVE_LONG_LONG
#define _SS_ALIGNSIZE (sizeof(PY_LONG_LONG))
#else
#define _SS_ALIGNSIZE (sizeof(double))
#endif /* HAVE_LONG_LONG */
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) * 2)
#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \
_SS_PAD1SIZE - _SS_ALIGNSIZE)
#ifndef HAVE_SOCKADDR_STORAGE
/*
* RFC 2553: protocol-independent placeholder for socket addresses
*/
#define _SS_MAXSIZE 128
#ifdef HAVE_LONG_LONG
#define _SS_ALIGNSIZE (sizeof(PY_LONG_LONG))
#else
#define _SS_ALIGNSIZE (sizeof(double))
#endif /* HAVE_LONG_LONG */
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) * 2)
#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \
_SS_PAD1SIZE - _SS_ALIGNSIZE)
struct sockaddr_storage {
#ifdef HAVE_SOCKADDR_SA_LEN
unsigned char ss_len; /* address length */
unsigned char ss_family; /* address family */
#else
unsigned short ss_family; /* address family */
#endif /* HAVE_SOCKADDR_SA_LEN */
char __ss_pad1[_SS_PAD1SIZE];
#ifdef HAVE_LONG_LONG
PY_LONG_LONG __ss_align; /* force desired structure storage alignment */
#else
double __ss_align; /* force desired structure storage alignment */
#endif /* HAVE_LONG_LONG */
char __ss_pad2[_SS_PAD2SIZE];
};
#endif /* !HAVE_SOCKADDR_STORAGE */
struct sockaddr_storage {
#ifdef HAVE_SOCKADDR_SA_LEN
unsigned char ss_len; /* address length */
unsigned char ss_family; /* address family */
#else
unsigned short ss_family; /* address family */
#endif /* HAVE_SOCKADDR_SA_LEN */
char __ss_pad1[_SS_PAD1SIZE];
#ifdef HAVE_LONG_LONG
PY_LONG_LONG __ss_align; /* force desired structure storage alignment */
#else
double __ss_align; /* force desired structure storage alignment */
#endif /* HAVE_LONG_LONG */
char __ss_pad2[_SS_PAD2SIZE];
};
#endif /* !HAVE_SOCKADDR_STORAGE */
#endif /* _SYS_SOCKET_H_ */
#ifdef __cplusplus
extern "C" {

View File

@@ -1,5 +1,14 @@
/* Errno module
/* Errno module */
Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include "Python.h"
@@ -783,8 +792,52 @@ initerrno(void)
#ifdef WSAN
inscode(d, ds, de, "WSAN", WSAN, "Error WSAN");
#endif
/* These symbols are added for EDK II support. */
#ifdef EMINERRORVAL
inscode(d, ds, de, "EMINERRORVAL", EMINERRORVAL, "Lowest valid error value");
#endif
#ifdef ENOTSUP
inscode(d, ds, de, "ENOTSUP", ENOTSUP, "Operation not supported");
inscode(d, ds, de, "ENOTSUP", ENOTSUP, "Operation not supported");
#endif
#ifdef EBADRPC
inscode(d, ds, de, "EBADRPC", EBADRPC, "RPC struct is bad");
#endif
#ifdef ERPCMISMATCH
inscode(d, ds, de, "ERPCMISMATCH", ERPCMISMATCH, "RPC version wrong");
#endif
#ifdef EPROGUNAVAIL
inscode(d, ds, de, "EPROGUNAVAIL", EPROGUNAVAIL, "RPC prog. not avail");
#endif
#ifdef EPROGMISMATCH
inscode(d, ds, de, "EPROGMISMATCH", EPROGMISMATCH, "Program version wrong");
#endif
#ifdef EPROCUNAVAIL
inscode(d, ds, de, "EPROCUNAVAIL", EPROCUNAVAIL, "Bad procedure for program");
#endif
#ifdef EFTYPE
inscode(d, ds, de, "EFTYPE", EFTYPE, "Inappropriate file type or format");
#endif
#ifdef EAUTH
inscode(d, ds, de, "EAUTH", EAUTH, "Authentication error");
#endif
#ifdef ENEEDAUTH
inscode(d, ds, de, "ENEEDAUTH", ENEEDAUTH, "Need authenticator");
#endif
#ifdef ECANCELED
inscode(d, ds, de, "ECANCELED", ECANCELED, "Operation canceled");
#endif
#ifdef ENOATTR
inscode(d, ds, de, "ENOATTR", ENOATTR, "Attribute not found");
#endif
#ifdef EDOOFUS
inscode(d, ds, de, "EDOOFUS", EDOOFUS, "Programming Error");
#endif
#ifdef EBUFSIZE
inscode(d, ds, de, "EBUFSIZE", EBUFSIZE, "Buffer too small to hold result");
#endif
#ifdef EMAXERRORVAL
inscode(d, ds, de, "EMAXERRORVAL", EMAXERRORVAL, "One more than the highest defined error value");
#endif
Py_DECREF(de);

View File

@@ -9,7 +9,9 @@
/* Namespace external symbols to allow multiple libexpat version to
co-exist. */
#include "pyexpatns.h"
#if !defined(UEFI_C_SOURCE)
#include "pyexpatns.h"
#endif
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
#define XML_USE_MSC_EXTENSIONS 1

View File

@@ -1,8 +1,19 @@
/** @file
Return the initial module search path.
This file is based upon the Modules/getpath.c file from the Python distribution
but has had everything not exactly necessary for operation on EDK II stripped
out.
Search in specified locations for the associated Python libraries.
For the EDK II, UEFI, implementation of Python, PREFIX and EXEC_PREFIX
are set as follows:
PREFIX = /Efi/StdLib
EXEC_PREFIX = PREFIX
The volume is assumed to be the current volume when Python was started.
Py_GetPath returns module_search_path.
Py_GetPrefix returns PREFIX
Py_GetExec_Prefix returns PREFIX
@@ -11,16 +22,13 @@
These are built dynamically so that the proper volume name can be prefixed
to the paths.
For the EDK II, UEFI, implementation of Python, PREFIX and EXEC_PREFIX
are set as follows:
PREFIX = /Efi/StdLib
EXEC_PREFIX = PREFIX
The following final paths are assumed:
The following final paths (for Python 2.7.10) are assumed:
/Efi/Tools/Python.efi The Python executable.
/Efi/StdLib/lib/python.VERSION The platform independent Python modules.
/Efi/StdLib/lib/python.VERSION/dynalib Dynamically loadable Python extension modules.
/Efi/StdLib/lib/python27.10 The version dependent Python modules.
/Efi/StdLib/lib/python.27 The version independent Python modules.
/Efi/StdLib/lib/python27.10/lib-dynload Dynamically loadable Python extension modules.
Copyright (c) 2015, Daryl McDaniel. All rights reserved.<BR>
Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
@@ -34,13 +42,12 @@
#include <osdefs.h>
#include <ctype.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SIFY_I( x ) #x
#define SIFY( y ) SIFY_I( y )
/* VERSION must be at least two characters long. */
#ifndef VERSION
#define VERSION "27"
#define VERSION SIFY(PY_MAJOR_VERSION) SIFY(PY_MINOR_VERSION)
#endif
#ifndef VPATH
@@ -61,20 +68,19 @@
#endif
#ifndef LIBPYTHON
#define LIBPYTHON "lib/python." VERSION
#define LIBPYTHON "lib/python" VERSION "." SIFY(PY_MICRO_VERSION)
#endif
#ifndef PYTHONPATH
#ifdef HAVE_ENVIRONMENT_OPS
#define PYTHONPATH PREFIX LIBPYTHON sDELIM \
EXEC_PREFIX LIBPYTHON "/lib-dynload"
#else
#define PYTHONPATH LIBPYTHON
#endif
#define PYTHONPATH LIBPYTHON
#endif
#ifndef LANDMARK
#define LANDMARK "os.py"
#define LANDMARK "os.py"
#endif
#ifdef __cplusplus
extern "C" {
#endif
static char prefix[MAXPATHLEN+1];
@@ -94,11 +100,7 @@ static char volume_name[32] = { 0 };
static int
is_sep(char ch)
{
#ifdef ALTSEP
return ch == SEP || ch == ALTSEP;
#else
return ch == SEP;
#endif
}
/** Reduce a path by its last element.
@@ -117,77 +119,6 @@ reduce(char *dir)
dir[i] = '\0';
}
#ifndef UEFI_C_SOURCE
/** Does filename point to a file and not directory?
@param[in] filename The fully qualified path to the object to test.
@retval 0 Filename was not found, or is a directory.
@retval 1 Filename refers to a regular file.
**/
static int
isfile(char *filename)
{
struct stat buf;
if (stat(filename, &buf) != 0) {
return 0;
}
//if (!S_ISREG(buf.st_mode))
if (S_ISDIR(buf.st_mode)) {
return 0;
}
return 1;
}
/** Determine if filename refers to a Python module.
A Python module is indicated if the file exists, or if the file with
'o' or 'c' appended exists.
@param[in] filename The fully qualified path to the object to test.
@retval 0
**/
static int
ismodule(char *filename)
{
if (isfile(filename)) {
//if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: file = \"%s\"\n", __func__, __LINE__, filename);
return 1;
}
/* Check for the compiled version of prefix. */
if (strlen(filename) < MAXPATHLEN) {
strcat(filename, Py_OptimizeFlag ? "o" : "c");
if (isfile(filename)) {
return 1;
}
}
return 0;
}
/** Does filename point to a directory?
@param[in] filename The fully qualified path to the object to test.
@retval 0 Filename was not found, or is not a regular file.
@retval 1 Filename refers to a directory.
**/
static int
isdir(char *filename)
{
struct stat buf;
if (stat(filename, &buf) != 0)
return 0;
if (!S_ISDIR(buf.st_mode))
return 0;
return 1;
}
#endif /* UEFI_C_SOURCE */
/** Determine if a path is absolute, or not.
An absolute path consists of a volume name, "VOL:", followed by a rooted path,
"/path/elements". If both of these components are present, the path is absolute.
@@ -466,7 +397,7 @@ calculate_path(void)
char *pythonpath = PYTHONPATH;
char *rtpypath = Py_GETENV("PYTHONPATH");
//char *home = Py_GetPythonHome();
char *path = getenv("PATH");
char *path = getenv("path");
char *prog = Py_GetProgramName();
char argv0_path[MAXPATHLEN+1];
char zip_path[MAXPATHLEN+1];
@@ -531,9 +462,9 @@ calculate_path(void)
This is the full path to the platform independent libraries.
########################################################################### */
strncpy(prefix, volume_name, MAXPATHLEN);
joinpath(prefix, PREFIX);
joinpath(prefix, lib_python);
strncpy(prefix, volume_name, MAXPATHLEN);
joinpath(prefix, PREFIX);
joinpath(prefix, lib_python);
/* ###########################################################################
Build the FULL path to the zipped-up Python library.
@@ -551,10 +482,10 @@ calculate_path(void)
Build the FULL path to dynamically loadable libraries.
########################################################################### */
strncpy(exec_prefix, volume_name, MAXPATHLEN);
joinpath(exec_prefix, EXEC_PREFIX);
joinpath(exec_prefix, lib_python);
joinpath(exec_prefix, "lib-dynload");
strncpy(exec_prefix, volume_name, MAXPATHLEN); // "fs0:"
joinpath(exec_prefix, EXEC_PREFIX); // "fs0:/Efi/StdLib"
joinpath(exec_prefix, lib_python); // "fs0:/Efi/StdLib/lib/python.27"
joinpath(exec_prefix, "lib-dynload"); // "fs0:/Efi/StdLib/lib/python.27/lib-dynload"
/* ###########################################################################
Build the module search path.
@@ -573,9 +504,9 @@ calculate_path(void)
strcpy(prefix, volume_name);
}
bufsz = strlen(prefix);
if(prefix[bufsz-1] == ':') {
prefix[bufsz] = SEP;
prefix[bufsz+1] = 0;
if(prefix[bufsz-1] == ':') { // if prefix consists solely of a volume_name
prefix[bufsz] = SEP; // then append SEP indicating the root directory
prefix[bufsz+1] = 0; // and ensure the new string is terminated
}
/* Calculate size of return buffer.

View File

@@ -1,4 +1,8 @@
/* Python interpreter main program */
/** @file
Python interpreter main program.
Copyright (c) 2015, Daryl McDaniel. All rights reserved.<BR>
**/
#include "Python.h"
#include "osdefs.h"
@@ -40,7 +44,7 @@ static char **orig_argv;
static int orig_argc;
/* command line options */
#define BASE_OPTS "3bBc:dEhiJm:OQ:RsStuUvVW:xX?"
#define BASE_OPTS "#3bBc:dEhiJm:OQ:sStuUvVW:xX?"
#ifndef RISCOS
#define PROGRAM_OPTS BASE_OPTS
@@ -59,6 +63,7 @@ static char *usage_line =
/* Long usage message, split into parts < 512 bytes */
static char *usage_1 = "\
Options and arguments (and corresponding environment variables):\n\
-# : alias stderr to stdout for platforms without STDERR output.\n\
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n\
-c cmd : program passed in as string (terminates option list)\n\
-d : debug output from parser; also PYTHONDEBUG=x\n\
@@ -71,9 +76,6 @@ static char *usage_2 = "\
-m mod : run library module as a script (terminates option list)\n\
-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\
-OO : remove doc-strings in addition to the -O optimizations\n\
-R : use a pseudo-random salt to make hash() values of various types be\n\
unpredictable between separate invocations of the interpreter, as\n\
a defense against denial-of-service attacks\n\
-Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\
-S : don't imply 'import site' on initialization\n\
@@ -102,15 +104,9 @@ PYTHONPATH : '%c'-separated list of directories prefixed to the\n\
static char *usage_5 = "\
PYTHONHOME : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n\
The default module search path uses %s.\n\
PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\
PYTHONCASEOK : ignore case in 'import' statements (UEFI default).\n\
PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n\
";
static char *usage_6 = "\
PYTHONHASHSEED: if this variable is set to 'random', the effect is the same\n\
as specifying the -R option: a random value is used to seed the hashes of\n\
str, bytes and datetime objects. It can also be set to an integer\n\
in the range [0,4294967295] to get hash values with a predictable seed.\n\
";
static int
@@ -127,7 +123,6 @@ usage(int exitcode, char* program)
fputs(usage_3, f);
fprintf(f, usage_4, DELIM);
fprintf(f, usage_5, DELIM, PYTHONHOMEHELP);
fputs(usage_6, f);
}
#if defined(__VMS)
if (exitcode == 0) {
@@ -251,6 +246,7 @@ Py_Main(int argc, char **argv)
int help = 0;
int version = 0;
int saw_unbuffered_flag = 0;
int saw_pound_flag = 0;
PyCompilerFlags cf;
cf.cf_flags = 0;
@@ -266,26 +262,27 @@ Py_Main(int argc, char **argv)
(including -W and -X options). */
_PyOS_opterr = 0; /* prevent printing the error in 1st pass */
while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
if (c == 'm' || c == 'c') {
/* -c / -m is the last option: following arguments are
not interpreter options. */
break;
}
switch (c) {
if (c == 'm' || c == 'c') {
/* -c / -m is the last option: following arguments are
not interpreter options. */
break;
}
switch (c) {
case '#':
if (saw_pound_flag == 0) {
if(freopen("stdout:", "w", stderr) == NULL) {
puts("ERROR: Unable to reopen stderr as an alias to stdout!");
}
saw_pound_flag = 0xFF;
}
break;
case 'E':
Py_IgnoreEnvironmentFlag++;
break;
case 'R':
Py_HashRandomizationFlag++;
break;
}
Py_IgnoreEnvironmentFlag++;
break;
default:
break;
}
}
/* The variable is only tested for existence here; _PyRandom_Init will
check its value further. */
if (!Py_HashRandomizationFlag &&
(p = Py_GETENV("PYTHONHASHSEED")) && *p != '\0')
Py_HashRandomizationFlag = 1;
_PyRandom_Init();
PySys_ResetWarnOptions();
@@ -426,7 +423,7 @@ Py_Main(int argc, char **argv)
PySys_AddWarnOption(_PyOS_optarg);
break;
case 'R':
case '#':
/* Already handled above */
break;

View File

@@ -1,9 +1,20 @@
/* select - Module containing unix select(2) call.
Under Unix, the file descriptors are small integers.
Under Win32, select only exists for sockets, and sockets may
have any value except INVALID_SOCKET.
Under BeOS, we suffer the same dichotomy as Win32; sockets can be anything
>= 0.
/* @file
select - Module containing unix select(2) call.
Under Unix, the file descriptors are small integers.
Under Win32, select only exists for sockets, and sockets may
have any value except INVALID_SOCKET.
Under BeOS, we suffer the same dichotomy as Win32; sockets can be anything
>= 0.
Copyright (c) 2015, Daryl McDaniel. All rights reserved.<BR>
Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include "Python.h"
@@ -107,7 +118,7 @@ seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
v = PyObject_AsFileDescriptor( o );
if (v == -1) goto finally;
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(UEFI_C_SOURCE)
max = 0; /* not used for Win32 */
#else /* !_MSC_VER */
if (!_PyIsSelectable_fd(v)) {
@@ -1236,17 +1247,17 @@ static PyTypeObject kqueue_queue_Type;
* kevent is not standard and its members vary across BSDs.
*/
#if !defined(__OpenBSD__)
# define IDENT_TYPE T_UINTPTRT
# define IDENT_CAST Py_intptr_t
# define DATA_TYPE T_INTPTRT
# define IDENT_TYPE T_UINTPTRT
# define IDENT_CAST Py_intptr_t
# define DATA_TYPE T_INTPTRT
# define DATA_FMT_UNIT INTPTRT_FMT_UNIT
# define IDENT_AsType PyLong_AsUintptr_t
# define IDENT_AsType PyLong_AsUintptr_t
#else
# define IDENT_TYPE T_UINT
# define IDENT_CAST int
# define DATA_TYPE T_INT
# define IDENT_TYPE T_UINT
# define IDENT_CAST int
# define DATA_TYPE T_INT
# define DATA_FMT_UNIT "i"
# define IDENT_AsType PyLong_AsUnsignedLong
# define IDENT_AsType PyLong_AsUnsignedLong
#endif
/* Unfortunately, we can't store python objects in udata, because
@@ -1298,7 +1309,7 @@ kqueue_event_init(kqueue_event_Object *self, PyObject *args, PyObject *kwds)
if (PyLong_Check(pfd)
#if IDENT_TYPE == T_UINT
&& PyLong_AsUnsignedLong(pfd) <= UINT_MAX
&& PyLong_AsUnsignedLong(pfd) <= UINT_MAX
#endif
) {
self->e.ident = IDENT_AsType(pfd);

View File

@@ -1,4 +1,5 @@
/* gzguts.h -- zlib internal header definitions for gz* operations
* Copyright (c) 2015, Daryl McDaniel. All rights reserved.<BR>
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -31,7 +32,7 @@
# include <stddef.h>
#endif
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
#if (defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)) && !defined(UEFI_C_SOURCE)
# include <io.h>
#endif
@@ -42,6 +43,11 @@
# define close _close
#endif
// Needed to get the declarations for open, read, write, close
#ifdef UEFI_C_SOURCE
# include <unistd.h>
#endif
#ifdef NO_DEFLATE /* for compatibility with old definition */
# define NO_GZCOMPRESS
#endif
@@ -99,7 +105,7 @@
Microsoft more than a decade later!), _snprintf does not guarantee null
termination of the result -- however this is only used in gzlib.c where
the result is assured to fit in the space provided */
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(UEFI_C_SOURCE)
# define snprintf _snprintf
#endif

View File

@@ -1,7 +1,10 @@
/* zutil.h -- internal interface and configuration of the compression library
/** @file
zutil.h -- internal interface and configuration of the compression library
Copyright (C) 2015, Daryl McDaniel.<BR>
* Copyright (C) 1995-2013 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
**/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
@@ -21,7 +24,7 @@
#include "zlib.h"
#if defined(STDC) && !defined(Z_SOLO)
#if defined(UEFI_C_SOURCE) || (defined(STDC) && !defined(Z_SOLO))
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
# include <stddef.h>
# endif
@@ -149,7 +152,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define fdopen(fd,mode) NULL /* No fdopen() */
#endif
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
#if !defined(UEFI_C_SOURCE) && (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined(__INTERIX)
# if defined(_WIN32_WCE)
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED